Page 5 of 6

Re: L3D - The Starts of a 3D Lib

Posted: Wed Oct 24, 2012 5:07 am
by waratte
Yeah, is this project still on? I'm interested.

Re: L3D - The Starts of a 3D Lib

Posted: Sat Oct 27, 2012 3:02 pm
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.

Re: L3D - The Starts of a 3D Lib

Posted: Mon Oct 29, 2012 11:56 pm
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...)

Re: L3D - The Starts of a 3D Lib

Posted: Tue Oct 30, 2012 5:06 am
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)

Re: L3D - The Starts of a 3D Lib

Posted: Tue Oct 30, 2012 7:18 am
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)

Re: L3D - The Starts of a 3D Lib

Posted: Tue Oct 30, 2012 7:08 pm
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.

Re: L3D - The Starts of a 3D Lib

Posted: Tue Oct 30, 2012 7:11 pm
by rokit boy
i love how my laptop is pure shit and the cubes from heaven keeps at 90fps, that is amazing

Re: L3D - The Starts of a 3D Lib

Posted: Wed Oct 31, 2012 10:38 am
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.

Re: L3D - The Starts of a 3D Lib

Posted: Wed Oct 31, 2012 11:46 am
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.

Re: L3D - The Starts of a 3D Lib

Posted: Sat Nov 03, 2012 2:39 am
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.