Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

AticAtac

Member Since 22 May 2000
Offline Last Active Mar 19 2013 09:05 AM
-----

Posts I've Made

In Topic: 3D free camera

26 January 2013 - 02:09 PM

to sum it up:

 

this is my quad in 3D-space

 

 

 

    0---3

    |      |

    |      |

   1----2

 

z=0

 

this is renderd on screen

 

 

    1---0

    |      |

    |      |

   2----3


In Topic: 3D free camera

26 January 2013 - 01:07 PM

I've still got one problem:

using the equations and rendering a quad with an image it seems that the rotation around z-axis is not right, because the image looks like to be rotated 90° to right (around z-axis).

So instead of rendering an image with arrow on it like this

 

^

|

|

|

 

its rendered like this:

 

 

------>

 

 

 

Here is my camera (view matrix) update code:

 

 

float cos_pitch = cosf(pitch);
    float sin_pitch = sinf(pitch);
    float cos_roll = cosf(roll);
    float sin_roll = sinf(roll);

    _forward.x = cos_pitch * sin_roll;
    _forward.y = -sin_pitch;
    _forward.z = cos_pitch * cos_roll;
    _forward.Normalise();

    _up.x = sin_pitch * sin_roll;
    _up.y = cos_pitch;
    _up.z = sin_pitch * cos_roll;
    _up.Normalise();

    _right = _up ^ _forward;    
    if (_right.IsZero())
        _right.x = 1.0f;
    else
        _right.Normalise();
    _up = _forward ^ _right;    

    _view_mat.m[0][0] =  _right.x; _view_mat.m[0][1] = _right.y; _view_mat.m[0][2] =  _right.z;
    _view_mat.m[1][0] =  _up.x; _view_mat.m[1][1] =  _up.y; _view_mat.m[1][2] =  _up.z;
    _view_mat.m[2][0] =  _forward.x; _view_mat.m[2][1] =  _forward.y; _view_mat.m[2][2] = _forward.z;
 

 

 

and here is my quad rendering code:

// x,y,z : top left, verts go counter-clockwise
void RenderQuad(float x, float y, float z, float w, float h)
{
    static CIwFVec3 verts[4];
    verts[0] = CIwFVec3(x, y, z);
    verts[1] = CIwFVec3(x, y-h, z);
    verts[2] = CIwFVec3(x+w, y-h, z);
    verts[3] = CIwFVec3(x+w, y, z);
    IwGxSetVertStreamWorldSpace(s_Verts, 4);

    // texture-atlas 512x512 , image on tex-atlas at (0,0) -> (63,63)
    static CIwFVec2 uvs[4];
    uvs[0] = CIwFVec2(0.0f, 0.0f);
    uvs[1] = CIwFVec2(0.0f, 63.0f/512.0f);
    uvs[2] = CIwFVec2(63.0f/512.0f, 63.0f/512.0f);
    uvs[3] = CIwFVec2(63.0f/512.0f, 0.0f);
    IwGxSetUVStream(uvs);

    static uint16 strips[4];
    strips[0] = 0;
    strips[1] = 1;
    strips[2] = 3;
    strips[3] = 2;
    IwGxDrawPrims(IW_GX_QUAD_STRIP, strips, 4);
}

In Topic: 3D free camera

23 January 2013 - 06:51 AM

Thx.

I picked the idea of using the 2 angles "pitch" and "roll" and reconstruct the vectors each time from these 2  and used the equations @C0lumbo gave me and it worked well.


In Topic: 2D isometric picking problem

03 December 2012 - 02:36 AM

These are my equations for the ISO-conversions (i use a hard-coded slope of 4:1 pixels (x:y)):
ISO_X,ISO_Z are the left-bottom offset of the iso space

void World2ISO(int wx, int wz, int wh, int& isox, int& isoy)
{
  isox = wx - wz + ISO_X;
  isoy = (-(wx + wz) / 4) - wh + ISO_Z;
}

void ISO2World(int isox, int isoy, int& wx, int& wz, int& wh)
{
  wh = 0;
  wx = (isox/2) - (2*isoy);
  wz = -(isox/2) - (2*isoy);
}


Maybe that helps you a bit

In Topic: First person 2D Dungeon Crawler

26 November 2012 - 07:38 AM

You might also look at the doom-engine (sources are available). It doesn't have the limitation of "90° walls" and there are tons of rersources for it, e.g. editors which you could use to create your own worlds. And there are different ports of "doom" with using OpenGL.

PARTNERS