L3D - The Starts of a 3D Lib

Showcase your libraries, tools and other projects that help your fellow love users.
waratte
Prole
Posts: 1
Joined: Tue Oct 16, 2012 2:40 am

Re: L3D - The Starts of a 3D Lib

Post by waratte »

Yeah, is this project still on? I'm interested.
10$man
Citizen
Posts: 77
Joined: Sun Apr 22, 2012 10:40 pm

Re: L3D - The Starts of a 3D Lib

Post by 10$man »

waratte wrote:Yeah, is this project still on? I'm interested.
Yes yes yes...
I'm just growing bored of trying to load .obj files.
I'l get to it though.
10$man
Citizen
Posts: 77
Joined: Sun Apr 22, 2012 10:40 pm

Re: L3D - The Starts of a 3D Lib

Post by 10$man »

Alright, so I reversed the order of which the points were fed to the drawPolygon function and nothing changed (Figures :P ).
So, I'm wondering, how can I sort a table by a specific place. For instance, in this case, I want to sort the Indices by there vertices Z coordinate. As far as I'm aware, table.sort won't be capable of handling this.
Is there an easier way then iterating through the table until I find the correct order? (I'm sure this would be pretty slow too...)
User avatar
substitute541
Party member
Posts: 484
Joined: Fri Aug 24, 2012 9:04 am
Location: Southern Leyte, Visayas, Philippines
Contact:

Re: L3D - The Starts of a 3D Lib

Post by substitute541 »

10$man wrote:Alright, so I reversed the order of which the points were fed to the drawPolygon function and nothing changed (Figures :P ).
So, I'm wondering, how can I sort a table by a specific place. For instance, in this case, I want to sort the Indices by there vertices Z coordinate. As far as I'm aware, table.sort won't be capable of handling this.
Is there an easier way then iterating through the table until I find the correct order? (I'm sure this would be pretty slow too...)
table.sort(vertTable, function(A,B) return A.z > B.z end)
Currently designing themes for WordPress.

Sometimes lurks around the forum.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: L3D - The Starts of a 3D Lib

Post by Roland_Yonaba »

10$man wrote:Is there an easier way then iterating through the table until I find the correct order? (I'm sure this would be pretty slow too...)
You'll have to use table.sort, providing a comparison function.
substitute541 wrote:table.sort(vertTable, function(A,B) return A.z > B.z end)
Substitute is totally right, here. I'll just point out that this way, items in the table will be sorted in decreasing z-index.
If you want them to be sorted in increasing z-index order, change the comparison function.
substitute541 wrote:table.sort(vertTable, function(A,B) return A.z < B.z end)
10$man
Citizen
Posts: 77
Joined: Sun Apr 22, 2012 10:40 pm

Re: L3D - The Starts of a 3D Lib

Post by 10$man »

Wow... I don't know what I never thought of using table.sort like that :death:
Thanks :)
I'l try this out and see what happens.
User avatar
rokit boy
Party member
Posts: 198
Joined: Wed Jan 18, 2012 7:40 pm

Re: L3D - The Starts of a 3D Lib

Post by rokit boy »

i love how my laptop is pure shit and the cubes from heaven keeps at 90fps, that is amazing
u wot m8
10$man
Citizen
Posts: 77
Joined: Sun Apr 22, 2012 10:40 pm

Re: L3D - The Starts of a 3D Lib

Post by 10$man »

rokit boy wrote:i love how my laptop is pure shit and the cubes from heaven keeps at 90fps, that is amazing
Awesome :)
Glad to hear that! I guess I'm doing something right.
On my computer it goes about 40 fps, and this is a desktop...
I think mainly the problem is my video card is terrible.


Also, as far as table.sort goes, It's not working particularly well, but I am gonna keep trying.
User avatar
substitute541
Party member
Posts: 484
Joined: Fri Aug 24, 2012 9:04 am
Location: Southern Leyte, Visayas, Philippines
Contact:

Re: L3D - The Starts of a 3D Lib

Post by substitute541 »

10$man wrote:
rokit boy wrote:i love how my laptop is pure shit and the cubes from heaven keeps at 90fps, that is amazing
Awesome :)
Glad to hear that! I guess I'm doing something right.
On my computer it goes about 40 fps, and this is a desktop...
I think mainly the problem is my video card is terrible.


Also, as far as table.sort goes, It's not working particularly well, but I am gonna keep trying.
... Not to be an advertiser but, please try to read my Love3D Library, specifically the z-sorting functions. There are lots of ways to do it.
Currently designing themes for WordPress.

Sometimes lurks around the forum.
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: L3D - The Starts of a 3D Lib

Post by Ref »

Surprised that you order your triangles using the 'left-hand' rule.
Though most implimentations use the 'right_hand' rule???
To get the lighting to work correctly, I had to use 'left-hand' point order - see attached.
Attachments
test7_m.love
Just added another object to Present3D.lua
(4.16 KiB) Downloaded 207 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest