How to Create Arbitrary Mesh - Now with Kinect

Aug 6, 2011 at 3:42 AM
Edited Aug 9, 2011 at 3:30 AM

 

Very impressive stuff, thanks for sharing. I've been studying different parts of the samples but I am stuck in what seems like a very basic thing, sorry for the newbie question.

I have a list of triangles with the color associated with each of the vertices and I want to create a SceneObject from this. I looked at the ColoredCube sample but this implements IDrawableShape whereas the sample using models (like the viper) create a SceneObject that can be added to the scene.

It seems to me that a Scene is easier to handle (including camera, etc.) than the way PrimitiveSample handles updating each primitive individually.

So, I think I need something that builds a SceneObject from my list of vertices, triangle indices and associated colors.

Any pointers or sample code on how to achieve the above?

Here is a quick video showing an early demo of my app. http://www.youtube.com/watch?v=dZfplklp1uw

The small airplane is loaded rom an OBJ model and drawn by Babylon on top of a Bing map. The simulation is controlled by Kinect, that can be seen in the lower-right window. This is a small WPF app that makes the Kinect data available to the Silverlight app.

So, can I get some help creating arbitrary meshes as described above?

Coordinator
Aug 9, 2011 at 6:26 AM

Hi really cool demo, like it!

So about your question, you can have a look at the Babylon.Imports project where we create the SceneObject from an .obj.

You can also create a IDrawableShape and use it inside a custom SceneObject.

Aug 9, 2011 at 4:54 PM

Thanks. I did study the OBJ Importer and understood enough to modify it to create the plane in the demo as there were some material problems with the original models. But I could not figure out how to assign different colors to different vertices thus the somplete plane is the same red color.

I will look at IDrawableShape as you suggest. But I am a real newbie on this 3D stuff so let me know if there is any idea or code on the specific task of associating a color to each vertex.

Thanks again for the toolkit, good stuff.

Aug 11, 2011 at 11:15 AM

 

OK, making progress but seeking some help.

I understand the ObjImporter enough to extend it to my current need, I believe. But, before I proceed, I want to see if I am in the right path. Two specific questions:

   1) What is the process to get a SceneObject from an IDrawableShape?

   2) If I will need the mesh in my object to be updated often (maybe real time), is there a preferred model to follow?

Thanks for any help on this.

Aug 14, 2011 at 8:37 PM

One more update and question.

I got the mesh creation thing down and did some performance optimization. You can see q quick video here: http://www.youtube.com/watch?v=q8_InXCxhvw

The above creates cubes using VertexPositionNormalColor unitl it reaches 5 million vertices. You can see that the performance is very good, the zooming and panning stays very responsive. The jerkiness is the video encoding more than the code itself.

With this I end up with an IDrawableShape with my model. I still could not figure out the route between that and a SceneObject. Help?