3D Rendering C ++ – Game Development Stack Exchange


I'm trying to create a rendering scene with the camera, but I'm clearly missing something because it's displayed well. But if I want to rotate my camera, my object will be rotated. Could you take a look and tell me if something is going to happen to you?

For the view matrix I do the following:

Transformation rotation (orientation camera);
Transformation translation (positionCamera);
return translation.inverse () * rotation.inverse ()

If I want to turn to the right:

orientationCamera = (Quaternion (1, {1,0,0}) * camera.orientation) .to_norm ();
# update frustum:
# I apply the view matrix to each of my 6 levels

Here I apply the transformation to these levels:

vector<4> tmp = matrix.inverse (). transpose () * plane.fourValues ​​();
back level (tmp);

If I want to show a point on my screen:

# Transformation is the perspective matrix
Transformation final = transformation.inverse () * camera.getTransform ();
Point point 2 = final transformation (point);
# then I indicate the point: (point2.x / w, point2.y / w)

I also wondered if I'm doing the translation right. If I move the position of the camera, all I have to do is update the PositionCamera with the new position and let the View Matrix function do its job. Initially, the position is at the origin.

Many Thanks.