Need help with MogreNewt

Tubulii

22-03-2010 18:36:28

Hi,

Now i have some problems with Mogrenewt. Each time I create a box and throw it through my level, my ground sinks a bit. The box does not hit it.To avoid this,
I set "isFreezed" to true but it still sinks.

Any Idea?

kraj0t

23-03-2010 09:54:22

Could you please post the code that you're using?

I don't think you need to use isFreezed. I've never used that myself.

Tubulii

23-03-2010 16:56:30

okay, no problem:
This is the code for the World(here: groundnode)

'MOgrerNewt
Dim stat_col As MogreNewt.CollisionPrimitives.TreeCollisionSceneParser = New MogreNewt.CollisionPrimitives.TreeCollisionSceneParser(World)
stat_col.ParseScene(GroundNode, True, 0)
Dim bod As MogreNewt.Body = New MogreNewt.Body(World, stat_col)
stat_col.Dispose()

bod.AttachNode(GroundNode)
bod.SetPositionOrientation(New Vector3(0.0F, 0, 0.0F), Quaternion.IDENTITY)
bod.Velocity = Vector3.ZERO
bod.AutoSleep = True
bod.IsFreezed = True
'bod.SetMassMatrix(0, bod.Intertia)

And this is the code executed by pressing space

' now "shoot" an object!
Dim vec, dir As Vector3
' we get the position and direction from the camera... Dim dir As Vector3, vec As Vector3
Dim camorient As Quaternion = CharacterModelNode._getDerivedOrientation
vec = -Camera.DerivedDirection
dir = camorient * vec

' then make the visual object (again a cylinder)
Dim pos As Vector3 = Camera.DerivedPosition
Dim size As New Vector3(2, 2, 2)
Dim mass As Single = size.x * size.y * size.z * 2.5F

' calculate the inertia based on box formula and mass
Dim inertia As Vector3
Dim offset As Vector3

' Parsed Function "Make boxes"
Dim box1 As Entity
Dim box1node As SceneNode

box1 = SceneManager.CreateEntity("Entity" & (System.Math.Max(System.Threading.Interlocked.Increment(mEntityCount), mEntityCount - 1)), "box.mesh")
box1node = SceneManager.RootSceneNode.CreateChildSceneNode()
box1node.AttachObject(box1)
box1node.SetScale(size)
' box1.NormaliseNormals = True

Dim col As MogreNewt.ConvexCollision = New MogreNewt.CollisionPrimitives.Box(World, size, mEntityCount)
col.CalculateInertialMatrix(inertia, offset)
inertia = inertia * mass
Dim bod As New MogreNewt.Body(World, col)
col.Dispose()
' bod.Velocity = Camera.Direction * 200
bod.AttachNode(box1node)
bod.SetMassMatrix(mass, inertia)
bod.IsGravityEnabled = True

box1.SetMaterialName("Examples/10PointBlock")
bod.LinearDamping = 300
bod.Force = (-Camera.DerivedDirection) * 200
' bod.SetTorque(Camera.Direction)
Dim body As MogreNewt.Body = bod
bod.SetPositionOrientation(pos, camorient)
' set the initial orientation and velocity!
body.Velocity = dir * 300.0F

Timer = 0.2F


(note: i experimented a bit, some lines are maybe useless...and it bases on the Mogrenewt tutorial)

kraj0t

23-03-2010 17:47:43

Tree collisions are already static. There's no need for you to set it to AutoSleep nor IsFreezed. Also - I know it's commented -, you shouldn't need to set the body's mass to zero.

I'll see if I get the chance to test it when I get home. Can't tell what the problem can be just looking at the code.

Tubulii

27-03-2010 08:25:34

Did you looked at the code?
And/Or can you recommend a good tutorial for basic MOGRENewt, because most of the Tuts I fuond in the web,are about rigid bodies(...)...