Gosu Forums
Topic Gosu / Gosu Exchange / Programming with 3d objects
By Makki Date 2015-07-03 19:40
So I've been busy trying to come up with a way to display 3d objects in ruby using nothing but 'gosu' and lots of code.
(thus all the 3d -> 2d conversion is done manually without other libraries such as 'opengl')

An easy way to do this would be to start by drawing a 3d cube, right?
So I followed this tutorial: http://www.skytopia.com/project/cube/cube.html

And I rewrote all the code in ruby and surprisingly it worked!

Then I used draw_quad() to draw every 6 sides of the cube and I also changed the pivot-point so that
the camera could now move freely on it's own, (instead of only facing the cube) like in a first person shooter.

Now this is where I ran into a problem, because whenever I move the camera close to the cube, while facing away from the cube,
the side you are closest to would appear in front of the camera (even though you are outside the cube)

Here's a link to the ruby-code for those interested: https://www.dropbox.com/s/18h0vpqsvwwcrcy/3d%20-%20Skytopia.zip?dl=0

So does anyone have some knowledge about how to draw a cube or a 2d plane in a 3d space?
By jlnr (dev) Date 2015-07-03 22:29
After glancing at the code, well, I don't know. But it looks pretty effective so far :)

I would suggest that you find a computer graphics book and implement a "classic" rendering pipeline built on 3D vectors and 4x4 matrices. Writing the vector and matrix types should be fun to do in Ruby, anyway. I don't have any book/blog pointers though, this was a university class for me.
If nothing else, doing 3D the "standard way" makes it easier to debug your solution by comparing it to other 3D code.
By Makki Date 2015-07-04 20:20
I guess reading a book would help, but I was hoping for some simple guideline.
Also when you mention doing 3d the "standard" what do you mean by that?
By jlnr (dev) Date 2015-07-04 23:30
Topic Gosu / Gosu Exchange / Programming with 3d objects