IvanJ147
18-11-2011 13:54:37
Hi all!!
I have a problem with PhysX Candy Wrapper.
I created a scene with maya: http://www.fileden.com/files/2007/8/9/1334751//imgProvaCandy01.jpg
There is only a cube, and its center is in the origin of axis. As you can see in the image, rotation and traslation is set to zero.
Then I created a software with this code:
ActorNode is definite in this way:
At last, this is the render loop:
Now, I have a problem: seems that the collision box is different than the cube mesh. The video of his behave is here:
http://www.youtube.com/watch?v=vcn1MT6aW2o
Anybody can help me?
I have a problem with PhysX Candy Wrapper.
I created a scene with maya: http://www.fileden.com/files/2007/8/9/1334751//imgProvaCandy01.jpg
There is only a cube, and its center is in the origin of axis. As you can see in the image, rotation and traslation is set to zero.
Then I created a software with this code:
Private Sub creaScena()
o.mSceneMgr = o.mRoot.CreateSceneManager(Mogre.SceneType.ST_GENERIC)
o.mRootNode = o.mSceneMgr.RootSceneNode
o.mSceneMgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_ADDITIVE
o.cameras(0) = o.mSceneMgr.CreateCamera("camera")
o.cameras(0).Position = New Mogre.Vector3(147, 83, 94)
o.cameras(0).LookAt(New Mogre.Vector3(0, 20, 0))
o.cameras(0).NearClipDistance = 1
o.viewPorts(0) = o.mRenderWindows(0).AddViewport(o.cameras(0))
o.viewPorts(0).BackgroundColour = New Mogre.ColourValue(0.8, 0.8, 0.8)
o.cameras(0).AutoAspectRatio = True
'creo luce
Dim l As Light
l = o.mSceneMgr.CreateLight("luce")
l.Position = New Vector3(0, 50, 50)
l.SetAttenuation(200, 0.8, 0.01, 0)
phy = Physics.Create
phy.Parameters.SkinWidth = 0.0025
sceneD = New SceneDesc
sceneD.SetToDefault()
sceneD.Gravity = New Vector3(0, -9.8, 0)
scene = phy.CreateScene(sceneD)
scene.Materials(0).Restitution = 0.5
scene.Materials(0).StaticFriction = 0.5
scene.Materials(0).DynamicFriction = 0.5
scene.Simulate(0)
'creo il piano
Dim e As Entity
Dim n As SceneNode
Dim a As ActorDesc
Dim actor As Actor
Dim an As ActorNode
Dim b As BodyDesc
Dim p As Plane = New Plane(Vector3.UNIT_Y, 0)
MeshManager.Singleton.CreatePlane("Terra", "Gruppo risorse", p, 100, 100, 1, 1, True, 10, 5, 5, Vector3.UNIT_Z)
e = o.mSceneMgr.CreateEntity("ground", "Terra")
e.SetMaterialName("matOggettoVerde")
n = o.mRootNode.CreateChildSceneNode("GroundNode", New Vector3(0, 0, 0))
n.AttachObject(e)
n._update(True, True)
a = New ActorDesc
a.Density = 1
a.Body = Nothing
a.GlobalPosition = n.Position
a.GlobalOrientation = n.Orientation.ToRotationMatrix
a.Shapes.Add(New PlaneShapeDesc(p)) ', Vector3.ZERO))
a.Shapes(0).LocalPose.SetScale(New Vector3(1, 1, 1))
actor = scene.CreateActor(a)
actor.Name = "Terreno"
an = New ActorNode(n, actor)
ActorNodeList.Add(an)
e = o.mSceneMgr.CreateEntity("cubo1", "Cubo.mesh")
e.SetMaterialName("matOggettoRosso")
e.CastShadows = True
n = o.mRootNode.CreateChildSceneNode("cuboNode1", New Vector3(0, 80, 0))
n.AttachObject(e)
n._update(True, True)
b = New BodyDesc
b.LinearVelocity = New Vector3(0, 0, 0)
b.AngularVelocity = New Vector3(0.2, 0.8, 0.2)
b.AngularDamping = 0
a = New ActorDesc
a.Density = 1
a.Body = b
a.GlobalPosition = n.Position
a.GlobalOrientation = n.Orientation.ToRotationMatrix
a.Shapes.Add(New BoxShapeDesc((e.BoundingBox.Size)))
actor = scene.CreateActor(a)
actor.Name = "Cubo1"
an = New ActorNode(n, actor)
ActorNodeList.Add(an)
End Sub
ActorNode is definite in this way:
Private Class ActorNode
Private sn As SceneNode
Private a As Actor
Public Sub New(scenenode As SceneNode, actor As Actor)
sn = scenenode
a = actor
End Sub
Public Sub update()
Dim mat As Matrix4 = a.GlobalPose
Dim rot As Quaternion = a.GlobalOrientationQuaternion
sn.Orientation = rot
sn.Position = mat.GetTrans
End Sub
End Class
At last, this is the render loop:
Private Sub EnterRenderLoop()
While disegnaScena
Application.DoEvents()
For Each a As ActorNode In ActorNodeList
a.update()
Next
scene.Simulate(1 / 60)
o.mRenderWindows(0).Update()
o.mRoot.RenderOneFrame()
scene.FlushStream()
scene.FetchResults(SimulationStatuses.AllFinished, True)
contaFrames += 1
End While
End
End Sub
Now, I have a problem: seems that the collision box is different than the cube mesh. The video of his behave is here:
http://www.youtube.com/watch?v=vcn1MT6aW2o
Anybody can help me?