AntonioND / nitro-engine

3D engine for the Nintendo DS
150 stars 10 forks source link

Trying to undestand differences between Cameras position and Models positions #6

Closed JustMeDaFaq closed 2 years ago

JustMeDaFaq commented 2 years ago

Hi, im trying to understand the differences when setting the positions of an camera in comparison to setting the position of an model.

Doing:

NE_ModelSetCoord(PlayerModel,-0.07424927f,1.3f,16.1f);
...
    NE_CameraSet(Camera,
             -0.07424927f,1.3f,16.1f, // Position
             0,0,0,   // Look at
             0, 1, 0);

Works and positions of the PlayerModel and the Camera are the same.

Tho, doing following doesnt work:

NE_ModelSetCoord(PlayerModel,-0.07424927f,1.3f,16.1f);
...
    NE_CameraSet(Camera,
             PlayerModel->x,PlayerModel->y,PlayerModel->z, // Position
             0,0,0,   // Look at
             0, 1, 0);

I know positions of an Model are declared as an int and are effectifely f32, shouldnt those values be compatible with the cameras NE_CameraSet function? Sorry for the questions!

JustMeDaFaq commented 2 years ago

A fellow dev helped me, i will update with solution when tested further! :)

JustMeDaFaq commented 2 years ago

Solution:

NE_CameraSetI(Camera,
            PlayerModel->x,PlayerModel->y,PlayerModel->z, // Position
             0,0,0,   // Look at
             0, 4096, 0);
AntonioND commented 2 years ago

That last piece of code works, but you could also do it like this so that it's more clear:

NE_CameraSetI(Camera,
              PlayerModel->x,PlayerModel->y,PlayerModel->z, // Position
              0,0,0,   // Look at
              0, floattof32(1.0), 0);