PDA

View Full Version : Displaying a CharacterClass



escozooz
04-29-2002, 02:57 PM
I am designing a class that basically can draw a character, with the member function draw().

This is half design and half implementation.

The class has following variables:
CVector3 location // cvector is struct float x, y ,z
Vector3 direction


Float rx, ry, rz // rotation variables

There are more but these are the basics. When GLUT calls the keyboard function ( member )it assesses http://www.opengl.org/discussion_boards/ubb/smile.gif whether to move the character or rotate.

The camera rotates around the character so the character class only cares about where it is and where its looking.

I don't know how to do this. How could i make it so the character will rotate with right and left keys. And move towards the way its facing, with forward and back keys?

Jambolo
04-29-2002, 08:47 PM
Easy.

When the keyboard says to turn or move, update the rotation and location values. It's not clear to me why you have both a direction vector and rotation values.

When it comes time to draw the character, use your values to call glTranslate to move him to the right spot and glRotate to face him in the right direction.

escozooz
04-30-2002, 05:24 PM
I need a direction vector and rotation variables because because the direction tells it what way to go but it could be moving sideways. I need the rotation variables to make him move forward.

I think