Panda PhysX

Return to Panda Features in Development

Postby rdb » Sat Oct 09, 2010 12:53 am

As long as you have the SDK installed, makepanda should automatically detect it and compile with support for it.
rdb
 
Posts: 8637
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby enn0x » Sat Oct 09, 2010 11:57 am

@whitelynx

I am making some progress. I can compile on 32bit and 64bit Linux now, and with current Panda3D CVS and PhysX 2.8.3 I can verify the same segfaults that you reported. This is, I get them on 64bit AND 32bit, so this is not a problem specific to 64bit.

Since this very code works fine for the 2.8.1 Linux SDKs there must have been something changed on the PhysX SDK side. I didn't see anything mentioned in the PhysX documentation though. Also, the PhysX Linux samples come only in binary form (no source code and no build files) on Linux, so I have virtually no chance to find out what is done differently in these samples.

Please remember that the PhysX 2.8.3 SDK's you downloaded are BETA, and even after some month there is no public release, so it might be that there are still bugs and strange effects in 2.8.3 Linux SDKs.

On Windows I have already moved to the (released, not beta!) 2.8.4 SDKs, which make things much easier with regard to distribution (there is no longer a requirement for a PhysX system software).
enn0x
 
Posts: 1278
Joined: Wed Nov 08, 2006 1:39 am
Location: Germany, Munich

Postby enn0x » Mon Oct 11, 2010 5:18 pm

Here is a tiny sample for PhysX, pure C++ and nothing to do with Panda3D. It compiles for the new 2.8.3 SDK, and it also reproduces the segfault within fetchResults. There is nothing wrong with the code.

Whitelynx, can you verify this please? Also, since you are the only one who officially downloaded the closed 2.8.3 beta SDK, can you perhaps report this to NVIDIA as a possible bug?

Code: Select all
// g++ -DNX_DISABLE_FLUIDS -DCORELIB -DNX32 -DLINUX -I/usr/include/PhysX/v2.8.3/SDKs/Physics/include -I"" -I/usr/include/PhysX/v2.8.3/LowLevel/API/include -I/usr/include/PhysX/v2.8.3/SDKs/Cooking/include -I/usr/include/PhysX/v2.8.3/SDKs/PhysXLoader/include -I/usr/include/PhysX/v2.8.3/LowLevel/hlcommon/include -I/usr/include/PhysX/v2.8.3/SDKs/Foundation/include -I/usr/include/PhysX/v2.8.3/SDKs/NxCharacter/include -O3 -Wall -c -fmessage-length=0 -m32 -o"foo.o" "./foo.cpp"
// g++ -L/usr/lib32 -m32 -o"foo"  ./foo.o -lPhysXLoader -ldl -lpthread

#include <iostream>
#include "NxPhysics.h"

using std::cout;
using std::endl;

static NxPhysicsSDK* gPhysicsSDK = NULL;
static NxScene* gScene = NULL;
static NxActor* gPlane = NULL;

int main(int argc, char** argv) {

  // Init SDK
  NxPhysicsSDKDesc desc;
  NxSDKCreateError errorCode = NXCE_NO_ERROR;

  gPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION, NULL, NULL, desc, &errorCode);
  gPhysicsSDK->setParameter(NX_SKIN_WIDTH, 0.05f);

  // Create scene
  NxSceneDesc sceneDesc;

  sceneDesc.gravity = NxVec3(0.0f, -9.81f, 0.0f);
  gScene = gPhysicsSDK->createScene(sceneDesc);

  // Create ground plane
  NxPlaneShapeDesc planeDesc;
  NxActorDesc actorDesc;

  actorDesc.shapes.pushBack(&planeDesc);
  gPlane = gScene->createActor(actorDesc);

  // Main loop
  for (int i=0; i<10; i++) {
    gScene->simulate(0.1);
    cout << " 1.." << endl;
    gScene->flushStream();
    cout << "   2.." << endl;
    gScene->fetchResults(NX_RIGID_BODY_FINISHED, true);
    cout << "     3.." << endl;
  }
}
enn0x
 
Posts: 1278
Joined: Wed Nov 08, 2006 1:39 am
Location: Germany, Munich

Postby rdb » Mon Oct 11, 2010 5:29 pm

I tried compiling the 64-bits version of that (replacing NX32 by NX64, removing -m32 and the lib32 reference in the commands), and it segfaulted at fetchResults.
rdb
 
Posts: 8637
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby enn0x » Tue Oct 12, 2010 6:39 pm

