I have run into two, possibly related, problems. Fixing either would allow me to build my games easier (I can brute force a solution, but would rather to it properly).
1. The dbLimbAngleY function does not return the proper value, even when the limb is clearly changing angle
2. The dbObjectPosition<X><Y><Z> and dbObjectAngle functions do not return values for an object that is glued to a limg, even when the object is moving
I will send the model and VC7 project to anyone interested in looking into this. The model was built with 3ds max 6 and converted to .x using Deep Exploration.
#include "DarkSDK.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
// key scan codes of interest
#define ciScanCode_P 25
// set id values for objects
int modid=20;
int objid=30;
int lmbid=2;
void doDbText(int& yloc,const char* format,...)
{
char szTxt[1024];
va_list marker;
// initialise variable arguments
va_start(marker,format);
// build local string
vsprintf(szTxt,format,marker);
// close it off
va_end(marker);
// write it out
dbText(10,yloc,szTxt);
// update the y location
yloc += 14;
}
void DisplayInformation()
{
float lx,ly,lz,la;
float ox,oy,oz,oa;
int yloc=10;
int fps=dbScreenFPS();
// get information about the limb
lx = dbLimbPositionX(modid,lmbid);
ly = dbLimbPositionY(modid,lmbid);
lz = dbLimbPositionZ(modid,lmbid);
la = dbLimbAngleY(modid,lmbid);
// get information about the objid object
ox = dbObjectPositionX(objid);
oy = dbObjectPositionY(objid);
oz = dbObjectPositionZ(objid);
oa = dbObjectAngleY(objid);
// set color
dbInk(dbRGB(255,255,0),dbRGB(255,255,255));
// show frames per second
doDbText(yloc,"FPS=%d",fps);
// output instructions
doDbText(yloc,"'P' key to animate object");
doDbText(yloc," and show limb/object movement");
// output frame information
doDbText(yloc,"object#=%d limb=%d",modid,lmbid);
doDbText(yloc,"frames=%d",dbTotalObjectFrames(modid));
doDbText(yloc,"current=%5.2f",dbObjectFrame(modid));
// output limb position
doDbText(yloc,"limb x=%.1f z=%.1f",lx,lz);
doDbText(yloc,"limb y=%.1f angle=%.1f",ly,la);
// output object position
doDbText(yloc,"object x=%.1f z=%.1f",ox,oz);
doDbText(yloc,"object y=%.1f angle=%.1f",oy,oa);
}
void DarkSDK(void)
{
// set the desired display mode (if available)
if (dbCheckDisplayMode(640,480,16)) dbSetDisplayMode(640,480,16);
// turn on synchronisation and set rate
dbSyncOn ();
dbSyncRate(60);
// set the directory for stuff
dbSetDir("media\\");
// load model to be tested
dbLoadObject("testmodel.x",modid);
dbPositionObject(modid,100.0f,0.0f,100.0f);
// make a thing to attach to limb
dbMakeObjectBox(objid,0.5f,10.0f,1.0f);
dbGlueObjectToLimb(objid,modid,lmbid);
// initialise camera position
dbPositionCamera(56.0f,42.5f,56.0f);
dbYRotateCamera(45.0f);
while (LoopSDK())
{
// check for one kind of break
if (dbEscapeKey()) break;
switch (dbScanCode())
{
case ciScanCode_P:
dbSetObjectSpeed(modid,10);
dbPlayObject(modid);
break;
}
// show stuff
DisplayInformation();
// update display
dbSync();
}
// stop playing if in motion
if (dbObjectPlaying(modid)) dbStopObject(modid);
// remove the object
dbDeleteObject(modid);
}
Cheers,
Ancient Lady