It compiled after making the changes but unfortunately I’m getting the following assertion in the console, just after the Panda window comes up:
Nice. Time to use the debugger and find out what is causing these asserts.
This error message means someone was incorrectly using Panda’s reference counts. In particular, someone explicitly used “delete” on an object that inherited from ReferenceCount, which you should never do. It might also mean that someone created a local instance of a ReferenceCount object on the stack, instead of using “new”.
Make sure that you understand how Panda’s reference-counting system works, that you use PT() when you need to keep ownership of a pointer, and that you never call delete on, or create a local instance of, a reference-counted object.
I changed my PhysVehicleMotorDesc, PhysVehicleGearsDesc etc. to references earlier, as suggested, but after changing them back to pointers, the asserts disappeared.
Thanks for the help, much appreciated, I hope there’s no more complications…
Wait. You mean this didn’t work:
PhysVehicleDesc vehicleDesc; PhysVehicleMotorDesc motorDesc; motorDesc.set_...; vehicleDesc.set_motor(motorDesc); scene->create_vehicle(vehicleDesc); // where scene is a PT(PhysScene)
If so I have a problem somewhere in my code…
Without being able to test it I think I found the problem. It the header for PhysVehicleDesc.h. Can you try and change the those tow members:
PhysVehicleMotorDesc *_motorDesc; PhysVehicleGearsDesc *_gearsDesc;
PT(PhysVehicleMotorDesc) _motorDesc; PT(PhysVehicleGearsDesc) _gearsDesc;
When running some of the samples included in the 0.4.7-8 release, some of them get weird results when moving the objects. It’s like objects always want to move in odd directions.
For example, in the materials demo, i can never get the cube to move forwards or backwards, it’s always some odd angle. The softbody demo also has an issue where the collision shape is in a different place than the actual body.
Is anyone else experiencing these kinds of issues or is it something i’m not seeing?
This is perfectly normal. PhysX uses a simplified friction model by default, and what you describe are the effects of this simplified model. From the PhysX documentation:
You can enable the more realistic “cone friction” model (at the price of a little bit performance) this way:
actor.setActorFlag( PhysActor.AFForceConeFriction, True )
Since I forgot to wrap scene flags you have to set this flag for each actor.
This is because of a line of code I forgot to remove before release. It is not possible to set a scale different from 1.0 for a NodePath assigned to a soft body. This is because PhysX computed the soft body vertices relative to the scene’s origin.
I have set a scale of 1.1 in release 0.4.7. The effect is that the soft body mesh seems to have an offset from the soft body geom depending on the distance from the origin. Just remove this line or set scale to 1.0
self.softNP = render.attachNewNode( self.soft.getSoftBodyNode( ) ) self.softNP.node( ).setFromGeom( geom ) self.softNP.setTexture( tex ) ###self.softNP.setScale( 1.1 ) <---- scale must be 1.0
PS: I’m pretty sure that 0.4.8 has been released with a scale of 1.0. 0.4.8 should not show this behaviour.
Cool, thanks for the info. So far, pandaPhysX is turning out to be everything i’ve been looking for, so this is great.
Oh, and yes, the softbody demo is fixed in 0.4.8.
Awesome. Totally Awesome. Came upon this while Googling. Good to have more additions to awesome Panda 3D. Thanks for taking this up.
Just wanted to point out that crouching in the Ralph sample (Character Controller) is a bit buggy. Ralph seems to get offset upwards on each crouch. So after several crouches he is in the sky.
I am working on a puzzle side-scroller and was wondering what is the best way to use physx with the player character. It seems the character controller suits my needs (much like the ralph sample you have put up). Full bone joints etc might be an overkill. Besides I cant figure out how skeleton animation and physx go hand in hand.
Also have to figure out how to constrain the character in the x and z axis only and not allow physics to throw the player off in depth.
So far I have to make sure my levels are aligned on the x-axis in blender so that the level looks like a side scroller level and I only have to change the camera x coordinate. I tried to use the orientation function described in the PhysX documentation for the actor but there is no function like that here. Am I looking at it wrong?
Any suggestions on the above from the point of view of a side scroller will be greatly appreciated.
PS: Why would I want to use a 3d engine for a side scroller? Firstly, wanted some 3d cinematic camera during certain events. And Trine uses 3d + physx as well (http://en.wikipedia.org/wiki/Trine_(video_game)) and it looks cool.
Have a look at the body flags. BF_FROZEN_POS_Y is probably what you need. However, I don’t know if this works with character controllers, since the controlled actor is kinematic.
Maybe the character controller is an overkill already. You could use a simple kinematic actor, and just move it along the x/z axis depending on user input.
Your actor has certainly a NodePath assigned. The NodePath position and orientation gets updated each frame, so you could use this as a reference. Or you can get the transform from actor.getGlobalMat() or actor.getGlobalPos(), since your camera will look always in the same direction (side-scroller).
EDIT: Re-parenting the camera to the NodePath assigned to the character’s actor might be enough already.
Reparenting the camera is an awesome idea. Things can be made so simple.
I’ll give the body flags a try and get back. I’ll give the character controller a whirl for sometime though. The auto step climbing etc seem lucrative. Though I have seen people complain about PhysX character controller on several forums.
More time to work on it this weekend. Thanks for the quick reply!
Hi, two quick questions:
One, if i wanted to have an actor freeze it’s position, as if it grabbed onto to the level geometry, what would be the best way to do this? I was thinking of creating a fixed joint, and then destroying it when done. But i’m wondering if that’d be slow or if there’s a better way.
The second, if i did need to create/destroy a joint like stated, is there a “destroy” method? I couldn’t find anything like it in the documentation.
This would be the method “remove” which removes a joint from a scene. It’s a method of PhysxJoint. All objects (PhysActor, PhysShape, PhysScene, …) should have this method.
I don’t know what the best method is, but a fixed joint should be one way to do this. Two other ways would be by using body flags:
- actor.setBodyFlag( PhysActor.BFKinematic, True ).
- actor.setBodyFlag( PhysActor.BFFrozenPosX, True ) + Y and Z flags.
Thanks, it works pretty well, so i’ll stick with it.
Also, how do i retrieve info about collisions from the scene? Specifically i need to know what collided with who, and where.
This would be “contact reporting”. There should be a sample in the samples folder.
First of all, you’ve done a fantastic job, the level of integration is astounding! It’s been a delight to work with.
That said, I do have a problem which I was hoping to get some help with. What I’m trying to do is generate contact reports but turn of collisions - I want to objects to pass through each other, but still report the collision. I know this could be done, because I had it working in Ogre’s PhysX wrapper (which took me an incredibly long time to get working properly, hence why I’m so impressed with your work).
How I did it in Ogre was to:
1). Set the Group Collision Flag on the scene to true.
2). Set the Actor Group Pair Flag on the scene to true.
3). Raise the Actor Flag with disables collisions on the actors which I wanted to generate reports without being affected by collisions.
Implementing this the same way Panda hasn’t worked, as objects pass through each other without generating reports. Any help would be very much appreciated.
Once again, good work!
As it always seems to happen, immediately after posting this I figured out what’s wrong: the flag in Ogre isn’t DisableCollisions, it’s DisableResponse. The value of the flag is 1<<1 in case anyone else tries to do this in the future.
Hello, and glad you like it. The last release didn’t have all ActorFlags, especially DisableResponse is missing. I don’t remember why I left them away. Sorry, the next release will contain the missing flags. For now the workaround would be to set the flags value directly (1<<1, like you already found out :-).
I just tried to run a sample from the 4.8 version zip with the 1.7.0 official package. I get the following error about a DLL missing or incorrect.
C:\Panda3D-1.7.0\bin>..\python\python.exe C:\devel\libpandaphysx_0.4.8\libpandap hysx_0.4.8\samples\01_Basics.py DirectStart: Starting the game. :interrogatedb(warning): Class MeshDrawer2D has a zero TypeHandle value; check t hat init_type() is called. Known pipe types: wdxGraphicsPipe9 (all display modules loaded.) Traceback (most recent call last): File "C:\devel\libpandaphysx_0.4.8\libpandaphysx_0.4.8\samples\01_Basics.py", line 40, in <module> from libpandaphysx import PhysEngine ImportError: DLL load failed: The specified procedure could not be found.
I got the Physx system software installed because when I downloaded it just now what I got on running it is an uninstaller dialog, so I guess it came with the nvidia drivers or something. Is this supposed to work? What do I need?
UPDATE: I learned about the situation from rdb. I got nxcharacter.dll from the multifile here: runtime.panda3d.org/physx/cmu_1.7/win32/ . Dropped it in the bin/ folder but still the same error.