direct3d11 - I need some clarification with the concept of "Spaces" (world space, view space, projection spaces, local spaces and screen spaces) (c++, direct3d 11) -


so far, understand these spaces define aspect of games' 3d world. view space camera, , define creating matrix contains camera position, camera target , "up" direction of camera.

this done in code follows...

xmmatrix cameraview; xmvector cameraposition;                         xmvector cameratarget; xmvector cameraup;  /* describing matrix */ cameraposition = xmvectorset(0.0f, 0.0f, -0.5f, 0.0f);       cameratarget = xmvectorset(0.0f, 0.0f, 0.0f, 0.0f);          cameraup = xmvectorset(0.0f, 1.0f, 0.0f, 0.0f);  /*  creating matrix*/ cameraview = xmmatrixlookatlh(cameraposition, cameratarget, cameraup);   

i have hard time trying visualize in head. in simple terms.. "enabling" player move around @ creating cameraview? (assuming 3d world created)

can explain me happening here

first suggestion: new directxmath , direct3d, should take @ directx tool kit , simplemath wrapper in particular. save lot of distraction here.

when render object, there's single transformation in place. takes object whatever coordinate system defined in (called 'local' or 'model' coordinate spaces) , end result x,y pixel position , z depth.

for humans, however, it's easier think of transformation happening in stages--when in fact power of homogenous coordinates , concatenation through multiplication, it's 1 vector-matrix multiply in practice. thought of world -> view -> projection.

  1. the 'world' matrix places points defined in local coordinates 'world' coordinates. allows models in own local coordinates, , placed relative one-another in scene. world coordinate system canonically define light sources located. commonly created combination of xmmatrixtranslation, xmmatrixrototation*, , xmmatrixscaling functions multiplied (and there many other ways create transformation matrices in library including using quaternions rotations).
  2. the 'view' matrix moves points in world coordinate space view coordinate space, typically thought of how camera sees things. that's code snippet show computing. given camera position in world coordinates, , camera target position in world coordinates, , arbitrary 'up' vector, function computes 'view' matrix needs using 'left-handed' viewing coordinates (hence "lh").
  3. the 'projection' matrix moves points view system generic normalized box defines 'projection' including applying either perspective or orthogonal projection. directxmath, done xmmatrixperspectivefovlh, xmmatrixorthographiclh, related functions.

see 3d projection

re: handedness

the choice of 'left-handed' vs. 'right-handed' viewing systems purely matter of taste , how content defined. historically direct3d used left-handed coordinates, , opengl used right-handed coordinates. in modern programmable shaders, there's nothing built system cares. have consistent. xna game studio , simplemath use 'right-handed' systems. directxmath in 99% of cases uses either.

see right-hand rule


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -