Archive 17/01/2023.

Move node and its childs with one command

syjgin

There are something wrong, when I try to animate my camera: it moves in wrong way. Maybe this takes place because on my move functions I have to move both camera node and separate center node:

void LevelCamera::VerticalTranslate(float amount)
{
    float currentRot = _cameraNode->GetRotation().YawAngle();
    Quaternion distilledRot;
    distilledRot.FromAngleAxis(currentRot, Vector3(0,1,0));
    Vector3 rotated = distilledRot.RotationMatrix() * Vector3(0,0,amount);
    _cameraNode->Translate(rotated, TS_WORLD);
    _centerPosition->Translate(rotated);
}

void LevelCamera::HorizontalTranslate(float amount)
{
    float currentRot = _cameraNode->GetRotation().YawAngle();
    Quaternion distilledRot;
    distilledRot.FromAngleAxis(currentRot, Vector3(0,1,0));
    Vector3 rotated = distilledRot.RotationMatrix() * Vector3(amount,0,0);
    _cameraNode->Translate(rotated, TS_WORLD);
    _centerPosition->Translate(rotated);
}

Maybe I made something wrong in camera moving? I have to remove all angles, except yaw, from camera rotation, because without this camera was moving by local axes, not rotated global:

Bluemoon

is _cameraNode parented to _centerPosition ?

thebluefish

Moving/Rotating/Scaling a parent node will apply to all of its children. If you are running into problems with it, you’re probably using bad hierarchy.