NxActor is not valid

randomcode

30-11-2016 13:37:15

I want to write my physx code by following this page:
http://www.ogre3d.org/tikiwiki/tiki-index.php?page=PhysX+Candy+Wrapper

But when i run my application, it don't work, and output print "NxActor is not valid"

Here is my code:
setup Physx:

physx = Physics.Create();
physx.Parameters.SkinWidth = 0.0025f;
SceneDesc scenedesc = new SceneDesc();
scenedesc.SetToDefault();
scenedesc.Gravity = new Mogre.Vector3(0, -9.8f, 0);
scenedesc.UpAxis = 1;

scenedesc.UserContactReport = this;

this.scene = physx.CreateScene(scenedesc);
this.scene.Materials[0].Restitution = 0.5f;
this.scene.Materials[0].StaticFriction = 0.5f;
this.scene.Materials[0].DynamicFriction = 0.5f;

this.scene.Simulate(0);
physx.RemoteDebugger.Connect("localhost", 5425);
return true;


Create Actor

float scale = 0.1f;
int id = 0;
Entity entity = m_SceneMgr.CreateEntity("ogrehead"+id.ToString(),"ogrehead.mesh");
SceneNode scenenode = m_SceneMgr.RootSceneNode.CreateChildSceneNode();
scenenode.AttachObject(entity);
scenenode.Position = new Vector3(0,10,0);
scenenode.Scale (Vector3.UNIT_SCALE * scale);

BodyDesc bodydesc = new BodyDesc();
bodydesc.LinearVelocity = new Vector3(0, 2, 5);
bodydesc.Mass = 40.0f;

ActorDesc actordesc = new ActorDesc();
actordesc.Density = 4;
actordesc.Body = bodydesc;
actordesc.GlobalPosition = scenenode.Position;
actordesc.GlobalOrientation = scenenode.Orientation.ToRotationMatrix();

actordesc.Shapes.Add(new SphereShapeDesc((float)System.Math.Sqrt((double)(entity.BoundingBox.HalfSize * scale).SquaredLength), entity.BoundingBox.Center * scale));


Sorry for the csharp code, i am using Physx Candy Wrapper