-
December 10th, 2008, 05:50 PM
#1
Drawing a cube
Okay so I'm reading a book about the win32 api and were on the chapter where we learn to add menus and shapes and the whole chapter ends with making a simple PaintProgram that can draw shapes, it has brushs, pens, and colors for those pens/brushes, and diffrent styles for those pens. Then theres exercises you do to extend upon that program. This is the exercise I'm stuck on:
"As you can see, a cube is made up of twelve lines. Write a function that
draws a cube to the client area of a window. Then add a new “cube” primitive to Program 15.5 that the
user can select from the menu and draw."
So my question to you is where do I even begin to learn how to write a function that can draw a cube. I tried seeing if it was a trick exercise and there is already a cube function in the library. But I don't see any cube functions on msdn.
Can anyone help?
-
December 11th, 2008, 10:30 AM
#2
Re: Drawing a cube
If you know how to draw lines then you can also draw a cube.
A cube is basically 2 squares drawn using some offset and then connect the corners of the square with some other lines. Of course, things get more complicated if you want to rotate the cube in 3D space.
-
December 11th, 2008, 12:47 PM
#3
Re: Drawing a cube
I know how to make lines easily. But for some reason it's mind boggling to me to take the lines and know to take them in 2d(i guess its 2d) space and tell the lines where to "spawn" to sorta make it appear to be a cube. The only way the book taught me is how to make simple lines that are generated with the mouse left click and as you hold it down it "captures" the beginning of the mouse click to the end. (When lifting up the left mouse button). Oh well
-
December 11th, 2008, 11:25 PM
#4
Re: Drawing a cube
You can use Polygon function. Your first step is to draw what you think a cube would look like on paper. Then assign coordinates to the corners and then use Polygon function to connect them.
First step, draw one face of the cube. Did you figure that out ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|