Re: OgrePhysX - added destruction + Demo
Posted: Thu Jun 14, 2012 2:32 pm
OK, I did it. Is anyone interested? Where can I upload it?
Support and community hang-out spot for Ogre3D
https://forums.ogre3d.org/
I'd be interested to see it. I was planning on attempting that but have been busy workingShtuka wrote:OK, I did it. Is anyone interested? Where can I upload it?
OgrePhysX is working with the new SDK.betajaen wrote:From what I hear the 3.x SDK is radically different from the 2.8.x SDK NxOgre is based upon, so a partial rewrite would be required.
/*
This source file is part of OgrePhysX.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
There is one entity for each split part. At the moment there is no method to access the parts from the outside, so you need a new method for that. Simply iterate mParts, for every part you can access the ogre node this way:assume I've created a Destructible---how can I access to the corresponding Entity for setting its material?
Code: Select all
((NodeRenderable*)part->mRenderedActor->getPointRenderable())->getOgreNode();I agree with the fact that the actual way is impressive ( to watch the debris collide after explode ) , but the cost is highUsing aggregates to speed-up insertion of objects in the scene
Adding objects to a scene can be costly if the number of objects is large and it all happens in one frame. This can be the case for a ragdoll, which is a good candidate for PxAggregate, as we discussed above. Another case might be localized debris, for which self-collisions are often disabled. It can be a good strategy to spawn all the debris at once in a PxAggregate, then remove and re-insert each actor from the aggregate to the scene, over N frames. This would amortize the cost of object insertion into the broad-phase structure, over N frames
_ Make a brand new class ( OgrePhysX::Aggregate) i , witch will be the pre-requisite for the creation of DEBRIS and RAGDOLL :PxActor& actor; // Some actor, previously created --> and member of DESTRUCTIBLE in our case
aggregate->addActor(actor);
Note that the actor should not have been added to the scene already. If it already belongs to a scene, the call is ignored. You should first add all the actors to an aggregate, then add the aggregate to the scene. Alternatively you can first add the aggregate to the scene, then the actors to the aggregate. In any case, do not add the actors both to the scene and to an aggregate.
Please , let me know what you think (An aggregate is a collection of actors managed as a single entity in the broad-phase data structures. This is purely an optimization, it does not provide extra features compared to regular actors.
The typical use case is a ragdoll, made of N different body parts, with each part a PhysX actor. This usually gives birth to N broad-phase entries for a single ragdoll. This might lead to performance issues since those N objects are almost always overlapping each-other each frame, and as a result a lot of useless overlap tests are performed in the broad-phase. It is often more efficient to have a single broad-phase object for the whole ragdoll, and do the body-body collision checks (if necessary) in a second pass.
Ezee wrote:Hi !
My previous post wasn't published ( for political reason - 2 videos in one post , Ughhh ...)
You are right sir ! I'm a little bit " exited " with that OgrePhysx 0.4 release .With a little bit of patience it would have been
Code: Select all
Destructible* createDestructible(const Ogre::String &meshSplitConfigFile, float breakForce = 1000.0f, float breakTorque = 1000.0f, float density = 100.0f, const Ogre::Vector3 &scale = Ogre::Vector3(1,1,1));
Destructible* createDestructible(const Ogre::String &meshSplitConfigFile, PxMaterial &material, float breakForce = 1000.0f, float breakTorque = 1000.0f, float density = 100.0f, const Ogre::Vector3 &scale = Ogre::Vector3(1,1,1));Code: Select all
Destructible* Scene::createDestructible(const Ogre::String &meshSplitConfigFile, float breakForce, float breakTorque, float density, const Ogre::Vector3 &scale)
{
return createDestructible(meshSplitConfigFile, World::getSingleton().getDefaultMaterial(), breakForce, breakTorque, density, scale);
}
Code: Select all
Destructible* createDEFAULTDestructible(const Ogre::String &meshSplitConfigFile, float breakForce = 1000.0f, float breakTorque = 1000.0f, float density = 100.0f, const Ogre::Vector3 &scale = Ogre::Vector3(1,1,1));
Destructible* createDestructible(const Ogre::String &meshSplitConfigFile, PxMaterial &material, float breakForce = 1000.0f, float breakTorque = 1000.0f, float density = 100.0f, const Ogre::Vector3 &scale = Ogre::Vector3(1,1,1));I'm interested in that heightfield support, but your repository doesn't have it. Maybe you forgot to add the files ?Shtuka wrote:Is OgrePhysX still being developped? I have added PhysX 3.2.1 and height field support, if anyone is interested.
Code: Select all
Actor<PxRigidStatic> createHeightField(const Ogre::Vector3& position, size_t numCols, size_t numRows, PxReal heightScale, PxReal rowScale, PxReal colScale, const PxHeightFieldDesc& hfDesc);
Actor<PxRigidStatic> createHeightField(const Ogre::Vector3& position, size_t numCols, size_t numRows, PxReal heightScale, PxReal rowScale, PxReal colScale, const PxHeightFieldDesc& hfDesc, PxMaterial &material);
Code: Select all
Actor<PxRigidStatic> Scene::createHeightField(const Ogre::Vector3& position, size_t numCols, size_t numRows, PxReal heightScale, PxReal rowScale, PxReal colScale, const PxHeightFieldDesc& hfDesc)
{
return createHeightField(position, numCols, numRows, heightScale, rowScale, colScale, hfDesc, World::getSingleton().getDefaultMaterial());
}
Actor<PxRigidStatic> Scene::createHeightField(const Ogre::Vector3& position, size_t numCols, size_t numRows, PxReal heightScale, PxReal rowScale, PxReal colScale, const PxHeightFieldDesc& hfDesc, PxMaterial &material)
{
PxHeightField* aHeightField = getPxPhysics()->createHeightField(hfDesc);
if (!aHeightField)
OGRE_EXCEPT(0, "createHeightField failed!", __FUNCTION__);
//PxTransform pose = PxTransform(PxVec3(position.x,position.y,position.z)
//, PxQuat(PxHalfPi, PxVec3(0.0f, 1.0f, 0.0f))
// );
PxTransform pose(PxVec3(-((PxReal)numRows*rowScale) / 2.0f,
0.0f,
-((PxReal)numCols*colScale) / 2.0f),
PxQuat::createIdentity()
//PxQuat(PxHalfPi, PxVec3(0.0f, 1.0f, 0.0f))
);
PxRigidStatic* aHeightFieldActor = getPxPhysics()->createRigidStatic(pose);
if (!aHeightFieldActor)
OGRE_EXCEPT(0, "createRigidStatic failed!", __FUNCTION__);
PxHeightFieldGeometry hfGeom(aHeightField, PxMeshGeometryFlags(), heightScale, rowScale, colScale);
PxShape* aHeightFieldShape = aHeightFieldActor->createShape(hfGeom, material);
if (!aHeightFieldShape)
OGRE_EXCEPT(0, "aHeightFieldActor->createShape failed!", __FUNCTION__);
mPxScene->addActor(*aHeightFieldActor);
Actor<PxRigidStatic> actor(aHeightFieldActor);
return actor;
}OK, well send me a PM when you post it.Shtuka wrote:Sorry, you'll have to wait until I am at my other computer.