예제 #1
0
        public void SetParameter(ModelRenderParameter p)
        {
            var param = p as PointLightRenderParameter;
            if (param == null)
            {
                return;
            }

            Shader.World = MathUtilXna.ToXnaMatrix(param.Transform);
            Shader.View = MathUtilXna.ToXnaMatrix(param.Camera.View);
            Shader.Projection = MathUtilXna.ToXnaMatrix(param.Camera.Projection);

            Shader.PointLightPosition = MathUtilXna.ToXnaVector(param.PointLight.Position);
            Shader.PointLightColor = MathUtilXna.ToXnaVector(param.PointLight.Color.ToVector3());
            Shader.PointLightAttenuationBegin = param.PointLight.AttenuationBegin;
            Shader.PointLightAttenuationEnd = param.PointLight.AttenuationEnd;

            Shader.NormalMap = (param.NormalMap as ITextureXna).Texture;
            Shader.DepthMap = (param.DepthMap as ITextureXna).Texture;

            Shader.IsCameraInLight = 
                (param.Camera.Eye - param.PointLight.Position).Length() 
                < (param.PointLight.AttenuationEnd + param.Camera.Near);

            Shader.LightID = param.LightID;
        }
예제 #2
0
        public void SetParameter(ModelRenderParameter p)
        {
            var param = p as SimpleModelRenderParameter;
            if (param == null)
            {
                return;
            }

            Shader.World = MathUtilXna.ToXnaMatrix(param.Transform);
            Shader.View = MathUtilXna.ToXnaMatrix(param.Camera.View);
            Shader.Projection = MathUtilXna.ToXnaMatrix(param.Camera.Projection);
            
            Shader.Alpha = param.Alpha;
            Shader.AmbientLightColor = MathUtilXna.ToXnaVector(param.AmbientLightColor);

            Shader.ShadowEnabled = param.IsShadowReceiver;
            if (Shader.ShadowEnabled)
            {
                Shader.LightViewProjection = MathUtilXna.ToXnaMatrix(param.LightCamera.View * param.LightCamera.Projection);
                Shader.ShadowMap = (param.ShadowMap as ITextureXna).Texture;
            }

            Shader.DiffuseLightMap = (param.DiffuseLightMap as ITextureXna).Texture;
            Shader.SpecularLightMap = (param.SpecularLightMap as ITextureXna).Texture;
        }
예제 #3
0
        public void Render(ModelRenderParameter param)
        {
            var renderer = ModelRendererFactoryMMDX.Instance.Create(param);
            renderer.Render(Model);

            foreach (var accessory in accessoryModels.Values)
            {
                renderer.Render(accessory);
            }
        }
예제 #4
0
        public IModelRendererMMDX Create(ModelRenderParameter param)
        {
            // 悔しいがダウンキャストを使う(もっといい手が見つかるまで・・・)

            switch (param.Type)
            {
                case ModelRendererType.Toon:
                    if (!RendererDic.ContainsKey(param.Type))
                    {
                        RendererDic[param.Type] = new ToonModelRendererMMDX();
                    }
                    var result = RendererDic[param.Type] as ToonModelRendererMMDX;
                    result.SetParameter(param as ToonModelRenderParameter);
                    return result;
                default:
                    break;
            }

            return new NullModelRendererMMDX();
        }
예제 #5
0
        public override void SetParameter(ModelRenderParameter p)
        {
            var param = p as DefaultModelRenderParameter;
            if (param == null)
            {
                return;
            }

            RenderParam = param;

            RenderParam.ParametersMatrix["View"] = RenderParam.Camera.View;
            RenderParam.ParametersMatrix["Projection"] = RenderParam.Camera.Projection;

            if (RenderParam.IsShadowReceiver)
            {
                RenderParam.ParametersMatrix["LightViewProjection"] = RenderParam.LightCamera.View * RenderParam.LightCamera.Projection;
                RenderParam.ParametersTexture["ShadowMap"] = (RenderParam.ShadowMap as ITextureXna).Texture;
            }

            RenderParam.ParametersTexture["DiffuseLightMap"] = (RenderParam.DiffuseLightMap as ITextureXna).Texture;
            RenderParam.ParametersTexture["SpecularLightMap"] = (RenderParam.SpecularLightMap as ITextureXna).Texture;
        }
예제 #6
0
        public override void SetParameter(ModelRenderParameter p)
        {
            var param = p as GBufferModelRenderParameter;
            if (param == null)
            {
                return;
            }

            Shader.World = MathUtilXna.ToXnaMatrix(param.Transform);
            Shader.View = MathUtilXna.ToXnaMatrix(param.Camera.View);
            Shader.Projection = MathUtilXna.ToXnaMatrix(param.Camera.Projection);

            InstancingType = param.InstancingType;

            if (param.InstancingType == InstancingType.Instanced)
            {
                //LoadProfiler.Instance.BeginMark("GBufferToArray");

                Shader.InstanceTransforms = FrameCacheData.Instance.InstanceTransformsToArray(param.InstanceTransforms);

                //LoadProfiler.Instance.EndMark();
            }
        }