Sorry, I should have added that I tried 64bit too, with the same compiler options you have used, and got the same result.

My conclusion is that - since I can't see any obvious mistake in this short sample - that Linux PhysX SDK 2.8.3 requires some new or modified defines. I try to dig up some info here...
enn0x
 
Posts: 1278
Joined: Wed Nov 08, 2006 1:39 am
Location: Germany, Munich

Postby Executor » Mon Nov 01, 2010 3:23 pm

I'm trying to compile the latest CVS on Windows, for the first time :), and am getting the following error (I have both VS C++ 2008 Express and VS 2005 installed with Win SDK 6.1 and PhysX SDK 2.8.1):

C:\PandaCVS\panda3d>makepanda\makepanda --use-physx
Generating library cache...
Generating dependencies...
[ 49%] Building C++ object built/tmp/physx_composite.obj
physx_composite.cxx
c:\pandacvs\panda3d\panda\src\physx\physxEnums.h(388) : error C2065: 'NX_LEGACY_
JOINT_DRIVE' : undeclared identifier
Storing dependency cache.
Elapsed Time: 18 sec

Build terminated.


Any ideas?

EDIT:
I found the following in the physxEnums.h file:

#ifndef PHYSX281
#define NX_FAST_MASSIVE_BP_VOLUME_DELETION 99
#define NX_LEGACY_JOINT_DRIVE 100
#endif /* PHYSX281 */


And lower down at line 388:

#ifndef LINUX /* The following enums are only defined in SDK version 2.8.1 */
P_fast_massive_bp_volume_deletion = NX_FAST_MASSIVE_BP_VOLUME_DELETION,
P_legacy_joint_drive = NX_LEGACY_JOINT_DRIVE,
#endif /* LINUX */


Shouldn't the first one be "#ifdef PHYSX281"? Tried it but it made no difference.
User avatar
Executor
 
Posts: 73
Joined: Tue Nov 25, 2008 6:10 am
Location: South Africa

Postby enn0x » Tue Nov 02, 2010 1:30 am

Ahhh, my fault. These flags are only defined in SDKs later than 2.8.1. So the preprocessor instruction in the lower half of physxEnums.h should be:
Code: Select all
#ifndef PHYSX281
    P_fast_massive_bp_volume_deletion       = NX_FAST_MASSIVE_BP_VOLUME_DELETION,
    P_legacy_joint_drive                    = NX_LEGACY_JOINT_DRIVE,
#endif


I also should have mentioned that we moved to newer versions of the PhysX SDK on Windows:
Windows: PhysX 2.8.4.4
Linux: PhysX 2.8.1

I recommend compiling on Windows 32bit using the 2.8.4.4 SDK. Windows 64bit is still untested. It's only Linux where we need to work with the obsolete 2.8.1 SDK.

Please notice that you no longer need to distribute a PhysX System Software from 2.8.4 on. You can, but you don't have to if you distribute just a few /dlls from the 2.8.4 SDK. The SDK documentation has a chapter about the new way of distributing.
enn0x
 
Posts: 1278
Joined: Wed Nov 08, 2006 1:39 am
Location: Germany, Munich

Postby Executor » Tue Nov 02, 2010 4:18 pm

Compiled, thanks.

When running, however, I got "<32bit>" printed to the console all the time. Found the following in physxScene.cxx:
Code: Select all
#ifdef NX64
  cout << "<64bit>";
#else
  cout << "<32bit>";
#endif

I guess it was for debugging purposes? Just commented it out...
User avatar
Executor
 
Posts: 73
Joined: Tue Nov 25, 2008 6:10 am
Location: South Africa

Postby enn0x » Tue Nov 02, 2010 6:37 pm

Yes, right, this has been for debugging purposes. I remove it in CVS too. Thanks for reporting.
enn0x
 
Posts: 1278
Joined: Wed Nov 08, 2006 1:39 am
Location: Germany, Munich

Postby enn0x » Wed Nov 17, 2010 2:10 am

There is a MacOSX version of the NVIDIA PhysX SDK by now. Version is 2.8.4, wich is the same as Windows.

I don't have a Mac, so I can't give it a try. But if someone is interested in attempting I would offer help with compiler errors. I don't expect the Panda3D code to compile out of the box on Mac, but it should be only minor modifications.
enn0x
 
Posts: 1278
Joined: Wed Nov 08, 2006 1:39 am
Location: Germany, Munich

Postby rdb » Wed Nov 17, 2010 2:30 am

