Drawing geometry

Started by
4 comments, last by cosmicfish 16 years, 1 month ago
Hi there I've got a bit of a problem here. I have to draw a lot of different 3D shapes like cubes, cylinders, torus, pyramid, triades, spheres, spherecaps, wedges, tubes, cones, sliced tubes... I'm a bit short on time to come up with the solutions myself and I'm sure those things have been done before way better and more efficient than I could ever do it. I was wondering if anyone could point me to a good website that has some code examples for drawing 3D geometry manually. (creating the vertices at the correct positions and drawing them with trianglefans/strips) thanks
Advertisement
Is this for a homework assignment? (I just need to know how much help it's appropriate to offer :).
It's not for homework, it's part of a bigger assignment and they don't really care how I make it, as long as they get some results.
There's some good info here. Also, Dave Eberly has a document that gives basic mesh descriptions of a few geometric solids at geometrictools.com.

I've done quite a bit of work with procedural mesh generation also: I know I've written (C++) code for at least some of the items on your list, including cubes, cylinders, torii, Platonic solids (tetrahedra and so forth), spheres, cones, and tubes. My mesh code also includes support for 'rounded' variations on some of these shapes and at least one type of subdivision surface, as well as capsules and a few other miscellaneous shapes, such as ellipsoids and torus knots.

Can you provide any more information about what you're doing? Assuming there's really no problem with you getting assistance with this, I'll be happy to help out if I can (at the very least, I can try to gather up the relevant code and post it here).
Well, I have to make a 3D visualizer for some software that stores primitive data (positions, dimensions) into a database. I just load the data en try to redraw the shapes exactly as they appear in there, add some fancy effects and also make sure it's easier to modify the shapes. The only thing is that there's over 20 different shapes in it and some of them are not very common.

I'm using Managed DirectX in C# btw
I've managed to make some of the primitives I asked about, but I've got another problem now. I want to store the vertex data in a Mesh object (it has to be a Mesh), but to draw anything, the Mesh also needs index data.

The problem is that the texture and normal data isn't correct if it's shared between triangles where one trangle is on the front of a box and the other on the side.

Before using a Mesh, for a box I had 24 vertices and drew them in pairs of tranglestrips for each face.

To get it right now I need 24 vertices, but also 12 trangles in my index buffer. To me it seems like this way the index buffer isn't doing any good and generating one for a cylinder for example can become complicated (for me at least).
Is there a way to tell the device what trangles from a Mesh have to be drawn without using an index buffer, something like drawing trianglestrips with device.DrawPrimitives? Or maybe another solution?

This topic is closed to new replies.

Advertisement