Physics with models

Nov 29, 2012 at 11:53 AM

I have been playing with the physics of nine engine and i'm a little stuck.

I am trying to move a model and when it hits another model like a box i want it to stop. Right now if i move the model it goes through the box and if i give the box a rigidbody the box and model just fall over. How do i check for models and stop movement? also do i have to use a rigidbody on a model like "Dude" to be able to make use of the physics?

Developer
Nov 29, 2012 at 12:17 PM

Have you looked at the in the tutorial where we use a Component to move a rigidbody?

Nov 29, 2012 at 1:19 PM

Yes i looked at the sample for moving a rigidbody and i was able to move a ridigbody using the same methods, but i was not able to stop a ridigbody from moving as soon as it hits another ridigbody. Also both ridigbody's would just fall over. Should i do something like give mass or use a if statement. I am trying to make a small game so i can learn about the engine and i'm trying to make a character not move through a wall.

Right now my character just falls over on colliding with a wall after it falls over i still can move it around but now its on its back.

Developer
Nov 29, 2012 at 1:43 PM

So the models are colliding? But fall over? Try changing stuff like damping. Or changing the body type to kismetic. Adding a joint(not added in xaml atm) maybe. You can read more about the physics on bepu's codeplex.

On Nov 29, 2012 3:20 PM, "oda" <notifications@codeplex.com> wrote:

From: oda

Yes i looked at the sample for moving a rigidbody and i was able to move a ridigbody using the same methods, but i was not able to stop a ridigbody from moving as soon as it hits another ridigbody. Also both ridigbody's would just fall over. Should i do something like give mass or use a if statement. I am trying to make a small game so i can learn about the engine and i'm trying to make a character not move through a wall.

Right now my character just falls over on colliding with a wall after it falls over i still can move it around but now its on its back.

Read the full discussion online.

To add a post to this discussion, reply to this email (nine@discussions.codeplex.com)

To start a new discussion for this project, email nine@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Nov 29, 2012 at 10:48 PM

Thank u for all the help, it seemed that i had no proper collision because the location of my models and modelcollider/boxcollider did not match. After correcting that i had the effect i needed. 

Now i have that i want to make my own props and characters only when i model them they are HUGE. What are the dimensions i need to look for when making a 3d model. Lets say i make a box if i say that the size is 10,10,10 is the metric then 10 cm or 10 feet? 

Developer
Nov 30, 2012 at 5:56 AM

So I am not a good modeler myself, so I have no clue. But the model 'Dude' is huge and then changed in the Content Pipeline with the properties, to make it smaller. And I just want you to keep in mind when using the Physics that it is not fully implemented to Nine. 

Jan 4, 2014 at 6:49 PM
So, I thought my question was relevant to this topic.

Following the tutorials, I got the basics of drawing models. Still fumble over programming the keyboard controls, but that can wait.

I'm trying to make a RTS that has some FPS features. I've decided that the best way to go about this and present a fully "contained and furnished" world, I would use a model instead of using a heightmap for the terrain surface. This would allow me to make "DeathMatch" like maps for a quick game feature, and then I would maker much larger maps, with building zones to concentrate bases near resources for the RTS, but still have this "battlefield" experience for FPS like functions. (Yah, I'm dreaming BIG. Wish me Luck.)

My issue really comes down to when the draw the model, it lacks collision. My "BaseFighter" falls through the floor. Then If I give the level model rigid body, they both fall together. BEPU documentation is thick for me, so I'm hoping the solution is right at the xaml file.

Any quick line of code that keeps the model absolutely stationary? I've provided an example below of what I'm tinkering with.

<Scene xmlns="http://schemas.microsoft.com/nine/2011/xaml">
<AmbientLight AmbientLightColor="0.2, 0.2, 0.2" />
<DirectionalLight DiffuseColor="0.8, 0.8, 0.8" SpecularColor="1, 1, 1" Direction="-1, -1, -1" />

<!--
    Create a flat terrain

<Surface Heightmap.Width="32" Heightmap.Height="32" Transform.Position="0, 0, 0" />
-->
<!-- 
    Uncomment the next line to add your own model

<Model Source="{ContentReference MyModel}" />
-->
<Group>
    <Model Source="{ContentReference Models/Level}" />
    <RigidBody>
        <ModelCollider Source="{ContentReference Models/Level}" />
    </RigidBody>
</Group>


<Group Transform.Position="0,10,10">
<Model Source="{ContentReference Models/BaseFighter}" />
    <RigidBody>
        <ModelCollider Source="{ContentReference Models/BaseFighter}" />
    </RigidBody>
</Group>
</Scene>
Developer
Jan 4, 2014 at 8:12 PM
<Scene xmlns="http://schemas.microsoft.com/nine/2011/xaml">
    <AmbientLight AmbientLightColor="0.2, 0.2, 0.2" />
    <DirectionalLight DiffuseColor="0.8, 0.8, 0.8" SpecularColor="1, 1, 1" Direction="-1, -1, -1" />

    <Group>
        <Model Source="{ContentReference Models/Level}" />
        <!-- without <RigidBody> it will be static -->
        <ModelCollider Source="{ContentReference Models/Level}" />
    </Group>


    <Group Transform.Position="0,10,10">
        <Model Source="{ContentReference Models/BaseFighter}" />
        <RigidBody>
            <ModelCollider Source="{ContentReference Models/BaseFighter}" />
        </RigidBody>
    </Group>
</Scene>
Jan 5, 2014 at 3:18 AM
Excellent, worked EXTREMELY well. I had some ugliness from my models I exported from Blender, and had to Scale the Level map up, but it worked extremely well all things considered. It takes a moment for the build to start running because of the large LevelModelMesh, but is solid all the same.

I was also able to get a grip on how to link keyboard controls using the ExamplePhysicsController. Now I'm able to draw two robots, one above the other to test playing with Collisions with the level. Must of spent an hour just changing types and ramming them together. :-D

I'm also having the same problem as described earlier in this discussion. I've got one robot linked to my direction keys. When I move him around, regardless of the Collision Shape I use, he'll just flip around like an idiot. Also has a tendency to roll down this staircase I made. Friction helps to keep things still. I don't even understand what restitution means. :-)

But when I try to use the mass and damping settings, I get one heck of an error I don't know heads or tails of. Its identical to the one I this discussion topic.
https://nine.codeplex.com/discussions/431918

I hope I'm not an idiot trying to re-invent the wheel. Any thoughts on solutions?