Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

In my first image, my model displays correctly:

enter image description here

But when I move the model's position along the Z-axis (forward) I get this, yet the Y-axis doesnt change. An if I keep going, the model disappears into the ground:

enter image description here

Any suggestions as to how I can get the model to translate properly visually? Here is how Im calling the model and the terrain in draw():

cameraPosition = new Vector3(camX, camY, camZ);

        // Copy any parent transforms.
        Matrix[] transforms = new Matrix[mShockwave.Bones.Count];
        mShockwave.CopyAbsoluteBoneTransformsTo(transforms);
        Matrix[] ttransforms = new Matrix[terrain.Bones.Count];
        terrain.CopyAbsoluteBoneTransformsTo(ttransforms);

        // Draw the model. A model can have multiple meshes, so loop.
        foreach (ModelMesh mesh in mShockwave.Meshes)
        {
            // This is where the mesh orientation is set, as well 
            // as our camera and projection.
            foreach (BasicEffect effect in mesh.Effects)
            {
                effect.EnableDefaultLighting();
                effect.PreferPerPixelLighting = true;
                effect.World = transforms[mesh.ParentBone.Index] *
                    Matrix.CreateRotationY(modelRotation)
                    * Matrix.CreateTranslation(modelPosition);
                // Looking at the model (picture shouldnt change other than rotation)
                effect.View = Matrix.CreateLookAt(cameraPosition, 
                    modelPosition, Vector3.Up);
                effect.Projection = Matrix.CreatePerspectiveFieldOfView(
                    MathHelper.ToRadians(45.0f), aspectRatio,
                    1.0f, 10000.0f);
                effect.TextureEnabled = true;
            }

            // Draw the mesh, using the effects set above.
            prepare3d();
            mesh.Draw();
        }

        //Terrain test
        foreach (ModelMesh meshT in terrain.Meshes)
        {

            foreach (BasicEffect effect in meshT.Effects)
            {
                effect.EnableDefaultLighting();
                effect.PreferPerPixelLighting = true;
                effect.World = ttransforms[meshT.ParentBone.Index] *
                    Matrix.CreateRotationY(0)
                    * Matrix.CreateTranslation(terrainPosition);
                // Looking at the model (picture shouldnt change other than rotation)
                effect.View = Matrix.CreateLookAt(cameraPosition,
                    terrainPosition, Vector3.Up);
                effect.Projection = Matrix.CreatePerspectiveFieldOfView(
                    MathHelper.ToRadians(45.0f), aspectRatio,
                    1.0f, 10000.0f);
                effect.TextureEnabled = true;
            }

            // Draw the mesh, using the effects set above.
            prepare3d();
            meshT.Draw();
            DrawText();
        }
        base.Draw(gameTime);
    }

I'm suspecting that there may be something wrong with how I'm handling my camera. The model rotates fine on its Y-axis.

share|improve this question

closed as too localized by Jonathan Hobbs, Tetrad Oct 16 '12 at 16:29

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Why should Y axis of model's position change if you move your model along Z axis? –  snake5 Sep 6 '12 at 5:22
    
snake5 I think that's the entire point of the question. Visually it looks like the Y-Axis is changing, but he isn't changing it :). –  Roy T. Sep 6 '12 at 6:06
    
Oh, I've got it now. Both Z and Y are changing, even though only Z is supposed to change, right? OP has some confusing wording there. In that case, I'd suggest stepping through the code with a debugger and look at the values. I'm also afraid there's too little information for us to find answers. –  snake5 Sep 6 '12 at 6:39
    
Forgive the "stupid human trick" questions, but... Are you sure the Z axis is forward? How are you getting the values for the text? –  Fibericon Sep 10 '12 at 7:25

1 Answer 1

up vote 0 down vote accepted

I had an bug in my camera. I was translating in Vector3.Up and Vector3.Right at the same time within my input class. Both were set to one thumbstick. Removing Vector3.Right from the thumbstick for movement in the cardinal directions resolved the problem.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.