Tuesday, February 14, 2012

More Triangles

Double the amount of triangles, in fact. (and also rotating, I would have made a .gif if I wasn't so lazy..)

Tutorial 03 in the DX11 SDK is the same code as 02, but it explained how the shaders work.

I read Tutorial 04 and took the important parts into my own little test application.
Tutorial 04 adds spaces, the object, world and view spaces, to be specific(not counting Projection and Screen Spaces). And this enables us to actually move things around, without really changing any vertex data, but by transforming the spaces. I would really recommend reading Tutorial 04, it's quite well written and I believe the concepts handled are very central.

Be warned that this is where people who have not learned Linear algebra would otherwise have to give up, and if you don't, don't be afraid if you don't understand the transformations part.These transformations are handled by the XNAmath functions in this tutorial anyway, so just ignore that part if it's too hard. The important thing is to learn thinking in three dimensions..

It also makes some use of these included spaces by rotating a colored cube.

I didn't like the cube and made a rotating triforce instead, because rendered triangles only have one side, I made it double sided, hence double the amount of triangles.

Here are the vertices if you want to try ;)

SimpleVertex vertices[] =
{
{XMFLOAT3( 0.0f, 0.5f, 0.0f ),XMFLOAT4( 1.0f, 1.0f, 0.0f, 0.8f )},
{XMFLOAT3( 0.25f, 0.0f, 0.0f ),XMFLOAT4( 1.0f, 1.0f, 0.0f, 0.8f )},
 {XMFLOAT3( -0.25f,0.0f, 0.0f ),XMFLOAT4( 1.0f, 1.0f, 0.0f, 0.8f )},

{XMFLOAT3( 0.25f, 0.0f, 0.0f ),XMFLOAT4( 1.0f, 1.0f, 0.0f, 0.8f )},
 {XMFLOAT3( 0.5f, -0.5f, 0.0f ),XMFLOAT4( 1.0f, 1.0f, 0.0f, 0.8f )},
 {XMFLOAT3( 0.0f, -0.5f, 0.0f ),XMFLOAT4( 1.0f, 1.0f, 0.0f, 0.8f )},

{XMFLOAT3( -0.25f, 0.0f, 0.0f ),XMFLOAT4( 1.0f, 1.0f, 0.0f, 0.8f )},
 {XMFLOAT3( 0.0f, -0.5f, 0.0f ),XMFLOAT4( 1.0f, 1.0f, 0.0f, 0.8f )},
 {XMFLOAT3( -0.5f, -0.5f, 0.0f ),XMFLOAT4( 1.0f, 1.0f, 0.0f, 0.8f )},

{XMFLOAT3( 0.0f, 0.5f, 0.0f ),XMFLOAT4( 1.0f, 1.0f, 0.0f, 0.8f )},
{XMFLOAT3( -0.25f,0.0f, 0.0f ),XMFLOAT4( 1.0f, 1.0f, 0.0f, 0.8f )},
{XMFLOAT3( 0.25f, 0.0f, 0.0f ),XMFLOAT4( 1.0f, 1.0f, 0.0f, 0.8f )},
        
{XMFLOAT3( 0.25f, 0.0f, 0.0f ),XMFLOAT4( 1.0f, 1.0f, 0.0f, 0.8f )},
 {XMFLOAT3( 0.0f, -0.5f, 0.0f ),XMFLOAT4( 1.0f, 1.0f, 0.0f, 0.8f )},
{XMFLOAT3( 0.5f, -0.5f, 0.0f ),XMFLOAT4( 1.0f, 1.0f, 0.0f, 0.8f )},
        
{XMFLOAT3( -0.25f, 0.0f, 0.0f ),XMFLOAT4( 1.0f, 1.0f, 0.0f, 0.8f )},
 {XMFLOAT3( -0.5f, -0.5f, 0.0f ),XMFLOAT4( 1.0f, 1.0f, 0.0f, 0.8f )},
{XMFLOAT3( 0.0f, -0.5f, 0.0f ),XMFLOAT4( 1.0f, 1.0f, 0.0f, 0.8f )},
};


To use it, you also need to make sure not to use the index buffer defined in the tutorial.

No comments:

Post a Comment