Beispiel #1
0
        /// <summary>
        /// チュートリアルなどで用いられる方法で GameObject を描画します。
        /// </summary>
        void DrawGameObjectsWithoutOptimization()
        {
            blockEffect.View       = view;
            blockEffect.Projection = projection;

            mesh.LevelOfDetail = 0;

            for (int i = 0; i < gameObjects.Count; i++)
            {
                var world =
                    Matrix.CreateScale(gameObjects.Items[i].Scale) *
                    Matrix.CreateFromAxisAngle(gameObjects.Items[i].RotateAxis, gameObjects.Items[i].Rotation);
                world.Translation = gameObjects.Items[i].Position;

                blockEffect.World = world;

                mesh.Draw(blockEffect);
            }
        }
Beispiel #2
0
        void DrawBlockMesh()
        {
            if (mesh == null)
            {
                return;
            }

            // LOD が無効な場合は描画しません。
            if (mesh.LevelOfDetailCount <= LevelOfDetail)
            {
                return;
            }

            // 指定の BlockMeshLod がロード済みではないならば、
            // より荒いロード済みの LOD を探します。
            int targetLod = LevelOfDetail;

            while (targetLod < mesh.LevelOfDetailCount && !mesh.MeshLods[targetLod].IsLoaded)
            {
                targetLod++;
            }

            // 描画に使える BlockMeshLod がまだ無いならば描画しません。
            if (mesh.LevelOfDetailCount == targetLod || !mesh.MeshLods[targetLod].IsLoaded)
            {
                return;
            }

            mesh.LevelOfDetail = targetLod;

            var effect = workspace.BasicBlockEffect;

            effect.View       = CurrentView.Matrix;
            effect.Projection = Projection.Matrix;
            SetDirectionalLights(effect);

            mesh.Draw(effect);
        }