character/camera crashing

Started by
8 comments, last by ManFriday 22 years, 8 months ago
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
Advertisement
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
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);
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
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
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
Im feeling ignored.
Did I ask this question in an improper maner?

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
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.
I meant Chris, as he has not responded to the question.

However, as Gary said he is not ceratin what my question is, I must assume that Chris is not sure what I''m talking about either. I''ll try being a little more clear & succinct in a new thread.

thanks Gary & Dr. P



Jason

This topic is closed to new replies.

Advertisement