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; }
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; }
public void Render(ModelRenderParameter param) { var renderer = ModelRendererFactoryMMDX.Instance.Create(param); renderer.Render(Model); foreach (var accessory in accessoryModels.Values) { renderer.Render(accessory); } }
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(); }
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; }
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(); } }
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; }
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); }
public void SetParameter(ModelRenderParameter param) { }
public void Render(ModelRenderParameter param) { var renderer = ModelRendererFactoryXna.Instance.Create(param); renderer.RenderStatic(Model); }
public abstract void SetParameter(ModelRenderParameter param);
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"; } }); }
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"; } }); }
void InitRenderer() { InitSimpleRenderer(); InitToonRenderer(); InitDefaultRenderer(); renderParam = simpleRenderParam; }
public void RenderModel(IModel primitive, ModelRenderParameter renderParam) { ModelInfoList[Buffer].Add(new ModelInfo() { Model = primitive, RenderParam = renderParam }); }
public void Render(ModelRenderParameter renderer) { }