I am a novice programmer in 3D graphics and i am using C++ and DirectX 9.
I would like to know how to draw Rectangles in 3d space when i now the coordinates of each point in 3d space.
For example i need to draw a shape whose bases are random rectangles.
(Coordinates given in x,y,z)
The top base(y=0) could be for example:
And the bottom base (y=-1) not symmetrical to the top base
Is there a given function where i can give those coordinates and the shape is drawn automatically?
If not, what other option do i have for accomplishing this task?
DirectX (or what used to be called Direct3D) has what you're asking for. The specifics of using it are beyond a simple post; you'll need to search for tutorials on the subject, and there are lots of books and free C++ libraries for doing this.
For an indepth discussion of 3D, David Eberly's texts regarding his 3D engine WildMagic is thorough, perhaps dense, with discussion on game engines that incorporate special effects and physics, but the basics are covered as well.
I'm not familiar with more gentle introductions, but I know there are many. If you're interest is going to remain limited to a few simple shapes then perhaps DirectX is appropriate, but if your interest is going to expand beyond that even slightly, you'll want to consider some kind of 3D engine.
One reason for that is the fact that the most widely used "alternate" standard (but by alternate I mean non-Microsoft specific; many, including me, consider DirectX the alternate) is OpenGL. OpenGL and DirectX are positioned similarly. That is, there is a C level interface that provides reasonably direct access to the hardware's 3D capability. OpenGL is available on devices ranging from 'supercomputers' to handheld game devices, whereas DirectX is only available on Microsoft devices and PC's.
What most engines, like Eberly's WildMagic, do is to encapsulate 3D drawing (and the representation of 3D objects) in such a way as to implement rendering independently of application code, so you can elect to use DirectX or OpenGL from one body of code - it is even possible to choose at runtime (though not in Eberly's implementation - others do).
There is some difference between a graphics engine and a game engine, which may affect your selection. A game engine includes components to handle physics, sound, input and graphics, while a graphics engine will only address graphics. By "engine" I mean a C++ library (and, there are C libraries also) that serve this purpose.
It is not, however, quite as simple as handing a list of points to a drawing function.
If your interest is strictly the display of a 3D graph, where the results are always going to be a rather simple solid shaded/wireframe outlined shape, you could choose a more old fashioned approach by drawing the shapes using 2D drawing primitives - especially if the output is not going to be animated. This involves the use of linear algebra, perhaps some 3D trig, to position the points as a projection onto a 2d surface, which then give the 2d points of simple convex polygons. This approach would seem simpler than invoking OpenGL or DirectX if, and I think only if, you're comfortable with the math. If you are, it turns out to be a relatively simple set of functions that perform the work, and the output is basic 3D solids (a pastel colored cartoon sketch, if you will). I'm sure many would cry foul for me saying that, but frankly the use of OpenGL or DirectX isn't all that simple if the math is familiar to you, and your expectations of the output are simple.
If my post was interesting or helpful, perhaps you would consider clicking the 'rate this post' to let me know (middle icon of the group in the upper right of the post).
Of what i read, i think i will not need the complexness of advanced 3d graphics, just some basic functions like drawing 3d polygons, scaling them , rotating them, and moving the camera around.
I am currently trying to find information in the DirectX Samples, but unfortunately most topics are either too advanced or irrelevant to what i need.
I have managed so far to create my own functions for creating and drawing my own 3d polygons, as long as the are Convex polygons.(Simply by using DrawPrimitive(D3DPT_TRIANGLEFAN....) )
I think i will not be able to make code able to manage Concave Polygons
If there is any library or article you know, which covers the above case, i would be delighted to learn about it.