Archived

This topic is now archived and is closed to further replies.

Lets try again..

This topic is 5619 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Lets say i make a class in one of nehe''s first examples (lets take the spinning cubes and pyramids). This class would keep the position of one of these objects in a vector (x,y,z). I would want it to be possible to move it like object.pos = (100, 59, 73) or something like that. So my question is, how would i make one of these world coordinates system?

Share this post


Link to post
Share on other sites
I''m not sure if it''s that thing that you want but here''s :

typedef struct
{

float x, y, z;

} OBJECT;

OBJECT Object;

Now, you can use :

Object.x = ...
Object.y = ...

etc ...

========================
Leyder Dylan
http://ibelgique.ifrance.com/Slug-Production/

Share this post


Link to post
Share on other sites
glLoadIdentity();
glTranslate(Object.x,Object.y,Object.z);
DrawObject();

For moving, give the object a speed and a vector to hold it's destination . Then just apply the speed to it's position each frame until it reaches the destination.

struct Vector
{
float x,y,z;
};

class Object
{
public:
void Place(Vector meh){ pos = meh };
void SetDes(Vector meh){ des = meh };
void Update(){ //if pos != des, move pos towards des };
void Draw();
private:
Vector pos;
Vector des;
float speed;
};

That's one way of setting things up at least.

EDIT: screwed up italics tag
------------
aud.vze.com - The Audacious Engine <-- It's not much, yet. But it's mine... my own... my preciousssss...
MSN: nmaster42@hotmail.com, AIM: LockePick42, ICQ: 74128155

[edited by - LockePick on July 26, 2002 1:34:25 PM]

Share this post


Link to post
Share on other sites
I'd guess thats a nice way to do it.
Thank you.


However it would still be damn nice to be able to move it like you move 2D object.

car.x = 50;
car.y = 100;

Oh well,
Thank you


EDIT: I figured how to do this :D

[edited by - ZitherMan on July 26, 2002 9:50:15 PM]

Share this post


Link to post
Share on other sites