IrrPhysx 0.2 - Nvidia Physx 2.8.1 wrapper

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
rootroot1
Posts: 44
Joined: Wed Nov 25, 2009 6:42 pm
Location: Odessa, Ukraine

Post by rootroot1 »

Thanks again and again Insomniacp :wink:

The theory helped me !!!!!!

I got it working great finally !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Solution:

Code: Select all

void moveRight() 
{ 
      m_cameraTarget.rotateXZBy(-90, vector3df(0,0,0)); 
      m_CharacterVec = m_cameraTarget; 
} 

void moveLeft() 
{ 
      m_cameraTarget.rotateXZBy(90, vector3df(0,0,0)); 
      m_CharacterVec = m_cameraTarget; 
} 

//and

void strafeRight()
{
	m_cameraTarget.rotateXZBy(-45, vector3df(0,0,0)); 
	m_CharacterVec = m_cameraTarget;
}

void strafeLeft()
{
	m_cameraTarget.rotateXZBy(45, vector3df(0,0,0)); 
	m_CharacterVec = m_cameraTarget;
}
P.S.

If you need full source, I can share.
(By the way, What is your real name ??)
Insomniacp
Posts: 288
Joined: Wed Apr 16, 2008 1:45 am
Contact:

Post by Insomniacp »

My real name is Pat Koeller
rootroot1
Posts: 44
Joined: Wed Nov 25, 2009 6:42 pm
Location: Odessa, Ukraine

Post by rootroot1 »

Ok, I'm glad to know you !!!!
I am Andrew Goncharenko.

------------------------------------------------------------------------------------

Let's return to our "old" topic (joints)...
Maybe you will try to create function to calculate global anchor for revolute joint, and then I will implement class for dynamic doors ??? :idea:

Also this is very usefull for IrrPhysx, maybe Chris will be interested to integrating such idea realisation direct to the wrapper :?: :?: :?:

--------------------------------------------------------------------------------------
Insomniacp
Posts: 288
Joined: Wed Apr 16, 2008 1:45 am
Contact:

Post by Insomniacp »

it should be possible. the global anchor won't be auto generated since other ones may be usable and needed for other implementations but for something like a door class kind of a thing it wouldn't be too difficult to create. I just found out that I can host an svn server from my web account at eleven2 so I will transfer the current one I have in my house over to it so I can make it publicly accessible, this should help everyone get this going quite well and help with the current issues. Of course I will wait for JP to give the ok for this move though I don't see why there would be a problem.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Joints would be an awesome feature to get into IrrPhysx so any work done on that can be sent to me or Insomniacp and we'll try and get it in to a future release.

As for the SVN going public i'm a bit reluctant due to the fact that most of the time the SVN has WIP code which doesn't really work in a way that I'd like to see the public using... but on the other hand it would certainly allow people who can cope with that to get up to date with what IrrPhysx has to offer and keep their development moving ahead as features become implemented instead of having to wait for each release I make... So yeah I guess it's probably ok, so long as people realise that the SVN isn't guaranteed to be in a particularly working state! This is where branches might be useful in a way so that we can work on things in a private branch and then integrate it over to the mainline code when it's in a workable state... But branches can be a bit of a pain to maintain so I hear... So we might just be able to make do as-is and just avoid checking in any code that would break features that are already there.
Image Image Image
Insomniacp
Posts: 288
Joined: Wed Apr 16, 2008 1:45 am
Contact:

Post by Insomniacp »

we could label revisions that are stable and tested to be stable. That way if someone wants for example the working character controllers once they are stable we just say revision XXXX is stable with character controllers and then people that aren't working on it can just go to those revisions or wait for a release.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

branches anyone?
rootroot1
Posts: 44
Joined: Wed Nov 25, 2009 6:42 pm
Location: Odessa, Ukraine

Post by rootroot1 »

Ok..

Character controller is good now ))))))))

But yesterday I found ragdoll example by "stoneyjones".
It's about skinned ragdoll in Irrlicht. It works great.
Here http://irrlicht.sourceforge.net/phpBB2/ ... doll+human

Here is a screen
Image

Today i begin to port it to use with irrPhysx interface

so...

Code: Select all


//PhysxObjects for body
IPhysxObject* CPhysxManager::createCapsuleObject1(NxReal height, NxReal radius, core::vector3df position)
{
	if (!Scene) return NULL;	

	NxVec3 pos(position.X, position.Y, position.Z);

	NxBodyDesc BodyDesc;
	BodyDesc.angularDamping = 1.5f;
	
	NxCapsuleShapeDesc CapDesc;
	CapDesc.height = height-(radius*2);
	CapDesc.radius = radius;
	CapDesc.localPose.t = NxVec3(0, 0.5f * height, 0);

	NxActorDesc CapActorDesc;
	CapActorDesc.shapes.pushBack(&CapDesc);
	CapActorDesc.body = &BodyDesc;
	CapActorDesc.density = 200.0f;	// you can change density to make it more "floppy" (lighter)
	CapActorDesc.globalPose.t = pos;

	NxActor* capsule = Scene->createActor(CapActorDesc);

	return createPhysxObject(capsule, EOT_CAPSULE);
}

IPhysxObject* CPhysxManager::createBoxObject1(NxReal dx, NxReal dy, NxReal dz, core::vector3df position) 
{
	if (!Scene) return NULL;	
	
	NxVec3 pos(position.X, position.Y, position.Z);

	NxBodyDesc bodyDesc;
	bodyDesc.angularDamping = 1.5f;

	NxBoxShapeDesc boxDesc;
	boxDesc.dimensions.set(dx*0.5f, dy*0.5f, dz*0.5f);
	boxDesc.localPose.t = NxVec3(0, 0.5f*dy, 0);

	NxActorDesc actorDesc;
	actorDesc.shapes.pushBack(&boxDesc);
	actorDesc.body = &bodyDesc;
	actorDesc.density = 350.0;		// you can set up a variable for density. i just did this for this demo.
	actorDesc.globalPose.t = pos;
	NxActor* box = Scene->createActor(actorDesc);

	return createPhysxObject(box, EOT_BOX);

}

.........

class PhysxRagdoll
{
public:
	struct boneSet
	{
		IBoneSceneNode* iBone;
		f32 length;
		SPhysxAndNodePair * actor;
	};

	boneSet head, torso, pelvis, pelvisRight, pelvisLeft, leftThigh, rightThigh, leftCalf, rightCalf;
	boneSet leftCollar, rightCollar, rightUpperArm, leftUpperArm, leftForeArm, rightForeArm, leftHand, rightHand;
	vector3df ragPosition;

	NxSphericalJoint* neck;
	NxFixedJoint* upperLeftShoulder;
	NxFixedJoint* upperRightShoulder;
	NxSphericalJoint* leftShoulder;
	NxSphericalJoint* rightShoulder;
	NxRevoluteJoint* spine;
	NxFixedJoint* leftHip;
	NxFixedJoint* rightHip;
	NxSphericalJoint* leftHipLow;
	NxSphericalJoint* rightHipLow;

	NxRevoluteJoint* leftElbow;
	NxRevoluteJoint* rightElbow;
	NxRevoluteJoint* leftWrist;
	NxRevoluteJoint* rightWrist;
	NxRevoluteJoint* leftKnee;
	NxRevoluteJoint* rightKnee;
	NxJoint* leftAnkle;
	NxJoint* rightAnkle;
	IPhysxManager* physx;

	PhysxRagdoll(array<SPhysxAndNodePair*>& Nodes, IPhysxManager* phx, IAnimatedMeshSceneNode* irrnode, vector3df position=vector3df(0,0,0))
	: physx(phx)
	{
		ragPosition = position;

		irrnode->setJointMode(EJUOR_READ);
		head.iBone = irrnode->getJointNode("head");
		torso.iBone = irrnode->getJointNode("torso");
		pelvis.iBone = irrnode->getJointNode("pelvis");
		pelvisRight.iBone = irrnode->getJointNode("pelvisright");
		pelvisLeft.iBone = irrnode->getJointNode("pelvisleft");
		leftCollar.iBone = irrnode->getJointNode("leftCollar");
		rightCollar.iBone = irrnode->getJointNode("rightCollar");
		leftUpperArm.iBone = irrnode->getJointNode("leftUpperArm");
		rightUpperArm.iBone = irrnode->getJointNode("rightUpperArm");
		leftForeArm.iBone = irrnode->getJointNode("leftForeArm");
		rightForeArm.iBone = irrnode->getJointNode("rightForeArm");
		leftHand.iBone = irrnode->getJointNode("leftHand");
		rightHand.iBone = irrnode->getJointNode("rightHand");
		leftThigh.iBone = irrnode->getJointNode("leftThigh");
		rightThigh.iBone = irrnode->getJointNode("rightThigh");
		leftCalf.iBone = irrnode->getJointNode("leftCalf");
		rightCalf.iBone = irrnode->getJointNode("rightCalf");
	//	leftFoot;
	//	rightFoot;

		irrnode->addChild(pelvis.iBone);
		pelvis.iBone->addChild(torso.iBone);
		pelvis.iBone->addChild(pelvisLeft.iBone);
		pelvis.iBone->addChild(pelvisRight.iBone);
		torso.iBone->addChild(head.iBone);
		torso.iBone->addChild(leftCollar.iBone);
		torso.iBone->addChild(rightCollar.iBone);
		leftCollar.iBone->addChild(leftUpperArm.iBone);
		rightCollar.iBone->addChild(rightUpperArm.iBone);
		leftUpperArm.iBone->addChild(leftForeArm.iBone);
		rightUpperArm.iBone->addChild(rightForeArm.iBone);
		leftForeArm.iBone->addChild(leftHand.iBone);
		rightForeArm.iBone->addChild(rightHand.iBone);
		pelvisRight.iBone->addChild(rightThigh.iBone);
		pelvisLeft.iBone->addChild(leftThigh.iBone);
		rightThigh.iBone->addChild(rightCalf.iBone);
		leftThigh.iBone->addChild(leftCalf.iBone);

		pelvis.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
		torso.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
		head.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
		pelvisRight.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
		pelvisLeft.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
		leftThigh.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
		rightThigh.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
		leftCalf.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
		rightCalf.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
		leftCollar.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
		rightCollar.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
		leftUpperArm.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
		rightUpperArm.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
		leftForeArm.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
		rightForeArm.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
		leftHand.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
		rightHand.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);

