Is it possible to draw custom triangle in 3D?
-
@xevdev Fun fact: you could probably simulate Gouraud shading if you drew gradient triangles over your polys ๐ค
What is the cost difference between triangle vs drawShape vs drawQuad with two points having the same coordinates?
Are outlines free?
Edit: I've answered my own question.
- triangle is twice as cheap as the other two methods, but it can't draw an outline unless you call the function twice with different settings, negating the advantage.
- drawShape is more costly than triangle but the outline is essentially free
- drawQuad takes a little less time to draw than drawShape. No outlines, but it's the only one offering texture mapping. Can also draw quads (obviously).
-
@Doriphor
Yes drawquad does textures at next to no cost and originally I had textures but eliminated as I was looking for speed . Not sure at the moment if it looses speed as i haven't implement textures. Also took out screen clipping for each polygon. Basically went for maximum speed to see how fast it could go. Only thing I kept was normals for lighting the polygons and even that doesn't work properly. To busy at the moment working in 40 degree heat building sheds to program anything. I'll be back ; { -
@Doriphor
As for the fastest sort I could program ( I'm not a programmer ) that I found on Wikipedia that worked was a comb sort line 1573 in wormhole.
I tried some others but recursion sorts bummed out at like 6 recursion?.
At 24 lines it was pretty !@#$ing good but if you or anyone can do a better one I'm all ears.
It worked on vectors again so it had to swap the vectors around.
It used the z axis for the sort
Used a pointer to the arrays position
And the x? Was the order all put into a list and churned out for the drawquad.
A sort would be good in fuze that that used an array of vectors like described. And that would be more helpful than sorting a list of numbers. -
@Doriphor
If you use drawquad as a triangle ie use the 4th coordinate as the 1st then it gives a better texture transform. Not ideal but there it is. -
Yes I knew about drawQuad being able to draw tris ๐ sadly it doesn't have perspective correction for textures ๐
For the sorting, I would also like to run some tests but Wikipedia is a pretty good source. I think you'd usually want to sort the z coordinate of the center of each tri.
Also yes you are a programmer. You wrote a pretty great and very complex piece of software, especially considering the tools we were given. I have worked with devs who couldn't get 1/10th of the way for a game like yours. Of course if you wanted to get into professional dev you'd probably have to learn some of the more boring stuff, but you definitely are a programmer. Never let people tell you otherwise!
And finally: recursion is eeeeviiilll. Don't use it. Ever. It's taught in courses and yes, it's more readable, but recursion breaks down quickly (and you're pretty much guaranteed to cause a stack overflow after a relatively small number of iterations, even with very simple calculations like the Fibonacci sequence) and even performance-wise, it doesn't hold up against loop-based algorithms. ๐
-
Itโs baffling that thereโs no draw triangle function for 3d. Baffling!
-
Recursion is basically a trick to make function based loops and use the function call stack as a substitute for making a memory based stack of your own. For example it makes looping over tree like structures quite easy in many cases, because to loop over a tree you need to keep the path to the current node from the root of the tree in memory (eg in a stack). However, Fuze has a rather small call limit atm, so lazily coding anything recursively will likely hit the limit before you have a handful of calls on the call stack.
-
@Gothon Avoiding recursion still usually results in better performance from my experience :)
-
@toxibunny
I dunno ?
I had a a fun time with one function and learned a lot.I remember as a 14 year old on my cpc464 experimenting with sine and cosine to try and get a 3d cube and being surprised it didn't display properly. No perspective. And I was good at tech drawing and wondering why.
So all I've done is derived from an equasion I got from a PlayStation 2 demo called yabasic. It plots a point in 3d space. And I've run from there. And learnt a lot about the limitations and will try to learn more.
I think once you know the limitations then your keen to learn a better way and thankfully we live now where we can find it on the internet.
Unlike that bloke who come up with quaternions before computers.
Pure genius and hopefully I can underkerstumble it one day too. -
@xevdev Wow :) So you wrote it all by youself! Anyway it looks amazing!