Drawing Complexs polygons
Hi every one
well, I'm trying to simulate a real enviroment of my little lego NXT Robot , I have a file saving some coordinates (points of X,Y) for a huge stone for example ,
and I want to connect these point together , and generate this huge stone , can anyone help me how can I do this task .
thanks in advance for you help
[357 byte] By [
MikaEg] at [2008-2-5]
If your object is very complex, then this task is probably too hard to do by hand, but you should research the .obj format. it is a plain text file of vertexes, edges, and faces. I think hand editing this is almost impossible for anything more complicated than a cube.
you should probably look into solid modeling programs like SolidWorks, Blender, 3D Studio, or Maya. Some of these programs should let you create objects from a list of vertexes. (I know Blender for example lets you run python scripts in it). This info might also help: http://channel9.msdn.com/wiki/default.aspx/Channel9.SimulationImportTutorials
First , thanks for your help
I nearly tried all these modeling programs
, but actually , the object is not static , I'm supposed to recieve some points and draw it dinamically ,
I just want to know , if I can draw an object throught these points , and How ,
ex: I have just 12 points and I know there arrangement and how can I connect them , I just need a way that can let me connect between these points generating a polygone of several traiangles , even if it was hard , as I may reduce the points to get simple shape.
Thanks for futher help.
I would try generating a .obj file using code (see http://en.wikipedia.org/wiki/Obj for a start on the format). Since you know the points, you can specify those easily in the file, and then you simply need to generate triangles for all the faces. Since you also say that you know how to connect them, you should be able to generate the faces easily as well. Once you have that, the simulation should be able to import the.obj file that you generated as a mesh for an object.
I'm not really sure how fast this is going to be though, especially if the object is complex and you're trying to rebuild the physics representation each time. Not having used meshes yet, I have no idea what the import speed is like.
I assume that you want a physical model as well as a visual model of the rock since you want your robot to be able to interact with it.
The complexity of the task is determined by how closely you want the rock to resemble its real-life counterpart. On one end of the spectrum, you could represent the rock with a single cube that has roughly the same size as the rock. You could do this easily with a singleshape entity (See SimulationTutorial1 for an example of creating a cube singleshape entity).
On the other end of the spectrum, you could come up with an algorithm to generate a convex hull mesh that covers the vertices specified in your rock model. You would then build a SimplifiedConvexMeshEnvironmentEntity that specifies the mesh and the engine will build a corresponding physics shape (see SimulationTutorial5). You can find more information about convex hull algorithms at:
http://en.wikipedia.org/wiki/Convex_hull
That whole convex hull thing can take quite awhile to get right, though. I would recommend an approach somewhere in the middle. You can build a MultiShapeEntity with 16, 25, or 36 (or more!) cubes depending on the resolution you want. The X and Z positions of each cube are set so that they form a grid on the ground that covers the area of the rock. The height of each cube is then set to the approximate height of the rock at the x and z position of the center of the cube. When this shape is initialized, the engine will build a mesh which represents the cubes. It may not look a lot like a rock but it will provide a useful model that your robot can interact with. Think of it like those rocks that are vaguely cube-like in Superman's fortress of solitude.