Recommended Posts

Hi everybody.
I´m in big trouble.
I can´t imagine how I can render, or more precisely, how to create vertex and index info of more complex objects.
I mean, due to the sphere example, there is a formula for every point of the sphere, but how do I index this points and how do I evaluate the distance among two points?
And this is not all. What about the torus, or this knot objects often seen in demos. I realy want to get deep into this topic.
I need your help to start off, because I have absolutely no idea where to start!!!
And if it needs complex numbers, no matter, I´m well introduced to it!
Thanks
Alex

0

Share this post

Link to post

Share on other sites

I'm going to move this over to GP&T; whilst you might be using Direct3D the basic algorithms/methods for creating primitives is independent of a particular API. Maybe the GP&T regulars can recommend some resources for you [smile]

Share this post

Link to post

Share on other sites

Original post by directNoobThanks, but I don´t need the premade objects. Instead, I need to do it my self.

There's certainly plenty of good info to be found on this subject (I can offer some tips/links), but just out of curiosity can you explain the context? Why do you need to generate these objects procedurally? And what shapes exactly are you interested in (aside from those that have already been mentioned)?

0

Share this post

Link to post

Share on other sites

I don't want to hijack the people already helping directNoob, but I wanted to plant this in his mind to help the concept to sink in.

directNoob:1. For procedural objects, you have to think about how to break it down into a triangluated surface.2. If you can break it down into rectangular gridlike patches, it's easy to convert that to triangles (cut the quadlaterals in half - viola, triangles)3. Look for planar, rotational and spherical symmetry to procedurally generate the object.

(just do it!)

Example - sphere An easy way to create a sphere is to think of it in terms of latitude and longitude.this imageshows this idea perfectly.See if you can come up with a process to recreate the points. (hint, in this case, the sphere is basically a 2d grid, wrapped to the shape of a sphere)

-Michael g.

0

Share this post

Link to post

Share on other sites

@Thr33dYour sample image suffers from problem due to the singularity at the poles. For spheres, a sub-division approach seems better suitable, especially since mapping coordinates can be interpolated easily.

To subdivide a suitable geometric object (any platonic polyeder will do - start with a tetrahedron for simplicity), you apply a basic subdivision algorithm and simply normalise the vertices.

Repeat the subdivision on the newly created sub-triangles to refine the resulting mesh. A tetrahedron conviniently consists of four equilateral triangles so it's a nice start to test this subdivision out with.

Using an octahedron or even an icosahedron (20 sides) reduces the number of subdivisions (and hence resulting triangles) required to form a smooth sphere.

HTH,Pat.

0

Share this post

Link to post

Share on other sites

I just want to get deeper into this material. I´m tired load x files for example.I want to make my own objects plus, I want to extent my mathematical horizon.When you have resources, please give it to me! I would be very grateful.I want to experiment with this object and figure out how the guys in the demo scene are doing it. But the worst thing is, I can´t get behind it myself.And this disappoints me very much.

@Thr33d:Ok, that´s easy.

r^2 = x^2 + y^2 + z^2 =>z = +-sqrt(r^2 - (x^2 + y^2))

With this formula, I get every point on the sphere.Did you ask for this?

GreetingsAlex

0

Share this post

Link to post

Share on other sites

A good place to start is here, with the 'Platonic solids' .pdf. Having these shapes available can be a handy point of departure for more complex shapes.

For spheres, the aforementioned lat-long approach is quite easy to code, provided you're not concerned about the irregular distribution of triangles. Otherwise you'll want to take darookie's advice and apply recursive subdivision to an octa- or icosahedron.

A torus can be generated with simple trig; you just need to think about the geometry involved (an inner ring with circumscribing rings at regular intervals) and derive the code accordingly.

From there, procedural generation of meshes can get more or less arbitrary complex. There are subdivision surfaces, generalized cylinders using curves and various types of curve frames - the list goes on. For more advanced meshes you'll need to be comfortable with vector math, and will most likely need to develop as a foundation a mesh class with support for connectivity queries.