3d graphic matrix in spin
fish
Posts: 55
Hi everyone,
I did a forum search on the subject of 3D matrices without luck.
I know that multi-dimensional arrays are not allowed in Spin,
so has anybody worked around this constraint to implement a rotation matrix (or translation matrix etc)?
thanks
-fish
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
". . . the fog is rising"~ Emily Dickinson
I did a forum search on the subject of 3D matrices without luck.
I know that multi-dimensional arrays are not allowed in Spin,
so has anybody worked around this constraint to implement a rotation matrix (or translation matrix etc)?
thanks
-fish
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
". . . the fog is rising"~ Emily Dickinson
Comments
One possible way: Combine all three indices into one index. Lowest 4 bits are X, next 4 bits are Y, next 4 bits are Z. To address an array element, do the following:
array[noparse][[/noparse]Z << 8 | Y << 4 | X] := some value
If you don't need 16 in each direction, you can change the number of bits. Each dimension would have to be a power of 2. Not all of the dimensions need to be the same size either.
Would your transform matrix be 3 x 3 x 3? If that is the case, you only need two bits per direction.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The more I know, the more I know I don't know.· Is this what they call Wisdom?
array[noparse][[/noparse] index(X,Y,Z) ] := var
var := array[noparse][[/noparse] index(X,Y,Z) ]
This would be a good application for a macro.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The more I know, the more I know I don't know.· Is this what they call Wisdom?
holodeck.virand.com
There is a 3D memory mapping Math page on the site.
Thanks for the input guys, and I will try what you have suggested.
I thought for sure someone had already done this.
I guess most folks who do Prop 3d graphics output composite vid and use Graphics object's methods for 3D math (or something like that, I can't recall exactly the objects used) or maybe they do the calculations without the matrices?
Anyway, my display is an OLED, so it looks like I will need to roll my own 3D engine of sorts.
I will give it a go.
thanks again.
-fish
P.S. If anyone has implemented a simple (not coupled to·an output device)·3d engine for the prop, I would be interested in your tricks/traps. thx!
Virand: very interesting, and doubles as a cocktail shaker [noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
". . . the fog is rising"~ Emily Dickinson
Post Edited (fish) : 1/16/2008 11:18:10 PM GMT
I'm trying to make a raycaster and another person made a retro 3D monster maze game.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Michael Park
PS, BTW, and FYI:
To search the forum, use search.parallax.com (do not use the Search button).
Check out the Propeller Wiki: propeller.wikispaces.com/