Draw 3D model at coordinates in C# xna? -


i'm drawing several primitives camera class supplies view, world , projection. these can move camera , see 3 of primitives. problem wan't add 3d model in project, ways know of draw 3d model won't work camera class. have tried using:

matrix[] transforms = new matrix[mymodel.bones.count];         mymodel.copyabsolutebonetransformsto(transforms);          foreach (modelmesh mesh in mymodel.meshes)         {             foreach (basiceffect effect in mesh.effects)             {                  effect.enabledefaultlighting();                 effect.world = transforms[mesh.parentbone.index] *                     matrix.createrotationy(0.0f)                     * matrix.createtranslation(modelposistion);                 effect.view = matrix.createlookat(cameraposistion, vector3.zero, vector3.up);                 effect.projection = matrix.createperspectivefieldofview(mathhelper.piover4, aspectratio, 1.0f, 10000.0f);             }             mesh.draw();         } 

but draws model in center of screen, while want stationary, can view other models in same project.

any how can achieved?

if understand problem: "as move camera, model follows".

most likely, isn't following, moving camera without changing camera "looking at". view matrix calls @ (camera pointed at) vector3.zero no matter position camera altered to. means if model position not change, , view matrix looking @ same world location, model not appear change position. may bigger or smaller or might see different angles, in same spot on screen. it's because telling camera @ same position in world.

changing camera position isn't enough freely around world, must change camera looking @ ( 2nd param of view matrix).

also, best think of camera having view , projection matrices. world matrix should thought of part of (or supplied by) model.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -