modified
#include <DarkGDK.h>
float anglea=0.0f;
float angleb=0.0f;
float pointatx=0.0f;
float pointaty=0.0f;
float pointatz=0.0f;
float dist=20.0f;
float movementpernotch=0.5f;
float maxzoom=200.0f;
float minzoom=5.0f;
float needtomovex;
float needtomovey;
float needtomovez;
float desta;
float destb;
float spd=10.0f; //i changed it for you
void attemptToMoveCamera(float x, float y, float z, float speed) //troublemaker
{
/* are x,y,z relative to the camera or are they universal coordinates? if they are relative coordinates then uncomment this
needtomovex = (dbCameraPositionX() + x); //changed to adding the x,y and z values; if they are relative coords that is what should have been done
needtomovey = (dbCameraPositionY() + y);
needtomovez = (dbCameraPositionZ() + z);
*/
/* wtf is this
if (needtomovex>0)
{
dbPositionCamera(dbCameraPositionX() + speed, dbCameraPositionY(), dbCameraPositionZ());
}
else
{
dbPositionCamera(dbCameraPositionX() - speed, dbCameraPositionY(), dbCameraPositionZ());
}
if (needtomovey>0)
{
dbPositionCamera(dbCameraPositionX(), dbCameraPositionY() + speed, dbCameraPositionZ());
}
else
{
dbPositionCamera(dbCameraPositionX(), dbCameraPositionY() - speed, dbCameraPositionZ());
}
if (needtomovez>0)
{
dbPositionCamera(dbCameraPositionX(), dbCameraPositionY(), dbCameraPositionZ() + speed);
}
else
{
dbPositionCamera(dbCameraPositionX(), dbCameraPositionY(), dbCameraPositionZ() - speed);
}
*/
float movex,movey,movez;
movex = dbCurveValue( x, dbCameraPositionX(), spd );
movey = dbCurveValue( y, dbCameraPositionY(), spd );
movez = dbCurveValue( z, dbCameraPositionZ(), spd );
dbPositionCamera( movex,movey,movez );
}
void controlCamera(int object)
{
pointatx = dbObjectPositionX(object);
pointaty = dbObjectPositionY(object);
pointatz = dbObjectPositionZ(object);
if (dbMouseMoveZ()>0)
{
if (dist > (minzoom + movementpernotch))
{
dist-=movementpernotch;
}
}
else if (dbMouseMoveZ()<0)
{
if (dist < (maxzoom - movementpernotch))
{
dist+=movementpernotch;
}
}
if (dbMouseClick()==4)
{
desta = anglea + dbMouseMoveX();
destb = angleb + dbMouseMoveY();
anglea = dbCurveAngle(desta, anglea, spd); //destination first
angleb = dbCurveAngle(destb, angleb, spd);
}
dbPositionCamera(pointatx + (dbSin(anglea)* dbCos(angleb) * dist), pointaty + (dbSin(angleb)*dist), pointatz+(dbCos(anglea)*dbCos(angleb)*dist));
//i swapped all the dbSin(angleb) and dbCos(angleb), assuming angleb is the x-angle and that 0 degrees is parallel with the ground;
//however if 0 degrees x points upwards then reverse this
dbPointCamera(pointatx, pointaty, pointatz);
}
take a close look
oh now i see what the first part of attemptToMoveCamera was, i must not have read the variable names correctly.