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 / Chase Camera?

Author
Message
Yoyokid
16
Years of Service
User Offline
Joined: 26th Nov 2007
Location:
Posted: 27th Nov 2007 01:40
ok, so i am a complete begginner, i am trying to create a chase camera, and am having no luck. I am using the dbSetCameraToFollow command, but i do not like the way it follows
here is my code(sorry its messy....)
[ float a = 0.0f;
float x = 0.0f;
float y = 0.0f;
float z = 0.0f;

dbSyncOn ( );
dbSyncRate ( 60 );
dbSetCameraRange(1.0f,30000.0f);
dbLoadImage("texture.jpg",1);
dbLoadImage("detail.jpg",2);
dbSetupTerrain( );
dbMakeObjectTerrain(2);
dbSetTerrainHeightMap(2,"map.bmp");
dbSetTerrainLight(2,1.0f,-0.25f,0.0f,1.0f,1.0f,0.78f,0.5f);
dbSetTerrainTexture(2,1,2);
dbSetTerrainScale(2,.9,.1,.9);
dbBuildTerrain(2);
dbPositionObject(2,-10,-4,0);
dbLoadObject("skybox2.x",3);
dbSetObjectLight(3,0);
dbScaleObject(3,30000,30000,30000);

dbLoadObject("bike.x", 1);


dbPositionObject(1,0,-4,0);
dbPositionCamera(0,5,0);
dbTurnObjectLeft(1,220);
dbSetObjectSpeed (1,90);
int dbmakeVector3(1);

while ( LoopGDK ( ) )
{
x = dbObjectPositionX(1);
y = dbObjectPositionY(1);
z = dbObjectPositionZ(1);
a = dbObjectAngleY(1);
dbSetCameraToFollow(x,y,z, -a + 20 ,5,2,10,1);

float fHeight = dbGetTerrainGroundHeight(2,x,z);
dbPositionObject(1, x, fHeight, z);

if (dbUpKey())
dbLoopObject(1, 10);
dbSetObjectSpeed (1,90);
if(dbUpKey())
dbMoveObject(1,-.1);
if(dbLeftKey())
dbTurnObjectLeft(1,2);
if(dbRightKey())
dbTurnObjectRight(1,2);
if (!dbUpKey())
dbSetObjectSpeed(1,0);
if(dbDownKey())
dbSetObjectSpeed(1,0);

dbText(0,0,dbStr(x));
dbText(0,10,dbStr(y));
dbText(0,20,dbStr(z));
dbText(0,30,dbStr(a));
dbUpdateTerrain();
dbSync ( );]

any help?

being a yoyoer has its ups and downs...
Deagle
19
Years of Service
User Offline
Joined: 28th Aug 2005
Location: Finland
Posted: 27th Nov 2007 06:28
You can
1. position the camera to the object's position
2. rotate the camera to the same angle as the object
3. move camera -200 or so.
In the loop, of course.

in other words;
dbPositionCamera(x,y,z);
dbRotateCamera(xangle,yangle,zangle);
dbMoveCamera(-200);

This makes a third person view.

Deagle aka D-Eagle
Yoyokid
16
Years of Service
User Offline
Joined: 26th Nov 2007
Location:
Posted: 27th Nov 2007 22:12
k thanks! i got that, and it works, but when ever it gets to 90 degrees, it flickers..anyway to smooth it out or something?


dbPositionCamera(x,y +2,z);
dbRotateCamera(b,a - 180 ,c );
dbMoveCamera(-5);
float fHeight = dbGetTerrainGroundHeight(2,x,z);
dbPositionObject(1, x, fHeight, z);

note: (a-180) because if it was pointed at the way the bike does, then it would point at the front of the bike...so i had to put it on opposite side.

being a yoyoer has its ups and downs...
Yoyokid
16
Years of Service
User Offline
Joined: 26th Nov 2007
Location:
Posted: 29th Nov 2007 03:49
any thing?

being a yoyoer has its ups and downs...

Login to post a reply

Server time is: 2024-11-19 17:34:07
Your offset time is: 2024-11-19 17:34:07