protected override void Initialize() { textureParam = Parameters["Texture"]; samplerParam = Parameters["TextureSampler"]; diffuseColorParam = Parameters["DiffuseColor"]; emissiveColorParam = Parameters["EmissiveColor"]; specularColorParam = Parameters["SpecularColor"]; specularPowerParam = Parameters["SpecularPower"]; eyePositionParam = Parameters["EyePosition"]; fogColorParam = Parameters["FogColor"]; fogVectorParam = Parameters["FogVector"]; worldParam = Parameters["World"]; worldInverseTransposeParam = Parameters["WorldInverseTranspose"]; worldViewProjParam = Parameters["WorldViewProj"]; light0 = new DirectionalLight(Parameters["DirLight0Direction"], Parameters["DirLight0DiffuseColor"], Parameters["DirLight0SpecularColor"], null); light1 = new DirectionalLight(Parameters["DirLight1Direction"], Parameters["DirLight1DiffuseColor"], Parameters["DirLight1SpecularColor"], null); light2 = new DirectionalLight(Parameters["DirLight2Direction"], Parameters["DirLight2DiffuseColor"], Parameters["DirLight2SpecularColor"], null); samplerParam.SetResource(GraphicsDevice.SamplerStates.Default); }
/// <summary> /// Initializes a new instance of the <see cref="PrimitiveQuad" /> class. /// </summary> /// <param name="graphicsDevice">The graphics device.</param> public PrimitiveQuad(GraphicsDevice graphicsDevice) { GraphicsDevice = graphicsDevice; quadEffect = ToDispose(new Effect(GraphicsDevice, effectBytecode)); quadPass = quadEffect.CurrentTechnique.Passes[0]; matrixParameter = quadEffect.Parameters["MatrixTransform"]; textureCopyPass = quadEffect.CurrentTechnique.Passes[1]; textureParameter = quadEffect.Parameters["Texture"]; textureSamplerParameter = quadEffect.Parameters["TextureSampler"]; // Default LinearClamp textureSamplerParameter.SetResource(GraphicsDevice.SamplerStates.LinearClamp); Transform = Matrix.Identity; sharedData = GraphicsDevice.GetOrCreateSharedData(SharedDataType.PerDevice, "Toolkit::PrimitiveQuad::VertexBuffer", () => new SharedData(GraphicsDevice)); }
/// <summary> /// Initializes a new instance of the <see cref="PrimitiveQuad" /> class. /// </summary> /// <param name="graphicsDevice">The graphics device.</param> public PrimitiveQuad(GraphicsDevice graphicsDevice) { GraphicsDevice = graphicsDevice; quadEffect = ToDispose(new Effect(GraphicsDevice, effectBytecode)); quadPass = quadEffect.CurrentTechnique.Passes[0]; matrixParameter = quadEffect.Parameters["MatrixTransform"]; textureCopyPass = quadEffect.CurrentTechnique.Passes[1]; textureParameter = quadEffect.Parameters["Texture"]; colorParameter = quadEffect.Parameters["Color"]; textureSamplerParameter = quadEffect.Parameters["TextureSampler"]; // Default LinearClamp textureSamplerParameter.SetResource(GraphicsDevice.SamplerStates.LinearClamp); Transform = Matrix.Identity; Color = new Color4(1.0f); sharedData = GraphicsDevice.GetOrCreateSharedData(SharedDataType.PerDevice, "Toolkit::PrimitiveQuad::VertexBuffer", () => new SharedData(GraphicsDevice)); }
public MeshCamera(Room room, float zoom, Vector2R?pos) : base(room, zoom, pos) { pendingVertices = new List <SpriteVertex>(); //permVertices = new List<SpriteVertex>(); //Perms = new HashSet<SpriteVertex>(); pendingVertexQueue = new BlockingCollection <List <SpriteVertex> >(3); device = OrbIt.Game.GraphicsDevice; Mesh = Buffer.Vertex.New <SpriteVertex>(OrbIt.Game.GraphicsDevice, 16 * 1024); layout = VertexInputLayout.FromBuffer(0, Mesh); effect = OrbIt.Game.Content.Load <Effect>("Effects/MixedShaders2"); texture = OrbIt.Game.Content.Load <Texture2D>("Textures/spritesheet"); mvpParam = effect.Parameters["mvp"]; spriteCountParam = effect.Parameters["SpriteCount"]; textureParam = effect.Parameters["ModelTexture"]; textureSamplerParameter = effect.Parameters["_sampler"]; effectPass = effect.Techniques["Render"].Passes[0]; textureParam.SetResource(texture); textureSamplerParameter.SetResource(device.SamplerStates.LinearClamp); spriteCountParam.SetValue((float)Enum.GetValues(typeof(Textures)).Length); }