public void Draw(Camera camera, MainLogic mainLogic, Vector3 modelPosition, Matrix modelRotation, GameTime gameTime) { float scale = (float)Math.Pow(10, GameSettings.m_size); CheckRenderChanges(scale); UpdateViewProjection(camera); AnimatedModelShader.EffectPasses pass = AnimatedModelShader.EffectPasses.Unskinned; _graphics.BlendState = BlendState.Opaque; _graphics.DepthStencilState = DepthStencilState.Default; float meshsize = 0.5f; object loadedModel = mainLogic.modelLoader.LoadedObject; AnimatedModel usedModel = loadedModel != null ? (AnimatedModel)loadedModel : null; if (usedModel != null) { meshsize = 1 / usedModel.Model.Meshes[0].BoundingSphere.Radius; } { object loadedMaterial = mainLogic.albedoLoader.LoadedObject; Texture2D loadedAlbedo = loadedMaterial != null ? (Texture2D)loadedMaterial : null; _animatedModelShader.AlbedoMap = loadedAlbedo; } { object loadedMaterial = mainLogic.normalLoader.LoadedObject; Texture2D loadedNormal = loadedMaterial != null ? (Texture2D)loadedMaterial : null; _animatedModelShader.NormalMap = loadedNormal; if (loadedNormal != null) { pass = AnimatedModelShader.EffectPasses.UnskinnedNormalMapped; } } { object loadedMaterial = mainLogic.roughnessLoader.LoadedObject; Texture2D loadedAlbedo = loadedMaterial != null ? (Texture2D)loadedMaterial : null; _animatedModelShader.RoughnessMap = loadedAlbedo; } { object loadedMaterial = mainLogic.metallicLoader.LoadedObject; Texture2D loadedAlbedo = loadedMaterial != null ? (Texture2D)loadedMaterial : null; _animatedModelShader.MetallicMap = loadedAlbedo; } { object loadedMaterial = mainLogic.bumpLoader.LoadedObject; Texture2D loadedAlbedo = loadedMaterial != null ? (Texture2D)loadedMaterial : null; _animatedModelShader.HeightMap = loadedAlbedo; if (loadedAlbedo != null && GameSettings.r_UsePOM) { pass = AnimatedModelShader.EffectPasses.UnskinnedNormalMapped; } } Matrix size = Matrix.CreateScale(scale * meshsize); Matrix meshscale = Matrix.CreateScale(meshsize); Matrix world = /*meshscale * */ (GameSettings.m_orientationy ? YupOrientation : Matrix.Identity) * modelRotation * Matrix.CreateTranslation(/*-usedModel.Meshes[0].BoundingSphere.Center*/ -modelPosition / (scale * meshsize)) * size; _animatedModelShader.AlbedoColor = GameSettings.bgColor; _animatedModelShader.Roughness = GameSettings.m_roughness; _animatedModelShader.Metallic = GameSettings.m_metallic; _animatedModelShader.UseLinear = GameSettings.r_UseLinear; if (loadedModel != null) { if (GameSettings.ao_Enable) { //Draw to depth buffer first! _graphics.SetRenderTarget(_linearDepthTarget); _graphics.Clear(Color.White); _graphics.RasterizerState = RasterizerState.CullCounterClockwise; _graphics.BlendState = BlendState.Opaque; usedModel.Draw(world, _view, _viewProjection, camera.Position, _animatedModelShader, AnimatedModelShader.EffectPasses.UnskinnedDepth, true); //Draw to the AO Map _graphics.SetRenderTarget(_ambientOcclusionTarget); _graphics.Clear(Color.White); //We draw the depth again onto our ao target, but without color and use only the pixels affected if (GameSettings.ao_UseStencil) { _graphics.BlendState = _blendNoColorWrite; _graphics.DepthStencilState = _stencilWriteOnly; usedModel.Draw(world, _view, _viewProjection, camera.Position, _animatedModelShader, AnimatedModelShader.EffectPasses.UnskinnedDepth, true); _graphics.DepthStencilState = _stencilReadOnly; } else { _graphics.DepthStencilState = DepthStencilState.None; } _graphics.BlendState = BlendState.Opaque; _ambientOcclusionShader.DrawAmbientOcclusion(); if (GameSettings.ao_UseBlur) { _ambientOcclusionShader.BlurAmbientOcclusion(_ambientOcclusionTarget, _ambientOcclusionBlur0, _ambientOcclusionBlur1); } } _graphics.SetRenderTarget(null); _graphics.DepthStencilState = DepthStencilState.Default;//_stencilWriteOnly; usedModel.Draw(world, _view, _viewProjection, camera.Position, _animatedModelShader, pass, !GameSettings.ao_Enable); if (usedModel.HasAnimation()) { if (usedModel.Clips.Count > 0 && GameSettings.m_updateAnimation) { usedModel.Update(gameTime); } if (GameSettings.m_startClip) { usedModel.PlayClip(usedModel.Clips[0], true); GameSettings.m_startClip = false; } } } else { if (GameSettings.ao_Enable) { _graphics.SetRenderTarget(GameSettings.ao_UseBlur ? _ambientOcclusionBlur1 : _ambientOcclusionTarget); _graphics.Clear(Color.White); } _graphics.SetRenderTarget(null); _graphics.BlendState = BlendState.Opaque; _graphics.Clear(Color.White); _animatedModelShader.DrawMesh(model, world, _view, _viewProjection, camera.Position, pass); } _graphics.BlendState = BlendState.Opaque; _graphics.RasterizerState = RasterizerState.CullClockwise; _graphics.DepthStencilState = DepthStencilState.Default; _skyboxRenderModule.Draw(Matrix.CreateTranslation(camera.Position) * _viewProjection, Vector3.Zero, 300); if (GameSettings.r_DrawDepthMap) { _spriteBatch.Begin(); _spriteBatch.Draw(_linearDepthTarget, new Rectangle(0, 0, GameSettings.g_ScreenWidth, GameSettings.g_ScreenHeight), Color.White); _spriteBatch.End(); } if (GameSettings.r_DrawAoMap) { _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, SamplerState.PointClamp); _spriteBatch.Draw(GameSettings.ao_UseBlur ? _ambientOcclusionBlur0 : _ambientOcclusionTarget, new Rectangle(0, 0, GameSettings.g_ScreenWidth, GameSettings.g_ScreenHeight), Color.White); _spriteBatch.End(); } DrawInteractivityAnimation(gameTime); }
public override void Draw(GameTime gameTime) { model.Draw(gameTime, Owner, Offset); }
public override void Draw(GameTime gameTime) { playerModel.Draw(gameTime); base.Draw(gameTime); }
/// <summary> /// Draw Method for AnimatedModels /// </summary> /// <param name="gameTime">important for the drawing because it depends on it</param> public virtual void Draw(GameTime gameTime) { AniModel.Draw(GameConstants.MainCam.X_View, GameConstants.MainCam.X_Projection); }