I have been having trouble with getting a simple Hello Havok world program to work. I have been trying to follow this sites instructions on how to do it:
http://marcoarena.wordpress.com/2011/04/17/nice-to-meet-you-havok/
// Base
#include
#include
#include
#include
// Physics
#include
#include
#include
#include
#include
#include
#include
// Visual Debugger includes
#include
#include
// Hello Havok World: this demo demonstrates how to make a physics simulation using Havok.
// Running the demo will create a hkpWorld, with two objects of type hkpRigidBody : a floor and
// a ball bouncing on it.
// If the VisualDebugger is running whilst the demo is run, the demo will automatically
// connect to the VisualDebugger and show the scene.
// The demo runs for 20 seconds, and to show the simulation is operating, displays on the console
// the coordinates of the hkpRigidBody as it moves once every second.
// generic function for errorReport (don't care about this, just put it here!)
static void HK_CALL errorReport(const char* msg, void* userContext)
{
using namespace std;
printf("%s", msg);
}
// Add the floor into the world
static void addFixedSurface(hkpWorld* world, const hkVector4& position, const hkVector4& dimensions)
{
hkReal m_fhkConvexShapeRadius = (hkReal) 0.05;
hkpShape* fixedSurfaceShape = new hkpBoxShape(dimensions,m_fhkConvexShapeRadius);
//create rigid body information structure
hkpRigidBodyCinfo m_rigidBodyInfo;
//MOTION_FIXED means static element in game scene
m_rigidBodyInfo.m_mass = 10.0;
m_rigidBodyInfo.m_shape = fixedSurfaceShape;
m_rigidBodyInfo.m_motionType = hkpMotion::MOTION_FIXED;
m_rigidBodyInfo.m_position = position;
//create a new rigid body with supplied info
hkpRigidBody* m_pRigidBody = new hkpRigidBody(m_rigidBodyInfo);
//add rigid body to the world
world->addEntity (m_pRigidBody);
//decrease reference counter for rigid body and shape
m_pRigidBody->removeReference();
fixedSurfaceShape->removeReference();
}
// MAIN FUNCTION
int HK_CALL main(int argc, const char** argv)
{
hkMallocAllocator baseMalloc;
// Need to have memory allocated for the solver. Allocate 1mb for it.
hkMemoryRouter* memoryRouter = hkMemoryInitUtil::initDefault(
&baseMalloc, hkMemorySystem::FrameInfo(1024 * 1024) );
hkBaseSystem::init( memoryRouter, errorReport );
{
// object for custom information about the world
hkpWorldCinfo info;
// e.g. set manually the gravity (try to tune this parameter!)
info.m_gravity.set( 0,-9.8f,0);
// use default information (try to use our "info" object)
hkpWorld* world = new hkpWorld( hkpWorldCinfo() );
// Register all collision agents (before adding entities, try doing the opposite!)
hkpAgentRegisterUtil::registerAllAgents( world->getCollisionDispatcher() );
// Bouncing sphere
hkpRigidBody* rigidBody;
{
// Create a sphere with radius 2.0 m
hkpSphereShape* sphereShape = new hkpSphereShape(2.0f);
// Sphere information
hkpRigidBodyCinfo bodyCinfo;
// spherical shape
bodyCinfo.m_shape = sphereShape;
// start position
bodyCinfo.m_position = hkVector4(0.0,15.0,0.0,0.0);
// Calculate the mass properties for the shape
const hkReal sphereMass = 10.0f; // mass of the sphere
hkpMassProperties massProperties; // output variable
// Compute the inertia tensor (e.g. dynamic information)
hkpInertiaTensorComputer::computeShapeVolumeMassProperties(
sphereShape, sphereMass, massProperties);
// Update mass properties
bodyCinfo.setMassProperties(massProperties);
// Elasticity (value between 0 and 1.99, default = 0.4)
bodyCinfo.m_restitution = (hkReal) 1.9;
// Create the rigid body
rigidBody = new hkpRigidBody(bodyCinfo);
// No longer need the reference on the sphereShape, as the rigidBody now owns it
sphereShape->removeReference();
}
// Add the rigidBody to the world
world->addEntity(rigidBody);
// Add a static floor
addFixedSurface(world, hkVector4(0.0,0.0,0.0,0.0), hkVector4(30.0,1.0,30.0,1.0));
// Register all the physics viewers
hkpPhysicsContext::registerAllPhysicsProcesses();
// Set up a physics context containing the world for the use in the visual debugger
hkpPhysicsContext* context = new hkpPhysicsContext;
context->addWorld(world);
// Set up the visual debugger
hkVisualDebugger* visualDebugger;
{
// Setup the visual debugger
hkArray contexts;
contexts.pushBack(context);
visualDebugger = new hkVisualDebugger(contexts);
visualDebugger->serve();
}
// A stopwatch (64-bit timer) for waiting until the real time has passed
hkStopwatch stopWatch;
stopWatch.start();
hkReal lastTime = stopWatch.getElapsedSeconds();
// Update as if running at 60 frames per second.
const int numStepsPerSecond = 60;
const hkReal timeStep = 1.0f / hkReal(numStepsPerSecond);
// Run for 20 seconds
for ( int i = 0; i < numStepsPerSecond * 20; ++i )
{
// Do a simulation step
world->stepDeltaTime(timeStep);
// Step the debugger
visualDebugger->step();
// Display (on the console) the position of the rigid body every second
if (i % 60 == 0)
{
hkVector4 pos = rigidBody->getPosition();
using namespace std;
printf("[%f,%f,%f]n", pos(0), pos(1), pos(2));
}
// Pause until the actual time has passed
while (stopWatch.getElapsedSeconds() < lastTime + timeStep)
;
lastTime += timeStep;
}
// Release the visual debugger
visualDebugger->removeReference();
// No longer need the ref of rigidBody - as the world now owns it
rigidBody->removeReference();
// Release the reference on the world
world->removeReference();
// Contexts are not reference counted at the base class level by the VDB as
// they are just interfaces really. So only delete the context after you have
// finished using the VDB.
context->removeReference();
}
hkBaseSystem::quit();
hkMemoryInitUtil::quit();
return 0;
}
// [id=keycode]
#include
// [id=productfeatures]
// We're using only physics - we undef products even if the keycode is present so
// that we don't get the usual initialization for these products.
//zcode
//////////////z
#undef HK_FEATURE_PRODUCT_AI
#undef HK_FEATURE_PRODUCT_ANIMATION
#undef HK_FEATURE_PRODUCT_CLOTH
#undef HK_FEATURE_PRODUCT_DESTRUCTION
#undef HK_FEATURE_PRODUCT_BEHAVIOR
#define HK_EXCLUDE_FEATURE_SerializeDeprecatedPre700
#define HK_EXCLUDE_FEATURE_RegisterVersionPatches
// Vdb needs the reflected classes
#define HK_EXCLUDE_FEATURE_MemoryTracker
#define HK_EXCLUDE_FEATURE_hkpAccurateInertiaTensorComputer
#define HK_EXCLUDE_FEATURE_CompoundShape
#define HK_EXCLUDE_FEATURE_hkpAabbTreeWorldManager
#define HK_EXCLUDE_FEATURE_hkpContinuousSimulation
#define HK_EXCLUDE_FEATURE_hkpKdTreeWorldManager
#include
I have been beating my head against the wall trying to figure out these linker errors. I discovered a few of my linker problems was caused because I did not insert a Linker input "hkCompat.lib" and/or "hkcdInternal.lib". The rest of these linker errors I can not identify.
///// start of build fail output
1>------ Build started: Project: havokVD, Configuration: Debug Win32 ------
1>Build started 3/9/2012 2:46:24 PM.
1>InitializeBuildStatus:
1> Touching "Debug\\havokVD.unsuccessfulbuild".
1>ClCompile:
1> HavokHello.cpp
1>ManifestResourceCompile:
1> All outputs are up-to-date.
1>HavokHello.obj : error LNK2001: unresolved external symbol "class hkClass const hkcdShapeTypeClass" (?hkcdShapeTypeClass@@3VhkClass@@B)
1>HavokHello.obj : error LNK2001: unresolved external symbol "class hkClass const hkcdShapeInfoCodecTypeClass" (?hkcdShapeInfoCodecTypeClass@@3VhkClass@@B)
1>HavokHello.obj : error LNK2001: unresolved external symbol "class hkClass const hkcdShapeDispatchTypeClass" (?hkcdShapeDispatchTypeClass@@3VhkClass@@B)
1>HavokHello.obj : error LNK2001: unresolved external symbol "class hkClass const hkcdShapeClass" (?hkcdShapeClass@@3VhkClass@@B)
1>hkpCollide.lib(hkpShapeBaseReflection.obj) : error LNK2001: unresolved external symbol "class hkClass const hkcdShapeClass" (?hkcdShapeClass@@3VhkClass@@B)
1>hkpDynamics.lib(hkpBreakableShapeReflection.obj) : error LNK2001: unresolved external symbol "class hkClass const hkcdShapeClass" (?hkcdShapeClass@@3VhkClass@@B)
1>HavokHello.obj : error LNK2001: unresolved external symbol "class hkTypeInfo const hkcdShapeTypeTypeInfo" (?hkcdShapeTypeTypeInfo@@3VhkTypeInfo@@B)
1>HavokHello.obj : error LNK2001: unresolved external symbol "class hkTypeInfo const hkcdShapeInfoCodecTypeTypeInfo" (?hkcdShapeInfoCodecTypeTypeInfo@@3VhkTypeInfo@@B)
1>HavokHello.obj : error LNK2001: unresolved external symbol "class hkTypeInfo const hkcdShapeDispatchTypeTypeInfo" (?hkcdShapeDispatchTypeTypeInfo@@3VhkTypeInfo@@B)
1>HavokHello.obj : error LNK2001: unresolved external symbol "class hkTypeInfo const hkcdShapeTypeInfo" (?hkcdShapeTypeInfo@@3VhkTypeInfo@@B)
1>hkpCollide.lib(hkpShapeBase.obj) : error LNK2001: unresolved external symbol "public: static unsigned int hkcdShapeVirtualTableUtil::s_unregisteredFunctions" (?s_unregisteredFunctions@hkcdShapeVirtualTableUtil@@2IA)
1>hkpCollide.lib(hkpShapeBase.obj) : error LNK2019: unresolved external symbol "public: __thiscall hkcdShape::hkcdShape(class hkFinishLoadedObjectFlag)" (??0hkcdShape@@QAE@VhkFinishLoadedObjectFlag@@@Z) referenced in function "public: __thiscall hkpShapeBase::hkpShapeBase(class hkFinishLoadedObjectFlag)" (??0hkpShapeBase@@QAE@VhkFinishLoadedObjectFlag@@@Z)
1>hkpCollide.lib(hkpCompressedMeshShapeBuilder.obj) : error LNK2001: unresolved external symbol "unsigned int __cdecl hkcdTriangleUtil::isDegenerate(class hkVector4 const &,class hkVector4 const &,class hkVector4 const &,class hkSimdReal const &)" (?isDegenerate@hkcdTriangleUtil@@YAIABVhkVector4@@00ABVhkSimdReal@@@Z)
1>hkpCollide.lib(hkTjunctionDetector.obj) : error LNK2001: unresolved external symbol "unsigned int __cdecl hkcdTriangleUtil::isDegenerate(class hkVector4 const &,class hkVector4 const &,class hkVector4 const &,class hkSimdReal const &)" (?isDegenerate@hkcdTriangleUtil@@YAIABVhkVector4@@00ABVhkSimdReal@@@Z)
1>hkpCollide.lib(hkpConvexPieceMeshShape.obj) : error LNK2001: unresolved external symbol "unsigned int __cdecl hkcdTriangleUtil::isDegenerate(class hkVector4 const &,class hkVector4 const &,class hkVector4 const &,class hkSimdReal const &)" (?isDegenerate@hkcdTriangleUtil@@YAIABVhkVector4@@00ABVhkSimdReal@@@Z)
1>hkpInternal.lib(hkpBvCompressedMeshShape_Construction.obj) : error LNK2001: unresolved external symbol "unsigned int __cdecl hkcdTriangleUtil::isDegenerate(class hkVector4 const &,class hkVector4 const &,class hkVector4 const &,class hkSimdReal const &)" (?isDegenerate@hkcdTriangleUtil@@YAIABVhkVector4@@00ABVhkSimdReal@@@Z)
1>hkpUtilities.lib(hkpConvexRadiusBuilder.obj) : error LNK2001: unresolved external symbol "unsigned int __cdecl hkcdTriangleUtil::isDegenerate(class hkVector4 const &,class hkVector4 const &,class hkVector4 const &,class hkSimdReal const &)" (?isDegenerate@hkcdTriangleUtil@@YAIABVhkVector4@@00ABVhkSimdReal@@@Z)
1>hkpCollide.lib(hkpMeshWeldingUtility.obj) : error LNK2001: unresolved external symbol "unsigned int __cdecl hkcdTriangleUtil::isDegenerate(class hkVector4 const &,class hkVector4 const &,class hkVector4 const &,class hkSimdReal const &)" (?isDegenerate@hkcdTriangleUtil@@YAIABVhkVector4@@00ABVhkSimdReal@@@Z)
1>hkpCollide.lib(hkpSimpleMeshShape.obj) : error LNK2019: unresolved external symbol "unsigned int __cdecl hkcdTriangleUtil::isDegenerate(class hkVector4 const &,class hkVector4 const &,class hkVector4 const &,class hkSimdReal const &)" (?isDegenerate@hkcdTriangleUtil@@YAIABVhkVector4@@00ABVhkSimdReal@@@Z) referenced in function "public: virtual unsigned int __thiscall hkpSimpleMeshShape::getFirstKey(void)const " (?getFirstKey@hkpSimpleMeshShape@@UBEIXZ)
1>hkpCollide.lib(hkpMeshShape.obj) : error LNK2001: unresolved external symbol "unsigned int __cdecl hkcdTriangleUtil::isDegenerate(class hkVector4 const &,class hkVector4 const &,class hkVector4 const &,class hkSimdReal const &)" (?isDegenerate@hkcdTriangleUtil@@YAIABVhkVector4@@00ABVhkSimdReal@@@Z)
1>hkpCollide.lib(hkpExtendedMeshShape.obj) : error LNK2001: unresolved external symbol "unsigned int __cdecl hkcdTriangleUtil::isDegenerate(class hkVector4 const &,class hkVector4 const &,class hkVector4 const &,class hkSimdReal const &)" (?isDegenerate@hkcdTriangleUtil@@YAIABVhkVector4@@00ABVhkSimdReal@@@Z)
1>hkpCollide.lib(hkpCompressedMeshShape.obj) : error LNK2001: unresolved external symbol "unsigned int __cdecl hkcdTriangleUtil::isDegenerate(class hkVector4 const &,class hkVector4 const &,class hkVector4 const &,class hkSimdReal const &)" (?isDegenerate@hkcdTriangleUtil@@YAIABVhkVector4@@00ABVhkSimdReal@@@Z)
1>hkpInternal.lib(hkpConvexPenetrationUtil.obj) : error LNK2019: unresolved external symbol "void __cdecl hkcdTriangleUtil::calcBarycentricCoordinates(class hkVector4 const &,class hkVector4 const &,class hkVector4 const &,class hkVector4 const &,class hkVector4 &)" (?calcBarycentricCoordinates@hkcdTriangleUtil@@YAXABVhkVector4@@000AAV2@@Z) referenced in function "public: static void __cdecl hkpCollideTriangleUtil::calcBarycentricCoordinates(class hkVector4 const &,class hkVector4 const &,class hkVector4 const &,class hkVector4 const &,class hkVector4 &)" (?calcBarycentricCoordinates@hkpCollideTriangleUtil@@SAXABVhkVector4@@000AAV2@@Z)
1>hkcdInternal.lib(hkcdGskImpl.obj) : error LNK2001: unresolved external symbol "void __cdecl hkcdTriangleUtil::calcBarycentricCoordinates(class hkVector4 const &,class hkVector4 const &,class hkVector4 const &,class hkVector4 const &,class hkVector4 &)" (?calcBarycentricCoordinates@hkcdTriangleUtil@@YAXABVhkVector4@@000AAV2@@Z)
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>\\\\Halflife\\Profiles\\zdd0006\\Documents\\Spring2012\\5260 group\\HavokVDebug\\havokVD\\Debug\\havokVD.exe : fatal error LNK1120: 13 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:21.07
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
//// end of build fail output
Can anyone suggest what I might be doing wrong so I can start programing again? Any help would be very much apperciated.