예제 #7
0
        public void SetParameter(ModelRenderParameter p)
        {
            var param = p as SimpleInstancingRenderParameter;
            if (param == null)
            {
                return;
            }

            Shader.InstanceTransforms = FrameCacheData.Instance.InstanceTransformsToArray(param.InstanceTransforms);

            Shader.TransformsUpdated = param.TransformsUpdated;
            Shader.View = MathUtilXna.ToXnaMatrix(param.Camera.View);
            Shader.Projection = MathUtilXna.ToXnaMatrix(param.Camera.Projection);
            Shader.AmbientLightColor = MathUtilXna.ToXnaVector(param.AmbientLightColor);
            Shader.ShadowEnabled = param.IsShadowReceiver;
            if (Shader.ShadowEnabled)
            {
                Shader.LightViewProjection = MathUtilXna.ToXnaMatrix(param.LightCamera.View * param.LightCamera.Projection);
                Shader.ShadowMap = (param.ShadowMap as ITextureXna).Texture;
            }

            Shader.DiffuseLightMap = (param.DiffuseLightMap as ITextureXna).Texture;
            Shader.SpecularLightMap = (param.SpecularLightMap as ITextureXna).Texture;
        }
예제 #8
0
        public void Render(ModelRenderParameter param)
        {
            if (!Initialized)
            {
                return;
            }

            var renderer = ModelRendererFactoryXna.Instance.Create(param);

            var skinnedModelRenderer = renderer as SkinnedModelRendererXna;

            if (skinnedModelRenderer == null)
            {
                return;
            }

            RotationTexture.Flip();
            TranslationTexture.Flip();

            RotationTexture.Texture.SetData<Microsoft.Xna.Framework.Quaternion>(AnimationPlayer.GetSkinRotations());
            TranslationTexture.Texture.SetData<Microsoft.Xna.Framework.Vector4>(AnimationPlayer.GetSkinTraslations());

            TextureSize.X = RotationTexture.Texture.Width;
            TextureSize.Y = RotationTexture.Texture.Height;

            skinnedModelRenderer.BoneRotationTexture = RotationTexture.Texture;
            skinnedModelRenderer.BoneTranslationTexture = TranslationTexture.Texture;
            skinnedModelRenderer.BoneTextureSize = TextureSize;

            renderer.RenderDynamic(Model);
        }
예제 #9
0
 public void SetParameter(ModelRenderParameter param)
 {
 }
예제 #10
0
 public void Render(ModelRenderParameter param)
 {
     var renderer = ModelRendererFactoryXna.Instance.Create(param);
     renderer.RenderStatic(Model);
 }
예제 #11
0
 public abstract void SetParameter(ModelRenderParameter param);
예제 #12
0
        void AddDefaultRenderer()
        {
            var rendererName = debugMenu.RootNode.Label + ".Renderer";

            debugMenu.AddChild(rendererName, new DebugMenuNodeInternal()
            {
                Label = "Default"
            });

            debugMenu.AddChild(rendererName + ".Default", new DebugMenuNodeExecutable()
            {
                Label = "Apply",
                ExecFunc = () =>
                {
                    renderParam = defaultRenderParam;
                    RendererName = "Default";
                }
            });
        }
예제 #13
0
        void AddSimpleRenderer()
        {
            var rendererName = debugMenu.RootNode.Label + ".Renderer";

            debugMenu.AddChild(rendererName, new DebugMenuNodeInternal()
            {
                Label = "Simple"
            });

            debugMenu.AddChild(rendererName + ".Simple", new DebugMenuNodeExecutable()
            {
                Label = "Apply",
                ExecFunc = () =>
                {
                    renderParam = simpleRenderParam;
                    RendererName = "Simple";
                }
            });
        }
예제 #14
0
        void InitRenderer()
        {
            InitSimpleRenderer();
            InitToonRenderer();
            InitDefaultRenderer();

            renderParam = simpleRenderParam;
        }
예제 #15
0
파일: RenderManager.cs 프로젝트: himapo/ccm
 public void RenderModel(IModel primitive, ModelRenderParameter renderParam)
 {
     ModelInfoList[Buffer].Add(new ModelInfo() { Model = primitive, RenderParam = renderParam });
 }
예제 #16
0
파일: NullModel.cs 프로젝트: himapo/ccm
 public void Render(ModelRenderParameter renderer)
 {
 }