c# - Direct3D 11 WorldViewProjection Matrix Transformation Not Working -


i have simple square i'm drawing in 3d space using direct3d 11 , slimdx, following coordinates (i know renders)

0,0,0.5 0,0.5,0.5 0.5,0.5,0.5 0.5,0,0.5 

i have camera class handles camera movement applying matrix transformations viewmatrix. e.g. camera.moveforward(float x) moves camera forward x. holds view , projection matrices. instantiate them using following code:

matrix view = matrix.lookatlh(     new vector3(0f, 0f, -5f),     new vector3(0f, 0f, 0f),     new vector3(0f, 1f, 0f)); matrix projection = matrix.perspectivefovlh(     (float)math.pi/2,     windowwidth/windowheight,     0.1f,     110f); 

the world matrix set identity matrix.

in shader code transform coordinates using following code:

ps_in vs(vs_in input) {     ps_in output = (ps_in)0;      output.pos = mul( input.pos, worldviewprojection );     output.col = float4(1,1,1,1);      return output; } 

where worldviewprojection set in code using following:

matrix worldview = matrix.multiply(world, camera.viewmatrix);     matrix worldviewprojection = matrix.multiply(worldview, camera.projectionmatrix); 

i know camera class's transformations working it's old code wrote mdx application worked fine, when runs see square, , moving forwards , backwards works fine, moving left , right seems rotate square around y (up) axis instead of translating it, moving , down has similar effect, rotating instead x (horizontal) axis.

for reference, camera movement functions:

public void moveright(float distance) {     position.z += (float)(math.sin(-angle.y) * -distance);     position.x += (float)(math.cos(-angle.y) * -distance);     updateviewmatrix(); }  public void moveforward(float distance) {     position.x += (float)(math.sin(-angle.y) * -distance);     position.z += (float)(math.cos(-angle.y) * -distance);     updateviewmatrix(); }  public void moveup(float distance) {     position.y -= distance;     updateviewmatrix(); }  private void updateviewmatrix() {     viewmatrix = matrix.translation(position.x, position.y, position.z) * matrix.rotationy(angle.y) * matrix.rotationx(angle.x) * matrix.rotationz(angle.z); } 

the issue may lie in line:

output.pos = mul( input.pos, worldviewprojection ); 

i change output.pos float4 , do:

output.pos = mul( float4(input.pos, 1), worldviewprojection ); 

let me know how works out. if isn't problem, i'll take deeper @ may going on.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -