Skip to main content
gamedev.net
🔒 Locked

Lets try again..

Started by ZitherMan 3 replies 250+ views
Original Post
ZitherMan
ZitherMan
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?
----------------------------
When hell freez
Leyder Dylan
Leyder Dylan
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/
========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/
ZitherMan
ZitherMan
I know that part... but how would i get it to work?
----------------------------
When hell freez
LockePick
LockePick
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]
ZitherMan
ZitherMan
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]
----------------------------
When hell freez

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.