Ooo! I'll give compiling it a try.
rdb
 
Posts: 8637
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby rdb » Wed Nov 17, 2010 11:16 am

OK, done, checked in the changes I needed to make. The latest OSX buildbot build should contain the PhysX support. (intel only, no ppc)

I haven't done extensive testing, but basic initialisation seems to work.
rdb
 
Posts: 8637
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby Craig » Wed Nov 17, 2010 11:31 am

rdb wrote:OK, done, checked in the changes I needed to make. The latest OSX buildbot build should contain the PhysX support. (intel only, no ppc)

I haven't done extensive testing, but basic initialisation seems to work.


I tested it some, and it seems to work for me as well.
Craig
 
Posts: 330
Joined: Thu Jul 02, 2009 8:55 pm

Postby rdb » Wed Nov 17, 2010 12:34 pm

enn0x wrote:My conclusion is that - since I can't see any obvious mistake in this short sample - that Linux PhysX SDK 2.8.3 requires some new or modified defines. I try to dig up some info here...


I took a pass at this, and checked in a fix. The PhysX samples now work fine for me on 64-bits Linux using the 2.8.3.3 SDK.
rdb
 
Posts: 8637
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby Executor » Fri Nov 19, 2010 4:16 am

Hay enn0x,

I'm getting the following error after downloading a 2 day old buildbot Windows build:

:physx(error): Error when setting up the PhysX subsystem: NXCE_PHYSX_NOT_FOUND
Assertion failed: error == NXCE_NO_ERROR at line 46 of c:\buildslave\dev_sdk_win
32\build\panda3d\panda\src\physx\physxManager.cxx


I have the latest System Software installed and SDK 2.8.4.4 on Windows 7 64bit.
User avatar
Executor
 
Posts: 73
Joined: Tue Nov 25, 2008 6:10 am
Location: South Africa

Postby enn0x » Fri Nov 19, 2010 3:16 pm

Hey executor,

this is a bit strange, since it works for me. Where did you place the following files:
- PhysXLoader.dll
- PhysXCore.dll
- PhysXCooking.dll
- PhysXDevice.dll
- cudart32_30_9.dll
- NxCharacter.dll
enn0x
 
Posts: 1278
Joined: Wed Nov 08, 2006 1:39 am
Location: Germany, Munich

Postby Executor » Mon Nov 22, 2010 3:02 am

I moved all those files to my games folder, where I already had the NxCharacter.dll, and it worked.

Didn't know they needed to be there?
User avatar
Executor
 
Posts: 73
Joined: Tue Nov 25, 2008 6:10 am
Location: South Africa

Postby enn0x » Mon Nov 22, 2010 6:41 am

Starting with PhysX SDK 2.8.4 there is a new deployment pattern. Have a look at the first pages of the PhysX SDK documentation, where the new deployment is described. For example we will be able to distribute games WITHOUT the need to have a system software installed. This is great news, because for example can now have all the above libraries inside Panda3D PhysxX runtime module.
enn0x
 
Posts: 1278
Joined: Wed Nov 08, 2006 1:39 am
Location: Germany, Munich

Postby wraithix » Fri Mar 25, 2011 3:10 am

I've just recently gotten back into coding after quite a long hiatus. I've had to install everything fresh, so at the moment I'm running Panda 1.7.1 with PhysX SDK 2.8.4.5. PhysX DLLs are copied into the bin, but after pulling down my code and try to run I get the following error:

Code: Select all
:physx(error): INVALID_PARAMETER: Supplied NxActorDesc::checkValid() returned 1. createActor returns NULL.

Assertion failed: actorPtr at line 396 of c:\buildslave\release_sdk_win32\build\panda3d\panda\src\physx\physxScene.cxx
Traceback (most recent call last):
self.mBody=base.mPhysicsMgr.getScene().createActor(actorDesc)


I understand what this error means, but not why I'm getting it. Here's the block of code where the error occurs:
Code: Select all
       
shapeDesc=PhysxConvexShapeDesc()
shapeDesc.setMesh(PhysxMeshPool.loadConvexMesh(collision))
       
# Set up body description for PhysX
bodyDesc=PhysxBodyDesc()
bodyDesc.setMass(self.mMass)
bodyDesc.setAngularDamping(self.mAngularDamping)
bodyDesc.setLinearDamping(self.mLinearDamping)
bodyDesc.setFlag(PhysxEnums.BFFrozenPosZ, True) # Limit movement the X/Y plane

