hey,
i have been playing around with sparky's.dll and got it mostly working. I have brought in the Miko_walk.x model (simply for testing etc) and made her walk and everything. However i have setup the mikowalk model object for collision. But it dosn't seem to be setting her collision data correctly. from walking around the room it apears to be picking her up as a very small cube just on the floor. so she partly enters walls and walks through the bed in the room.
video demonstrating linked
http://www.sanitarium.fm/upmod/upt2.avi
#include "DarkGDK.h"
#include "Player.h"
#include "SC_Collision.h"
//Creates player and initiates collision detection
void CreatePlayer (void)
{
SetCurrentDirectory ("Models");
dbLoadObject ( "Miko_walk.x", 10 );
dbSetObjectSpecular ( 10, 0 );
dbXRotateObject ( 10, 270 );
dbFixObjectPivot ( 10 );
SC_SetupObject (10,2,1);
SetCurrentDirectory ("..");
}
void RemovePlayer (void)
{
dbDeleteObject (10);
}
#include "DarkGDK.h"
#include "Physics.h"
#include "SC_Collision.h"
void WalkForwards (int obj,float Speed)
{
dbLoopObject ( obj, 0, 6720 );
dbSetObjectSpeed ( obj, 11000);
float littleRadius = 2.0f;
float oldx = dbObjectPositionX(obj);
float oldy = dbObjectPositionY(obj);
float oldz = dbObjectPositionZ(obj);
dbMoveObject (obj, Speed);
dbMoveCamera (Speed);
float x = dbObjectPositionX(obj);
float y = dbObjectPositionY(obj);
float z = dbObjectPositionZ(obj);
int collide = SC_SphereSlide( 0, oldx,oldy,oldz, x,y,z, littleRadius,obj );
if ( collide > 0 )
{
dbPositionObject( obj, SC_GetCollisionSlideX(),SC_GetCollisionSlideY(),SC_GetCollisionSlideZ() );
}
SC_UpdateObject( obj );
}
void WalkBackwards (int obj,float Speed)
{
float littleRadius = 2.0f;
float oldx = dbObjectPositionX(obj);
float oldy = dbObjectPositionY(obj);
float oldz = dbObjectPositionZ(obj);
dbMoveObject (obj, Speed);
dbMoveCamera (Speed);
float x = dbObjectPositionX(obj);
float y = dbObjectPositionY(obj);
float z = dbObjectPositionZ(obj);
int collide = SC_SphereSlide( 0, oldx,oldy,oldz, x,y,z, littleRadius,obj );
if ( collide > 0 )
{
dbPositionObject( obj, SC_GetCollisionSlideX(),SC_GetCollisionSlideY(),SC_GetCollisionSlideZ() );
}
SC_UpdateObject( obj );
dbPlayObject (obj);
}
void EnforceGravity (int gravity,int obj)
{
float littleRadius = 2.0f;
float oldx = dbObjectPositionX(obj);
float oldy = dbObjectPositionY(obj);
float oldz = dbObjectPositionZ(obj);
dbMoveObjectDown (obj,gravity);
float x = dbObjectPositionX(obj);
float y = dbObjectPositionY(obj);
float z = dbObjectPositionZ(obj);
int collide = SC_SphereSlide( 0, oldx,oldy,oldz, x,y,z, littleRadius,obj );
if ( collide > 0 )
{
dbPositionObject( obj, SC_GetCollisionSlideX(),SC_GetCollisionSlideY(),SC_GetCollisionSlideZ() );
}
SC_UpdateObject( obj );
}
#include "DarkGDK.h"
#include "3dWorld.h"
#include "SC_Collision.h"
//Loads up .dbo map and skybox as passed from the sub call
//and creates a collision map for the map object with sparkys collision
void LoadMap (char *mapname, int mapnum, char *sbox, int boxnum)
{
// Load a Map object
SetCurrentDirectory ( "Maps");
if (dbFileExist (mapname) == 1)
{
dbLoadObject (mapname,mapnum);
SC_SetupComplexObject (mapnum,1,2);
dbSetObjectLight ( 1, 0 );
dbPositionCamera ( 40, 80, 40 );
}
// load a model for our sky
SetCurrentDirectory ("..");
SetCurrentDirectory ( "Skybox" );
if (dbFileExist (sbox) == 1 )
{
dbLoadObject ( sbox, boxnum );
dbSetObjectLight ( 2, 0 );
dbSetObjectTexture ( 2, 3, 2 );
dbScaleObject ( 2, 5000, 5000, 5000 );
}
SetCurrentDirectory ("..");
}
//Unloads resources
void UnloadMap (int mapnum, int boxnum)
{
dbDeleteObject (mapnum);
dbDeleteObject (boxnum);
}
*EDIT*
ok the problem dosn't apear to be quite what i thought.
i have attached an image from when i do an SC_DrawObjectBounds
and have setup the object as a complex object. (seems to act exactly the same way as setting up the object normally).
any help is apriciated.