Quote: "oh ok. the variable gunWaggle is what exactly? is the source code for the dark dungeon example included with the program? "
Not sure about gunWaggle. That's probably a bad example. And yes, it's in the sample directory.
Here's an improvement to the original example I gave:
#include <DarkGDK.h>
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
dbMakeObjectCube ( 1, 20.0f );
float xPosMod = dbObjectPositionX ( 1 ) - dbCameraPositionX();
float yPosMod = dbObjectPositionY ( 1 ) - dbCameraPositionY();
float zPosMod = dbObjectPositionZ ( 1 ) - dbCameraPositionZ();
double gunAngleX;
double gunAngleY;
double gunAngleZ;
double cameraAngleX;
double cameraAngleY;
double cameraAngleZ;
double oldGunAngleX = dbObjectAngleX ( 1 );
double oldGunAngleY = dbObjectAngleY ( 1 );
double oldGunAngleZ = dbObjectAngleZ ( 1 );
while ( LoopGDK ( ) )
{
dbControlCameraUsingArrowKeys ( 0, 2.0f, 2.0f );
dbPositionObject ( 1, dbCameraPositionX() + xPosMod,
dbCameraPositionY() + yPosMod,
dbCameraPositionZ() + zPosMod);
dbSetObjectToCameraOrientation ( 1 );
gunAngleX = dbObjectAngleX ( 1 );
gunAngleY = dbObjectAngleY ( 1 );
gunAngleZ = dbObjectAngleZ ( 1 );
cameraAngleX = dbCameraAngleX ( 0 );
cameraAngleY = dbCameraAngleY ( 0 );
cameraAngleZ = dbCameraAngleZ ( 0 );
if ( oldGunAngleX != gunAngleX )
{
if ( gunAngleX != cameraAngleX ) {
dbXRotateObject ( 1, -(gunAngleX-cameraAngleX) );
oldGunAngleX = dbObjectAngleX ( 1 );
}
}
if ( oldGunAngleY != gunAngleY )
{
if ( gunAngleY != cameraAngleY ) {
dbYRotateObject ( 1, -(gunAngleY-cameraAngleY) );
oldGunAngleY = dbObjectAngleY ( 1 );
}
}
if ( oldGunAngleZ != gunAngleZ )
{
if ( gunAngleZ != cameraAngleZ ) {
dbZRotateObject ( 1, -(gunAngleZ-cameraAngleZ) );
oldGunAngleZ = dbObjectAngleZ ( 1 );
}
}
dbSync ( );
}
}
Now it's just a matter of throwing in the trigonometry required.
Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo