public void RenderWater(BaseCamera camera, ref Matrix4 projectionMatrix, float nearClipPlane, float farClipPlane , DirectionalLight sun = null, List <PointLight> lights = null) { PostConstructor(); /*Water distortion cycle*/ m_shader.startProgram(); m_fbo.ReflectionTexture.BindTexture(TextureUnit.Texture0); m_fbo.RefractionTexture.BindTexture(TextureUnit.Texture1); m_waterDistortionMap.BindTexture(TextureUnit.Texture2); m_waterNormalMap.BindTexture(TextureUnit.Texture3); m_fbo.DepthTexture.BindTexture(TextureUnit.Texture4); m_shader.setTransformationMatrices(ref m_modelMatrix, camera.GetViewMatrix(), ref projectionMatrix); m_shader.setReflectionSampler(0); m_shader.setRefractionSampler(1); m_shader.setDuDvSampler(2); m_shader.setNormalMapSampler(3); m_shader.setDepthSampler(4); m_shader.setCameraPosition(camera.GetEyeVector()); m_shader.setDistortionProperties(m_moveFactor, m_waveStrength); m_shader.setDirectionalLight(sun); m_shader.setPointLight(lights); m_shader.setClippingPlanes(ref nearClipPlane, ref farClipPlane); m_shader.setMist(m_mist); m_shader.setTransparancyDepth(TransparencyDepth); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); m_buffer.RenderVAO(PrimitiveType.Triangles); GL.Disable(EnableCap.Blend); m_shader.stopProgram(); }
public void Draw(BaseCamera camera) { foreach (var block in items) { block?.Draw(camera); } }
public void renderEntities(DirectionalLight sun, BaseCamera camera, Matrix4 projectionMatrix, Landscape terrain = null, Vector4 clipPlane = new Vector4()) { postConstructor(terrain); _shader.startProgram(); _texture[0].BindTexture(TextureUnit.Texture0); if (_texture.Count > 1) { _texture[1].BindTexture(TextureUnit.Texture1); if (_texture.Count == 3) { _texture[2].BindTexture(TextureUnit.Texture2); } } _shader.setTextureSampler(0); _shader.setMaterial(_grassMaterial); _shader.setViewMatrix(camera.GetViewMatrix()); _shader.setProjectionMatrix(ref projectionMatrix); _shader.setSun(sun); _shader.setWind(_wind); _shader.setTime(timeElapsed); _shader.setClipPlane(ref clipPlane); _shader.setMist(_mist); VAOManager.renderInstanced(_buffer, PrimitiveType.Triangles, _plants.Count); _shader.stopProgram(); }
public void RenderWaterReflection(WaterPlane water, BaseCamera camera, ref Matrix4 ProjectionMatrix, Vector4 clipPlane, bool bApplyLensFlareScale = false) { if (m_postConstructor) { return; } Matrix4 modelMatrix = Matrix4.Identity; if (bApplyLensFlareScale) { modelMatrix *= Matrix4.CreateScale(LENS_FLARE_SIZE_TO_SUN_SIZE, -LENS_FLARE_SIZE_TO_SUN_SIZE, LENS_FLARE_SIZE_TO_SUN_SIZE); } float translationPositionY = (2 * water.GetTranslation().Y) - m_lightSource.Position.Y; modelMatrix *= Matrix4.CreateTranslation(m_lightSource.Position.X, translationPositionY, m_lightSource.Position.Z); GL.Enable(EnableCap.ClipDistance0); m_shader.startProgram(); m_texture1.BindTexture(TextureUnit.Texture0); m_texture2.BindTexture(TextureUnit.Texture1); m_shader.setUniformValues(ref modelMatrix, camera.GetViewMatrix(), ref ProjectionMatrix, m_lightSource, 0, 1); m_shader.SetClipPlane(ref clipPlane); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); m_buffer.RenderVAO(PrimitiveType.Triangles); GL.Disable(EnableCap.Blend); m_shader.stopProgram(); GL.Disable(EnableCap.ClipDistance0); }
/// <summary> /// Draw a bounding frustrum representation /// </summary> /// <param name="frustum">Frustrum</param> /// <param name="camera">Camera</param> /// <param name="color">Color</param> public static void Draw(BoundingFrustum frustum, BaseCamera camera, Color color) { if (effect == null) { effect = new BasicEffect(YnG.GraphicsDevice); effect.VertexColorEnabled = true; effect.LightingEnabled = false; } Vector3[] corners = frustum.GetCorners(); for (int i = 0; i < 8; i++) { vertices[i].Position = corners[i]; vertices[i].Color = color; } effect.View = camera.View; effect.Projection = camera.Projection; foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); YnG.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineList, vertices, 0, 8, indices, 0, indices.Length / 2); } }
public override void Update(BaseCamera camera, ref Matrix world) { if (!_effectLoaded) { return; } // Update matrices base.Update(camera, ref world); EnvironmentMapEffect environmentMapEffect = (EnvironmentMapEffect)_effect; // Texture environmentMapEffect.Texture = _texture; environmentMapEffect.EnvironmentMap = _environmentTexture; environmentMapEffect.EnvironmentMapAmount = _environmentAmount; environmentMapEffect.EnvironmentMapSpecular = _specularColor * _specularIntensity; environmentMapEffect.FresnelFactor = _fresnelFactor; // Fog UpdateFog(environmentMapEffect); // Lights if (UpdateLights(environmentMapEffect)) { environmentMapEffect.EmissiveColor = _emissiveColor; environmentMapEffect.DiffuseColor = _diffuseColor * _diffuseIntensity; environmentMapEffect.Alpha = _alphaColor; } }
public void RenderWaterReflection(WaterPlane water, BaseCamera camera, Vector3 sunDirection, Matrix4 projectionMatrix, Vector4 clipPlane) { if (m_bPostConstructor) { return; } GL.Enable(EnableCap.ClipDistance0); Matrix4 mirrorMatrix; mirrorMatrix = GetMirrorMatrix(water); m_shader.startProgram(); m_skyboxDayTexture.BindTexture(TextureUnit.Texture0); m_skyboxNightTexture.BindTexture(TextureUnit.Texture1); m_shader.SetTransformationMatrices(ref projectionMatrix, camera.GetViewMatrix(), ref mirrorMatrix); m_shader.SetDayCubeTexture(0); m_shader.SetNightCubeTexture(1); m_shader.SetDayCycleValue(sunDirection.Normalized().Y); m_shader.SetMist(m_mist); m_shader.SetClipPlane(ref clipPlane); m_buffer.RenderVAO(PrimitiveType.Triangles); m_shader.stopProgram(); GL.Disable(EnableCap.ClipDistance0); }
// Use this for initialization void Start() { // Get character m_Character = GetComponent <Character>(); // Current camera if (m_TPSCamera != null) { m_CurrentCamera = m_TPSCamera; if (m_FPSCamera != null) { m_FPSCamera.GetComponent <Camera>().enabled = false; Camera.SetupCurrent(m_CurrentCamera.CameraComponent); } } Input_Dictionary = new Dictionary <string, List <string> >(); List <string> PC_List = new List <string>() { "Throttle", "Rudder", "Pitch", "Roll" }; Input_Dictionary.Add(input_tag, PC_List); }
private void ResetCamera(BaseCamera camera) { camera.BeginInit(); var targetPositionCamera = camera as TargetPositionCamera; if (targetPositionCamera != null) { targetPositionCamera.Heading = 30; targetPositionCamera.Attitude = -20; targetPositionCamera.Bank = 0; targetPositionCamera.Distance = 200; targetPositionCamera.TargetPosition = new Point3D(0, 0, 0); } else { var freeCamera = camera as FreeCamera; if (freeCamera != null) { freeCamera.CameraPosition = new Point3D(100, 150, -300); freeCamera.TargetPosition = new Point3D(0, 0, 0); } } camera.Offset = new Vector3D(0, 0, 0); camera.EndInit(); }
/// Switch current camera with another camera private void SwitchCamera() { // Check camera null if (m_TPSCamera != null && m_FPSCamera != null) { // Switch camera if (m_CurrentCamera == m_TPSCamera) { m_CurrentCamera = m_FPSCamera; m_FPSCamera.CameraComponent.enabled = true; m_TPSCamera.CameraComponent.enabled = false; } else { m_CurrentCamera = m_TPSCamera; m_FPSCamera.CameraComponent.enabled = false; m_TPSCamera.CameraComponent.enabled = true; } // Set new current camera Camera.SetupCurrent(m_CurrentCamera.CameraComponent); // Set current camera to character if (m_Character != null) { m_Character.BaseCamera = m_CurrentCamera; } } }
public void TryCameraCollision(BaseCamera camera) { ThirdPersonCamera thirdPersonCamera = camera as ThirdPersonCamera; if (thirdPersonCamera == null) { return; } // Start moving from camera target to it's seek position float distanceFromTargetToCamera = thirdPersonCamera.MaxDistanceFromTargetToCamera; Vector3 cameraForwardVector = thirdPersonCamera.GetEyeSpaceForwardVector(); Vector3 startPosition = thirdPersonCamera.GetTargetVector(); float safeInterval = thirdPersonCamera.CameraCollisionSphereRadius; for (float interval = safeInterval; interval <= distanceFromTargetToCamera; interval += (thirdPersonCamera.CameraCollisionSphereRadius / 10.0f)) { var intermediatePosition = startPosition - cameraForwardVector * interval; FSphere cameraCollisionSphere = new FSphere(intermediatePosition, thirdPersonCamera.CameraCollisionSphereRadius); var boundingBoxes = GetBoundingBoxesForCameraCollisionTest(ref cameraCollisionSphere, thirdPersonCamera.GetThirdPersonTarget().GetRootComponent()); if (boundingBoxes.Count > 0) { //if (IsCameraCollisionWithBoundingBoxes(ref cameraCollisionSphere, boundingBoxes)) //{ // break; //} } safeInterval = interval; } thirdPersonCamera.SetDistanceFromTargetToCamera(safeInterval); }
private void OnMouseMove(object sender, MouseEventArgs e) { if (GameWorld.GetWorldInstance().GetLevel() != null) { BaseCamera camera = GameWorld.GetWorldInstance().GetLevel().Camera; if (camera == null) { return; } if (camera.SwitchCamera) { camera.Rotate(e.X, e.Y, new Point(Width, GLControl.Height)); Cursor.Hide(); if ((EngineStatics.PrevCursorPosition.X != -1) && (EngineStatics.PrevCursorPosition.Y != -1)) // need to calculate delta of mouse position { Int32 xDelta = e.X - EngineStatics.PrevCursorPosition.X; Int32 yDelta = e.Y - EngineStatics.PrevCursorPosition.Y; } EngineStatics.PrevCursorPosition = e.Location; } else { Cursor.Show(); Cursor.Draw(this.CreateGraphics(), new Rectangle(this.Location.X, this.Location.Y, this.Size.Width, this.Size.Height)); } GLControl.Update(); // need to update frame after invalidation to redraw changes } }
protected override void Initialize() { base.Initialize(); floor = new Floor(GraphicsDevice); floor.Initialize(Content, "Textures/checkerboard", new Vector2(20)); tank_light = new Tank(); tank_light.Initialize(Content.Load <Model>("Models/Tank_Light")); tank_light.Move(Matrix.CreateTranslation(new Vector3(10, 0, 0)), Matrix.Identity); tank_medium = new Tank(); tank_medium.Initialize(Content.Load <Model>("Models/Tank_Medium")); tank_medium.Move(Matrix.CreateTranslation(new Vector3(0, 0, 0)), Matrix.Identity); tank_dual = new Tank(); tank_dual.Initialize(Content.Load <Model>("Models/Tank_Dual")); tank_dual.Move(Matrix.CreateTranslation(new Vector3(-10, 0, 0)), Matrix.Identity); var center = new Point(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2); lookController = ControlHandler.GetLookController(center); movementController = ControlHandler.GetMovementController(center); camera = new AbsoluteCamera(GraphicsDevice, lookController, movementController); camera.SetPosition(new Vector3(0, -20, 10)); camera.SetRotation(Matrix.CreateFromYawPitchRoll(0, 1, 0)); }
public void RenderWaterRefraction(DirectionalLight directionalLight, BaseCamera camera, ref Matrix4 ProjectionMatrix, Vector4 clipPlane) { if (m_bPostConstructor) { return; } Matrix4 modelMatrix = Matrix4.Identity; GL.Enable(EnableCap.ClipDistance0); liteRefractionShader.startProgram(); _textureBlack.BindTexture(TextureUnit.Texture0); _textureR.BindTexture(TextureUnit.Texture1); _textureG.BindTexture(TextureUnit.Texture2); _textureB.BindTexture(TextureUnit.Texture3); _blendMap.BindTexture(TextureUnit.Texture4); liteRefractionShader.SetTextureR(1); liteRefractionShader.SetTextureG(2); liteRefractionShader.SetTextureB(3); liteRefractionShader.SetTextureBlack(0); liteRefractionShader.SetBlendMap(4); liteRefractionShader.SetMaterial(_terrainMaterial); liteRefractionShader.SetTransformationMatrices(ref modelMatrix, camera.GetViewMatrix(), ref ProjectionMatrix); liteRefractionShader.SetDirectionalLight(directionalLight); liteRefractionShader.SetClippingPlane(ref clipPlane); _buffer.RenderVAO(PrimitiveType.Triangles); liteRefractionShader.stopProgram(); GL.Disable(EnableCap.ClipDistance0); }
/// <summary> /// Draw members on screen if visible. /// </summary> /// <param name="gameTime">GameTime object.</param> /// <param name="device">GraphicsDevice object</param> public override void Draw(GameTime gameTime, GraphicsDevice device, BaseCamera camera) { if (Visible) { _members.Draw(gameTime, device, camera, null); } }
public override void Update(BaseCamera camera, ref Matrix world) { // Matrices _effect.Parameters["World"].SetValue(world); _effect.Parameters["View"].SetValue(camera.View); _effect.Parameters["Projection"].SetValue(camera.Projection); // Lights _effect.Parameters["AmbientColor"].SetValue(_ambientColor); _effect.Parameters["AmbientIntensity"].SetValue(_ambientIntensity); _effect.Parameters["DiffuseColor"].SetValue(_diffuseColor); _effect.Parameters["DiffuseIntensity"].SetValue(_diffuseIntensity); _effect.Parameters["SpecularColor"].SetValue(_specularColor * _specularIntensity); _effect.Parameters["LightDirection"].SetValue(_diffuseDirection); // Textures #if MONOGAME _effect.Parameters["ColorMap"].SetValue(_texture); _effect.Parameters["NormalMap"].SetValue(_normalMap); #else _effect.Parameters["ColorMapSampler"].SetValue(_texture); _effect.Parameters["NormalMapSampler"].SetValue(_normalMap); #endif // Position _effect.Parameters["EyePosition"].SetValue(world.Translation); }
void ModeChange() { if (gameTask.controllerTask.CameraModeChangeButton()) { if (cameraMode == CameraMode.Free) { gameTask.eventCount--; cameraMode = CameraMode.Target; BaseCamera newBase = gameObject.AddComponent <TargetCamera>(); newBase.LoadCamera(baseCamera); Destroy(baseCamera); baseCamera = newBase; } else if (cameraMode == CameraMode.Target && gameTask.eventCount == 0) { gameTask.eventCount++; cameraMode = CameraMode.Free; BaseCamera newBase = gameObject.AddComponent <FreeCamera>(); newBase.LoadCamera(baseCamera); Destroy(baseCamera); baseCamera = newBase; } } }
public void Update(Vector3 direction, BaseCamera camera) { foreach (var split in Splits) { split.LookAt(direction, camera.Position + camera.Look * split.Size / 2); } }
public IEnumerator 優先順の設定が反映される() { BaseCamera.GetUniversalAdditionalCameraData().renderType = CameraRenderType.Base; OverlayCamera1.GetUniversalAdditionalCameraData().renderType = CameraRenderType.Overlay; OverlayCamera2.GetUniversalAdditionalCameraData().renderType = CameraRenderType.Overlay; OverlayCamera3.GetUniversalAdditionalCameraData().renderType = CameraRenderType.Overlay; var component1 = OverlayCamera1.gameObject.AddComponent <AddOverlayCameraToCameraStack>(); var component2 = OverlayCamera2.gameObject.AddComponent <AddOverlayCameraToCameraStack>(); var component3 = OverlayCamera3.gameObject.AddComponent <AddOverlayCameraToCameraStack>(); component1.GetType().GetField("priority", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(component1, 10.0f); component2.GetType().GetField("priority", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(component2, -10.0f); component3.GetType().GetField("priority", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(component3, 0.0f); yield return(null); var cameraStack = BaseCamera.GetUniversalAdditionalCameraData().cameraStack; Assert.That(cameraStack[0], Is.EqualTo(OverlayCamera2)); Assert.That(cameraStack[1], Is.EqualTo(OverlayCamera3)); Assert.That(cameraStack[2], Is.EqualTo(OverlayCamera1)); yield return(SceneManager.UnloadSceneAsync(OverlayScene3)); yield return(SceneManager.UnloadSceneAsync(OverlayScene2)); yield return(SceneManager.UnloadSceneAsync(OverlayScene1)); yield return(SceneManager.UnloadSceneAsync(BaseScene)); }
public void RegisterCamera(BaseCamera camera) { // if (camera) //print("Register new camera on scene " + SceneManager.GetActiveScene().name); //else //print("Unregister camera on scene " + SceneManager.GetActiveScene().name); currentCamera = camera; }
public void StencilPass(BaseCamera camera, ref Matrix4 projectionMatrix) { PostConstructor(); m_stencilPassShader.startProgram(); m_stencilPassShader.SetUniformVariables(ref projectionMatrix, camera.GetViewMatrix(), ref m_modelMatrix); m_buffer.RenderVAO(PrimitiveType.Triangles); m_stencilPassShader.stopProgram(); }
public DirectionalLightWithShadow(BaseCamera viewerCamera, TextureParameters ShadowMapSettings, Vector3 Direction, Vector4 Ambient, Vector4 Diffuse, Vector4 Specular) : base(Direction, Ambient, Diffuse, Specular) { m_viewerCamera = viewerCamera; m_shadowOrthographicProjectionBuilder = new ShadowOrthoBuilder(); m_shadowMapCache = null; InitResources(ShadowMapSettings); }
private void GetEdgePoints(BaseCamera viewerCamera, ConvexVolume volume, out Vector3 LBN, out Vector3 RTF) { Vector3 ViewerPosition = viewerCamera.GetEyeVector(); // Find left and right edges Vector3 IntersectionPointC = GetLeftRightIntersectionPoint(ViewerPosition, volume.FarPlane, volume.LeftPlane); Vector3 IntersectionPointB = GetLeftRightIntersectionPoint(ViewerPosition, volume.FarPlane, volume.RightPlane); // Find top and bottom edges Vector3 IntersectionPointBottom = GetTopBottomIntersectionPoint(ViewerPosition, volume.FarPlane, volume.BottomPlane); Vector3 IntersectionPointTop = GetTopBottomIntersectionPoint(ViewerPosition, volume.FarPlane, volume.TopPlane); float left, right, top, bottom, near, far; // left Dictionary <float, Vector3> projectedValues = new Dictionary <float, Vector3>(); projectedValues.Add(GeometryMath.ProjectVectorOnNormalizedVector(IntersectionPointB, -RightVector), IntersectionPointB); projectedValues.Add(GeometryMath.ProjectVectorOnNormalizedVector(IntersectionPointC, -RightVector), IntersectionPointC); projectedValues.Add(GeometryMath.ProjectVectorOnNormalizedVector(ViewerPosition, -RightVector), ViewerPosition); left = projectedValues[projectedValues.Keys.Max()].X; // right projectedValues.Clear(); projectedValues.Add(GeometryMath.ProjectVectorOnNormalizedVector(IntersectionPointB, RightVector), IntersectionPointB); projectedValues.Add(GeometryMath.ProjectVectorOnNormalizedVector(IntersectionPointC, RightVector), IntersectionPointC); projectedValues.Add(GeometryMath.ProjectVectorOnNormalizedVector(ViewerPosition, RightVector), ViewerPosition); right = projectedValues[projectedValues.Keys.Max()].X; // top projectedValues.Clear(); projectedValues.Add(GeometryMath.ProjectVectorOnNormalizedVector(IntersectionPointTop, UpVector), IntersectionPointTop); projectedValues.Add(GeometryMath.ProjectVectorOnNormalizedVector(IntersectionPointBottom, UpVector), IntersectionPointBottom); projectedValues.Add(GeometryMath.ProjectVectorOnNormalizedVector(ViewerPosition, UpVector), ViewerPosition); top = projectedValues[projectedValues.Keys.Max()].Y; // bottom projectedValues.Clear(); projectedValues.Add(GeometryMath.ProjectVectorOnNormalizedVector(IntersectionPointTop, -UpVector), IntersectionPointTop); projectedValues.Add(GeometryMath.ProjectVectorOnNormalizedVector(IntersectionPointBottom, -UpVector), IntersectionPointBottom); projectedValues.Add(GeometryMath.ProjectVectorOnNormalizedVector(ViewerPosition, -UpVector), ViewerPosition); bottom = projectedValues[projectedValues.Keys.Max()].Y; // far projectedValues.Clear(); projectedValues.Add(GeometryMath.ProjectVectorOnNormalizedVector(IntersectionPointB, ForwardVector), IntersectionPointB); projectedValues.Add(GeometryMath.ProjectVectorOnNormalizedVector(IntersectionPointC, ForwardVector), IntersectionPointC); projectedValues.Add(GeometryMath.ProjectVectorOnNormalizedVector(ViewerPosition, ForwardVector), ViewerPosition); far = projectedValues[projectedValues.Keys.Max()].Z; // near projectedValues.Clear(); projectedValues.Add(GeometryMath.ProjectVectorOnNormalizedVector(IntersectionPointB, -ForwardVector), IntersectionPointB); projectedValues.Add(GeometryMath.ProjectVectorOnNormalizedVector(IntersectionPointC, -ForwardVector), IntersectionPointC); projectedValues.Add(GeometryMath.ProjectVectorOnNormalizedVector(ViewerPosition, -ForwardVector), ViewerPosition); near = projectedValues[projectedValues.Keys.Max()].Z; LBN = new Vector3(left, bottom, near); RTF = new Vector3(right, top, far); }
public override void Update(BaseCamera camera, ref Matrix world) { // Matrices IEffectMatrices effectMatrices = (IEffectMatrices)_effect; effectMatrices.World = world; effectMatrices.View = camera.View; effectMatrices.Projection = camera.Projection; }
private void ProceedTransformationDirty() { BaseCamera worldCamera = GameWorld.GetWorldInstance().GetLevel().Camera; if (worldCamera != null && worldCamera is ThirdPersonCamera) { (worldCamera as ThirdPersonCamera).SetThirdPersonTargetTransformationDirty(); // Update position of third person camera } }
public override void Draw(GameTime gameTime, GraphicsDevice device, BaseCamera camera) { PreDraw(camera); device.BlendState = BlendState.AlphaBlend; _geometry.Draw(device, _material); device.BlendState = BlendState.Opaque; }
public void SetCurrentCamera(int camId) { BaseCamera cam = GetCamera(camId); if (cam == null) { return; } currentCamera = cam; }
public void RenderWaterRefraction(DirectionalLight Sun, BaseCamera camera, ref Matrix4 ProjectionMatrix, Vector4 clipPlane = new Vector4()) { if (bPostConstructor) { return; } Matrix4 modelMatrix; modelMatrix = GetWorldMatrix(); /*If clip plane is setted - enable clipping plane*/ if (clipPlane.X == 0 && clipPlane.Y == 0 && clipPlane.Z == 0 && clipPlane.W == 0) { GL.Disable(EnableCap.ClipDistance0); } else { GL.Enable(EnableCap.ClipDistance0); } m_liteRefractionShader.startProgram(); //Бинд шейдера m_texture.BindTexture(TextureUnit.Texture0); // diffusemap texture bool bEnableNM = m_normalMap != null; bool bEnableSM = m_specularMap != null; if (bEnableNM) { m_normalMap.BindTexture(TextureUnit.Texture1); // normalmap } if (bEnableSM) { m_specularMap.BindTexture(TextureUnit.Texture2); //Bind specular map } m_liteReflectionShader.SetTexture(0); if (bEnableNM) { m_liteRefractionShader.SetNormalMap(1); } if (bEnableSM) { m_liteRefractionShader.SetSpecularMap(2); } m_liteRefractionShader.SetAlbedoTexture(0); m_liteRefractionShader.SetMaterial(m_material); m_liteRefractionShader.SetTransformationMatrices(ref modelMatrix, camera.GetViewMatrix(), ref ProjectionMatrix); m_liteRefractionShader.SetDirectionalLight(Sun); m_liteRefractionShader.SetClipPlane(ref clipPlane); m_skin.Buffer.RenderVAO(PrimitiveType.Triangles); m_liteRefractionShader.stopProgram(); }
public void Draw(BaseCamera camera) { effect.InitializeDrawEffect(camera); effect.World = Matrix.Identity * Matrix.CreateTranslation(Position); foreach (var pass in effect.CurrentTechnique.Passes) { pass.Apply(); graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, 12); } }
public void SetActiveCamera(BaseCamera newCamera) { if (activeCam == newCamera) { return; } newCamera.SetLastCameraRotation(activeCam.GetRotation()); EnableCameraComponents(activeCam, false); EnableCameraComponents(newCamera, true); activeCam = newCamera; }
private void ExecuteCameraAnimation(BaseCamera cam, AnimationVector3 v2Anim) { v2Anim.Animated += delegate { var angle = v2Anim.Current.Z; var radius = v2Anim.Current.X; CurrentCamRadius = radius; CurrentCamTabAngle = angle; radius += v2Anim.Current.Y; cam.Position = new Microsoft.Xna.Framework.Vector3((float)(Math.Cos(angle) * radius), 0, (float)(Math.Sin(angle) * radius)); }; }
private void PlotTiles(BaseCamera camera, int mousex, int mousey) { var map = MapEditorManager.CurrentMap; var rect = MapEditorManager.SelectedTilesRectangle; if (!ComponentHelpers.PointInBounds(camera, mousex, mousey)) return; MapPoint plotstart = camera.ScreenSpaceToWorldSpace(new ScreenPoint(mousex, mousey)).ToMapPoint(); for (int i = 0; i < rect.Width * rect.Height; i++) { int y = (i / rect.Width); int x = (i - (y * rect.Width)); MapPoint tilepoint = new MapPoint(plotstart.X + x, plotstart.Y + y); MapPoint sheetpoint = new MapPoint(rect.X + x, rect.Y + y); if (ComponentHelpers.PointInMap(map, tilepoint)) { var action = new PlaceTileAction(tilepoint.IntX, tilepoint.IntY, MapEditorManager.CurrentLayer, map.GetTileSetValue(sheetpoint)); action.Do(context); actionbuffer.Add(action); } } MapEditorManager.OnMapChanged(); }
private void PlotSelectionRect(SpriteBatch spritebatch, BaseCamera camera, Rectangle rect) { var selecttexture = EditorXNA.CreateSelectRectangle(rect.Width, rect.Height); var startplot = new Vector2(rect.X, rect.Y); spritebatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.Default, RasterizerState.CullCounterClockwise, null, camera.TransformMatrix); spritebatch.Draw(selecttexture, startplot, Color.White); spritebatch.End(); }
private void ChangeCameraType(CameraType newCamType) { //DisableAllCameraTypes(); DisableCurrentCamera (); switch (newCamType) { case CameraType.CHASE_CAM: _currentCamera = ChaseCam; //ChaseCam.enabled = true; break; case CameraType.ORBITAL_CAM: //OrbitalCam.enabled = true; _currentCamera = OrbitalCam; break; case CameraType.OVERHEAD_CAM: _currentCamera = OrbitalCam; break; case CameraType.FPS_CAM: _currentCamera = FPSCam; break; case CameraType.OVERVIEW_CAM: _currentCamera = OverviewCam; break; } //Cursor.visible = newCamType != CameraType.OVERHEAD_CAM; //Cursor.lockState = (newCamType == CameraType.OVERHEAD_CAM) ? CursorLockMode.Locked : CursorLockMode.Confined; EnableCurrentCamera (); CameraTargetChanged (LookAtTarget); }
private void DrawGrabbable(SpriteBatch spritebatch, BaseCamera camera, Map map, Grabbable grabbable) { Check.NullArgument<SpriteBatch>(spritebatch, "spritebatch"); Check.NullArgument<BaseCamera>(camera, "camera"); Check.NullArgument<Map>(map, "map"); Check.NullArgument<Grabbable>(grabbable, "grabbable"); var startpoint = grabbable.GetStartPoint(); spritebatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.Default, RasterizerState.CullCounterClockwise, null, camera.TransformMatrix); foreach (var tile in grabbable.Tiles) { Rectangle destrect = new Rectangle((startpoint.IntX + tile.Offset.IntX ) * map.TileSize, (startpoint.IntY + tile.Offset.IntY) * map.TileSize, map.TileSize, map.TileSize); MapPoint mappoint = new MapPoint(startpoint.IntX + tile.Offset.IntX, startpoint.IntY + tile.Offset.IntY); if (!ComponentHelpers.PointInMap(map, mappoint)) continue; PlotLayerTile(spritebatch, map, destrect, tile.Layer1); PlotLayerTile(spritebatch, map, destrect, tile.Layer2); PlotLayerTile(spritebatch, map, destrect, tile.Layer3); PlotLayerTile(spritebatch, map, destrect, tile.Layer4); } spritebatch.End(); }