		irrnode->setJointMode(scene::EJUOR_CONTROL);
		updateFamily(irrnode);

		line3d<f32> bLine;

		bLine.start = pelvis.iBone->getAbsolutePosition();
		bLine.end = torso.iBone->getAbsolutePosition();
		pelvis.length = bLine.getLength();

		bLine.start = torso.iBone->getAbsolutePosition();
		bLine.end = head.iBone->getAbsolutePosition();
		torso.length = bLine.getLength();

		bLine.start = pelvisRight.iBone->getAbsolutePosition();
		bLine.end = rightThigh.iBone->getAbsolutePosition();
		pelvisRight.length = bLine.getLength();

		bLine.start = pelvisLeft.iBone->getAbsolutePosition();
		bLine.end = leftThigh.iBone->getAbsolutePosition();
		pelvisLeft.length = bLine.getLength();

		bLine.start = rightThigh.iBone->getAbsolutePosition();
		bLine.end = rightCalf.iBone->getAbsolutePosition();
		rightThigh.length = bLine.getLength();

		bLine.start = leftThigh.iBone->getAbsolutePosition();
		bLine.end = leftCalf.iBone->getAbsolutePosition();
		leftThigh.length = bLine.getLength();

		bLine.start = leftCollar.iBone->getAbsolutePosition();
		bLine.end = leftUpperArm.iBone->getAbsolutePosition();
		leftCollar.length = bLine.getLength();

		bLine.start = rightCollar.iBone->getAbsolutePosition();
		bLine.end = rightUpperArm.iBone->getAbsolutePosition();
		rightCollar.length = bLine.getLength();

		bLine.start = leftUpperArm.iBone->getAbsolutePosition();
		bLine.end = leftForeArm.iBone->getAbsolutePosition();
		leftUpperArm.length = bLine.getLength();

		bLine.start = rightUpperArm.iBone->getAbsolutePosition();
		bLine.end = rightForeArm.iBone->getAbsolutePosition();
		rightUpperArm.length = bLine.getLength();

		bLine.start = leftForeArm.iBone->getAbsolutePosition();
		bLine.end = leftHand.iBone->getAbsolutePosition();
		leftForeArm.length = bLine.getLength();

		bLine.start = rightForeArm.iBone->getAbsolutePosition();
		bLine.end = rightHand.iBone->getAbsolutePosition();
		rightForeArm.length = bLine.getLength();

		head.length = 14;
		leftHand.length = 8;
		rightHand.length = 8;
		leftCalf.length = 30;
		rightCalf.length = 30;

		NxScene * pscene = physx->getScene();

