Sunday, January 13, 2019

mathematics - Render 3d object to 2d surface (embedded system)


i am working on an embedded system of a sort, and in some free time i would like to test its drawing capabilities.


System in question is ARM Cortex M3 microcontroller attached to EasyMX Stellaris board. And i have a small 320x240 TFT screen :)


Now, i have some free time each day and i want to create rotating cube. Micro C PRO for ARM doesnt have 3d drawing capabilities, which means it must be done in software.


From the book Introduction to 3D Game Programming with DirectX 10 i know matrix algebra for transformations but that is cool when you have DirectX to set camera right.


I gues i could make 2d object to rotate, but how would i go with 3d one?


Any ideas and examples are welcome. Although i would prefer advices. I'd like to understand this.



Answer



You do realize that a directX camera is just a couple of matrix transformations? You have a ModelView, Projection, then Viewport matrix transformation to each vertex in that order to change the 3d coordinates to 2d coordinates.



More details about transformation along the standard pipeline (I believe DirectX and OpenGL both work the same way).


Then you rasterize the triangles based on the 2d locations(that resulted from your transformations) of the now 2d array of vertices you have. This can get complicated quick but using the PIT test and fully coloring any pixel that collides should be simple enough and effective in your case.


The other way to do this and the easier way is to make a ray tracer. Simply un-project the ray by using the transformation matrix you wish to apply on your object.


Haven't played around with low level sort of stuff in a while so I may be misremembering but either route shouldn't be too hard. Understand how the hardware pipeline works and implement it in software or write a ray tracer.


Btw this is where I learned what I know about the graphics pipeline.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...