ok, so i cant get PhysX to work...
tried my own code, but did not work, so i tried with the sample code that came with Fulcrum, didnt work either... =S
#include "DarkGDK.h"
#include "physics.h"
void createWorld();
void createGround();
void createCharacter();
void createStairs();
void createBalls();
void createWall();
void createUprights();
void colourObjects();
void reset();
void moveCharacterControllerWithMouseAndKeys();
void displayData();
// Object numbers
int groundID = 1;
int characterID = 2;
int stairsFirstStepID = 3;
int numberOfSteps = 50; //3-52
int firstBallID = 53;
int numberOfBalls = 100; //53-152
int firstWallBlockID = 153;
int numberOfWallBlocks = 200; //154-352
int upright1ID = 353;
int upright2ID = 354;
int upright3ID = 355;
int upright4ID = 356;
int terrainID = 357;
physics myPhysics;
void DarkGDK ( void )
{
// PHYSICS
myPhysics.start(true, 0.5, 0.5, 0.5);
myPhysics.setGravity(0, -15, 0);
createWorld();
dbSyncOn ( );
dbSyncRate ( 60 );
dbPositionCamera ( 0, 0, -10 );
dbMakeLight(1);
dbPositionLight(1, 0, 100, 100);
//TERRAIN
dbLoadImage ( "texture.jpg", 1 );
dbLoadImage ( "detail.jpg", 2 );
dbSetupTerrain ( );
dbMakeObjectTerrain ( terrainID );
dbSetTerrainHeightMap ( terrainID, "map.bmp" );
dbSetTerrainScale ( terrainID, 3.0f, 0.6f, 3.0f );
dbSetTerrainLight ( terrainID, 1.0f, -0.25f, 0.0f, 1.0f, 1.0f, 0.78f, 0.5f );
dbSetTerrainTexture ( terrainID, 1, 2 );
dbBuildTerrain ( terrainID );
dbPositionObject(terrainID, -200, -100, -200);
myPhysics.makeTriangleMesh(terrainID);
myPhysics.simulate();
while ( LoopGDK ( ) )
{
if(dbSpaceKey()) reset();
myPhysics.update();
moveCharacterControllerWithMouseAndKeys(); // Put after update(), more so if you are applying forces
displayData();
dbUpdateTerrain();
dbSync ( );
}
myPhysics.stop();
return;
}
void createWorld()
{
createGround();
createCharacter();
createStairs();
createBalls();
createWall();
createUprights();
colourObjects();
}
void createGround()
{
dbMakeObjectBox(groundID, 200, 0, 200);
myPhysics.makeBox(groundID, false, 0);
}
void createCharacter()
{
// This is where you would load in your character model, I will use a box
dbMakeObjectBox(characterID, 1, 3, 1);
// I will offset the box as if it had been loaded in with its base(not centre)
// at (0, 0, 0), this is what the character controller expects and how most models
// are positioned in their local space
dbOffsetLimb(characterID, 0, 0, 1.5, 0); // Half of height(3), 1.5
dbPositionObject(characterID, 90, 0.1, 0); // place just above ground
myPhysics.makeCharacterController(characterID, 1.0, 45.0);
}
void createStairs()
{
for(int i = stairsFirstStepID; i < stairsFirstStepID + numberOfSteps; i++)
{
dbMakeObjectBox(i, 50, 1, 20);
dbPositionObject(i, 0, i - stairsFirstStepID + 0.5, 30 + i);
myPhysics.makeBox(i, false, 0);
}
}
void createBalls()
{
for(int i = firstBallID; i < firstBallID + numberOfBalls; i++)
{
dbMakeObjectSphere(i, 4, 20, 20);
dbPositionObject(i, 35 - dbRnd(i - firstBallID + 40), 100 + dbRnd(200), 45 + dbRnd(10));
myPhysics.makeSphere(i, true, 10.0f);
myPhysics.applyForce(i, 0, 0, 15);
}
}
void createWall()
{
int x;
int y;
int blockCount = firstWallBlockID;
for(x = 0; x < 20; x++)
{
for(y = 0; y < 10; y++)
{
// 200 blocks, 20 * 10
dbMakeObjectBox(blockCount, 2, 2, 2);
dbPositionObject(blockCount, x * 2 - 20, y * 2 + 1, -30);
myPhysics.makeBox(blockCount, true, 1.0f);
blockCount++;
}
}
}
void createUprights()
{
// First two convex meshes are static, therefore
// desity value is not used, just set to zero.
// Convex meshes have a maximum of 256 polygons.
dbMakeObjectCylinder(upright1ID, 20);
dbPositionObject(upright1ID, 75, 10, 75);
myPhysics.makeConvexMesh(upright1ID, false, 0);
dbMakeObjectCylinder(upright2ID, 20);
dbPositionObject(upright2ID, -75, 10, 75);
myPhysics.makeConvexMesh(upright2ID, false, 0);
// Next two convex meshes are dynamic
// Convex meshes have a maximum of 256 polygons.
dbMakeObjectCylinder(upright3ID, 5);
dbPositionObject(upright3ID, -10, 2.5, 0);
myPhysics.makeConvexMesh(upright3ID, true, 1.0f);
dbMakeObjectCylinder(upright4ID, 5);
dbPositionObject(upright4ID, 10, 2.5, 0);
myPhysics.makeConvexMesh(upright4ID, true, 1.0f);
}
void colourObjects()
{
for(int i = groundID; i < upright4ID + 1; i++)
{
if(i != 2)
dbColorObject(i, dbRGB(dbRND(255), dbRND(255), dbRND(255)));
}
}
void reset()
{
// You would not really delete everything and create everything again for a reset,
// but it is simpler and also a good way to test the release commands.
dbDeleteObject(groundID);
myPhysics.releaseActor(groundID);
dbDeleteObject(characterID);
myPhysics.releaseController(characterID);
for(int i = stairsFirstStepID; i < upright4ID + 1 ; i++)
{
dbDeleteObject(i);
myPhysics.releaseActor(i);
}
// Start again
createWorld();
}
void displayData()
{
dbText(0, 0, "Fulcrum Physics v1.1 demo (powered by PhysX)");
dbText(0, 30, "Use mouse and arrow keys to move, Space key to reset.");
dbText(0, 60, "FPS: ");
dbText(150, 60, dbStr(dbScreenFPS()));
dbText(0, 75, "Poly Count: ");
dbText(150, 75, dbStr(dbStatistic(1)));
}
void moveCharacterControllerWithMouseAndKeys()
{
float speed = 0;
// KEYS
if (dbUpKey())
{
speed = 0.2;
}
if (dbDownKey())
{
speed = -0.2;
}
// Move controller
// Controller is not controlled by physics so you need to add gravity yourself
float gravity = -0.5;
float angleY = dbObjectAngleY(characterID);
float moveX = dbSin(angleY); // Calculate X component
float moveZ = dbCos(angleY); // Calculate Z component
myPhysics.moveCharacterController(characterID, moveX * speed, gravity, moveZ * speed);
// MOUSE
static float YAngle = 0;
YAngle = YAngle + dbMouseMoveY() / 5;
static float XAngle = 0;
XAngle = XAngle + dbMouseMoveX() / 5;
// CAMERA
dbYRotateObject(characterID, dbCurveValue(XAngle, dbObjectAngleY(characterID), 10));
dbXRotateCamera(dbCurveValue(YAngle, dbCameraAngleX(), 10));
dbSetCameraToFollow(dbObjectPositionX(characterID), dbObjectPositionY(characterID), dbObjectPositionZ(characterID), dbObjectAngleY(characterID) - 15, 5, 3 + (dbCameraAngleX() / 20), 1, 0);
dbYRotateCamera(dbObjectAngleY(characterID));
}
And here is the build log:
1>------ Build started: Project: FulcrumPhysX, Configuration: Debug Win32 ------
1>Linking...
1> Creating library Debug\FulcrumPhysX.lib and object Debug\FulcrumPhysX.exp
1>Main.obj : error LNK2019: unresolved external symbol "public: void __thiscall physics::stop(void)" (?stop@physics@@QAEXXZ) referenced in function "void __cdecl DarkGDK(void)" (?DarkGDK@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: void __thiscall physics::update(void)" (?update@physics@@QAEXXZ) referenced in function "void __cdecl DarkGDK(void)" (?DarkGDK@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: void __thiscall physics::simulate(void)" (?simulate@physics@@QAEXXZ) referenced in function "void __cdecl DarkGDK(void)" (?DarkGDK@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: bool __thiscall physics::makeTriangleMesh(int)" (?makeTriangleMesh@physics@@QAE_NH@Z) referenced in function "void __cdecl DarkGDK(void)" (?DarkGDK@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: void __thiscall physics::setGravity(float,float,float)" (?setGravity@physics@@QAEXMMM@Z) referenced in function "void __cdecl DarkGDK(void)" (?DarkGDK@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: bool __thiscall physics::start(bool,float,float,float)" (?start@physics@@QAE_N_NMMM@Z) referenced in function "void __cdecl DarkGDK(void)" (?DarkGDK@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: bool __thiscall physics::makeBox(int,bool,float)" (?makeBox@physics@@QAE_NH_NM@Z) referenced in function "void __cdecl createGround(void)" (?createGround@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: bool __thiscall physics::makeCharacterController(int,float,float)" (?makeCharacterController@physics@@QAE_NHMM@Z) referenced in function "void __cdecl createCharacter(void)" (?createCharacter@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: void __thiscall physics::applyForce(int,float,float,float)" (?applyForce@physics@@QAEXHMMM@Z) referenced in function "void __cdecl createBalls(void)" (?createBalls@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: bool __thiscall physics::makeSphere(int,bool,float)" (?makeSphere@physics@@QAE_NH_NM@Z) referenced in function "void __cdecl createBalls(void)" (?createBalls@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: bool __thiscall physics::makeConvexMesh(int,bool,float)" (?makeConvexMesh@physics@@QAE_NH_NM@Z) referenced in function "void __cdecl createUprights(void)" (?createUprights@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: void __thiscall physics::releaseController(int)" (?releaseController@physics@@QAEXH@Z) referenced in function "void __cdecl reset(void)" (?reset@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: void __thiscall physics::releaseActor(int)" (?releaseActor@physics@@QAEXH@Z) referenced in function "void __cdecl reset(void)" (?reset@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: void __thiscall physics::moveCharacterController(int,float,float,float)" (?moveCharacterController@physics@@QAEXHMMM@Z) referenced in function "void __cdecl moveCharacterControllerWithMouseAndKeys(void)" (?moveCharacterControllerWithMouseAndKeys@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: __thiscall physics::physics(void)" (??0physics@@QAE@XZ) referenced in function "void __cdecl `dynamic initializer for 'myPhysics''(void)" (??__EmyPhysics@@YAXXZ)
1>Main.obj : error LNK2019: unresolved external symbol "public: __thiscall physics::~physics(void)" (??1physics@@QAE@XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'myPhysics''(void)" (??__FmyPhysics@@YAXXZ)
1>Debug\FulcrumPhysX.exe : fatal error LNK1120: 16 unresolved externals
1>Build log was saved at "file://c:\Users\Johan\Documents\Programmering\FulcrumPhysX\FulcrumPhysX\Debug\BuildLog.htm"
1>FulcrumPhysX - 17 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
What can i do to solve this?