예제 #1
0
        protected override void DrawGeometry(Microsoft.Xna.Framework.Matrix view, Microsoft.Xna.Framework.Matrix projection, object[] optionalParameters, RendererBase.EffectConfigurer effectConfigurer, RendererBase.RendererParameters instance)
        {
            mEffect.World = instance.World;
            mEffect.View = view;
            mEffect.Projection = projection;

            mEffect.Parameters["xOverlayColor"].SetValue(instance.OverlayColor.ToVector3());
            mEffect.Parameters["xOverlayColorWeight"].SetValue(instance.OverlayWeight);
            mEffect.Parameters["xTextureOffset"].SetValue(instance.TextureAnimationOffset);

            mEffect.Parameters["xIsBeingSpaghettified"].SetValue(false);

            mEffect.Texture = mMesh.AlphaMap;

            effectConfigurer(mEffect, instance, optionalParameters);

            VertexBuffer vertexBuffer = mMesh.VertexBuffer;
            IndexBuffer indexBuffer = mMesh.IndexBuffer;

            GraphicsManager.Device.SetVertexBuffer(vertexBuffer);
            GraphicsManager.Device.Indices = indexBuffer;

            mEffect.CurrentTechnique.Passes[0].Apply();

            GraphicsManager.Device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertexBuffer.VertexCount, 0, indexBuffer.IndexCount / 3 - 2);

            GraphicsManager.Device.SetVertexBuffer(null);
            GraphicsManager.Device.Indices = null;
        }
예제 #2
0
        protected override void ShadowMapConfigurer(AnimationUtilities.SkinnedEffect effect, RendererBase.RendererParameters instance, object[] optionalParameters)
        {
            Matrix lightView = (optionalParameters[0] as Matrix?).Value;
            Matrix lightProjection = (optionalParameters[1] as Matrix?).Value;

            effect.CurrentTechnique = effect.Techniques["ShadowCast"];

            effect.Parameters["xLightView"].SetValue(lightView);
            effect.Parameters["xLightProjection"].SetValue(lightProjection);
        }
예제 #3
0
        protected override void PickingConfigurer(AnimationUtilities.SkinnedEffect effect, RendererBase.RendererParameters instance, object[] optionalParameters)
        {
            effect.CurrentTechnique = effect.Techniques["PickingShade"];

            Vector4 indexColor = new Vector4((float)(instance.ObjectID << 8 >> 24) / 255, (float)(instance.ObjectID << 16 >> 24) / 255, (float)(instance.ObjectID << 24 >> 24) / 255, 1f);
            effect.Parameters["xPickingIndex"].SetValue(indexColor);
        }
예제 #4
0
 protected override void NoShadeConfigurer(AnimationUtilities.SkinnedEffect effect, RendererBase.RendererParameters instance, object[] optionalParameters)
 {
     effect.CurrentTechnique = effect.Techniques["NoShade"];
 }
예제 #5
0
 protected override void UIConfigurer(AnimationUtilities.SkinnedEffect effect, RendererBase.RendererParameters instance, object[] optionalParameters)
 {
     NoShadeConfigurer(effect, instance, optionalParameters);
 }
예제 #6
0
        protected override void ShadowMapConfigurer(AnimationUtilities.SkinnedEffect effect, RendererBase.RendererParameters instance, object[] optionalParameters)
        {
            base.ShadowMapConfigurer(effect, instance, optionalParameters);

            Matrix[] skinTransforms = new Matrix[] { Matrix.Identity };
            if (instance is AnimateModelParameters)
            {
                skinTransforms = ((instance as AnimateModelParameters).SkinTransforms);
            }
            effect.SetBoneTransforms(skinTransforms);

            effect.CurrentTechnique = effect.Techniques["SkinnedShadowCast"];
        }
예제 #7
0
        private static void UpdateSceneExtents(RendererBase.RendererParameters instance)
        {
            if (!(instance is TerrainRenderer.TerrainParameters))
            {
                mMinSceneExtent = Vector3.Min(mMinSceneExtent, instance.BoundingBox.Min);
                mMaxSceneExtent = Vector3.Max(mMaxSceneExtent, instance.BoundingBox.Max);

                return;
            }

            foreach (BoundingBox boundingBox in (instance as TerrainRenderer.TerrainParameters).BoundingBoxes)
            {
                mMinSceneExtent = Vector3.Min(mMinSceneExtent, boundingBox.Min);
                mMaxSceneExtent = Vector3.Max(mMaxSceneExtent, boundingBox.Max);
            }
        }
예제 #8
0
        public static void EnqueueRenderable(RendererBase.RendererParameters instance, Type rendererType)
        {
            if (!mCanRender)
            {
                throw new Exception("Unable to render " + instance.Name + " before calling BeginRendering() or after FinishRendering().\n");
            }

            RendererBase renderer = AssetLibrary.LookupRenderer(instance.Name, rendererType);
            if (!mRenderQueue.Contains(renderer))
            {
                mRenderQueue.Enqueue(renderer);
            }

            renderer.AddInstance(instance);

            UpdateSceneExtents(instance);
        }