2

XNAでプログラミングを始めました。ブレンダーからエクスポートされた「fbx」メッシュモデルを簡単にロードするプロジェクトを開発しました。すべてが完璧に機能します。しかし今、私は自分のモデルを何度か複製/コピーして床を作りたいと思っています! 10 X 10 モデルのマトリックス。いくつかのコードを試しましたが動作しません。これが私のサンプルコードです。

モデルを複製できない理由がわかりません。

どうもありがとうございました。

//Function draw models mesh
    private void draw_groundLand1()
    {
        //Draw 10 times model texture to make small ground
        for (int a = 0; a < 10; a++)
        {     
            // Copy any parent transforms.
            Matrix[] transforms = new Matrix[model_ground_land1.Bones.Count];
            model_ground_land1.CopyAbsoluteBoneTransformsTo(transforms);

            // Draw the model. A model can have multiple meshes, so loop.
            foreach (ModelMesh mesh in model_ground_land1.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.World = transforms[mesh.ParentBone.Index] *
                Matrix.CreateRotationY(cubeGroundLand1_modelRotation) * Matrix.CreateTranslation(cubeGroundLand1_position);
                    effect.View = View;
                    //effect.Texture = text_ground_lan1;
                    effect.Projection = Projection;
                }
                // Draw the mesh, using the effects set above.
                mesh.Draw();
            }

            //Move position for the next mesh modal to draw
            cubeGroundLand1_position.X += (float)1.0;
        }
    }
4

1 に答える 1

1

私は自分の解決策を見つけました -> このコード ligne "cubeGroundLand1_position.X += (float)1.0;" を移動するだけです。

お気に入り:

private void draw_groundLand1()
    {

        for (int a = 0; a < 10; a++)
        {
            // Copy any parent transforms.
            Matrix[] transforms = new Matrix[model_ground_land1.Bones.Count];
            model_ground_land1.CopyAbsoluteBoneTransformsTo(transforms);

            // Draw the model. A model can have multiple meshes, so loop.
            foreach (ModelMesh mesh in model_ground_land1.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.World = transforms[mesh.ParentBone.Index] *
                Matrix.CreateRotationY(cubeGroundLand1_modelRotation) * Matrix.CreateTranslation(cubeGroundLand1_position);
                    effect.View = View;
                    //effect.Texture = text_ground_lan1;
                    effect.Projection = Projection;

                    cubeGroundLand1_position.X = (float)a+1;
                }
                // Draw the mesh, using the effects set above.
                mesh.Draw();
            }
        }
于 2012-11-25T13:45:33.017 に答える