begginer need help

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
alfarza
Posts: 45
Joined: Mon Jul 04, 2011 5:35 am

begginer need help

Post by alfarza »

hi every one i'm new in bepu and xna :oops:
i'm trying to make my first step in bepu, i'm using xna4 and the newer version of bepu 0.16 , what i want to do is put one box(entity) and attach a cube model to it , then when game is running i want the etity falling to the ground , actualy i'm try to do that but the entity still in it's position whitout falling on the ground , i was attach the model with entity position (using the world matrix) . and i was also write a code for static mesh (ground) for collision with that box , here is my code:

using BEPUphysics;
using BEPUphysics.DataStructures;
using BEPUphysics.Entities;
using BEPUphysics.Collidables;
using BEPUphysics.MathExtensions;
using BEPUphysics.Entities.Prefabs;

// variable
Space space;
Vector3 cubeBoxPos;

// load content
cube = Content.Load<Model>("E/cube");
space = new Space();
space.ForceUpdater.Gravity = new Vector3(0, -9.8f, 0);
Vector3[] vertices;
int[] indices;
TriangleMesh.GetVerticesAndIndicesFromModel(ground_w_d, out vertices, out indices);
var mesh_level = new StaticMesh(vertices, indices, new AffineTransform(new Vector3(0, 0, 0)));
Box cubeBox;
cubeBoxPos = new Vector3(0, 20, 20);
cubeBox = new Box(cubeBoxPos, 1, 1, 1, 1);
space.Add(cubeBox);
space.Add(mesh_level);
// update
space.Update();
System.Diagnostics.Debug.WriteLine(cubeBoxPos);// to know the position of box entity

where is the wrong ?
thanx for any one need to help.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: begginer need help

Post by Norbo »

Nothing immediately jumps out as obviously wrong. I'd recommend comparing your project to the BasicSetupDemo and GettingStartedDemo (http://bepuphysics.codeplex.com/wikipag ... umentation), which includes some basic simulation setup and very basic rendering.

It could just be that the graphic is not being moved correctly with the entity.
alfarza
Posts: 45
Joined: Mon Jul 04, 2011 5:35 am

Re: begginer need help

Post by alfarza »

i do a compare before and i don't know what the problem is . i know that the entity box still in it's position because the code "System.Diagnostics.Debug.WriteLine(cubeBoxPos);" tell me the position of box entity .any idea?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: begginer need help

Post by Norbo »

That line just outputs the cubeBoxPos variable, not the cubeBox.Position property. The variable won't change when the entity's position changes.
alfarza
Posts: 45
Joined: Mon Jul 04, 2011 5:35 am

Re: begginer need help

Post by alfarza »

thanx norbo that's right .... . Position :D
Post Reply