/// <summary>Overridden from <see cref="Engine.MapSystem.MapObject.OnRender(Camera)"/>.</summary> protected override void OnRender( Camera camera ) { base.OnRender( camera ); //no update in cubemap generation mode if( Map.Instance.CubemapGenerationMode ) return; bool playerIntellectFPSCamera = false; { PlayerIntellect playerIntellect = Intellect as PlayerIntellect; if( playerIntellect != null ) playerIntellectFPSCamera = playerIntellect.FPSCamera; } bool fpsCamera = playerIntellectFPSCamera && RendererWorld.Instance.DefaultCamera == camera; if( activeWeapon != null && GameMap.Instance.GameType != GameMap.GameTypes.TPSArcade ) { //FPS mesh material activeWeapon.FPSMeshMaterialNameEnabled = fpsCamera && !camera.IsForShadowMapGeneration(); //update weapon vertical orientation if( activeWeaponAttachedObject.MapObject is Gun ) { //for guns if( fpsCamera ) { Vec3 p = camera.Position + camera.Rotation * Type.WeaponFPSAttachPosition; Quat r = camera.Rotation; Vec3 s = new Vec3( 1, 1, 1 ); activeWeaponAttachedObject.MapObject.SetTransform( p, r, s ); activeWeaponAttachedObject.MapObject.SetOldTransform( p, r, s ); //Vec3 diff = playerIntellect.LookDirection.GetVector(); //float dirV = -MathFunctions.ATan( diff.Z, diff.ToVec2().Length() ); //float halfDirV = dirV * .5f; //Quat rot = new Quat( 0, MathFunctions.Sin( halfDirV ), 0, // MathFunctions.Cos( halfDirV ) ); //activeWeaponAttachedObject.RotationOffset = rot; //activeWeaponAttachedObject.PositionOffset = // Type.FPSCameraOffset + Type.WeaponFPSAttachPosition * rot; } else { float dirV; if( EntitySystemWorld.Instance.IsClientOnly() ) { //client specific dirV = client_weaponVerticalAngle; } else { Vec3 diff = TurnToPosition - Position; dirV = -MathFunctions.ATan( diff.Z, diff.ToVec2().Length() ); } float halfDirV = dirV * .5f; Quat rot = new Quat( 0, MathFunctions.Sin( halfDirV ), 0, MathFunctions.Cos( halfDirV ) ); activeWeaponAttachedObject.RotationOffset = rot; activeWeaponAttachedObject.PositionOffset = Type.WeaponAttachPosition; } } else { //for melee weapons activeWeaponAttachedObject.RotationOffset = Quat.Identity; activeWeaponAttachedObject.PositionOffset = Vec3.Zero; } //no cast shadows from active weapon in the FPS mode foreach( MapObjectAttachedObject weaponAttachedObject in activeWeapon.AttachedObjects ) { MapObjectAttachedMesh weaponAttachedMesh = weaponAttachedObject as MapObjectAttachedMesh; if( weaponAttachedMesh != null && weaponAttachedMesh.MeshObject != null ) { if( weaponAttachedMesh.RemainingTime == 0 ) weaponAttachedMesh.MeshObject.CastShadows = !fpsCamera; } } } //only weapon visible in the FPS mode foreach( MapObjectAttachedObject attachedObject in AttachedObjects ) attachedObject.Visible = !fpsCamera || attachedObject == activeWeaponAttachedObject; //no cast shadows in the FPS mode if( camera.IsForShadowMapGeneration() && playerIntellectFPSCamera ) { foreach( MapObjectAttachedObject attachedObject in AttachedObjects ) attachedObject.Visible = false; } }
public override void OnSceneManagementGetObjectsForCamera( Camera camera, List<SceneNode> outSceneNodes, List<StaticMeshObject> outStaticMeshObjects, List<RenderLight> outLights ) { RenderLight shadowGenerationLight = null; if( camera.IsForShadowMapGeneration() ) shadowGenerationLight = camera.GetShadowMapGenerationLight(); if( shadowGenerationLight != null ) { //shadow generation int directionalLightPSSMTextureIndex = 0; Vec3 pointLightFaceDirection = Vec3.Zero; if( shadowGenerationLight.Type == RenderLightType.Directional && SceneManager.Instance.IsShadowTechniquePSSM() ) directionalLightPSSMTextureIndex = camera.GetDirectionalLightPSSMTextureIndex(); if( shadowGenerationLight.Type == RenderLightType.Point && SceneManager.Instance.IsShadowTechniqueShadowmapBased() ) pointLightFaceDirection = camera.Direction; GetShadowCastersForLight( SceneManager.Instance.CurrentUpdatingCamera, shadowGenerationLight, directionalLightPSSMTextureIndex, pointLightFaceDirection, outSceneNodes, outStaticMeshObjects ); } else { //usual camera GetObjectsForUsualCamera( camera, outSceneNodes, outStaticMeshObjects, outLights ); } //add objects never culled by the frustum if( SceneManager.Instance.OverrideVisibleObjects == null && Map.Instance != null ) { Map.Instance.Walk_AddObjectsWithDisabled_AllowSceneManagementCulling_Property( shadowGenerationLight != null, outSceneNodes, outStaticMeshObjects, outLights ); } }
/// <summary>Overridden from <see cref="Engine.MapSystem.MapObject.OnRender(Camera)"/>.</summary> protected override void OnRender(Camera camera) { base.OnRender(camera); //no update in cubemap generation mode if (Map.Instance.CubemapGenerationMode) return; bool playerIntellectFPSCamera = false; { if (Intellect != null && Intellect == PlayerIntellect.Instance) playerIntellectFPSCamera = PlayerIntellect.Instance.FPSCamera; } bool fpsCamera = playerIntellectFPSCamera && RendererWorld.Instance.DefaultCamera == camera; if (activeWeapon != null && GameMap.Instance.GameType != GameMap.GameTypes.TPSArcade) { //FPS mesh material activeWeapon.FPSMeshMaterialNameEnabled = fpsCamera && !camera.IsForShadowMapGeneration(); //update weapon vertical orientation if (activeWeaponAttachedObject.MapObject is Gun) { //for guns if (fpsCamera) { Vec3 diff = PlayerIntellect.Instance.LookDirection.GetVector(); float dirV = -MathFunctions.ATan(diff.Z, diff.ToVec2().Length()); float halfDirV = dirV * .5f; Quat rot = new Quat(0, MathFunctions.Sin(halfDirV), 0, MathFunctions.Cos(halfDirV)); activeWeaponAttachedObject.RotationOffset = rot; activeWeaponAttachedObject.PositionOffset = Type.FPSCameraOffset + Type.WeaponFPSAttachPosition * rot; } else { Vec3 diff = SeePosition - Position; float dirV = -MathFunctions.ATan(diff.Z, diff.ToVec2().Length()); float halfDirV = dirV * .5f; Quat rot = new Quat(0, MathFunctions.Sin(halfDirV), 0, MathFunctions.Cos(halfDirV)); activeWeaponAttachedObject.RotationOffset = rot; activeWeaponAttachedObject.PositionOffset = Type.WeaponAttachPosition; } } else { //for melee weapons activeWeaponAttachedObject.RotationOffset = Quat.Identity; activeWeaponAttachedObject.PositionOffset = Vec3.Zero; } //Update transform of the attached weapon. //That there was no twitching because of interpolation { Vec3 p; Quat r; Vec3 s; activeWeaponAttachedObject.GetGlobalTransform(out p, out r, out s); activeWeaponAttachedObject.MapObject.SetTransform(p, r, s); activeWeaponAttachedObject.GetGlobalOldTransform(out p, out r, out s); activeWeaponAttachedObject.MapObject.SetOldTransform(p, r, s); } //no cast shadows from active weapon in the FPS mode foreach (MapObjectAttachedObject weaponAttachedObject in activeWeapon.AttachedObjects) { MapObjectAttachedMesh weaponAttachedMesh = weaponAttachedObject as MapObjectAttachedMesh; if (weaponAttachedMesh != null && weaponAttachedMesh.MeshObject != null) { if (weaponAttachedMesh.RemainingTime == 0) weaponAttachedMesh.MeshObject.CastShadows = !fpsCamera; } } } //only weapon visible in the FPS mode foreach (MapObjectAttachedObject attachedObject in AttachedObjects) attachedObject.Visible = !fpsCamera || attachedObject == activeWeaponAttachedObject; //no cast shadows in the FPS mode if (camera.IsForShadowMapGeneration() && playerIntellectFPSCamera) { foreach (MapObjectAttachedObject attachedObject in AttachedObjects) attachedObject.Visible = false; } }
protected override void OnRender( Camera camera ) { base.OnRender( camera ); if( !camera.IsForShadowMapGeneration() && MapEditorInterface.Instance != null && MapEditorInterface.Instance.IsEntitySelected( this ) ) { //render volume if( physicsHeight != 0 && Type.PhysicsDensity != 0 ) { Bounds bounds = new Bounds( Position - new Vec3( 0, 0, physicsHeight / 2 ) ); bounds.Expand( new Vec3( Size.X, Size.Y, physicsHeight ) / 2 ); camera.DebugGeometry.Color = new ColorValue( 0, 0, 1 ); camera.DebugGeometry.AddBounds( bounds ); } } }