public void Draw(CameraAbstract camera) { var baseWorld = scale * rotation * Matrix.CreateTranslation(position); foreach (var mesh in mirrorModel.Meshes) { var localWorld = modelTransforms[mesh.ParentBone.Index] * baseWorld; foreach (var part in mesh.MeshParts) { var effect = part.Effect; effect.Parameters["World"].SetValue(localWorld); effect.Parameters["View"].SetValue(camera.ViewMatrix); effect.Parameters["Projection"].SetValue(camera.ProjectionMatrix); //Material.SetEffectParameters(effect); } mesh.Draw(); } }
private void SetEffectParameters(CameraAbstract camera, Matrix localWorld) { effect.Parameters["FogEnabled"]?.SetValue(Material.FogEnabled); effect.Parameters["FogStart"]?.SetValue(Material.FogStart); effect.Parameters["FogEnd"]?.SetValue(Material.FogEnd); effect.Parameters["FogIntensity"]?.SetValue(Material.FogIntensity); effect.Parameters["LightDirection"]?.SetValue(((LightingMaterial)Material).LightDirection); effect.Parameters["LightPosition"]?.SetValue(((LightingMaterial)Material).LightPosition); effect.Parameters["LightColor"]?.SetValue(((LightingMaterial)Material).LightColor); effect.Parameters["SpecularColor"]?.SetValue(((LightingMaterial)Material).SpecularColor); effect.Parameters["LightAttenuation"]?.SetValue( ((LightingMaterial)Material).LightAttenuation); effect.Parameters["LightFalloff"]?.SetValue(((LightingMaterial)Material).LightFalloff); effect.Parameters["LightTypes"]?.SetValue(((LightingMaterial)Material).LightTypes.Select(x => (float)x).ToArray()); effect.Parameters["AmbientColor"].SetValue(Color.Black.ToVector3()); if (LiquidTexture != null) { effect.CurrentTechnique = effect.Techniques["TexturedLiquid"]; effect.Parameters["BackgroundColor"].SetValue(Color.Gray.ToVector4()); effect.Parameters["ForegroundColor"].SetValue(Color.IndianRed.ToVector4()); effect.Parameters["BasicTexture"].SetValue(LiquidTexture); } else { effect.Parameters["BasicTexture"].SetValue(texture); } effect.Parameters["View"].SetValue(camera.ViewMatrix); effect.Parameters["TextureEnabled"].SetValue(true); effect.Parameters["Projection"].SetValue(camera.ProjectionMatrix); effect.Parameters["World"].SetValue(localWorld); }
public override void Draw(CameraAbstract camera) { Matrix worldMatrix; if (camera is TargetCamera) { worldMatrix = scale * rotation * Matrix.CreateTranslation(position) * (camera).WorldMatrix; } else { worldMatrix = scale * rotation * Matrix.CreateTranslation(position) * ((Camera.Camera)camera).WorldMatrix; } SetEffectParameters(camera, worldMatrix); foreach (var pass in effect.CurrentTechnique.Passes) { pass.Apply(); graphicsDevice.DrawUserPrimitives( PrimitiveType.TriangleList, platformVertex, 0, platformVertex.Length / 3); } }
public abstract void Draw(CameraAbstract camera);