function outputs two values, but i dont know how to use booth
Posted: Thu Jul 04, 2024 4:48 pm
Hello, im writing a clipping algorythm for my 3D renderer and in one scenario its supposed to see if a triangle is clipping, turn it into two which arent and then return those, but i can only ever see one of them, despite each working seperatly
if i do this on line 58 of triangle.lua:
this is the result: if is switch them around:
This happens (you can see both images would fill each others missing triangles):
The code which receives the clipped triangles looks like this:
.love is attached, standard fps controlls (r resets the camera, press that if upon loading up the screen is blank), changing the mesh for testing purposes is possible by changing the string in LoadMesh() function
Just to make it clear im using post this as my last resort, ive checked my code against the tutorial and github and even ports to other languages of the engine.
https://github.com/OneLoneCoder/Javidx9 ... 3.cpp#L310
if i do this on line 58 of triangle.lua:
Code: Select all
return {3, triangle_out, triangle_out2 }
this is the result: if is switch them around:
Code: Select all
return {3, triangle_out2, triangle_out }
Code: Select all
clippedTris = {}
local result = Triangle.clipAgainstPlane({x = 0, y = 0, z = 0.01}, {x = 0, y = 0, z = 1}, triViewed)
if result[1] == 1 then table.insert(clippedTris, triViewed) end
if result[1] == 2 then table.insert(clippedTris, result[2]) end
if result[1] == 3 then clippedTris[#clippedTris+1] = result[2] clippedTris[#clippedTris+1] = result[3] end
Just to make it clear im using post this as my last resort, ive checked my code against the tutorial and github and even ports to other languages of the engine.
https://github.com/OneLoneCoder/Javidx9 ... 3.cpp#L310