Physx question related to scale

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Physx question related to scale

Post by Seven »

After creating a PhysX object, what is the correct method to scale the size of the object.

imagine creating a small test object that is an Irrlicht sphere and building a physX body to go with it.

Code: Select all

// create an Irrlicht sphere
m_Node = SMGR->addSphereSceneNode(10);

// create a Physx body for it
CreateSphereActor();

void CSObject::CreateSphereActor()
{
	if (!m_Node) return;
	
	//How the actor "works"
	NxBodyDesc BodyDesc;
	BodyDesc.angularDamping	= 0.5f; //Will make the body go all gravity on us

	// Add a single-shape actor to the scene
	NxSphereShapeDesc SphereDesc;
	SphereDesc.radius = m_Node->getScale().X;

	//General info about the actor.
	NxActorDesc BallActorDesc;
	BallActorDesc.shapes.pushBack(&SphereDesc);
	BallActorDesc.body			= &BodyDesc; //Then how he should "work"
	BallActorDesc.density		= 1.0f;     //We give him a density, so he will have a mass.
		
	//And we set him in space somewhere.
	vector3df pos = m_Node->getPosition();
	BallActorDesc.globalPose.t  = NxVec3(pos.X,pos.Y,pos.Z);
	
	//Now we create him!
	m_NxActor = m_Level->GetNxScene()->createActor(BallActorDesc); 
}
after this point, how woul dyou resize the object. In Irrlicht, we simply call the m_Node->setScale(scale) function, but I cannot find a good method to 'scale' the physX object.

One idea was to destroy the physX object and then recreate it, but you would need to store all of the current 'data' associated with it.

Anyone got any ideas for resizing the object?

Seven
gheft
Posts: 34
Joined: Mon Jul 30, 2007 4:11 am

Post by gheft »

There is no way of resizing an existing physx object so the only way is to recreate the object. just use the the same actor desc and copy over the transforms. If you want to scale a convex mesh you have to scale every vertex.
of course it will probably be pretty slow if you want to be changing scale alot.
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Post by Seven »

i was afraid of that :(

my application is an editor type app that allows users to add/remove/edit all of the objects in the game in real time, including scale. It looks like I will just have to recreate the object after the final scale is done.

thanks for the reply though
Seven
Post Reply