		pelvis.actor = new SPhysxAndNodePair;
		pelvis.actor->PhysxObject		= physx->createCapsuleObject1(pelvis.length, 2, pelvis.iBone->getAbsolutePosition()); 
		pelvis.actor->SceneNode			= pelvis.iBone;
		pelvis.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(pelvis.iBone->getAbsoluteTransformation().getRotationDegrees()));

		torso.actor = new SPhysxAndNodePair;
		torso.actor->PhysxObject		= physx->createBoxObject1(24, torso.length, 8, torso.iBone->getAbsolutePosition());
		torso.actor->SceneNode			= torso.iBone;
		torso.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(torso.iBone->getAbsoluteTransformation().getRotationDegrees()));

		head.actor = new SPhysxAndNodePair;
		head.actor->PhysxObject			= physx->createCapsuleObject1(head.length, 5, head.iBone->getAbsolutePosition());
		head.actor->SceneNode			= head.iBone;
		head.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(head.iBone->getAbsoluteTransformation().getRotationDegrees()));

		pelvisRight.actor = new SPhysxAndNodePair;
		pelvisRight.actor->PhysxObject	= physx->createCapsuleObject1(pelvisRight.length, 2, pelvisRight.iBone->getAbsolutePosition());
		pelvisRight.actor->SceneNode	= pelvisRight.iBone;
		pelvisRight.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(pelvisRight.iBone->getAbsoluteTransformation().getRotationDegrees()));
	
		pelvisLeft.actor = new SPhysxAndNodePair;
		pelvisLeft.actor->PhysxObject	= physx->createCapsuleObject1(pelvisLeft.length, 2, pelvisLeft.iBone->getAbsolutePosition());
		pelvisLeft.actor->SceneNode		= pelvisLeft.iBone;
		pelvisLeft.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(pelvisLeft.iBone->getAbsoluteTransformation().getRotationDegrees()));

		leftCollar.actor = new SPhysxAndNodePair;
		leftCollar.actor->PhysxObject	= physx->createCapsuleObject1(leftCollar.length, 2, leftCollar.iBone->getAbsolutePosition());
		leftCollar.actor->SceneNode		= leftCollar.iBone;
		leftCollar.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(leftCollar.iBone->getAbsoluteTransformation().getRotationDegrees()));
	
		rightCollar.actor = new SPhysxAndNodePair;
		rightCollar.actor->PhysxObject	= physx->createCapsuleObject1(rightCollar.length, 2, rightCollar.iBone->getAbsolutePosition());
		rightCollar.actor->SceneNode	= rightCollar.iBone;
		rightCollar.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(rightCollar.iBone->getAbsoluteTransformation().getRotationDegrees()));

		leftUpperArm.actor = new SPhysxAndNodePair;
		leftUpperArm.actor->PhysxObject	= physx->createCapsuleObject1(leftUpperArm.length, 4, leftUpperArm.iBone->getAbsolutePosition());
		leftUpperArm.actor->SceneNode	= leftUpperArm.iBone;
		leftUpperArm.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(leftUpperArm.iBone->getAbsoluteTransformation().getRotationDegrees()));
	
		leftForeArm.actor = new SPhysxAndNodePair;
		leftForeArm.actor->PhysxObject	= physx->createCapsuleObject1(leftForeArm.length, 3, leftForeArm.iBone->getAbsolutePosition());
		leftForeArm.actor->SceneNode	= leftForeArm.iBone;
		leftForeArm.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(leftForeArm.iBone->getAbsoluteTransformation().getRotationDegrees()));

		leftHand.actor = new SPhysxAndNodePair;
		leftHand.actor->PhysxObject	= physx->createCapsuleObject1(leftHand.length, 2, leftHand.iBone->getAbsolutePosition());
		leftHand.actor->SceneNode	= leftHand.iBone;
		leftHand.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(leftHand.iBone->getAbsoluteTransformation().getRotationDegrees()));

		rightUpperArm.actor = new SPhysxAndNodePair;
		rightUpperArm.actor->PhysxObject	= physx->createCapsuleObject1(rightUpperArm.length, 4, rightUpperArm.iBone->getAbsolutePosition());
		rightUpperArm.actor->SceneNode		= rightUpperArm.iBone;
		rightUpperArm.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(rightUpperArm.iBone->getAbsoluteTransformation().getRotationDegrees()));
	
		rightForeArm.actor = new SPhysxAndNodePair;
		rightForeArm.actor->PhysxObject		= physx->createCapsuleObject1(rightForeArm.length, 3, rightForeArm.iBone->getAbsolutePosition());
		rightForeArm.actor->SceneNode		= rightForeArm.iBone;
		rightForeArm.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(rightForeArm.iBone->getAbsoluteTransformation().getRotationDegrees()));
	
		rightHand.actor = new SPhysxAndNodePair;
		rightHand.actor->PhysxObject	= physx->createCapsuleObject1(rightHand.length, 2, rightHand.iBone->getAbsolutePosition());
		rightHand.actor->SceneNode		= rightHand.iBone;
		rightHand.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(rightHand.iBone->getAbsoluteTransformation().getRotationDegrees()));

		leftThigh.actor = new SPhysxAndNodePair;
		leftThigh.actor->PhysxObject	= physx->createCapsuleObject1(leftThigh.length, 6, leftThigh.iBone->getAbsolutePosition());
		leftThigh.actor->SceneNode		= leftThigh.iBone;
		leftThigh.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(leftThigh.iBone->getAbsoluteTransformation().getRotationDegrees()));
	
		leftCalf.actor = new SPhysxAndNodePair;
		leftCalf.actor->PhysxObject		= physx->createCapsuleObject1(leftCalf.length, 4, leftCalf.iBone->getAbsolutePosition());
		leftCalf.actor->SceneNode		= leftCalf.iBone;
		leftCalf.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(leftCalf.iBone->getAbsoluteTransformation().getRotationDegrees()));

	////	leftFoot = CreateBox(NxVec3(0.6,1.5,0.2), NxVec3(0.4,0.2,0.75), 10);
	////	leftFoot->setGlobalOrientationQuat(qRotAround);
	
		rightThigh.actor = new SPhysxAndNodePair;
		rightThigh.actor->PhysxObject	= physx->createCapsuleObject1(rightThigh.length, 6, rightThigh.iBone->getAbsolutePosition());
		rightThigh.actor->SceneNode		= rightThigh.iBone;
		rightThigh.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(rightThigh.iBone->getAbsoluteTransformation().getRotationDegrees()));

		rightCalf.actor = new SPhysxAndNodePair;
		rightCalf.actor->PhysxObject	= physx->createCapsuleObject1(rightCalf.length, 4, rightCalf.iBone->getAbsolutePosition());
		rightCalf.actor->SceneNode		= rightCalf.iBone;
		rightCalf.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(rightCalf.iBone->getAbsoluteTransformation().getRotationDegrees()));

	////	rightFoot = CreateBox(NxVec3(-0.6,1.5,0.2), NxVec3(0.4,0.2,0.75), 10);
	////	rightFoot->setGlobalOrientationQuat(qRotAround);

		////	These flags are supposed to keep certain actors from colliding with others
		pscene->setActorPairFlags(*pelvisLeft.actor->PhysxObject->getActor(), *pelvisRight.actor->PhysxObject->getActor(), NX_IGNORE_PAIR);
		pscene->setActorPairFlags(*pelvis.actor->PhysxObject->getActor(), *pelvisRight.actor->PhysxObject->getActor(), NX_IGNORE_PAIR);
		pscene->setActorPairFlags(*pelvis.actor->PhysxObject->getActor(), *pelvisLeft.actor->PhysxObject->getActor(), NX_IGNORE_PAIR);
		pscene->setActorPairFlags(*leftCollar.actor->PhysxObject->getActor(), *rightCollar.actor->PhysxObject->getActor(), NX_IGNORE_PAIR);
		pscene->setActorPairFlags(*leftCollar.actor->PhysxObject->getActor(), *torso.actor->PhysxObject->getActor(), NX_IGNORE_PAIR);
		pscene->setActorPairFlags(*rightCollar.actor->PhysxObject->getActor(), *torso.actor->PhysxObject->getActor(), NX_IGNORE_PAIR);

		neck  = CreateBodySphericalJoint(pscene, head.actor->PhysxObject->getActor(), torso.actor->PhysxObject->getActor(), head.iBone->getAbsolutePosition(), vector3df(0,1,0));
		spine = CreateBodyRevoluteJoint(pscene, pelvis.actor->PhysxObject->getActor(), torso.actor->PhysxObject->getActor(), torso.iBone->getAbsolutePosition(), vector3df(1,0,0), NxReal(-0.01 * NxPi), NxReal(0.01 * NxPi));	

		//upperLeftShoulder = CreateBodyFixedJoint(pscene, head.actor->PhysxObject->getActor(), leftCollar.actor->PhysxObject->getActor(), leftCollar.iBone->getAbsolutePosition(), vector3df(0,1,0));
		//upperLeftShoulder = CreateBodyFixedJoint(pscene, head.actor->PhysxObject->getActor(), rightCollar.actor->PhysxObject->getActor(), rightCollar.iBone->getAbsolutePosition(), vector3df(0,1,0));

		leftShoulder = CreateBodySphericalJoint(pscene, leftCollar.actor->PhysxObject->getActor(), leftUpperArm.actor->PhysxObject->getActor(), leftUpperArm.iBone->getAbsolutePosition(), vector3df(0,1,0));
		rightShoulder = CreateBodySphericalJoint(pscene, rightCollar.actor->PhysxObject->getActor(), rightUpperArm.actor->PhysxObject->getActor(), rightUpperArm.iBone->getAbsolutePosition(), vector3df(0,1,0));

		leftHip  =  CreateBodyFixedJoint(pscene, torso.actor->PhysxObject->getActor(), pelvisLeft.actor->PhysxObject->getActor(), torso.iBone->getAbsolutePosition(), vector3df(0,1,0));
		rightHip =  CreateBodyFixedJoint(pscene, torso.actor->PhysxObject->getActor(), pelvisRight.actor->PhysxObject->getActor(), torso.iBone->getAbsolutePosition(), vector3df(0,1,0));

		leftHipLow  = CreateBodySphericalJoint(pscene, pelvisLeft.actor->PhysxObject->getActor(), leftThigh.actor->PhysxObject->getActor(), leftThigh.iBone->getAbsolutePosition(), vector3df(0,1,0));
		rightHipLow = CreateBodySphericalJoint(pscene, pelvisRight.actor->PhysxObject->getActor(), rightThigh.actor->PhysxObject->getActor(), rightThigh.iBone->getAbsolutePosition(), vector3df(0,1,0));

		leftElbow  = CreateBodyRevoluteJoint(pscene, leftUpperArm.actor->PhysxObject->getActor(), leftForeArm.actor->PhysxObject->getActor(), leftForeArm.iBone->getAbsolutePosition(), vector3df(1,0,0), NxReal(-0.5*NxPi), NxReal(0.9*NxPi));
		rightElbow = CreateBodyRevoluteJoint(pscene, rightUpperArm.actor->PhysxObject->getActor(), rightForeArm.actor->PhysxObject->getActor(), rightForeArm.iBone->getAbsolutePosition(), vector3df(1,0,0), NxReal(-0.5*NxPi), NxReal(0.9*NxPi));

		leftWrist  = CreateBodyRevoluteJoint(pscene, leftHand.actor->PhysxObject->getActor(), leftForeArm.actor->PhysxObject->getActor(), leftHand.iBone->getAbsolutePosition(), vector3df(1,0,0), NxReal(-0.5*NxPi), NxReal(0.5*NxPi));
		rightWrist = CreateBodyRevoluteJoint(pscene, rightHand.actor->PhysxObject->getActor(), rightForeArm.actor->PhysxObject->getActor(), rightHand.iBone->getAbsolutePosition(), vector3df(1,0,0), NxReal(-0.5*NxPi), NxReal(0.5*NxPi));

		leftKnee =  CreateBodyRevoluteJoint(pscene, leftThigh.actor->PhysxObject->getActor(), leftCalf.actor->PhysxObject->getActor(), leftCalf.iBone->getAbsolutePosition(), vector3df(1,0,0), NxReal(0*NxPi), NxReal(0.85*NxPi));
		rightKnee = CreateBodyRevoluteJoint(pscene, rightThigh.actor->PhysxObject->getActor(), rightCalf.actor->PhysxObject->getActor(), rightCalf.iBone->getAbsolutePosition(), vector3df(1,0,0), NxReal(0*NxPi), NxReal(0.85*NxPi));

	//	NxRevoluteJointDesc jointDesc;
	//	jointDesc.flags |= NxRevoluteJointFlag::NX_RJF_LIMIT_ENABLEDNX_SJF_SWING_LIMIT_ENABLED; //|=
	//	jointDesc.swingLimit.value = NxReal(0.2*NxPi);
	//	jointDesc.flags |= NX_SJF_TWIST_LIMIT_ENABLED;
	//	jointDesc.twistLimit.low.value = NxReal(-0.04*NxPi);
	//	jointDesc.twistLimit.high.value = NxReal(0.04*NxPi);

		//leftAnkle = CreateRevoluteJoint(leftFoot,leftCalf,NxVec3(0.6,1.3,0),NxVec3(1,0,0));
		//rightAnkle = CreateRevoluteJoint(rightFoot,rightCalf,NxVec3(-0.6,1.3,0),NxVec3(-1,0,0));

	
		Nodes.push_back(pelvis.actor);
		Nodes.push_back(torso.actor);
		Nodes.push_back(head.actor);
		Nodes.push_back(pelvisRight.actor);
		Nodes.push_back(pelvisLeft.actor);
		Nodes.push_back(leftThigh.actor);
		Nodes.push_back(rightThigh.actor);
		Nodes.push_back(leftCalf.actor);
		Nodes.push_back(rightCalf.actor);
		Nodes.push_back(leftCollar.actor);
		Nodes.push_back(rightCollar.actor);
		Nodes.push_back(leftUpperArm.actor);
		Nodes.push_back(rightUpperArm.actor);
		Nodes.push_back(leftForeArm.actor);
		Nodes.push_back(rightForeArm.actor);
		Nodes.push_back(leftHand.actor);
		Nodes.push_back(rightHand.actor);
	}

	void updateFamily(ISceneNode* Node)
	{
	   Node->updateAbsolutePosition();
	   irr::core::list<ISceneNode*>::ConstIterator it = Node->getChildren().begin();
	   for (; it != Node->getChildren().end(); ++it)
	   {
		  updateFamily((*it));
	   }
	}

	static NxMat33 getMat33Rot(vector3df nodeRot)
	{
		// Quaternion
		NxQuat q1, q2, q3;
		q1.fromAngleAxis(nodeRot.X, NxVec3(1,0,0));
		q2.fromAngleAxis(nodeRot.Y, NxVec3(0,1,0));
		q3.fromAngleAxis(nodeRot.Z, NxVec3(0,0,1));

	//	NxQuat q;	
	//	q = q3*q2*q1;  // Use global axes
	//	q = q1*q2*q3;  // Use local axes

		// Orientation matrix
		NxMat33 orient1, orient2, orient3;
		orient1.fromQuat(q1);
		orient2.fromQuat(q2);
		orient3.fromQuat(q3);

		NxMat33 orient;
		orient = orient3*orient2*orient1;  // Use global axes
	//	orient = orient1*orient2*orient3;  // Use local axes

		// 1. Set actor orientation from NxMat33
	///////////////////////////////		nbullet->setGlobalOrientation(orient);		<<----

		// 2. Get NxMat33 from NxQuat
	//	orient.fromQuat(q);
	//	actor->setGlobalOrientation(orient);

		// 3. Set actor orientation directly from NxQuat
	//	actor->setGlobalOrientationQuat(q);
		return orient;
	}
};
It works, but no rightly :cry: :cry: :cry:

