MCPcopy Create free account
hub / github.com/axmolengine/axmol / updateCamera

Method updateCamera

tests/cpp-tests/Source/Camera3DTest/Camera3DTest.cpp:533–650  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

531}
532void onTouchesCancelled(const std::vector<Touch*>& touches, ax::Event* event) {}
533void Camera3DTestDemo::updateCamera(float fDelta)
534{
535 if (_mesh)
536 {
537 if (_cameraType == CameraType::ThirdPerson)
538 {
539 updateState(fDelta);
540 if (isState(_curState, State_Move))
541 {
542 move3D(fDelta);
543 if (isState(_curState, State_Rotate))
544 {
545 Vec3 curPos = _mesh->getPosition3D();
546
547 Vec3 newFaceDir = _targetPos - curPos;
548 newFaceDir.y = 0;
549 newFaceDir.normalize();
550 Vec3 up;
551 _mesh->getNodeToWorldTransform().getUpVector(&up);
552 up.normalize();
553 Vec3 right;
554 Vec3::cross(-newFaceDir, up, &right);
555 right.normalize();
556 Vec3 pos = Vec3(0, 0, 0);
557 Mat4 mat;
558 mat.m[0] = right.x;
559 mat.m[1] = right.y;
560 mat.m[2] = right.z;
561 mat.m[3] = 0.0f;
562
563 mat.m[4] = up.x;
564 mat.m[5] = up.y;
565 mat.m[6] = up.z;
566 mat.m[7] = 0.0f;
567
568 mat.m[8] = newFaceDir.x;
569 mat.m[9] = newFaceDir.y;
570 mat.m[10] = newFaceDir.z;
571 mat.m[11] = 0.0f;
572
573 mat.m[12] = pos.x;
574 mat.m[13] = pos.y;
575 mat.m[14] = pos.z;
576 mat.m[15] = 1.0f;
577 _mesh->setAdditionalTransform(&mat);
578 }
579 }
580 }
581 if (_bZoomOut == true)
582 {
583 if (_camera)
584 {
585 if (_cameraType == CameraType::ThirdPerson)
586 {
587 Vec3 lookDir = _camera->getPosition3D() - _mesh->getPosition3D();
588 Vec3 cameraPos = _camera->getPosition3D();
589 if (lookDir.length() <= 300)
590 {

Callers

nothing calls this directly

Calls 12

getUpVectorMethod · 0.80
getRotation3DMethod · 0.80
crossFunction · 0.50
Vec3Function · 0.50
getPosition3DMethod · 0.45
normalizeMethod · 0.45
lengthMethod · 0.45
getNormalizedMethod · 0.45
setPosition3DMethod · 0.45
setRotation3DMethod · 0.45

Tested by

no test coverage detected