コード例 #1
0
        public void DrawRoom(Matrix view, Matrix projection, Vector3 position, Vector3 characterOffset, bool isCrouched, bool showBoundingBox, bool DrawHat)
        {
            device.BlendState      = BlendState.Opaque;
            device.RasterizerState = RasterizerState.CullCounterClockwise;

            roomEffect.CurrentTechnique = roomEffect.Techniques["Colored"];

            int effectCount = 0;

            foreach (ModelMesh mesh in room.Meshes)
            {
                if (mesh.Name != "hat" || DrawHat)
                {
                    foreach (Effect currentEffect in mesh.Effects)
                    {
                        Matrix worldMatrix = bones[mesh.ParentBone.Index] * roomWorldMatrix;
                        currentEffect.Parameters["xWorldViewProjection"].SetValue(worldMatrix * view * projection);
                        currentEffect.Parameters["xWorld"].SetValue(worldMatrix);
                        currentEffect.Parameters["xLightPos"].SetValue(lightPos);
                        currentEffect.Parameters["xLightPower"].SetValue(lightPower);
                        currentEffect.Parameters["xAmbient"].SetValue(ambientPower);
                        currentEffect.Parameters["DiffuseColor"].SetValue(OriginalDiffuseColors[effectCount++]);
                    }
                    mesh.Draw();
                }
                else
                {
                    effectCount++;
                }
            }


            if (showBoundingBox)
            {
                bBoxManager.DrawBoundingBoxes(view, projection, position, characterOffset, isCrouched);
            }
        }