Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / 3D Theory & Graphics / Primitive routines for 3d editor? Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
Max

August 11, 1999, 03:26 PM

Since a few weeks I'm working on a 3d editor. Loading objects from 3d studio works fine, but I need to implement functions to create my own primitives, like boxes, spheres and that kind of stuff. Does anybody know where I can find some information about this?

Thanks

 
Jeroen

August 15, 1999, 07:09 AM

>>Since a few weeks I'm working on a 3d editor. Loading objects from 3d studio works fine,
>>but I need to implement functions to create my own primitives, like boxes, spheres and that
>>kind of stuff. Does anybody know where I can find some information about this?

In my own engine, I have function to create one of the five regular (or platonic) solids.
I could send you the data-sets for them (they are not procedurally created).
Further, I have a routine from way back which creates an 80-faced sphere.


Jeroen

 
Jeroen

August 15, 1999, 07:10 AM

>>Since a few weeks I'm working on a 3d editor. Loading objects from 3d studio works fine,
>>but I need to implement functions to create my own primitives, like boxes, spheres and that
>>kind of stuff. Does anybody know where I can find some information about this?

In my own engine, I have function to create one of the five regular (or platonic) solids.
I could send you the data-sets for them (they are not procedurally created).
Further, I have a routine from way back which creates an 80-faced sphere.


Jeroen

 
Raven

August 17, 1999, 12:13 PM

>> Since a few weeks I'm working on a 3d editor. Loading objects from 3d studio works fine,
>> but I need to implement functions to create my own primitives, like boxes, spheres and that
>> kind of stuff. Does anybody know where I can find some information about this?
Simplest way to do this is to take the equation of the solid you want to generate and take a step through it to tesselate this into any resolution you want. This might not be the best thing for stuff like cylinders, where the top and bottom can be one convex n-gon instead of many small triangles. Be creative! these things are simple so you can very well make up a routine to procedurally generate it. Example to generate a sphere:

1. Take a cube made from triangles where the distance from each vertex to the masscenter is 1
2. Subdivide the triangles its made from.
3. Normalize the distances from all the vertices to the masscenter. Now you have an approximation of a sphere.
4. Rewind and repeat until satisfactory

And please, dont ask how to generate a box! There really isnt anything simpler than that:)

- Raven

 
Tim Lewis

August 17, 1999, 11:27 PM

one way of making 3d object easily is to define solids by 2d cross sections; A cube is just two connected squares so you have a routine to draw a square that returns the first vertex
it created, you draw two squares and then have another routine to connect the two lists
with a set of quads (or it the shape is likely to generate non-plainar polygons, triangles).
A cylinder follows similar principles and the code is pretty much identical (infact, you could create a cube with a cylinder made from 4 sided n-gons). The code to make a 2d ellipse would look something like this pseudo C (i.e. it won't work if you try to compile:)

vertex *mkellipse(px,py,pz,rx,ry,nsides)
{
for (i=0;i

 
This thread contains 5 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.