# Set up actor description for PhysX
actorDesc=PhysxActorDesc()
actorDesc.setBody(bodyDesc)
actorDesc.addShape(shapeDesc)
actorDesc.setGlobalPos(model.getPos())
   
# Create the body as defined by the physics entity
self.mBody=base.mPhysicsMgr.getScene().createActor(actorDesc)


As far as I recall, everything was working when I last tried to run (which was some time ago). I just wanted to check whether there were any changes to Panda/PhysX's API recently that might have broken this code before I tear it apart.
wraithix
 
Posts: 27
Joined: Wed Dec 23, 2009 1:57 am

Postby enn0x » Fri Mar 25, 2011 7:44 am

Difficult. I don't see any obvious errors in your setup, and actorDesc.isValid() seems to return true.

My best guess is a version mismatch. You are using dlls from the PhytsX SDK 2.8.4.5 (released 16. Mar 2011) while Panda3d 1.7.1 uses the PhysX SDK 2.8.4.4.

Can you run the samples for PhysX using the 2.8.4.5 dlls? (http://enn0x.p3dp.com/samples.zip)

A second guess would be that the PhysX-native format for saving cooked meshes has changed between the releases, and you need to cook them again. But I don't think this is the problem.
enn0x
 
Posts: 1278
Joined: Wed Nov 08, 2006 1:39 am
Location: Germany, Munich

Postby wraithix » Fri Mar 25, 2011 4:22 pm

Your instincts were correct. The samples wouldn't run, so I installed 2.8.4.4 and it fixed all of my problems. Thanks for your help, you've saved me hours of confusion!
wraithix
 
Posts: 27
Joined: Wed Dec 23, 2009 1:57 am

Postby Krush » Fri Apr 01, 2011 12:39 am

Can someone post a .blend file of a example level that has like 4 walls and a floor with a hill or something in it? I can't figure out how to make a level with the cook stuff, all my things seem to keep lacking whatever is needed to label the collision.
- Krush
User avatar
Krush
 
Posts: 45
Joined: Mon Jan 24, 2011 8:13 pm
Location: USA

Postby enn0x » Fri Apr 01, 2011 1:55 am

Seen like you have problems with cooking, and not Blender. Would make sense if you post a blend file and we show you how to cook.
enn0x
 
Posts: 1278
Joined: Wed Nov 08, 2006 1:39 am
Location: Germany, Munich

Postby Krush » Fri Apr 01, 2011 2:08 am

enn0x wrote:Seen like you have problems with cooking, and not Blender. Would make sense if you post a blend file and we show you how to cook.

Guess I should start with a simple thing first.

I used the cook.py file that came with the samples so I thought it parsed the nodes and I just didn't have the right nodes or something.
- Krush
User avatar
Krush
 
Posts: 45
Joined: Mon Jan 24, 2011 8:13 pm
Location: USA

Postby enn0x » Fri Apr 01, 2011 8:04 am

Ok, first thing I notices is that the .egg file and the .blend file don't match: the .blend file contains a "quad" and a "box", while the .egg file contains no box, but a slighty more sophisticated terrain with one "hill" and one "ditch".

I tested with both versions, and the cook.py script produced exactly what I was expecting. What might have puzzled you is that the small script doesn't consider the GeomNode's transforms - it just reads the vertex data, and thus you get a 1x1 quad and a box at (0,0,0).

Well, the script is just an example for how to use the cooking API. It's easy to modify the script though:
Code: Select all
def processNP(modelNP):
  vertices = []
  triangles = []

  for geomNP in modelNP.findAllMatches('**/+GeomNode'):
    geomNode = geomNP.node()
    ts = geomNode.getTransform()
    for geom in geomNode.getGeoms():
      processVertices(geom, vertices, ts)
      processIndices(geom, triangles)

  return vertices, triangles

def processVertices(geom, vertices, ts):
  m = ts.getMat().getUpper3()
  p = ts.getMat().getRow3(3)

  vdata = geom.getVertexData()
  reader = GeomVertexReader(vdata, 'vertex')
  while not reader.isAtEnd():
    v = reader.getData3f()
    v = m.xform(v) + p
    vertices.append(Point3(v))


One sidenote: The simple cook.py script takes ALL the geometry within or below a NodePath, no matter how many GeomNodes they are. If you want to cook more complex levels you should break the levels down into more-or-less convex chunks. For example a bridge or arc over a valey in your terrain should be broken down into the terrain and the bridge (that is, one .nxb file for the terrain and one for the bridge). Also you might want to filter intangible objects within the script - it's up to you how you mark them in you egg files (or Blender).
enn0x
 
Posts: 1278
Joined: Wed Nov 08, 2006 1:39 am
Location: Germany, Munich

Postby Krush » Fri Apr 01, 2011 1:53 pm

I guess you're right it was more of a cooking issue. My next question is related to the bridge example you had.

Say I had a model of a house with a window (hole) in one side, would that need to be split up so that the roof that forms the top part of the window would be a separate nxb file?
- Krush
User avatar
Krush
 
Posts: 45
Joined: Mon Jan 24, 2011 8:13 pm
Location: USA

Postby enn0x » Fri Apr 01, 2011 4:01 pm

Can't say for sure. The algorithms for optimization of collision meshes used by PhysX are closed source, so I don't know exactly how it behaves.

You could start cooking in one piece, and keep in mind that if relevant "holes" are optimized away you have to split up into smaller pieces.
enn0x
 
Posts: 1278
Joined: Wed Nov 08, 2006 1:39 am
Location: Germany, Munich

Postby Krush » Fri Apr 01, 2011 6:34 pm

enn0x wrote:Can't say for sure. The algorithms for optimization of collision meshes used by PhysX are closed source, so I don't know exactly how it behaves.

You could start cooking in one piece, and keep in mind that if relevant "holes" are optimized away you have to split up into smaller pieces.

Yeah the potential removal of the 'holes' due to optimization was what I was asking, thought maybe someone might have ran into it already and could save me the trial and error, but with what you've told me I should be able to make some decent progress this weekend with converting all my stuff over to using physx instead of the ODE.
- Krush
User avatar
Krush
 
Posts: 45
Joined: Mon Jan 24, 2011 8:13 pm
Location: USA

Postby Krush » Sat Apr 02, 2011 7:49 pm

Any ideas why this code would crash?

Code: Select all
from direct.directbase import DirectStart
from direct.showbase.Loader import Loader
from panda3d.core import Filename
from panda3d.core import Point3, Vec3
from panda3d.physx import PhysxActorDesc
from panda3d.physx import PhysxMeshPool
from panda3d.physx import PhysxTriangleMeshShapeDesc

class PhysicalObject(object):
   def __init__(self, scene, name):
      self.scene = scene

      index = str(name).rfind('/')
      if index != -1:
         self.name = name[index+1:len(name)]
         fileFolder = name[0:index]

      self.modelFile = name + ".egg"
      self.meshFile = name + ".nxb"

      self.model = None
      self.modelNodeRoot = None
      self.actor = None

   def destroy(self, unloadModel=False):
      if self.actor != None:
         self.actor.detachNodePath()
      if self.modelNodeRoot != None:
         self.modelNodeRoot.remove()
      if self.model != None:
         if unloadModel:
            loader.unloadModel(self.model)
         self.model.removeNode()
      if self.actor != None:
         self.actor.release()

      self.model = None
      self.actor = None

   def createActorDesc(self, pos=Point3(0,0,0)):
      actorDesc = PhysxActorDesc()

      # add the mesh shape if there is one
      if self.meshFile != None:
         mesh = PhysxMeshPool.loadTriangleMesh(Filename(self.meshFile))
         shapeDesc = PhysxTriangleMeshShapeDesc()
         shapeDesc.setMesh(mesh)
         actorDesc.addShape(shapeDesc)

      actorDesc.setName(self.name)
      actorDesc.setGlobalPos(pos)

      return actorDesc

   def createActor(self, actorDesc):
      if self.modelFile == None:
         log.error("No model file found")

      self.model = loader.loadModel(self.modelFile)
      self.model.reparentTo(render)

      self.actor = self.scene.createActor(actorDesc)
      self.actor.attachNodePath(self.model)

      self.modelNodeRoot = self.model.find("-PandaNode")

"""
"""

base.setBackgroundColor(.2, .2, .2)
base.camLens.setFov(75)
base.camLens.setNear(0.01)
base.disableMouse()

base.cam.setPos(0, -20, 4)
base.cam.lookAt(0, 0, 1)

from panda3d.physx import PhysxEnums, PhysxManager, PhysxSceneDesc

# Scene
sceneDesc = PhysxSceneDesc()
sceneDesc.setGravity(Vec3(0, 0, -9.81))
sceneDesc.setFlag(PhysxEnums.SFForceConeFriction, True)

scene = PhysxManager.getGlobalPtr().createScene(sceneDesc)

myobject = PhysicalObject(scene, './Assets/Graphics/Models/Maps/testWorld')

actorDesc = myobject.createActorDesc()
myobject.createActor(actorDesc)


I narrowed it down to the line:
Code: Select all
self.actor = self.scene.createActor(actorDesc)


It doesn't seem to crash if the actorDesc is created in that function, or if it is created in the main file instead of using the object to make its own. I can't figure out why this is happening though. Makes it harder to reuse code with this crash as I have to basically copy paste a bunch of the same actorDesc code in any other object types i make especially if they need a body or shapes added
- Krush
User avatar
Krush
 
Posts: 45
Joined: Mon Jan 24, 2011 8:13 pm
Location: USA

Postby Krush » Sun Apr 03, 2011 2:34 am

In case anyone is wondering I figured out the issue with my code inside the createActorDesc I'm making a PhysxTriangleMeshShapeDesc() object but it appears the addShape call to stick it in the actor description doesn't make a copy of it, it just points to it, so when the code leaves that function it cleans up that object and now it's pointing at garbage when it tries to create the actor

So basically all I did was make a simple object to temporarily store that shape until after the actor is created then allow it to be cleaned up as usual.

Like this:
Code: Select all
from direct.directbase import DirectStart
from direct.showbase.Loader import Loader
from panda3d.core import Filename
from panda3d.core import Point3, Vec3
from panda3d.physx import PhysxActorDesc
from panda3d.physx import PhysxMeshPool
from panda3d.physx import PhysxTriangleMeshShapeDesc

class PhysicalObject(object):
   def __init__(self, scene, name):
      self.scene = scene

      index = str(name).rfind('/')
      if index != -1:
         self.name = name[index+1:len(name)]
         fileFolder = name[0:index]

      self.modelFile = name + ".egg"
      self.meshFile = name + ".nxb"

      self.model = None
      self.modelNodeRoot = None
      self.actor = None

   def destroy(self, unloadModel=False):
      if self.actor != None:
         self.actor.detachNodePath()
      if self.modelNodeRoot != None:
         self.modelNodeRoot.remove()
      if self.model != None:
         if unloadModel:
            loader.unloadModel(self.model)
         self.model.removeNode()
      if self.actor != None:
         self.actor.release()

      self.model = None
      self.actor = None

   def createActorDesc(self, pos=Point3(0,0,0)):
      desc = Description()

      actorDesc = PhysxActorDesc()

      # add the mesh shape if there is one
      if self.meshFile != None:
         mesh = PhysxMeshPool.loadTriangleMesh(Filename(self.meshFile))
         shapeDesc = PhysxTriangleMeshShapeDesc()
         shapeDesc.setMesh(mesh)
         desc.shapeDesc = shapeDesc
         actorDesc.addShape(shapeDesc)

      actorDesc.setName(self.name)
      actorDesc.setGlobalPos(pos)

      desc.actorDesc = actorDesc
      return desc

   def createActor(self, actorDesc):
      if self.modelFile == None:
         print "No model file found"
      else:
         self.model = loader.loadModel(self.modelFile)
         self.model.reparentTo(render)

      self.actor = self.scene.createActor(actorDesc)

      if self.model != None:
         self.actor.attachNodePath(self.model)
         self.modelNodeRoot = self.model.find("-PandaNode")

"""
"""

class Description():
   def __init__(self):
      self.actorDesc = None
      self.shapeDesc = None

base.setBackgroundColor(.2, .2, .2)
base.camLens.setFov(75)
base.camLens.setNear(0.01)
base.disableMouse()

base.cam.setPos(0, -20, 4)
base.cam.lookAt(0, 0, 1)

from panda3d.physx import PhysxEnums, PhysxManager, PhysxSceneDesc

# Scene
sceneDesc = PhysxSceneDesc()
sceneDesc.setGravity(Vec3(0, 0, -9.81))
sceneDesc.setFlag(PhysxEnums.SFForceConeFriction, True)

scene = PhysxManager.getGlobalPtr().createScene(sceneDesc)

myobject = PhysicalObject(scene, './models/testWorld')

desc = myobject.createActorDesc()
myobject.createActor(desc.actorDesc)


All i did was add that Description class to hold both so the shape can't be cleaned up until I'm done with it
- Krush
User avatar
Krush
 
Posts: 45
Joined: Mon Jan 24, 2011 8:13 pm
Location: USA

PreviousNext

Return to Panda Features in Development

Who is online

Users browsing this forum: No registered users and 1 guest