Hello everyone,
i´ve been trying to replicate/copy this 3D Engine by javid9x on Youtube, but ive been stuck on the part approx 35 Minutes in.The code on the github doesnt seem way more different to what im trying (except for not yet having rotation matrices). The Issue is that despite having copied exactly what he´s done, i cant get my cube from 0, 0, 0 and thus perspective.
Any Help appriciated
Issues when translating c to lua [Solved]
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- NoreoAlles
- Party member
- Posts: 130
- Joined: Mon Jan 03, 2022 5:42 pm
Issues when translating c to lua [Solved]
- Attachments
-
- 3D.love
- (2.38 KiB) Downloaded 119 times
Last edited by NoreoAlles on Sat Jun 29, 2024 6:12 pm, edited 1 time in total.
"Why do they call it oven when you of in the cold food of out hot eat the food?" - Jon Arbuckle
Re: Issues when translating c to lua
One line in your MultiplyMatrixVector function is wrong:
Change from this
to this
I actually ignored this originally because it seemed fine but the results on screen can only be explained by not dividing by w (or w being 1), so added some logging and lo it's not entering that conditional.
Edit: Actually there was one other change I made but I completely forgot I did it. You are translating the actual triangles every frame, I also changed translatedTri to be manually constructed rather than copying tris.
instead of
Change from this
Code: Select all
if not w == 0 then
Code: Select all
if w ~= 0 then
Edit: Actually there was one other change I made but I completely forgot I did it. You are translating the actual triangles every frame, I also changed translatedTri to be manually constructed rather than copying tris.
Code: Select all
triTranslated.vectors[1] = Vector.new(tris.vectors[1].x, tris.vectors[1].y, tris.vectors[1].z)
triTranslated.vectors[2] = Vector.new(tris.vectors[2].x, tris.vectors[2].y, tris.vectors[2].z)
triTranslated.vectors[3] = Vector.new(tris.vectors[3].x, tris.vectors[3].y, tris.vectors[3].z)
Code: Select all
triTranslated = tris
- NoreoAlles
- Party member
- Posts: 130
- Joined: Mon Jan 03, 2022 5:42 pm
Re: Issues when translating c to lua
Thank you so much, i already had an issue with that line of code, it was
, but i changed it to if not and thought that should of worked
Code: Select all
if ... then else do thing end
"Why do they call it oven when you of in the cold food of out hot eat the food?" - Jon Arbuckle
Re: Issues when translating c to lua
Just double checking you saw the edit too, both changes are required to get the correct resultNoreoAlles wrote: ↑Sat Jun 29, 2024 5:56 pm Thank you so much, i already had an issue with that line of code, it was, but i changed it to if not and thought that should of workedCode: Select all
if ... then else do thing end
- NoreoAlles
- Party member
- Posts: 130
- Joined: Mon Jan 03, 2022 5:42 pm
Re: Issues when translating c to lua
Yes, thank you works all fine now, hope you havent seen my post where i replaced my code with yours but still messed up. Thanks again, im gonna turn this engine into a *so retro* star trek inspired space exploration game later down the line, which, judging by your profile pic might interest you.marclurr wrote: ↑Sat Jun 29, 2024 6:00 pmJust double checking you saw the edit too, both changes are required to get the correct resultNoreoAlles wrote: ↑Sat Jun 29, 2024 5:56 pm Thank you so much, i already had an issue with that line of code, it was, but i changed it to if not and thought that should of workedCode: Select all
if ... then else do thing end
"Why do they call it oven when you of in the cold food of out hot eat the food?" - Jon Arbuckle
Who is online
Users browsing this forum: Bing [Bot], MisterImpossible and 3 guests