AntonioND / nitro-engine

3D engine for the Nintendo DS
150 stars 10 forks source link

3d: add way of drawing simple polys outside of range supported by v16 #20

Closed WiIIiam278 closed 1 year ago

WiIIiam278 commented 1 year ago

Thanks for your superb work on this lib!!

It'd be nice if nitro-engine provided a way of drawing polygons outside -6 < x < 6 | -6 < z < 6, which isn't currently possible without dipping into libnds and manually calling one of the glTranslate methods (as this is the approximate max range supported by the 4.12 fixed point number)

My use case is drawing a super-simple shadow below a character, so would rather not have to bother making and loading a super simple model when I can just draw it directly.

Perhaps an alternate/better solution for my use case (as I note you say to avoid drawing polys where possible) would be some methods for the 3d engine to draw simple planes/shapes?

note: I could have missed something in the docs!! very sorry for wasting your time if so (am quite new to this)!

AntonioND commented 1 year ago

I think that the problem here is that the way you're doing things isn't very DS-friendly.

In general, I'd say it's a bad idea to try to go over the +/-7.9 limit. I think you should generally design your models so that they are drawn around a +/-1.0 box, and you set the scale of the model to the actual size. The actual limit is imposed by the format of the vertices of glVertex() function, as you have said, not the actual hardware.

The problem with trying to split polygons into multiple polygons is that it isn't trivial from a mathematical point of view, and the lack of accuracy of the GPU of the DS will cause visible lines between polygons depending on how you rotate them.

Is this workaround good enough for you?

WiIIiam278 commented 1 year ago

hey, sorry for the slow reply!!

thanks for your input -- I think I perhaps confused you/myself slightly with this one!

I'm drawing a simple 3d shape below my model I'm already moving around to look like a shadow for that model (see pic). to save on RAM loading a whole separate model from FAT, I decided to use your inbuilt functions to draw polys manually. basically my issue was that I couldn't draw my shape outside the 7.9 limit box -- which makes sense given your intended use case there I think :). indeed, not very DS friendly and a bit hacky, but my workaround does the trick!

image

thanks so much for your work!

AntonioND commented 1 year ago

I'm happy you found a workaround!