Results 1 to 7 of 7

Thread: question about drawing 3D

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2010
    Posts
    231

    question about drawing 3D

    Hi all I am trying to draw my 3D enemy each time I call the enemy class at random position , but without success

    That is my drawing code:
    Code:
       if ((texture != null) && (texture.Meshes.Count > 0))
                {
                    Matrix[] transforms = new Matrix[texture.Bones.Count];
                    texture.CopyAbsoluteBoneTransformsTo(transforms);
                  
                    foreach (ModelMesh meshh in texture.Meshes)
                    {                   
                        foreach (BasicEffect effect in meshh.Effects)
                        {
                            effect.EnableDefaultLighting();
                            effect.World = transforms[meshh.ParentBone.Index] *
                                Matrix.CreateRotationY(modelRotation)
                                * Matrix.CreateTranslation(position);
                            effect.View = Matrix.CreateLookAt(new Vector3(0.0f, 50.0f, 5000.0f),
                              Vector3.Zero, Vector3.Up);
                            effect.Projection = Matrix.CreatePerspectiveFieldOfView(
                                MathHelper.ToRadians(45.0f), aspectRatio,
                                1.0f, 10000.0f);
                        }                  
                        meshh.Draw();
                    }            
                }
    At this line Matrix.CreateTranslation(position); position is Vector3 an the argument in it are always random:
    Code:
     Microsoft.Xna.Framework.Vector3 position = new Microsoft.Xna.Framework.Vector3(random.Next(0, GraphicsDevice.Viewport.Width), random.Next(0,300),1000.0f);
                  Enemy  eninit = new Enemy(secondModel, position, 100, 100, 0.5f);
    But when I call the class 3 times I get 3 models at same coordinates.
    This is the whole idea:

    But there is one difference now everything on the above picture is 3D !
    Last edited by mitko29; Feb 2nd, 2012 at 12:32 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width