I know that the problem is here, but what

Code: Select all

//upperLeftShoulder = CreateBodyFixedJoint(pscene, head.actor->PhysxObject->getActor(), leftCollar.actor->PhysxObject->getActor(), leftCollar.iBone->getAbsolutePosition(), vector3df(0,1,0));
		//upperLeftShoulder = CreateBodyFixedJoint(pscene, head.actor->PhysxObject->getActor(), rightCollar.actor->PhysxObject->getActor(), rightCollar.iBone->getAbsolutePosition(), vector3df(0,1,0));

		//leftShoulder = CreateBodySphericalJoint(pscene, leftCollar.actor->PhysxObject->getActor(), leftUpperArm.actor->PhysxObject->getActor(), leftUpperArm.iBone->getAbsolutePosition(), vector3df(0,1,0));
		//rightShoulder = CreateBodySphericalJoint(pscene, rightCollar.actor->PhysxObject->getActor(), rightUpperArm.actor->PhysxObject->getActor(), rightUpperArm.iBone->getAbsolutePosition(), vector3df(0,1,0));
<---
if i uncomment this
ragdoll become invisible and framerate is too low :evil: :evil:

Here is my screen
Image



I NEED HELP !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :idea: :idea: :idea:

Here is the FULL sources and binary !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
http://etlweb.net.ua/C4.zip
m3ltd0wn
Posts: 107
Joined: Wed Dec 12, 2007 8:32 am
Location: Romania

reply

Post by m3ltd0wn »

just WOW!

:shock:
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Good work root, not sure what the problem would be though... Is the ragdoll invisible or has it just fallen through the scene?
Image Image Image
rootroot1
Posts: 44
Joined: Wed Nov 25, 2009 6:42 pm
Location: Odessa, Ukraine

Post by rootroot1 »

Hello again, Chris !!!!

Ragdoll is not falling througt, it gust dont work in the part I've described
above.

Please download my binary, and try to compile my project by your own, uncomment the part

Code: Select all

//upperLeftShoulder = CreateBodyFixedJoint(pscene, head.actor->PhysxObject->getActor(), leftCollar.actor->PhysxObject->getActor(), leftCollar.iBone->getAbsolutePosition(), vector3df(0,1,0)); 
      //upperLeftShoulder = CreateBodyFixedJoint(pscene, head.actor->PhysxObject->getActor(), rightCollar.actor->PhysxObject->getActor(), rightCollar.iBone->getAbsolutePosition(), vector3df(0,1,0)); 

      //leftShoulder = CreateBodySphericalJoint(pscene, leftCollar.actor->PhysxObject->getActor(), leftUpperArm.actor->PhysxObject->getActor(), leftUpperArm.iBone->getAbsolutePosition(), vector3df(0,1,0)); 
      //rightShoulder = CreateBodySphericalJoint(pscene, rightCollar.actor->PhysxObject->getActor(), rightUpperArm.actor->PhysxObject->getActor(), rightUpperArm.iBone->getAbsolutePosition(), vector3df(0,1,0)); 
In the first look everything is fine, but something is wrong, but what exactly ???????????

Maybe you can figure it out :idea: :idea: :roll:

I think it will be very usefull for your wrapper !!!!!!!!!!!!!!!!!!!!!!!
Waiting for your suggestions ///// :!: :!:

Thanks in advance.
Andrew.
rootroot1
Posts: 44
Joined: Wed Nov 25, 2009 6:42 pm
Location: Odessa, Ukraine

Post by rootroot1 »

I've spent all night playng with physx feautures and found
a problem. :cry: :cry: :cry:


I have found a problem,
Its about number of physx objects.

When we create more than 1000 instances
framerate becomes critical ( about 30 fps, and less if 1000+ instances )

Is this PhysX limitations ??? (Smth about 64 kb rigid bodies per scene)

If there the way to figure it out (threading??), or no ???????????? :cry: :cry:

My card have PhysX support ( 9500 GT 512 Mb), all simulations done by hardware, but this problem exists (I want to create thousands of objects, but not one thousand)...........................

Maybe i should switch to Newton or Bullet,
what do you think ??
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I don't know anything about the limitations of the number of Physx objects really... Obviously if you get into large numbers then you're going to be putting a high load on the processor(s) and the framerate will begin to suffer. It's also possible that it's not just Physx that's killing the framerate... What are the objects you're rendering? Even rendering 1000 cubes can destroy your framerate but there are certainly optimisations you can make to the rendering in order to improve it.

There may also be other ways to handle your large number of Physx objects... Why do you need more than 1000 at any one time? What are these objects?

I can't really help you out with the ragdoll issues you're having currently as I don't have any time to work on IrrPhysx :(
Image Image Image
rootroot1
Posts: 44
Joined: Wed Nov 25, 2009 6:42 pm
Location: Odessa, Ukraine

Post by rootroot1 »

Comes from SDK docs -->
Only one application can use the PhysX hardware at a time. The first application to access the hardware obtains exclusive access to it; however, it is possible to prevent the SDK from using the hardware even if it is present (see Hardware Detection for details).

Each hardware scene can hold up to 64k (D6) joints and 4080 or 64k rigid bodies (depending upon if NX_SF_RESTRICTED_SCENE is set).
There is a further limitation on the number of active rigid bodies. While a scene can contain 64k rigid bodies(if it is not a restricted scene), only 4k bodies, 4k D6 joints, 4k constraints and 8k shapes can be active.
The hardware supports a maximum of 32 faces and 32 vertices for convex mesh objects. Larger objects will fall back to software.
In addition, using large meshes with the PhysX hardware requires the application to perform mesh paging operations.
Since the hardware uses a different solver, the behavior of joints and contacts differs from that of the software SDK. In particular, scenes using D6 joints may be stable in software but not hardware and vice versa depending on the configuration. Keep the following in mind when using the hardware:
As in software, over constrained/opposing joints lead to poor behavior and instability.
Hardware joints behave better if they are initially configured in a balanced/stable system. For example, in a fixed D6 joint system, such as a breakable tower, it is better to have all D6 joints initially in an un-biased pose; otherwise, the SW or HW has to perform calculations to balance the system.
In some cases, turning off pose projection may improve the stability of D6 joint systems.
There is a limit of 64 contexts; a scene will take 1 or 2 contexts depending on flags upon creation. A software scene (NX_SIMULATION_SW) will always take 1 context, a hardware scene will take 1 context if NX_SF_RESTRICTED_SCENE is set, otherwise 2 contexts.
Why do you need more than 1000 at any one time? What are these objects?
I want to create huge asteroid field.


Maybe It will be faster to create this objects using dynamic TriMesh with?? :roll:

For my scene I load 3 * 100,000 triangles meshes as level buildings and get 65+ fps, if +1500 cube nodes with dynamics about 30 fps, but this is good result too.
Last edited by rootroot1 on Thu Jan 14, 2010 4:31 pm, edited 2 times in total.
rootroot1
Posts: 44
Joined: Wed Nov 25, 2009 6:42 pm
Location: Odessa, Ukraine

Post by rootroot1 »

I found some optimization hints !!!!!!!!!!!!!!!!!!!!!!!!!!!!! :P :P

for triangle meshes

Code: Select all

	//hardware & non-hardware specific paging modes
if(hardware)
	MeshShapeDesc.meshPagingMode = NX_MESH_PAGING_AUTO;
else
	MeshShapeDesc.meshPagingMode = NX_MESH_PAGING_FALLBACK;
for scene

Code: Select all

       sceneDesc.flags |= NX_SF_RESTRICTED_SCENE;
and now I'll try to add threading (as in SDk lesson)
this step will increase performance a little
Post Reply