# Physics Simulation Forum

 All times are UTC

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Advice about Kinect and Dynamic HeightfieldPosted: Mon Mar 05, 2012 11:54 pm

Joined: Mon Mar 05, 2012 11:39 pm
Posts: 18
Location: Lancaster, UK
Hi folks,

I am attempting to convert a real-time-ish point cloud from a Kinect into a collision object and was wondering what advice you have about the best way to go about such a thing.

I was considering using the heightfield shape, mapping the point cloud into a grid and then simply updating the z-values of each vertex in the collision data, but I don't know if this is desirable or even possible? My other thought was to use a cloth soft body, but this might have quite a bit of overhead?

Any help / advice you have to offer would be greatly appreciated!

John

p.s. This is very similar to what I want to do:
viewtopic.php?f=9&t=6853&hilit=heightfield

Top

 Post subject: Re: Advice about Kinect and Dynamic HeightfieldPosted: Mon Mar 12, 2012 8:38 pm

Joined: Mon Mar 05, 2012 11:39 pm
Posts: 18
Location: Lancaster, UK
Just wanted to say I managed to get this working by updating the BvhTriangleMeshShape. I'll post up the source to the project soon if anyone is interested.

Here are some pics of the work so far: http://goo.gl/fIixl

Cheers,

John

Code:
private void RebuildTerrainPhysicsMesh()
{
// If our ground has not been created yet, or destroyed.
if (GroundBody == null)
{
// Ensure our groundMesh and groundShape are destroyed and properly disposed of.
if (GroundMesh != null)
{
GroundMesh = null;
}
if (GroundShape != null)
{
Physics.CollisionShapes.Remove(GroundShape);
GroundShape.Dispose();
GroundShape = null;
}

// Create the mesh container.
GroundMesh = new IndexedMesh();
int iTotalTriangles = 2 * (iTerrainWidth - 1) * (iTerrainHeight - 1);
GroundMesh.Allocate(this.tTerrainVB.Length, sizeof(float) * 3, iTotalTriangles, sizeof(uint) * 3);

// Write the verts.
BulletSharp.DataStream pData = GroundMesh.LockVerts();
for (int i = 0, n = tTerrainVB.Length; i < n; ++i)
{
pData.Write(tTerrainVB[i].Position.x);
pData.Write(tTerrainVB[i].Position.y + 1.0f);
pData.Write(tTerrainVB[i].Position.z);
}
pData.Close();

// And write the indicies.
IntArray tIndexData = GroundMesh.TriangleIndices;
for (int i = 0, n = tTerrainIB.Length; i < n; ++i)
tIndexData[i] = (int)tTerrainIB[i];

// Setup the shape.
TriangleIndexVertexArray vertexArray = new TriangleIndexVertexArray();
GroundShape = new BvhTriangleMeshShape(vertexArray, true);

// And the rigid body in the world.
GroundBody = Physics.LocalCreateRigidBody(0, Matrix4.IDENTITY, GroundShape);
GroundBody.UserObject = "Ground";
}

// Otherwise we have a valid shape already, just push the updates and refit it.
else
{
BulletSharp.DataStream pData = GroundMesh.LockVerts();
for (int i = 0, n = tTerrainVB.Length; i < n; ++i)
{
pData.Write(tTerrainVB[i].Position.x);
pData.Write(tTerrainVB[i].Position.y + 1.0f);
pData.Write(tTerrainVB[i].Position.z);
}
pData.Close();

GroundShape.RecalcLocalAabb();
GroundShape.RefitTree(GroundShape.LocalAabbMin, GroundShape.LocalAabbMax);
}
}

Top

 Post subject: Re: Advice about Kinect and Dynamic HeightfieldPosted: Tue Mar 13, 2012 7:40 pm

Joined: Mon Mar 05, 2012 11:39 pm
Posts: 18
Location: Lancaster, UK
Just wanted to say a big thanks to everyone involved in making Bullet (and Ogre).

Follow this link for some pics of the finished (ish) game: http://goo.gl/GBgkS

Cheers,

John

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 3 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 12 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ BULLET PHYSICS LIBRARY USERS    General Bullet Physics Support and Feedback    Release Announcements    Applications, Games, Demos or Movies using Bullet PHYSICS AUTHORING TOOLS, SERIALIZATION AND STANDARDS    Physics authoring tools, serialization, standards and related topics RESEARCH AND DEVELOPMENT IN COLLISION DETECTION & PHYSICS. Don't post Bullet support questions here!    Research and development discussion about Collision Detection and Physics Simulation    Links, Papers, Libraries, Demos, Movies, Comparisons       Non-technical forum and license/patent discussion    Career Opportunities