PDA

View Full Version : Starting out.



meshwal
04-20-2016, 01:53 AM
Hi,

So I don't have much of an idea about openGL. Just started. But I've been tasked with the simulation of a 3D bulldozer. Now I have an idea of how to implement the movement of the bulldozer but I have no clue how to create the bulldozer itself. Which primitives do I use to create it? It can be really simple btw. As in I can make it as simple as using cubes to create the body and maybe using triangles to make the shaft. Any suggestions on other ways I can create the body?

reaktor24
04-20-2016, 02:11 AM
You could always try Blender which is a free 3D modelling package: https://www.blender.org/

gwartney
04-20-2016, 12:21 PM
You could always try Blender which is a free 3D modelling package: https://www.blender.org/ I would do what reaktor24 mentioned. I would go to a place like blend swap to find a model of what you are looking for import it into blender modify if needed and animate it in there. Then take and load the model into open gl with the obj file.

Carmine
04-21-2016, 05:40 PM
Making a simple bulldozer from scaled cubes is trivial using modeling commands such as glScale, glTranslate, and glRotate. The harder part for a beginner would be opening a graphics window with an understanding of the associated coordinate system. Can you do this? Can you display a simple cube in an OpenGL window?

meshwal
04-26-2016, 10:59 AM
Making a simple bulldozer from scaled cubes is trivial using modeling commands such as glScale, glTranslate, and glRotate. The harder part for a beginner would be opening a graphics window with an understanding of the associated coordinate system. Can you do this? Can you display a simple cube in an OpenGL window?

I do know how to display a simple cube. But yeah I'm not sure i understand how the gluOrtho function works. We're doing this in college so there are some parts i understand but i missed out on the first class so i missed the explanation of a few basic concepts.

Carmine
04-26-2016, 02:08 PM
gluOrtho maps a volume of space to the window/viewport you've opened.
Anything outside of the specified volume would not show up in your window.
See https://www.opengl.org/sdk/docs/man2/xhtml/glOrtho.xml for more info.
Can you display two cubes side-by-side, with one a little smaller than the other?
This would be done using the modeling commands and glPushMatrix/glPopMatrix.
That would be the next step.
You may also want to post your code (use [ code] and [ /code] tags for clarity).

meshwal
04-27-2016, 09:01 AM
gluOrtho maps a volume of space to the window/viewport you've opened.
Anything outside of the specified volume would not show up in your window.
See https://www.opengl.org/sdk/docs/man2/xhtml/glOrtho.xml for more info.
Can you display two cubes side-by-side, with one a little smaller than the other?
This would be done using the modeling commands and glPushMatrix/glPopMatrix.
That would be the next step.
You may also want to post your code (use [ code] and [ /code] tags for clarity).

No I haven't tried that out yet. Also reading about gluOrtho, it mentions the use of matrices. What role do the matrices play in the viewing volume?

GClements
04-27-2016, 07:16 PM
No I haven't tried that out yet. Also reading about gluOrtho, it mentions the use of matrices. What role do the matrices play in the viewing volume?
The vertex positions are transformed first by the model-view matrix then by the projection matrix. The resulting geometry is then clipped to the viewing volume, which is fixed: in clip coordinates, it's bounded by the planes -w<x<w, -w<y<w, -w<z<w; in normalised device coordinates, the corresponding planes are -1<x<1, -1<y<1, -1<z<1 (i.e. the faces of the unit cube).

If you transform the fixed viewing volume by the inverse of the projection matrix, you get the viewing volume in eye coordinates. For an orthographic projection, this will be an axis-aligned cuboid; for a perspective projection, it will be a pyramid frustum. Transforming that by the inverse of the model-view matrix gives you the viewing volume in object coordinates.

The functions which are normally used to generate projection matrices (glOrtho, gluOrtho2D, glFrustum and gluPerspective) construct matrices which will map specific points or angles in the source coordinate system to the faces of the fixed clipping volume.

Carmine
04-27-2016, 09:13 PM
The math which underlies 3D graphics viewing and modeling transformations is matrix multiplication. Fixed function OpenGL sort of hides this from you, which is a good thing for beginners. Functions like gluOrtho and glRotate generate 4x4 matrices and apply them to the vertices defining your objects (like a cube) via matrix multipication. You do not have worry about the underlying matrix stuff to do your assignment. The next step I'd recommend is placing multiple cubes in your scene. Should be pretty easy to build a simple bulldozer from correctly scaled and positioned cubes.