Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / attaching an object to camera move ?1

Author
Message
kareem3d
15
Years of Service
User Offline
Joined: 3rd Aug 2009
Location:
Posted: 16th Aug 2009 17:25
how to Object Move with camera??

i made the camera move with arrows and with mouse but i don't know how to make the object move with the camera??

this is my code :

#include "DarkGDK.h"

void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
dbHideMouse();

dbMakeObjectBox(1,10,10,10);

float camerax=0;
float cameray=0;

while ( LoopGDK ( ) )
{
camerax = dbWrapValue ( camerax + dbMouseMoveY() *0.2);
cameray = dbWrapValue ( cameray + dbMouseMoveX() *0.2);

dbXRotateCamera(camerax);
dbYRotateCamera(cameray);

if(dbLeftKey())
{
dbMoveCameraLeft(0,speed);
}
if(dbRightKey())
{
dbMoveCameraRight(0,speed);
}
dbSync ( );
}
return;
}
Silvester
18
Years of Service
User Offline
Joined: 7th Dec 2005
Location: Netherlands
Posted: 16th Aug 2009 17:29 Edited at: 16th Aug 2009 17:35


And for the love of god please post code in CODE boxes, it's really annoying to read it like this.

It's not the world that turns against you, it's you that turns against the world.
kareem3d
15
Years of Service
User Offline
Joined: 3rd Aug 2009
Location:
Posted: 16th Aug 2009 18:28
i put ur code in the project but something where wrong --> i didn't see the object so i added +3 to ur code ::

dbPositionObject(1, dbCameraPositionX(), dbCameraPositionY(), dbCameraPositionZ()+3);

to put the object in front of the camera but the problem is that the object isn't the center of the camera rotation !!

so when i rotate the mouse 180 degree the object totally disappear!!

next time i will post code in CODE boxes..@@#
prasoc
16
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 16th Aug 2009 18:32
adding +3 to the Z-axis will make it go forward ON THE Z-AXIS not on the camera's forward axis. Try dbMoveObject(1,3);


Your signature has been erased by a mod
Silvester
18
Years of Service
User Offline
Joined: 7th Dec 2005
Location: Netherlands
Posted: 16th Aug 2009 21:11 Edited at: 16th Aug 2009 21:11
If you want an object to be in front of the camera at ALL costs, put it in the right place before the loop runs, then use dbLockObjectOn(int ID);, if I'm correct that will make it unable to move anywhere else.

It's not the world that turns against you, it's you that turns against the world.

Login to post a reply

Server time is: 2024-11-19 03:05:41
Your offset time is: 2024-11-19 03:05:41