/// <summary> /// Draw /// </summary> /// <param name="gt"></param> /// <param name="obj"></param> /// <param name="render">The render.</param> /// <param name="cam">The cam.</param> /// <param name="lights"></param> protected override void Draw(GameTime gt, IObject obj, RenderHelper render, ICamera cam, IList <Light.ILight> lights) { Pid.SetValue(shaderId); PuseGlow.SetValue(useGlow); PuseBump.SetValue(useBump); PuseSpecular.SetValue(useSpecular); PView.SetValue(cam.View); PProjection.SetValue(cam.Projection); PCameraPos.SetValue(cam.Position); PreflectionIndex.SetValue(reflectionIndex); Matrix wld = obj.WorldMatrix; for (int i = 0; i < obj.Modelo.MeshNumber; i++) { BatchInformation[] bi = obj.Modelo.GetBatchInformation(i); for (int j = 0; j < bi.Count(); j++) { //PDiffuse.SetValue(obj.Modelo.getTexture(TextureType.DIFFUSE,i,j)); //PTexture.SetValue(obj.Modelo.GetTextureInformation(i)[j].getCubeTexture(TextureType.ENVIRONMENT)); render.device.Textures[0] = obj.Modelo.GetTextureInformation(i)[j].getTexture(TextureType.DIFFUSE); render.device.Textures[4] = obj.Modelo.GetTextureInformation(i)[j].getCubeTexture(TextureType.ENVIRONMENT); if (useBump) { //PNormalMap.SetValue(obj.Modelo.getTexture(TextureType.BUMP, i, j)); render.device.Textures[1] = obj.Modelo.GetTextureInformation(i)[j].getTexture(TextureType.BUMP); } if (useSpecular) { //PSpecularMap.SetValue(obj.Modelo.getTexture(TextureType.SPECULAR, i, j)); render.device.Textures[2] = obj.Modelo.GetTextureInformation(i)[j].getTexture(TextureType.SPECULAR); PspecularIntensityScale.SetValue(SpecularIntensityMapScale); PspecularPowerScale.SetValue(SpecularPowerMapScale); } else { PspecularIntensity.SetValue(specularIntensity); PspecularPower.SetValue(specularPower); } if (useGlow) { //Pglow.SetValue(obj.Modelo.getTexture(TextureType.GLOW, i, j)); render.device.Textures[3] = obj.Modelo.GetTextureInformation(i)[j].getTexture(TextureType.GLOW); } Matrix w1 = Matrix.Multiply(bi[j].ModelLocalTransformation, wld); PWorld.SetValue(w1); PWorldInverseTranspose.SetValue(Matrix.Transpose(Matrix.Invert(w1))); render.RenderBatch(bi[j], _shader); } } }
/// <summary> /// Draw /// </summary> /// <param name="gt"></param> /// <param name="obj"></param> /// <param name="render">The render.</param> /// <param name="cam">The cam.</param> /// <param name="lights"></param> protected override void Draw(GameTime gt, IObject obj, RenderHelper render, ICamera cam, IList <Light.ILight> lights) { Pid.SetValue(shaderId); PuseParalax.SetValue(useParalax); PuseGlow.SetValue(useGlow); PuseBump.SetValue(useBump); PuseSpecular.SetValue(useSpecular); PView.SetValue(cam.View); PProjection.SetValue(cam.Projection); if (useParalax) { this._shader.Parameters["CameraPos"].SetValue(cam.Position); } Matrix wld = obj.WorldMatrix; for (int i = 0; i < obj.Modelo.MeshNumber; i++) { BatchInformation[] bi = obj.Modelo.GetBatchInformation(i); for (int j = 0; j < bi.Count(); j++) { Matrix w1 = Matrix.Multiply(bi[j].ModelLocalTransformation, wld); PWorld.SetValue(w1); render.device.Textures[0] = obj.Modelo.getTexture(TextureType.DIFFUSE, i, j); //PTexture.SetValue(obj.Modelo.getTexture(TextureType.DIFFUSE, i, j)); if (useBump) { if (useParalax) { //this._shader.Parameters["HeightMap"].SetValue(obj.Modelo.getTexture(TextureType.PARALAX,i,j)); render.device.Textures[5] = obj.Modelo.getTexture(TextureType.PARALAX, i, j); this._shader.Parameters["scaleBias"].SetValue(scaleBias); } PWorldInverseTranspose.SetValue(Matrix.Transpose(Matrix.Invert(w1))); //PNormalMap.SetValue(obj.Modelo.getTexture(TextureType.BUMP, i, j)); render.device.Textures[1] = obj.Modelo.getTexture(TextureType.BUMP, i, j); } if (useSpecular) { //PSpecularMap.SetValue(obj.Modelo.getTexture(TextureType.SPECULAR, i, j)); render.device.Textures[2] = obj.Modelo.getTexture(TextureType.SPECULAR, i, j); PspecularIntensityScale.SetValue(SpecularIntensityMapScale); PspecularPowerScale.SetValue(SpecularPowerMapScale); } else { PspecularIntensity.SetValue(specularIntensity); PspecularPower.SetValue(specularPower); } if (useGlow) { //Pglow.SetValue(obj.Modelo.getTexture(TextureType.GLOW, i, j)); render.device.Textures[3] = obj.Modelo.getTexture(TextureType.GLOW, i, j); } if (useAmbientCubeMap) { //PAmbientCube.SetValue(obj.Modelo.GetCubeTexture(TextureType.AMBIENT_CUBE_MAP, i, j)); render.device.Textures[4] = obj.Modelo.GetCubeTexture(TextureType.AMBIENT_CUBE_MAP, i, j); PAmbientCubeMapScale.SetValue(AmbientCubeMapScale); } render.RenderBatch(bi[j], _shader); } } }