PhysX in TGE Version 0.3 (Work-In-Progress)
by Shannon "ScarWars" Scarvaci · 07/03/2006 (11:35 am) · 269 comments
Outline
1. License
2. Get SDK from Ageia
3. Implementation
4. Scripts
5. Know Issues
6. Need your supports!
License:
The license of PhysX is following:
Get SDK from Ageiq
You can obtain the SDK from www.ageia.com website, my currently version for this physics is 2.7.0.
If you are using Visual Studio then you need to add "include" and "library" in the project configuration.
(If you using linux or mac, then i don't know where to setup because I dont have linux or mac with me)
Directory for include files:
C:\Program Files\AGEIA PhysX SDK\v2.6.4\SDKs\Physics\include
C:\Program Files\AGEIA PhysX SDK\v2.6.4\SDKs\Foundation\include
C:\Program Files\AGEIA PhysX SDK\v2.6.4\SDKs\PhysXLoader\include
C:\Program Files\AGEIA PhysX SDK\v2.6.4\SDKs\Cooking\include
Directory for library files:
C:\Program Files\AGEIA PhysX SDK\v2.6.4\SDKs\lib\win32
Note: These files' path's are relative to my hard drive, your files may be in different directory depending on how you installed the PhysX SDK.
Please install AGEIA PhysX Runtime in your PC (prefered lastest version)
Also put two dll file (PhysXLoader.dll and NxCooking.dll from AGEIA PhysX SDK\v2.7.0\SDKs\Bin\win32) in the example folder.
Implementation
Copy the 17 files from "PhysX" folder into engine/PhysX and modify some TGE's source code files.
Player
in game/player.h in bold
game/player.cc at the top in bold
game/player.cc in Player::Player() function
game/player.cc in Player::onAdd() function
game/player.cc in Player::setPosition(...)
Terrain
in terrain/terrData.cc
at the top of the file
terrain/terrData.cc in TerrainBlock::onAdd function near the end
Interior
in interior/interior.h
in interior/interiorInstance.h
in interior/interiorInstance.cc
TSStatic
in ts/tsShapeInstance.h
in game/tsStatic.h
in game/tsStatic.cc
ShapeBase
in game\shapeBase.h
Material in GameBase
in game\gameBase.h
Scripts
Copy three script files (PhysX.cs, physXActorBox.cs and physXActorSphere.cs) in starter.fps/server/scripts and add three lines of code in starter.fps/server/scripts/games.cs
add one line of code in common/client/mission.cs
and in every mission file need to add PhysXWorld as show in bold:
If you want to testing around by droping the object in the free-look camera, then use default.bind.cs script
Know Issues
Terrain is the problem here because PhysX can accept 256x256 collision mesh in their engine which is mean squareSize equal to one! So the TGE's default squareSize is 8 and you see object will miss the collision in some area of the terrain. Possible solution is to create chunks, for example if you use squareSize of 8 then use 64 chunks of 256x256 collision mesh.
Loading the mesh of 256x256 collision will very slow but there possible solution is to write the mesh to file create by PhysX engine and read the file from PhysX will be lots faster, similar to lighting system which is used in TGE.
I've tried number of way to use Terrain collision in PhysX such as split in four section, NxHeightfield which make it very slow but I haven't tried this in PPU yet. So I have to stick with 256x256 collision mesh for a while.
Player/ShapeBase collision with PhysX's object is not complete.
Networking:
Loading objects from the begin in the remote client sometime not showing but if object appear during the gameplay will work ok. That something i need to be working on. (There may be some problem because of improved speed, but didn't test it yet)
Improved PhysX Speed
Big thank to decryptoid for helping us in PhysX, esp. for speed improvement.
Need your supports!
Now you can play with PhysX in your TGE game! If you find any improvement for this Physics in coding or script or anything please post here and I'll happy to update in here.
Also please use TDNfor any info to advise for our community
In the future:
- Run in PPU.
- Player collision.
- ShapeBase, (TSStatic and Interior - Completed) collision.
- Use advance physics such as joints, clothes and fluid. Done two type of joints
Enjoy your Physics!
Check out the video.
First Video
Second Video
Joints Video (4MB, prefer download before watch)
This is my first resource, please be kind to me :)
Due to file limit please download from here Updated 13th Apirl 2006
Here TGEA PhysX Resource here
1. License
2. Get SDK from Ageia
3. Implementation
4. Scripts
5. Know Issues
6. Need your supports!
License:
The license of PhysX is following:
Free:
* Commercial & non-commercial use on PC
Must keep registration information currect
Must agree to the EULA at the time of download (pops up, but is copied below)
Available for Windows & Linux (soon)
No PhysX HW support requirement
* PS3 platform (through Sony pre-purchase)
* All platforms through some of our middleware partnerships, such as UE3, Gamebryo 2.2,
and others
k per platform:
* Xbox 360
* Fee may be waived at our discretion for multi-platform developers providing PC HW support
* Fee may be waived at our discretion for some Tools & Middleware providersGet SDK from Ageiq
You can obtain the SDK from www.ageia.com website, my currently version for this physics is 2.7.0.
If you are using Visual Studio then you need to add "include" and "library" in the project configuration.
(If you using linux or mac, then i don't know where to setup because I dont have linux or mac with me)
Directory for include files:
C:\Program Files\AGEIA PhysX SDK\v2.6.4\SDKs\Physics\include
C:\Program Files\AGEIA PhysX SDK\v2.6.4\SDKs\Foundation\include
C:\Program Files\AGEIA PhysX SDK\v2.6.4\SDKs\PhysXLoader\include
C:\Program Files\AGEIA PhysX SDK\v2.6.4\SDKs\Cooking\include
Directory for library files:
C:\Program Files\AGEIA PhysX SDK\v2.6.4\SDKs\lib\win32
Note: These files' path's are relative to my hard drive, your files may be in different directory depending on how you installed the PhysX SDK.
Please install AGEIA PhysX Runtime in your PC (prefered lastest version)
Also put two dll file (PhysXLoader.dll and NxCooking.dll from AGEIA PhysX SDK\v2.7.0\SDKs\Bin\win32) in the example folder.
Implementation
Copy the 17 files from "PhysX" folder into engine/PhysX and modify some TGE's source code files.
Player
in game/player.h in bold
//----------------------------------------------------------------------------
[b]struct sNxActor;[/b]
class Player: public ShapeBase
{
typedef ShapeBase Parent;
[b]sNxActor *mActor;[/b]
protected:
/// Bit masks for different types of events
enum MaskBits {game/player.cc at the top in bold
//----------------------------------------------------------------------------- // Torque Game Engine // Copyright (C) GarageGames.com, Inc. //----------------------------------------------------------------------------- [b]#include "physX/PhysX.h" #include "physX/PhysXWorld.h"[/b] #include "game/player.h"
game/player.cc in Player::Player() function
mMountPending = 0; [b]mActor = NULL;[/b] }
game/player.cc in Player::onAdd() function
gCamFXMgr.clear();
}
[b]PhysXWorld *PxWorld = PhysXWorld::getWorld(isServerObject());
if (PxWorld) {
mActor = PxWorld->AddShapeBase(this);
}[/b]
return true;game/player.cc in Player::setPosition(...)
else {
mat.set(EulerF(0, 0, rot.z));
mat.setColumn(3,pos);
}
[b]if (mActor) {
QuatF q(mat);
Point3F pos;
mat.getColumn(3,&pos);
NxQuat quat;
quat.setXYZW(q.x,q.y,q.z,q.w);
mActor->actor->setGlobalOrientationQuat(quat);
mActor->actor->setGlobalPosition(NxVec3(pos.x,pos.y,pos.z));
}[/b]
Parent::setTransform(mat);
mRot = rot;
}Terrain
in terrain/terrData.cc
at the top of the file
#include "terrain/terrRender.h" #include "terrain/blender.h" [b]#include "physX/PhysXWorld.h"[/b] extern bool gDGLRender;
terrain/terrData.cc in TerrainBlock::onAdd function near the end
if(!unpackEmptySquares())
return(false);
[b]PhysXWorld *PxWorld = PhysXWorld::getWorld(isServerObject());
if (PxWorld) {
PxWorld->SetupTerrainCollision(); // old style
}[/b]
return true;
}Interior
in interior/interior.h
class Interior
{
...
friend class EditInteriorResource;
[b]friend class PhysXInterior;[/b]in interior/interiorInstance.h
class InteriorInstance : public SceneObject
{
...
friend class FloorPlan;
[b]friend class PhysXInterior;
friend class PhysXWorld;[/b]in interior/interiorInstance.cc
#include "platform/profiler.h"
[b]#include "physX/PhysXWorld.h"[/b]
...
bool InteriorInstance::onAdd()
{
...
addToScene();
[b]PhysXWorld *PxWorld = PhysXWorld::getWorld(isServerObject());
if (PxWorld) {
PxWorld->SetupInterior(*this);
}[/b]
return true;
}TSStatic
in ts/tsShapeInstance.h
class TSShapeInstance
{
...
friend class TSPartInstance;
[b]friend class PhysXTSStatic;
friend class PhysXActor;[/b]in game/tsStatic.h
class TSStatic : public SceneObject
{
...
friend class TSStaticConvex;
[b]friend class PhysXTSStatic;[/b]in game/tsStatic.cc
#include "sim/netConnection.h"
[b]#include "physX/PhysXWorld.h"[/b]
...
bool TSStatic::onAdd()
{
...
addToScene();
[b]PhysXWorld *PxWorld = PhysXWorld::getWorld(isServerObject());
if (PxWorld) {
PxWorld->SetupTSStatic(*this);
}[/b]
return true;
}ShapeBase
in game\shapeBase.h
class ShapeBase : public GameBase
{
typedef GameBase Parent;
friend class ShapeBaseConvex;
friend class ShapeBaseImageData;
[b]friend class PhysXWorld;[/b]Material in GameBase
in game\gameBase.h
[b]struct PhysXMaterialData;[/b]
struct GameBaseData : public SimDataBlock {
...
void unpackData(BitStream* stream);
[b]// PhysX
PhysXMaterialData* mMaterialBlock;[/b]
};
...
class GameBase : public SceneObject
{
...
enum GameBaseMasks {
InitialUpdateMask = Parent::NextFreeMask,
DataBlockMask = InitialUpdateMask << 1,
ExtendedInfoMask = DataBlockMask << 1,
ControlMask = ExtendedInfoMask << 1,
[b]//NextFreeMask = ControlMask << 1
// PhysX
MaterialDataBlockMask = ControlMask << 1,
NextFreeMask = MaterialDataBlockMask << 1[/b]
};
...
[b]// PhysX
bool setMaterialDataBlock(PhysXMaterialData* dptr);
bool onNewMaterialDataBlock(PhysXMaterialData* dptr);[/b]
};
...in game\gameBase.cc[b]#include "physX/PhysX.h"
#include "physX/PhysXActor.h"[/b]
#include "platform/platform.h"
...
GameBaseData::GameBaseData()
{
...
[b]mMaterialBlock = 0;[/b]
}
...
[b]IMPLEMENT_CONSOLETYPE(PhysXMaterialData)
IMPLEMENT_GETDATATYPE(PhysXMaterialData)
IMPLEMENT_SETDATATYPE(PhysXMaterialData)[/b]
void GameBaseData::initPersistFields()
{
Parent::initPersistFields();
...
[b]addField("materialBlock", TypePhysXMaterialDataPtr, Offset(mMaterialBlock, GameBaseData));[/b]
}
...
bool GameBase::onNewDataBlock(GameBaseData* dptr)
{
...
[b]onNewMaterialDataBlock(mDataBlock->mMaterialBlock);[/b]
setMaskBits(DataBlockMask);
return true;
}
...
bool GameBase::setDataBlock(GameBaseData* dptr)
{
...
}
[b]bool GameBase::setMaterialDataBlock(PhysXMaterialData* dptr)
{
if (isGhost() || isProperlyAdded()) {
if (mDataBlock->mMaterialBlock != dptr)
return onNewMaterialDataBlock(dptr);
}
else
mDataBlock->mMaterialBlock = dptr;
return true;
}
bool GameBase::onNewMaterialDataBlock(PhysXMaterialData* dptr)
{
mDataBlock->mMaterialBlock = dptr;
if (!mDataBlock->mMaterialBlock)
return false;
setMaskBits(MaterialDataBlockMask);
return true;
}[/b]
...
U32 GameBase::packUpdate(NetConnection *, U32 mask, BitStream *stream)
{
...
[b]if (stream->writeFlag((mask & MaterialDataBlockMask) && mDataBlock->mMaterialBlock != NULL)) {
stream->writeRangedU32(mDataBlock->mMaterialBlock->getId(),
DataBlockObjectIdFirst,
DataBlockObjectIdLast);
}[/b]
// cafTODO: ControlMask
return 0;
}
void GameBase::unpackUpdate(NetConnection *con, BitStream *stream)
{
...
[b]if (stream->readFlag()) {
PhysXMaterialData* dptrMD = 0;
SimObjectId id = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
if (!Sim::findObject(id,dptrMD) || !setMaterialDataBlock(dptrMD))
con->setLastError("Invalid packet GameBase::unpackUpdate()");
}[/b]
}Scripts
Copy three script files (PhysX.cs, physXActorBox.cs and physXActorSphere.cs) in starter.fps/server/scripts and add three lines of code in starter.fps/server/scripts/games.cs
// PhysX
exec("./physX.cs");
exec("./physXActorBox.cs");
exec("./physXActorSphere.cs");
exec("./physXJoints.cs");add one line of code in common/client/mission.cs
function clientCmdMissionStart(%seq)
{
// The client recieves a mission start right before
// being dropped into the game.
[b]startPhysX();[/b]
}and in every mission file need to add PhysXWorld as show in bold:
new SimGroup(MissionGroup) {
[b]new PhysXWorld() {
errorReport = false; // set to true if you want error report from PhysX
};[/b]
new ScriptObject(MissionInfo) {
...If you want to testing around by droping the object in the free-look camera, then use default.bind.cs script
function addCrate(%val)
{
if (%val)
commandToServer('pxcrate');
}
function addBox(%val)
{
if (%val)
commandToServer('pxbox');
}
function addRock(%val)
{
if (%val)
commandToServer('pxsphere');
}
moveMap.bind( keyboard, "alt r", addCrate);
moveMap.bind( keyboard, "alt t", addBox);
moveMap.bind( keyboard, "alt y", addRock);Know Issues
Terrain is the problem here because PhysX can accept 256x256 collision mesh in their engine which is mean squareSize equal to one! So the TGE's default squareSize is 8 and you see object will miss the collision in some area of the terrain. Possible solution is to create chunks, for example if you use squareSize of 8 then use 64 chunks of 256x256 collision mesh.
Loading the mesh of 256x256 collision will very slow but there possible solution is to write the mesh to file create by PhysX engine and read the file from PhysX will be lots faster, similar to lighting system which is used in TGE.
I've tried number of way to use Terrain collision in PhysX such as split in four section, NxHeightfield which make it very slow but I haven't tried this in PPU yet. So I have to stick with 256x256 collision mesh for a while.
Player/ShapeBase collision with PhysX's object is not complete.
Networking:
Loading objects from the begin in the remote client sometime not showing but if object appear during the gameplay will work ok. That something i need to be working on. (There may be some problem because of improved speed, but didn't test it yet)
Improved PhysX Speed
Big thank to decryptoid for helping us in PhysX, esp. for speed improvement.
Need your supports!
Now you can play with PhysX in your TGE game! If you find any improvement for this Physics in coding or script or anything please post here and I'll happy to update in here.
Also please use TDNfor any info to advise for our community
In the future:
- Run in PPU.
- Player collision.
- ShapeBase, (TSStatic and Interior - Completed) collision.
- Use advance physics such as joints, clothes and fluid. Done two type of joints
Enjoy your Physics!
Check out the video.
First Video
Second Video
Joints Video (4MB, prefer download before watch)
This is my first resource, please be kind to me :)
Due to file limit please download from here Updated 13th Apirl 2006
Here TGEA PhysX Resource here
About the author
#222
7>Compiling manifest to resources...
7>Linking...
7>gameTSCtrl.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall GameTSCtrl::~GameTSCtrl(void)" (??1GameTSCtrl@@UAE@XZ) referenced in function "public: virtual void * __thiscall GameTSCtrl::`scalar deleting destructor'(unsigned int)" (??_GGameTSCtrl@@UAEPAXI@Z)
7>gameTSCtrl.obj : error LNK2019: unresolved external symbol "public: static void __cdecl GameTSCtrl::initPersistFields(void)" (?initPersistFields@GameTSCtrl@@SAXXZ) referenced in function "public: virtual void __thiscall ConcreteClassRep::init(void)const " (?init@?$ConcreteClassRep@VGameTSCtrl@@@@UBEXXZ)
10/04/2007 (5:33 am)
When I try to compile, everything goes good except this happens during Linking:7>Compiling manifest to resources...
7>Linking...
7>gameTSCtrl.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall GameTSCtrl::~GameTSCtrl(void)" (??1GameTSCtrl@@UAE@XZ) referenced in function "public: virtual void * __thiscall GameTSCtrl::`scalar deleting destructor'(unsigned int)" (??_GGameTSCtrl@@UAEPAXI@Z)
7>gameTSCtrl.obj : error LNK2019: unresolved external symbol "public: static void __cdecl GameTSCtrl::initPersistFields(void)" (?initPersistFields@GameTSCtrl@@SAXXZ) referenced in function "public: virtual void __thiscall ConcreteClassRep
#223
Copy the 17 files from "PhysX" folder into engine/PhysX and modify some TGE's source code files."
What PhysX folder? I have searched my SDK folders, and I cannot locate a folder that contains 17 files. Obviously I've missed something, right? I am using SDk version 2.7.2 with Runtime version 7.06.25. Any help or thoughts?
11/05/2007 (7:31 am)
Question fellas!! In the instructions at the top of the post, where it states: "ImplementationCopy the 17 files from "PhysX" folder into engine/PhysX and modify some TGE's source code files."
What PhysX folder? I have searched my SDK folders, and I cannot locate a folder that contains 17 files. Obviously I've missed something, right? I am using SDk version 2.7.2 with Runtime version 7.06.25. Any help or thoughts?
#224
I'm trying to implement Decryptoid's code for allowing a projectile to interact with PhysX objects (shown about midway in the posts). However, when I add the code and compile, I get the following errors:
13>..\engine\game\projectile.cc(986) : error C2065: 'NxVec3' : undeclared identifier
13>..\engine\game\projectile.cc(986) : error C2146: syntax error : missing ';' before identifier 'nvHitPosition'
13>..\engine\game\projectile.cc(986) : error C2065: 'nvHitPosition' : undeclared identifier
13>..\engine\game\projectile.cc(991) : error C2146: syntax error : missing ';' before identifier 'nvHitNormalForce'
13>..\engine\game\projectile.cc(991) : error C2065: 'nvHitNormalForce' : undeclared identifier
13>..\engine\game\projectile.cc(994) : error C2680: 'PhysXActor *' : invalid target type for dynamic_cast
13> 'PhysXActor' : class must be defined before using in a dynamic_cast
13>..\engine\game\projectile.cc(997) : error C2027: use of undefined type 'PhysXActor'
13> ../engine\ts/tsShapeInstance.h(83) : see declaration of 'PhysXActor'
13>..\engine\game\projectile.cc(997) : error C2227: left of '->mActor' must point to class/struct/union/generic type
13>..\engine\game\projectile.cc(997) : error C2227: left of '->actor' must point to class/struct/union/generic type
13>..\engine\game\projectile.cc(997) : error C2227: left of '->addForceAtPos' must point to class/struct/union/generic type
13>..\engine\game\projectile.cc(997) : error C2065: 'NX_IMPULSE' : undeclared identifier
Any thoughts as too what I'm doing wrong? Before I added this code, the Torque compiled just fine, fyi. Thanks for any help!
Brett
11/07/2007 (12:54 pm)
Got the answer to my question, but now I have a new one :)I'm trying to implement Decryptoid's code for allowing a projectile to interact with PhysX objects (shown about midway in the posts). However, when I add the code and compile, I get the following errors:
13>..\engine\game\projectile.cc(986) : error C2065: 'NxVec3' : undeclared identifier
13>..\engine\game\projectile.cc(986) : error C2146: syntax error : missing ';' before identifier 'nvHitPosition'
13>..\engine\game\projectile.cc(986) : error C2065: 'nvHitPosition' : undeclared identifier
13>..\engine\game\projectile.cc(991) : error C2146: syntax error : missing ';' before identifier 'nvHitNormalForce'
13>..\engine\game\projectile.cc(991) : error C2065: 'nvHitNormalForce' : undeclared identifier
13>..\engine\game\projectile.cc(994) : error C2680: 'PhysXActor *' : invalid target type for dynamic_cast
13> 'PhysXActor' : class must be defined before using in a dynamic_cast
13>..\engine\game\projectile.cc(997) : error C2027: use of undefined type 'PhysXActor'
13> ../engine\ts/tsShapeInstance.h(83) : see declaration of 'PhysXActor'
13>..\engine\game\projectile.cc(997) : error C2227: left of '->mActor' must point to class/struct/union/generic type
13>..\engine\game\projectile.cc(997) : error C2227: left of '->actor' must point to class/struct/union/generic type
13>..\engine\game\projectile.cc(997) : error C2227: left of '->addForceAtPos' must point to class/struct/union/generic type
13>..\engine\game\projectile.cc(997) : error C2065: 'NX_IMPULSE' : undeclared identifier
Any thoughts as too what I'm doing wrong? Before I added this code, the Torque compiled just fine, fyi. Thanks for any help!
Brett
#225
Heh, should have tried to fix it before I posted. I wasted a lot of time thinking it was a bug in the networking, but then I realized that the only difference between dedicated and single player is that listen servers also have client code called. The startPhysX() command only gets called on the client, which is fine for single player and listen servers, but not dedicated.
You'll need to call startPhysX(); and I suggest you do it from GameConnection::loadMission() in missionDownload.cs, as this is the same spot it's called for the client (the client command fired off here calls startPhysX, but obviously this never happens on a dedicated server).
11/12/2007 (10:10 pm)
Old post: Quote:Hey, has anyone seen this work on a dedicated server in 1.5.x? It works fine on a listen server, but on a dedicated server the physics never actually start. Everything gets set up, and appears to be working fine, but nothing ever actually moves (on the client or server). New objects register correctly with PhysX, but their positions never change from spawn locations.
Heh, should have tried to fix it before I posted. I wasted a lot of time thinking it was a bug in the networking, but then I realized that the only difference between dedicated and single player is that listen servers also have client code called. The startPhysX() command only gets called on the client, which is fine for single player and listen servers, but not dedicated.
You'll need to call startPhysX(); and I suggest you do it from GameConnection::loadMission() in missionDownload.cs, as this is the same spot it's called for the client (the client command fired off here calls startPhysX, but obviously this never happens on a dedicated server).
#226
Basically, there isn't any. That is to say, while there's a system written to warp objects, that's not the full scale interpolation we want.
The whole resource is set up with the theory of creating a server and client instance of a PhysXWorld, however if you do some exploration you'll find that the client instance never actually does anything. A lot of support code is built for it, but in the end there are conditions in PhysXWorld.cpp and PhysXActor.cpp that keep anything from actually starting on the client.
And that's a good thing, considering what happens if you actually start the client-side physics in multiplayer. Apparently the client-side stuff is never getting the proper setup, because they just slide around as if they have 0 friction (you'll notice in your client console logs that every material is "null"). Disabling this is likely an intentional setup, since things could get really ugly in a full client/server physics setup. For example, if a joint breaks on the client (as actually happened), the server will never feel the need to tell the client about it unless you send joint connection info unconditionally, wasting a lot of bandwidth. Anyway, I'm still curious about the original intention with this setup.. why create the client instance at all if it does nothing?
Single player is a different story entirely. Here, all the data is always in sync; the server object and the client object are the same object, so you don't really need or want any interpolation. In fact, the built-in interpolation, being broken, actually introduces some glitching in single player. Enabling client-side physics smooths things out, and doesn't really introduce any problems because the material data is shared correctly here.
Anyway, what you see when you're in a dedicated server game setup as default (with the tweak to actually call physics start on the server), is the objects being run only on the server. This means that all the physics are 100% accurate, but they only run at the rate of incoming updates. Between ticks there's supposed to be some warp stuff, but it's not set up to work quite right. This setup is fine for internet multiplayer, where 100% smooth physics aren't as important as perfect netsync, but we at least want the warp to work as well as it does for the Vehicle class.
The desired functionality is PhysX doing the interpolation and prediction by actually running on the client, then being warped around as needed according to new server updates, just like Vehicle's interaction with Rigid. If this isn't done, then any PhysX object suffers from a kind of pysics lag, no matter how good the warping effect is, it will lag enough to mess with Players, especially if the player controls a PhysX object (touching objects that don't exist, input lag, etc). With the client running the physics, objects will move naturally based on the last server update, and we expect that the results will be pretty much the same as on the server. When it's not, we warp, but this only really comes up when control objects get involved and skew the client from the server.
You can control the client side joint issue by simply not allowing the client to attach or detach joints unless explicitly told by the server. I still have no idea what's going on with the friction/material stuff, though.
11/16/2007 (4:26 pm)
Okay, so I did a little more research into the multiplayer interpolation issues.Basically, there isn't any. That is to say, while there's a system written to warp objects, that's not the full scale interpolation we want.
The whole resource is set up with the theory of creating a server and client instance of a PhysXWorld, however if you do some exploration you'll find that the client instance never actually does anything. A lot of support code is built for it, but in the end there are conditions in PhysXWorld.cpp and PhysXActor.cpp that keep anything from actually starting on the client.
And that's a good thing, considering what happens if you actually start the client-side physics in multiplayer. Apparently the client-side stuff is never getting the proper setup, because they just slide around as if they have 0 friction (you'll notice in your client console logs that every material is "null"). Disabling this is likely an intentional setup, since things could get really ugly in a full client/server physics setup. For example, if a joint breaks on the client (as actually happened), the server will never feel the need to tell the client about it unless you send joint connection info unconditionally, wasting a lot of bandwidth. Anyway, I'm still curious about the original intention with this setup.. why create the client instance at all if it does nothing?
Single player is a different story entirely. Here, all the data is always in sync; the server object and the client object are the same object, so you don't really need or want any interpolation. In fact, the built-in interpolation, being broken, actually introduces some glitching in single player. Enabling client-side physics smooths things out, and doesn't really introduce any problems because the material data is shared correctly here.
Anyway, what you see when you're in a dedicated server game setup as default (with the tweak to actually call physics start on the server), is the objects being run only on the server. This means that all the physics are 100% accurate, but they only run at the rate of incoming updates. Between ticks there's supposed to be some warp stuff, but it's not set up to work quite right. This setup is fine for internet multiplayer, where 100% smooth physics aren't as important as perfect netsync, but we at least want the warp to work as well as it does for the Vehicle class.
The desired functionality is PhysX doing the interpolation and prediction by actually running on the client, then being warped around as needed according to new server updates, just like Vehicle's interaction with Rigid. If this isn't done, then any PhysX object suffers from a kind of pysics lag, no matter how good the warping effect is, it will lag enough to mess with Players, especially if the player controls a PhysX object (touching objects that don't exist, input lag, etc). With the client running the physics, objects will move naturally based on the last server update, and we expect that the results will be pretty much the same as on the server. When it's not, we warp, but this only really comes up when control objects get involved and skew the client from the server.
You can control the client side joint issue by simply not allowing the client to attach or detach joints unless explicitly told by the server. I still have no idea what's going on with the friction/material stuff, though.
#227
11/26/2007 (11:35 am)
Does anyone else have the problem where the game crashes when you remove an actor?
#228
Any ideas?
12/09/2007 (7:34 am)
Not sure what is going on here, i get no compile errors or warnings. But when i launch my game it crashes instantly. This happens as soon as i double click the exe file.Any ideas?
#229
12/09/2007 (1:54 pm)
I finally got the thing to compile by deleting nxAllocatable and all #include references, but, as I expected, the game crashes once I click the start mission button on the mission select dialog. The last line of the console says something about loading player.cs, and that's it. This angers me...
#230
12/11/2007 (9:53 pm)
If you're having build or immediate load crashes, then the problem is certainly in your implementation. There shouldn't be any reason you have to delete anything to get it working. Either you're not linking something correctly, don't have the correct DLLs in place, or you've messed up one of the installation steps and need to start over. Obviously there could be other incompatibilities with modified copies of TGE, but that's unlikely.
#231
Does anybody know how to make breakable joints?
01/06/2008 (6:13 pm)
Iv got it compiled and tested great!!!!Does anybody know how to make breakable joints?
#232
01/17/2008 (9:26 am)
How do you add the joints into the game?
#233
01/25/2008 (7:12 am)
@Cristaballa and Taylor - If you run the phys_test.mis mission, you will see an example of joints. You can toggle their ability to break in the datablocks.
#234
In PhysXActor.cpp, place the following at the bottom of the file:
In PhysXActor.h, copy in the following code:
Try firing at the stack of crates and other PhysXActors now.
01/29/2008 (10:10 am)
If anyone is interested in getting started with PhysX explosions, this is a good starter code snippet:In PhysXActor.cpp, place the following at the bottom of the file:
void PhysXActor::applyImpulse(const Point3F& position, const VectorF& vec)
{
NxVec3 pos(vec.x, vec.y, vec.z);
NxVec3 dir = mActor->actor->getGlobalPosition() - pos;
NxReal scaling = 1.0f - dir.magnitude() / 10;
if (scaling < 0.0f)
scaling = 0.0f;
dir.setMagnitude(0.99);
Con::errorf("***PHYSX*** ---- Applying impluse to %d", getId());
mActor->actor->addForce(4000 * dir, NX_IMPULSE);
setMaskBits(PositionMask);
}In PhysXActor.h, copy in the following code:
// Placed below bool getNodeLocalPoint() [b]void applyImpulse(const Point3F& pos,const VectorF& vec);[/b]
Try firing at the stack of crates and other PhysXActors now.
#235
please help me =( why i have this error? and this resource not function? =(
03/05/2008 (3:56 am)
=( hi have this problem uff----Compiling arcane.fx/server/scripts/physX/physX.cs... Loading compiled script arcane.fx/server/scripts/physX/physX.cs. Warning: (c:\torque\afx_combopack\engine\console\consoleobject.cc @ 62) Couldn't find class rep for dynamic class: PhysXMaterialData arcane.fx/server/scripts/physX/physX.cs (16): Unable to instantiate non-conobject class PhysXMaterialData. Warning: (c:\torque\afx_combopack\engine\console\consoleobject.cc @ 62) Couldn't find class rep for dynamic class: PhysXMaterialData arcane.fx/server/scripts/physX/physX.cs (22): Unable to instantiate non-conobject class PhysXMaterialData. Compiling arcane.fx/server/scripts/physX/physXActorBox.cs... Loading compiled script arcane.fx/server/scripts/physX/physXActorBox.cs. Warning: (c:\torque\afx_combopack\engine\console\consoleobject.cc @ 62) Couldn't find class rep for dynamic class: PhysXMaterialData arcane.fx/server/scripts/physX/physXActorBox.cs (17): Unable to instantiate non-conobject class PhysXMaterialData. Warning: (c:\torque\afx_combopack\engine\console\consoleobject.cc @ 62) Couldn't find class rep for dynamic class: PhysXActorData arcane.fx/server/scripts/physX/physXActorBox.cs (27): Unable to instantiate non-conobject class PhysXActorData. Compiling arcane.fx/server/scripts/physX/physXActorSphere.cs... Loading compiled script arcane.fx/server/scripts/physX/physXActorSphere.cs. Warning: (c:\torque\afx_combopack\engine\console\consoleobject.cc @ 62) Couldn't find class rep for dynamic class: PhysXMaterialData arcane.fx/server/scripts/physX/physXActorSphere.cs (16): Unable to instantiate non-conobject class PhysXMaterialData. Warning: (c:\torque\afx_combopack\engine\console\consoleobject.cc @ 62) Couldn't find class rep for dynamic class: PhysXActorData arcane.fx/server/scripts/physX/physXActorSphere.cs (29): Unable to instantiate non-conobject class PhysXActorData. Compiling arcane.fx/server/scripts/physX/physXJoints.cs... Loading compiled script arcane.fx/server/scripts/physX/physXJoints.cs. Warning: (c:\torque\afx_combopack\engine\console\consoleobject.cc @ 62) Couldn't find class rep for dynamic class: PhysXActorData arcane.fx/server/scripts/physX/physXJoints.cs (25): Unable to instantiate non-conobject class PhysXActorData. Warning: (c:\torque\afx_combopack\engine\console\consoleobject.cc @ 62) Couldn't find class rep for dynamic class: PhysXActorData arcane.fx/server/scripts/physX/physXJoints.cs (38): Unable to instantiate non-conobject class PhysXActorData. Warning: (c:\torque\afx_combopack\engine\console\consoleobject.cc @ 62) Couldn't find class rep for dynamic class: PhysXSphericalJointData arcane.fx/server/scripts/physX/physXJoints.cs (47): Unable to instantiate non-conobject class PhysXSphericalJointData. Warning: (c:\torque\afx_combopack\engine\console\consoleobject.cc @ 62) Couldn't find class rep for dynamic class: PhysXActorData arcane.fx/server/scripts/physX/physXJoints.cs (60): Unable to instantiate non-conobject class PhysXActorData. Warning: (c:\torque\afx_combopack\engine\console\consoleobject.cc @ 62) Couldn't find class rep for dynamic class: PhysXActorData arcane.fx/server/scripts/physX/physXJoints.cs (72): Unable to instantiate non-conobject class PhysXActorData. Warning: (c:\torque\afx_combopack\engine\console\consoleobject.cc @ 62) Couldn't find class rep for dynamic class: PhysXRevoluteJointData arcane.fx/server/scripts/physX/physXJoints.cs (0): Unable to instantiate non-conobject class PhysXRevoluteJointData. --- Warning: (c:\torque\afx_combopack\engine\console\consoleobject.cc @ 62) Couldn't find class rep for dynamic class: PhysXWorld arcane.fx/data/missions/Livello1.mis (0): Unable to instantiate non-conobject class PhysXWorld.
please help me =( why i have this error? and this resource not function? =(
#236
03/07/2008 (6:57 am)
Please help me!!! =(
#238
1>../engine\game/gameBase.h(199) : error C2146: syntax error : missing '}' before identifier 'MaterialDataBlockMask'
1>../engine\game/gameBase.h(199) : error C2864: 'GameBase::MaterialDataBlockMask' : only static const integral data members can be initialized within a class
1>../engine\game/gameBase.h(200) : error C2327: 'GameBase::MaterialDataBlockMask' : is not a type name, static, or enumerator
1>../engine\game/gameBase.h(200) : error C2065: 'MaterialDataBlockMask' : undeclared identifier
1>../engine\game/gameBase.h(202) : error C2365: 'NextFreeMask' : redefinition; previous definition was 'enumerator'
1> ../engine\game/gameBase.h(199) : see declaration of 'NextFreeMask'
1>../engine\game/gameBase.h(202) : error C2864: 'GameBase::NextFreeMask' : only static const integral data members can be initialized within a class
1>../engine\game/gameBase.h(202) : error C2143: syntax error : missing ';' before '}'
1>../engine\game/gameBase.h(224) : error C2065: 'mDataBlock' : undeclared identifier
1>../engine\game/gameBase.h(231) : error C2575: 'onNewDataBlock' : only member functions and bases can be virtual
1>../engine\game/gameBase.h(262) : error C2065: 'mProcessTick' : undeclared identifier
1>../engine\game/gameBase.h(279) : error C2065: 'mAfterObject' : undeclared identifier
1>../engine\game/gameBase.h(282) : error C3861: 'plUnlink': identifier not found
1>../engine\game/gameBase.h(290) : error C2575: 'processTick' : only member functions and bases can be virtual
1>../engine\game/gameBase.h(295) : error C2575: 'interpolateTick' : only member functions and bases can be virtual
1>../engine\game/gameBase.h(300) : error C2575: 'advanceTime' : only member functions and bases can be virtual
1>../engine\game/gameBase.h(303) : error C2575: 'preprocessMove' : only member functions and bases can be virtual
1>../engine\game/gameBase.h(325) : error C2575: 'writePacketData' : only member functions and bases can be virtual
1>../engine\game/gameBase.h(331) : error C2575: 'readPacketData' : only member functions and bases can be virtual
1>../engine\game/gameBase.h(340) : error C2575: 'getPacketDataChecksum' : only member functions and bases can be virtual
1>../engine\game/gameBase.h(347) : error C2065: 'mControllingClient' : undeclared identifier
1>../engine\game/gameBase.h(351) : error C2575: 'setControllingClient' : only member functions and bases can be virtual
1>../engine\game/gameBase.h(354) : error C2512: 'ConcreteClassRep' : no appropriate default constructor available
why is this not working?
im new to compiling so it might be something really simple.
plz help!
03/25/2008 (2:00 am)
im getting an error that says:1>../engine\game/gameBase.h(199) : error C2146: syntax error : missing '}' before identifier 'MaterialDataBlockMask'
1>../engine\game/gameBase.h(199) : error C2864: 'GameBase::MaterialDataBlockMask' : only static const integral data members can be initialized within a class
1>../engine\game/gameBase.h(200) : error C2327: 'GameBase::MaterialDataBlockMask' : is not a type name, static, or enumerator
1>../engine\game/gameBase.h(200) : error C2065: 'MaterialDataBlockMask' : undeclared identifier
1>../engine\game/gameBase.h(202) : error C2365: 'NextFreeMask' : redefinition; previous definition was 'enumerator'
1> ../engine\game/gameBase.h(199) : see declaration of 'NextFreeMask'
1>../engine\game/gameBase.h(202) : error C2864: 'GameBase::NextFreeMask' : only static const integral data members can be initialized within a class
1>../engine\game/gameBase.h(202) : error C2143: syntax error : missing ';' before '}'
1>../engine\game/gameBase.h(224) : error C2065: 'mDataBlock' : undeclared identifier
1>../engine\game/gameBase.h(231) : error C2575: 'onNewDataBlock' : only member functions and bases can be virtual
1>../engine\game/gameBase.h(262) : error C2065: 'mProcessTick' : undeclared identifier
1>../engine\game/gameBase.h(279) : error C2065: 'mAfterObject' : undeclared identifier
1>../engine\game/gameBase.h(282) : error C3861: 'plUnlink': identifier not found
1>../engine\game/gameBase.h(290) : error C2575: 'processTick' : only member functions and bases can be virtual
1>../engine\game/gameBase.h(295) : error C2575: 'interpolateTick' : only member functions and bases can be virtual
1>../engine\game/gameBase.h(300) : error C2575: 'advanceTime' : only member functions and bases can be virtual
1>../engine\game/gameBase.h(303) : error C2575: 'preprocessMove' : only member functions and bases can be virtual
1>../engine\game/gameBase.h(325) : error C2575: 'writePacketData' : only member functions and bases can be virtual
1>../engine\game/gameBase.h(331) : error C2575: 'readPacketData' : only member functions and bases can be virtual
1>../engine\game/gameBase.h(340) : error C2575: 'getPacketDataChecksum' : only member functions and bases can be virtual
1>../engine\game/gameBase.h(347) : error C2065: 'mControllingClient' : undeclared identifier
1>../engine\game/gameBase.h(351) : error C2575: 'setControllingClient' : only member functions and bases can be virtual
1>../engine\game/gameBase.h(354) : error C2512: 'ConcreteClassRep
why is this not working?
im new to compiling so it might be something really simple.
plz help!
#239
I Am shure it is very small but my error is
Error 1 error C2059: syntax error : 'string' c:\program files\ageia technologies\sdk\v2.7.3\sdks\physics\include\NxAllocateable.h 29 Torque Demo
Error 2 error C2091: function returns function c:\program files\ageia technologies\sdk\v2.7.3\sdks\physics\include\NxAllocateable.h 29 Torque Demo
Error 3 error C2802: static member 'operator new' has no formal parameters c:\program files\ageia technologies\sdk\v2.7.3\sdks\physics\include\NxAllocateable.h 29 Torque Demo
Error 4 error C2059: syntax error : 'string' c:\program files\ageia technologies\sdk\v2.7.3\sdks\physics\include\NxAllocateable.h 30 Torque Demo
Error 5 error C2090: function returns array c:\program files\ageia technologies\sdk\v2.7.3\sdks\physics\include\NxAllocateable.h 30 Torque Demo
Error 6 error C2761: 'void *(__cdecl *NxAllocateable::operator new(void))(size_t,NxMemoryType)' : member function redeclaration not allowed c:\program files\ageia technologies\sdk\v2.7.3\sdks\physics\include\NxAllocateable.h 42 Torque Demo
Error 7 fatal error C1903: unable to recover from previous error(s); stopping compilation c:\program files\ageia technologies\sdk\v2.7.3\sdks\physics\include\NxAllocateable.h 42 Torque Demo
03/31/2008 (12:17 pm)
Hi i am having a problem with the newer version of Ageia Physx and this tutorial.I Am shure it is very small but my error is
Error 1 error C2059: syntax error : 'string' c:\program files\ageia technologies\sdk\v2.7.3\sdks\physics\include\NxAllocateable.h 29 Torque Demo
Error 2 error C2091: function returns function c:\program files\ageia technologies\sdk\v2.7.3\sdks\physics\include\NxAllocateable.h 29 Torque Demo
Error 3 error C2802: static member 'operator new' has no formal parameters c:\program files\ageia technologies\sdk\v2.7.3\sdks\physics\include\NxAllocateable.h 29 Torque Demo
Error 4 error C2059: syntax error : 'string' c:\program files\ageia technologies\sdk\v2.7.3\sdks\physics\include\NxAllocateable.h 30 Torque Demo
Error 5 error C2090: function returns array c:\program files\ageia technologies\sdk\v2.7.3\sdks\physics\include\NxAllocateable.h 30 Torque Demo
Error 6 error C2761: 'void *(__cdecl *NxAllocateable::operator new(void))(size_t,NxMemoryType)' : member function redeclaration not allowed c:\program files\ageia technologies\sdk\v2.7.3\sdks\physics\include\NxAllocateable.h 42 Torque Demo
Error 7 fatal error C1903: unable to recover from previous error(s); stopping compilation c:\program files\ageia technologies\sdk\v2.7.3\sdks\physics\include\NxAllocateable.h 42 Torque Demo
#240
03/31/2008 (1:47 pm)
Ok i fixed my problem by removing some parts of that file but now whenever i delete a object in the editor the game crashes? anybody else have this problem and any fix? 
Torque Owner Bryce
Tactical AI Kit