STD - A 3d library

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
mickeyjm
Party member
Posts: 237
Joined: Thu Dec 29, 2011 11:41 am

STD - A 3d library

Post by mickeyjm » Fri Jan 04, 2013 3:02 pm

I introduce my latest project

Show us Three Dimensions

Yet another 3D rendering engine, only I took the time to convert it into a library and include a rotatable camera.

Controls (Demo only, define your own if you use the library):

Code: Select all

uparrow = move camera up (+Y)
downarrow = move camera down (-Y)
leftarrow = move camera left (-X)
rightarrow = move camera right (+X)
comma = move camera backwards (-Z)
full stop/period = move camera forwards (+Z)

minus = decrease FOV
plus = increase FOV

mouse = rotate camera
n and m = change pitch

escape = close
Features:

Code: Select all

Rotatable Camera
Movable Camera
Vertex Sorting
Only one -z coordinate related graphical errors (that Ive seen)
Vector manipulation
Currently working on:

Code: Select all

+Back face culling support (Just need to make a function to sort faces anti clockwise)
*Vertices need to be triangles (Done)
*FOV in degrees, not arbitary distance (Done)
*Mouse Hidden in Demo (Done)
+Proper rendering off offscreen points (Working on)
-Bug involving floor rendering weirdly (Will be fixed with offscreen point problem)
+More vector functions (Done, more will be added if neccessary)
+Better performance
Version 1.1 Changelog:

Code: Select all

+ Added STD.renderList(object1,object2,etc)
+ Added Pitch control in demo
+ Added vectors.lua
  +STDV.newVector(x,y,z) => vector
  +vector:add(vector) => new vector
  +vector:subtract(vector) => new vector
  +vector:scale(originVector, scale) => scaled vector
  +vector:magnitude() => magnitude
  +vector:rotateAround(originVector,directionVector) => rotated vector (direction Vector is a normal vector but with angles in x,y,z)
+Added STD.showBorders
+Added ability to define faces with a colour
+Added ability to define faces with vectors (doesn't replace number version)

*Made render.lua use vectors.lua (self requires)
*Began fixing rendering bug spotted by Roland whee the ground renders weirdly
*Updated demo to show an array of cubes rather than 1
*Updated demo to show coloured faces (all bottom faces are black)
Attachments
STD.zip
Library version 1.1
(1.96 KiB) Downloaded 84 times
STDDemo_1.1.love
Demo of version 1.1
(2.99 KiB) Downloaded 239 times
Last edited by mickeyjm on Thu Jan 10, 2013 4:31 pm, edited 4 times in total.
Your screen is very zoomed in...

User avatar
srcn
Citizen
Posts: 59
Joined: Fri Dec 28, 2012 2:22 am
Location: Tartu
Contact:

Re: STD - A 3d library

Post by srcn » Fri Jan 04, 2013 5:09 pm

wow thats pretty cool
I am a mad scientist!

User avatar
mickeyjm
Party member
Posts: 237
Joined: Thu Dec 29, 2011 11:41 am

Re: STD - A 3d library

Post by mickeyjm » Fri Jan 04, 2013 6:04 pm

thanks :)

BTW does anyone have any links to tutorials on only drawing what is visible (whatever the term for that is) Ive tried google but as I mentioned in Nixola's Cube thread I can never get meaningful results regarding 3d
Your screen is very zoomed in...

User avatar
Roland_Yonaba
Inner party member
Posts: 1562
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: STD - A 3d library

Post by Roland_Yonaba » Fri Jan 04, 2013 6:17 pm

Looks nice.
But, is that me or some weird things happen when attempting to look "up" (especially when U <= -8 ~ -9)... :roll:

User avatar
mickeyjm
Party member
Posts: 237
Joined: Thu Dec 29, 2011 11:41 am

Re: STD - A 3d library

Post by mickeyjm » Sat Jan 05, 2013 9:41 am

I see what you mean, from what I can tell that is the camera dipping below the ground and as a result the ground is rendered above you. Ill take a look into it and try and fix it.

EDIT: Turns out it is due to the way I render polygons with points off of the screen. Im trying to fix THAT probelm now
Your screen is very zoomed in...

scutheotaku
Party member
Posts: 235
Joined: Sat Dec 15, 2012 6:54 am

Re: STD - A 3d library

Post by scutheotaku » Sun Jan 06, 2013 3:47 am

Very cool!
Quick question - I haven't looked at your code, but is that FOV number a correct representation of the FOV? Because when I turn the FOV down to a more normal range (70 to the low hundreds), things work very strangely...

Other than that and the problem Roland mentioned, this looks really good!
mickeyjm wrote: BTW does anyone have any links to tutorials on only drawing what is visible (whatever the term for that is) Ive tried google but as I mentioned in Nixola's Cube thread I can never get meaningful results regarding 3d
Here are some links that may prove useful:
http://en.wikipedia.org/wiki/Hidden_sur ... ermination
http://www.gamedev.net/page/resources/_ ... ines-r1212
http://www.gamasutra.com/view/feature/3 ... rithms.php
http://myweb.lmu.edu/dondi/share/cg/hsr.pdf
http://coitweb.uncc.edu/~krs/courses/50 ... l_lod2.pdf
http://content.gpwiki.org/index.php/Backface_culling
http://medialab.di.unipi.it/web/IUM/Wat ... ode66.html

User avatar
mickeyjm
Party member
Posts: 237
Joined: Thu Dec 29, 2011 11:41 am

Re: STD - A 3d library

Post by mickeyjm » Sun Jan 06, 2013 11:05 am

Regarding the FOV, the number is referring to the distance away from the camera the screen is calculated, and not the angle of the FOV. I would have liked to have it as the angle but the tutorial I used for rendering didn't have that method.

Thanks for the feedback and the links, I should be able to boost performance and fix some bugs with those links a lot easier now.
Your screen is very zoomed in...

wssmith04
Prole
Posts: 28
Joined: Sat Nov 10, 2012 9:02 pm

Re: STD - A 3d library

Post by wssmith04 » Sat Jan 12, 2013 12:55 pm

Good job!!!! It shows a lot of potential. :D
--Will

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests