character/camera crashing
Hi,
Im fooling around with the camera, trying to create a third person camera that follows behind a character running around on a landscape. I have been borrowing from the Drive Object exmaple for the code to do the 3rd person camera.
I have an entity:
EntityNode *MyPlayer;
and when I get to this line:
PR_Transform (MyPlayer->Info.Entity->orientation.rot_mat);
the program crashes back to the desktop.
Anyone know what I''m doing wrong?
thanks
Jason
Ok, so I think I figured out what I was doing wrong.
It looks like there was nothing in
MyPlayer->Info.Entity->orientation.rot_mat
and that is why it was crashing.
I did this:
PR_MatrixTranslate (m, MyPlayer->Info.Rotation.x, MyPlayer->Info.Rotation.y, MyPlayer->Info.Rotation.z);
PR_Transform (m);
and that seemed to fix the crashing problem.
Now my issue is getting my character rotate left or right.
Im doing something like this:
if (kbdon[KEY_A])
OM_RotateEntity (MyPlayer, 0,0,-2.0f * ticks * 1.3);
to rotate the model but it doest just rotate left, as I want it to.
It rotates around some axis that im just not understanding.
Anyone have an idea what I might be doing wrong?
Jason
It looks like there was nothing in
MyPlayer->Info.Entity->orientation.rot_mat
and that is why it was crashing.
I did this:
PR_MatrixTranslate (m, MyPlayer->Info.Rotation.x, MyPlayer->Info.Rotation.y, MyPlayer->Info.Rotation.z);
PR_Transform (m);
and that seemed to fix the crashing problem.
Now my issue is getting my character rotate left or right.
Im doing something like this:
if (kbdon[KEY_A])
OM_RotateEntity (MyPlayer, 0,0,-2.0f * ticks * 1.3);
to rotate the model but it doest just rotate left, as I want it to.
It rotates around some axis that im just not understanding.
Anyone have an idea what I might be doing wrong?
Jason
i thought you should rotate around y-axis to turn left/right.
maybe should be:
OM_RotateEntity (MyPlayer, 0, -2.0f * ticks * 1.3, 0);
maybe should be:
OM_RotateEntity (MyPlayer, 0, -2.0f * ticks * 1.3, 0);
Oh yes, I tried that initially. I had posted the code after I fiddled around with it a bit.
doing this:
OM_RotateEntity (MyPlayer, 0, -2.0f * ticks * 1.3, 0);
still cuases him to rotate in a strange fasion, rather than just turning left or right.
thanks
Jason
EDIT:
Ok, after pulling my head out of my rump I decided to take a look at the warning messages I was getting during compile time.
This one popped up:
warning C4013: 'OM_RotateEntity' undefined; assuming extern returning int
I'm not sure why that happened, but once I put this:
void OM_RotateEntity (EntityNode *node, PR_REAL x, PR_REAL y, PR_REAL z);
at the top of my code, the model started rotating properly.
sweet. now I just need to figure out why the camera doest spin around with the model.
ManFriday
Edited by - manfriday on August 16, 2001 6:41:01 PM
doing this:
OM_RotateEntity (MyPlayer, 0, -2.0f * ticks * 1.3, 0);
still cuases him to rotate in a strange fasion, rather than just turning left or right.
thanks
Jason
EDIT:
Ok, after pulling my head out of my rump I decided to take a look at the warning messages I was getting during compile time.
This one popped up:
warning C4013: 'OM_RotateEntity' undefined; assuming extern returning int
I'm not sure why that happened, but once I put this:
void OM_RotateEntity (EntityNode *node, PR_REAL x, PR_REAL y, PR_REAL z);
at the top of my code, the model started rotating properly.
sweet. now I just need to figure out why the camera doest spin around with the model.
ManFriday
Edited by - manfriday on August 16, 2001 6:41:01 PM
I know, I know. Im doing all the posting to my own thread...
Anyway, to reiterate what Im trying to do:
Im loading a .chr file into a landscape
Im trying to follow behind the character using a third person camera (like in the drive object exmaple).
I have the model moving forward and backward and rotating left and right.
The camera follows the character properly when moving forward or backwards, but does NOT rotate with the character.
Here is the code Im using to acomplish this (borrowed mostly from the driveobject example)
void CheckMove(PR_DWORD ticks)
{
if (kbdon[KEY_W])
MoveSpeed = 1.0f;
else if (kbdon[KEY_S])
MoveSpeed = -1.0f;
else
MoveSpeed = 0.0f;
PR_Globals.tvector[0] = 0.0f;
PR_Globals.tvector[1] = 0.0f;
PR_Globals.tvector[2] = -72.0f * MoveSpeed;
PR_Transform (MyPlayer->Info.Character->LayerEntities[0]->segment_orientation->rot_mat);
OM_MoveEntity (MyPlayer, PR_Globals.tvector[0], CheckForTerrain(MyPlayer), PR_Globals.tvector[2],0);
if (kbdon[KEY_A])
OM_RotateEntity (MyPlayer, 0, -4.0f * ticks,0);
if (kbdon[KEY_D])
OM_RotateEntity (MyPlayer, 0, + 4.0f * ticks,0);
}
void CalculateFollowCam (void)
{
// calculate the following camera
PR_Globals.tvector[0] = 0.0f;
PR_Globals.tvector[1] = 0.0f;
PR_Globals.tvector[2] = -400.0f;
PR_Transform (MyPlayer->Info.Character->LayerEntities[0]->segment_orientation->rot_mat);
PR_PositionCameraSource (camera,MyPlayer->Info.Location.x - PR_Globals.tvector[0],
MyPlayer->Info.Location.y - PR_Globals.tvector[1]+170,
MyPlayer->Info.Location.z - PR_Globals.tvector[2]);
PR_PositionCameraTarget (camera, MyPlayer->Info.Location.x,
MyPlayer->Info.Location.y + 75,
MyPlayer->Info.Location.z);
}
if anyone has an insigt into this, I would be most greateful.
thanks
Jason
Anyway, to reiterate what Im trying to do:
Im loading a .chr file into a landscape
Im trying to follow behind the character using a third person camera (like in the drive object exmaple).
I have the model moving forward and backward and rotating left and right.
The camera follows the character properly when moving forward or backwards, but does NOT rotate with the character.
Here is the code Im using to acomplish this (borrowed mostly from the driveobject example)
void CheckMove(PR_DWORD ticks)
{
if (kbdon[KEY_W])
MoveSpeed = 1.0f;
else if (kbdon[KEY_S])
MoveSpeed = -1.0f;
else
MoveSpeed = 0.0f;
PR_Globals.tvector[0] = 0.0f;
PR_Globals.tvector[1] = 0.0f;
PR_Globals.tvector[2] = -72.0f * MoveSpeed;
PR_Transform (MyPlayer->Info.Character->LayerEntities[0]->segment_orientation->rot_mat);
OM_MoveEntity (MyPlayer, PR_Globals.tvector[0], CheckForTerrain(MyPlayer), PR_Globals.tvector[2],0);
if (kbdon[KEY_A])
OM_RotateEntity (MyPlayer, 0, -4.0f * ticks,0);
if (kbdon[KEY_D])
OM_RotateEntity (MyPlayer, 0, + 4.0f * ticks,0);
}
void CalculateFollowCam (void)
{
// calculate the following camera
PR_Globals.tvector[0] = 0.0f;
PR_Globals.tvector[1] = 0.0f;
PR_Globals.tvector[2] = -400.0f;
PR_Transform (MyPlayer->Info.Character->LayerEntities[0]->segment_orientation->rot_mat);
PR_PositionCameraSource (camera,MyPlayer->Info.Location.x - PR_Globals.tvector[0],
MyPlayer->Info.Location.y - PR_Globals.tvector[1]+170,
MyPlayer->Info.Location.z - PR_Globals.tvector[2]);
PR_PositionCameraTarget (camera, MyPlayer->Info.Location.x,
MyPlayer->Info.Location.y + 75,
MyPlayer->Info.Location.z);
}
if anyone has an insigt into this, I would be most greateful.
thanks
Jason
Im sorry to be such a pest, but this is driving me bonkers.
Am I even getting the rotation matrix of the character properly? is that my problem?
I would really appreciate any help Chris or anyone else could give me.
thanks
Jason
Am I even getting the rotation matrix of the character properly? is that my problem?
I would really appreciate any help Chris or anyone else could give me.
thanks
Jason
I''d try to answer your question but I haven''t worked with the CHR stuff all that much and I''m not too sure what your current question is.
Gary
Gary
I''m not ignoring you, I just don''t know either. Maybe in a couple of weeks I''ll be able to help, but hopefully by then you''ll have it working.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement