Can someone explain how 3D Graphics (3D Cubes/polygons) Work?
Root / Programming Questions / [.]
chemicalexCreated:
I want to make a 3D modeling game, something like those 3D space shooter games with the graphic screen. I know it includes (lots of) maths, but how do I pull t off? Thanks.
/9Warning: Not helpful9/ This is kind of beyond the scope of this site... There are many good tutorials on this out there. Also, Givers P3D uses some extra fancy stuff in regards to how drawing and updating is done, so you wouldn't really get results like that, I don't think.I'm not asking for fancy graphics.
/9Warning: Not helpful9/ This is kind of beyond the scope of this site... There are many good tutorials on this out there. Also, Givers P3D uses some extra fancy stuff in regards to how drawing and updating is done, so you wouldn't really get results like that, I don't think.I'm not asking for fancy graphics.
I didn't mean graphics. I meant speed.That either.
He probably wants flat-shaded polygons like what we have in the programs section. Use that. http://smilebasicsource.com/page?pid=74
Study other's programs. You can find many tutorials over the internet for this stuff too.
https://www.khanacademy.org/computing/computer-programming/programming-games-visualizations/programming-3d-shapes/a/generating-3d-shapes
http://petercollingridge.appspot.com/3D-tutorial
Some games use pre-rendered "3d" spritesThanks, but I think copper's answer did the trick. I should probably start-
How have you got on with this?
I knocked together a simple 3D engine just to see if I could do it. The main problem was keeping 60fps when more than about 12 triangles were being drawn per frame.
You'll probably find that you hit this limitation and end up spending a lot of time trying to make your code faster.
If you're still looking for tips to start off:
- You'll first need to figure out how you're going to define your 3D model data. I researched different ways of storing this information, and settled on using a pair of arrays, one is a list of vertex positions (x,y,z coords), and the other is a list of faces, which are triangles defined by vertices from the vertex array.
- You'll want to define your camera position (and rotation), and make button presses alter those values.
- Then it's just a matter of projecting the 3D points of your model to the 2D plane of your camera view. Read up on 3D projection. Try a couple of different techniques out and compare rendering speed.
- Finally, draw triangles using these 2D points. Draw lines as well - it helps define the object.
Once you have a basic renderer working, then look into concepts like 'surface normals' and how you can use then to skip drawing polygons which face away from the camera.
If you're using a perspective projection and find your code's getting bogged down with sin() and cos() calls then consider creating sin[] and cos[] arrays when your game is initialising and using them to look up the results.
Hope this helps? Let us know any clever tricks you come up with :-)
Why am i getting notifications for a two year old thread.To make you necro it. Is it possible to make a sprite "cube?"