public override void RenderShape(VisionViewBase view, ShapeRenderMode mode) { if (TimeOfDay == null) { return; } const int iSteps = 24; float fStep = 1.0f / (float)iSteps; float fLen = 200.0f * EditorManager.Settings.GlobalUnitScaling; float fTime = 0.0f; Vector3F lastCorner = Vector3F.Zero; for (int i = 0; i < iSteps; i++, fTime += fStep) { if (!EditorManager.RendererNodeManager.GetTimeOfDaySnapshot(fTime, daytimeParams)) { continue; } Vector3F newCorner = Position + daytimeParams.SunDirection * fLen * 0.75f; if (i > 0) { view.RenderSolidTriangle(Position, newCorner, lastCorner, VisionColors.Get(daytimeParams.AmbientColor)); view.RenderSolidTriangle(Position, lastCorner, newCorner, VisionColors.Get(daytimeParams.AmbientColor)); } Vector3F vEnd = Position + daytimeParams.SunDirection * fLen; view.RenderLine(Position, vEnd, VisionColors.Get(daytimeParams.SunColor), 1.0f); uint iColor = (i == 12) ? VisionColors.White : VisionColors.Yellow; view.WriteText3D(vEnd, i.ToString() + ":00", iColor); // time lastCorner = newCorner; } }
/// <summary> /// overridden function to set/update all specific properties on the engine instance /// </summary> public override void SetEngineInstanceBaseProperties() { if (_engineInstance == null) { return; } EnginePGroup.BeginUpdateParams(); EnginePGroup.SetRandomBaseSeed(_uiRandomBaseSeed); EnginePGroup.SetEffectFile(_effectFile); // first set the effect... base.SetEngineInstanceBaseProperties(); // ...then position etc. EnginePGroup.SetVisibleBitmask((uint)_iVisibleBitmask); EnginePGroup.SetLightInfluenceBitmask((uint)_iLightInfluenceBitmask); EnginePGroup.SetPreferredDirLightKey(_preferredDynamicDirLightKey); EnginePGroup.SetLightSamplingOffset(_lightSamplingOffset); EnginePGroup.SetAmbientColor(VisionColors.Get(_ambientColor)); EnginePGroup.SetPaused(_bPaused); EnginePGroup.SetHalted(_bHalted); EnginePGroup.SetWindSpeed(_windSpeed, _bLocalSpaceWind); EnginePGroup.UpdateParticleColors(); EnginePGroup.SetIntensity(_fIntensity); EnginePGroup.SetApplyTimeOfDayLight(_bApplyTimeOfDayLighting); EnginePGroup.SetRemoveWhenFinished(_removeWhenFinished); UpdateMeshEmitterEntity(); EnginePGroup.EndUpdateParams(); }
public override void RenderShape(VisionViewBase view, ShapeRenderMode mode) { base.RenderShape(view, mode); if (this.Visible == true) { uint iColor = VisionColors.RGBA(0, 255, 255, 255); view.RenderRectangle2D(0, 0, ResolutionX * _editScale, ResolutionY * _editScale, iColor, 1.0f); } }
/// <summary> /// overridden function to render the shape /// </summary> /// <param name="view">destination view</param> /// <param name="mode">render mode</param> public override void RenderShape(VisionViewBase view, ShapeRenderMode mode) { base.RenderShape(view, mode); if (_engineInstance != null) { if (mode == ShapeRenderMode.Selected || (ParentLayer == ParentLayer.ParentScene.ActiveLayer && _bPreview3D)) { EngineBox.RenderShape(view, mode, VisionColors.Get(_previewColor)); } } }
public void ShowTraceResult(VisionViewBase view) { if (bResultValid) { float cx = 0, cy = 0, cz = 0; float r = EditorManager.Settings.GlobalUnitScaling * 5.0f; if (view.Project2D(hitPoint, ref cx, ref cy, ref cz)) { view.WriteText2D(cx, cy, hitPoint.ToString(), VisionColors.Yellow); } view.RenderCross(hitPoint, r, VisionColors.Yellow, 1.0f); view.RenderLine(hitPoint, hitPoint + hitNormal * r * 3.0f, VisionColors.RGB(100, 255, 100), 1.0f); } }
public override void RenderHotSpot(VisionViewBase view, ShapeRenderMode mode) { base.RenderHotSpot(view, mode); if (!OnScreen) { return; } Vector2F center2d = Sprite.CenterPosition; view.RenderRectangle2D( center2d.X - 5, center2d.Y - 5, center2d.X + 5, center2d.Y + 5, VisionColors.RGBA(0, 255, 0, 255), 1.0f); }
/// <summary> /// Overridden function to set all shape's properties (color, ...) on the engine instance /// </summary> public override void SetEngineInstanceBaseProperties() { base.SetEngineInstanceBaseProperties(); if (_engineInstance == null) { return; } EngineProjector.SetTexture(_textureFile); EngineProjector.SetTransparency(_transp); EngineProjector.SetConeAngles(_fConeAngleX, _fConeAngleY); EngineProjector.SetLength(_fLength * UniformScaling); EngineProjector.SetFadeOutRange(_fFadeOutDist * UniformScaling); EngineProjector.SetColor(VisionColors.RGBA(_color.R, _color.G, _color.B, _iIntensity)); EngineProjector.SetLightmapped(_bLightmapped); EngineProjector.SetGeometryTypeMask(_geomTypeFilter); EngineProjector.SetFarClipDistance(_fFarClipDistance); EngineProjector.SetInfluenceBitmask((uint)_iInfluenceBitmask); EngineProjector.SetCustomShaderEffect(_shaderFX); }
public void RenderSelection(VisionViewBase view, ShapeRenderMode mode) { if (!Valid) { return; } uint iColor = VisionColors.RGBA(50, 20, 150, 50); /* * Vector3F v0 = new Vector3F(WorldSpaceExtent.X1, WorldSpaceExtent.Y1, DisplayZ); * Vector3F v1 = new Vector3F(WorldSpaceExtent.X2, WorldSpaceExtent.Y1, DisplayZ); * Vector3F v2 = new Vector3F(WorldSpaceExtent.X1, WorldSpaceExtent.Y2, DisplayZ); * Vector3F v3 = new Vector3F(WorldSpaceExtent.X2, WorldSpaceExtent.Y2, DisplayZ); * * view.RenderSolidTriangle(v0, v1, v2, iColor); * view.RenderSolidTriangle(v1, v3, v2, iColor); */ float fMin = DisplayZ - EditorManager.Settings.MaxPickingDistance; BoundingBox renderBox = new BoundingBox(WorldSpaceExtent.X1, WorldSpaceExtent.Y1, fMin, WorldSpaceExtent.X2, WorldSpaceExtent.Y2, DisplayZ); view.RenderSolidBox(renderBox, iColor); }
/// <summary> /// Overridden render function: Let the engine instance render itself and render a box /// </summary> /// <param name="view"></param> /// <param name="mode"></param> public override void RenderShape(VisionViewBase view, ShapeRenderMode mode) { // EngineNode.RenderShape(view, mode); base.RenderShape(view, mode); if (this.Selected == true) { uint iColor = VisionColors.RGBA(0, 0, 255, 255); float fScaleX = UIEditorMessageService.GetInstance().GetResolutionScaleX(); float fScaleY = UIEditorMessageService.GetInstance().GetResolutionScaleY(); float fScreenPosX = PosX; float fScreenPosY = PosY; if (Parent != null && Parent is UIShapeBase) { fScreenPosX += ((UIShapeBase)Parent).PosX; fScreenPosY += ((UIShapeBase)Parent).PosY; } view.RenderRectangle2D(fScreenPosX * fScaleX, fScreenPosY * fScaleY, (fScreenPosX + SizeX) * fScaleX, (fScreenPosY + SizeY) * fScaleY, iColor, 1.0f); } }
public void ShowDistance(VisionViewBase view) { _start.ShowTraceResult(view); if (!bResultValid) { return; } view.RenderArrow(_start.hitPoint, hitPoint, VisionColors.Blue, 1.0f, 5.0f * EditorManager.Settings.GlobalUnitScaling); Vector3F diff = hitPoint - _start.hitPoint; float cx = 0, cy = 0, cz = 0; if (view.Project2D(_start.hitPoint + diff * 0.5f, ref cx, ref cy, ref cz)) { view.WriteText2D(cx, cy, string.Format("Distance: {0}", diff.GetLength()), VisionColors.RGB(255, 255, 100)); } }
public override void RenderShape(VisionViewBase view, ShapeRenderMode mode) { if (FinalVisibleState == true && EditorManager.Scene.AllShapesOfType(typeof(HavokAiEditorPlugin.Shapes.HavokNavMeshShape)).Count != 0) { HavokAiManaged.ManagedModule.ComputeAndDrawPath(view, _vStartPoint, _vEndPoint, _fCharacterRadius, _fCharacterHeight, _fpathDisplayOffset * _fCharacterHeight, VisionColors.Get(_pathColor)); } base.RenderShape(view, mode); }
public HotSpotUpdateCubemap(CubemapShape owner) : base(owner, @"textures\Refresh.tga", VisionColors.RGB(200, 200, 200), VisionColors.White, 8.0f) { this.Set2DOffset(30, 16); }
public AdjustPasteSizeHotspot(TerrainSelectionShape selShape) : base(selShape, @"textures\fit_to_size32.png", VisionColors.RGBA(230, 230, 230, 255), VisionColors.White, 16.0f) { this.ToolTipText = "Take the selection size from the clipboard data (same size in world units)"; }
public PasteSelectionHotspot(TerrainSelectionShape selShape) : base(selShape, @"textures\paste32.png", VisionColors.RGBA(230, 230, 230, 255), VisionColors.White, 16.0f) { this.ToolTipText = "Pastes the current clipboard content into this selection (uses scaling)"; }
public CopySelectionHotspot(TerrainSelectionShape selShape) : base(selShape, @"textures\copy32.png", VisionColors.RGBA(230, 230, 230, 255), VisionColors.White, 16.0f) { this.ToolTipText = "Copies the current selection into the clipboard"; }
/// <summary> /// Overridden function /// </summary> public override void OnSelected() { base.OnSelected(); // start button _hotSpotStartEvent = new HotSpotPlayButton(this, @"textures\Media_play.TGA", VisionColors.RGBA(200, 200, 200, 255), VisionColors.White, 15.0f); _hotSpotStartEvent.ToolTipText = "Start event"; _hotSpotStartEvent.Set2DOffset(0.0f, 30.0f); EditorManager.ActiveView.HotSpots.Add(_hotSpotStartEvent); // Update the engine instance, in order to offer stolen info-only events the possibility to convert into a playable event instance. Thus hotspot button // will be always available for all event instances. Please note: All stolen event instances, which have a "Max playbacks behavior" without failing // (1 = steal oldest, 2 = steal newest, 3 = steal quietest), will not recover. This is absolute necessary, in order to avoid an endless cycle of stealing // and recovering of such event instances, as none of the requests for a not info-only event will fail. Thus for these events, the hotspot button will // not be available. EngineFmodEvent.Update(); UpdateHotspotVisibility(); }
/// <summary> /// Overridable that is called when the mouse cursor moves in the view /// </summary> /// <param name="e">Mouse event arguments directly passed through</param> /// <param name="eKeyMod">Key modifier bitmask (Shift, Alt, ...)</param> /// <param name="iOldX">Previous screen x position</param> /// <param name="iOldY">Previous screen y position</param> /// <returns>return true to redraw the view immediately</returns> public override bool OnMouseMove(MouseEventArgs e, KeyModifier eKeyMod, int iOldX, int iOldY) { if (Dragmode == MOUSE_MODE.UI_AREA_SELECT) { View.RenderRectangle2D(m_MouseDownPoint.X, m_MouseDownPoint.Y, e.X, e.Y, VisionColors.RGBA(255, 255, 255, 255), 1.0f); } else if (eKeyMod == KeyModifier.Ctrl) { } else { if (m_selectedShapeList.Count > 0) { if (Dragmode == MOUSE_MODE.UI_MOVE || Dragmode == MOUSE_MODE.UI_COPY) { // this.MoveUIShape(m_selectedShape, e.X, e.Y); foreach (UIShapeBase shape in m_selectedShapeList) { this.MoveUIShapeDelta(shape, e.X - iOldX, e.Y - iOldY); } } else if (Dragmode == MOUSE_MODE.UI_SIZE) { foreach (UIShapeBase shape in m_selectedShapeList) { Rectangle2D newRect = new Rectangle2D(); float fDeltaX = (e.X - iOldX); float fDeltaY = (e.Y - iOldY); if (View.Cursor == Cursors.PanNW) { newRect.Add(shape.ScreenBound.X2, shape.ScreenBound.Y2); newRect.Add(shape.ScreenBound.X1 + fDeltaX, shape.ScreenBound.Y1 + fDeltaY); newRect.Validate(); shape.ScreenBound = newRect; } else if (View.Cursor == Cursors.PanSW) { newRect.Add(shape.ScreenBound.X2, shape.ScreenBound.Y1); newRect.Add(shape.ScreenBound.X1 + fDeltaX, shape.ScreenBound.Y2 + fDeltaY); newRect.Validate(); shape.ScreenBound = newRect; } else if (View.Cursor == Cursors.PanNE) { newRect.Add(shape.ScreenBound.X1, shape.ScreenBound.Y2); newRect.Add(shape.ScreenBound.X2 + fDeltaX, shape.ScreenBound.Y1 + fDeltaY); newRect.Validate(); shape.ScreenBound = newRect; } else if (View.Cursor == Cursors.PanSE) { newRect.Add(shape.ScreenBound.X1, shape.ScreenBound.Y1); newRect.Add(shape.ScreenBound.X2 + fDeltaX, shape.ScreenBound.Y2 + fDeltaY); newRect.Validate(); shape.ScreenBound = newRect; } } } } else { } if (Dragmode == MOUSE_MODE.UI_NONE) { UIShapeBase tempShape = this.GetUIShapeFromSelection(e.X, e.Y); if (tempShape == null) { View.Cursor = Cursors.Default; } else { int margin = 15; Rectangle2D mouseBound = new Rectangle2D(); mouseBound.Add(e.X - margin, e.Y - margin); mouseBound.Add(e.X + margin, e.Y + margin); float fX1 = tempShape.ScreenBound.X1; float fY1 = tempShape.ScreenBound.Y1; float fX2 = tempShape.ScreenBound.X2; float fY2 = tempShape.ScreenBound.Y2; if (mouseBound.IsInside(fX1, fY1)) { View.Cursor = Cursors.PanNW; } else if (mouseBound.IsInside(fX1, fY2)) { View.Cursor = Cursors.PanSW; } else if (mouseBound.IsInside(fX2, fY1)) { View.Cursor = Cursors.PanNE; } else if (mouseBound.IsInside(fX2, fY2)) { View.Cursor = Cursors.PanSE; } else if (tempShape is UIShapeDialog) // 다이얼로그는 사이즈조정밖에 안됨 { View.Cursor = Cursors.Arrow; } else { View.Cursor = Cursors.SizeAll; } } } } return(false); }
/// <summary> /// Overridden function /// </summary> public override void OnSelected() { base.OnSelected(); System.Diagnostics.Debug.Assert(_hotSpotVolume == null); // hotspot for sound volume _hotSpotVolume = new HotSpotDistance(this, @"textures\Hotspot_V.tga", VisionColors.Cyan, HotSpotBase.PickType.Square, 10.0f); _hotSpotVolume.DisplayScaling = 100.0f; _hotSpotVolume.StartDistance = Volume; _hotSpotVolume.Axis = this.ZAxis; _hotSpotVolume.ToolTipText = "Volume"; _hotSpotVolume.SetRange(0.0f, 1.0f); EditorManager.ActiveView.HotSpots.Add(_hotSpotVolume); // hotspots for distance fading _hotSpotFadeMin = new HotSpotDistance(this, @"textures\Hotspot_D.tga", VisionColors.Blue, HotSpotBase.PickType.Square, 4.0f); _hotSpotFadeMin.StartDistance = MinDistance; _hotSpotFadeMin.Axis = this.XAxis; _hotSpotFadeMin.DisplayScaling = UniformScaling; _hotSpotFadeMin.ToolTipText = "min distance"; EditorManager.ActiveView.HotSpots.Add(_hotSpotFadeMin); _hotSpotFadeMax = new HotSpotDistance(this, @"textures\Hotspot_D.tga", VisionColors.Blue, HotSpotBase.PickType.Square, 4.0f); _hotSpotFadeMax.StartDistance = MaxDistance; _hotSpotFadeMax.Axis = this.XAxis; _hotSpotFadeMax.DisplayScaling = UniformScaling; _hotSpotFadeMax.ToolTipText = "max distance"; EditorManager.ActiveView.HotSpots.Add(_hotSpotFadeMax); // hotspots for cone angles _hotSpotOuterCone = new HotSpotConeAngle(this, @"textures\Hotspot_A.tga", VisionColors.Red, HotSpotBase.PickType.Square, 4.0f); _hotSpotOuterCone.Distance = 120.0f * EditorManager.Settings.GlobalUnitScaling; _hotSpotOuterCone.StartAngle = this.ConeOutside; _hotSpotOuterCone.ToolTipText = "Outer cone angle"; EditorManager.ActiveView.HotSpots.Add(_hotSpotOuterCone); _hotSpotInnerCone = new HotSpotConeAngle(this, @"textures\Hotspot_A.tga", VisionColors.Red, HotSpotBase.PickType.Square, 4.0f); _hotSpotInnerCone.Distance = 100.0f * EditorManager.Settings.GlobalUnitScaling; _hotSpotInnerCone.StartAngle = this.ConeInside; _hotSpotInnerCone.ToolTipText = "Inner cone angle"; EditorManager.ActiveView.HotSpots.Add(_hotSpotInnerCone); // hotspot for playing sound _hotSpotPlaySound = new HotSpotPlayButton(this, @"textures\Media_play.TGA", VisionColors.RGBA(200, 200, 200, 255), VisionColors.White, 15.0f); _hotSpotPlaySound.ToolTipText = "Play sound"; _hotSpotPlaySound.Set2DOffset(0.0f, 30.0f); EditorManager.ActiveView.HotSpots.Add(_hotSpotPlaySound); UpdateHotspotVisibility(); }
/// <summary> /// constructor /// </summary> /// <param name="owner">the owning CustomVolumeShape</param> /// <param name="insert">at which place to insert</param> public HotSpotAddVolumeVertex(CustomVolumeShape owner, int insert) : base(owner, @"Textures\Hotspot_add.dds", VisionColors.RGBA(255, 255, 255, 180), VisionColors.White, 8.0f) { _insert = insert; }
/// <summary> /// Updates the fog in the engine. Optionally redraws the view /// </summary> /// <param name="bRedraw"></param> public void Update(bool bRedraw) { EditorManager.EngineManager.SetLinearDepthFog(_bEnabled, _fStartDist, _fStartEnd, VisionColors.Get(_color)); if (bRedraw) { EditorManager.ActiveView.UpdateView(false); } // update the dependedncies V3DLayer parentLayer = (V3DLayer)OwnerSceneObject; if (parentLayer != null) { // update the current renderer //parentLayer.Renderer.Update(); } }
public void TestNavMeshGeneration() { // Create a nav mesh shape EditorManager.GetShapeCreatorPluginByName("Nav Mesh").ExecutePlugin(); HavokNavMeshShape navMeshShape = (HavokAiEditorPlugin.Shapes.HavokNavMeshShape)EditorManager.Scene.FindFirstShapeOfType(typeof(HavokNavMeshShape), true); Assert.IsNotNull(navMeshShape); // Build the nav mesh ShapeCollection staticGeometries = new ShapeCollection(); int numGeometryVertices = 0, numGeometryTriangles = 0, numEntities = 0, numStaticMeshes = 0, numTerrains = 0; int numCarvers = 0, numSeedPoints = 0, numLocalSettings = 0; HavokAiPanelDialogs.HavokAiPanel.gatherGeometricShapes(ref staticGeometries, ref numEntities, ref numStaticMeshes, ref numTerrains, ref numCarvers, ref numSeedPoints, ref numLocalSettings); bool built = navMeshShape.Build(staticGeometries, ref numGeometryVertices, ref numGeometryTriangles); Assert.IsTrue(built); // Add Navmesh to world navMeshShape.AddNavMeshToWorld(); // Create a path shape EditorManager.GetShapeCreatorPluginByName("Nav Mesh Test Path").ExecutePlugin(); HavokNavMeshTestPathShape pathShape = (HavokAiEditorPlugin.Shapes.HavokNavMeshTestPathShape)EditorManager.Scene.FindFirstShapeOfType(typeof(HavokNavMeshTestPathShape), true); Assert.IsNotNull(pathShape); // Verify that a known path exists on the nav mesh pathShape.StartPoint = new Vector3F(-500.0f, 0.0f, 0.0f); pathShape.EndPoint = new Vector3F(500.0f, 0.0f, 0.0f); pathShape.CharacterRadius = 20.0f; bool foundPath = HavokAiManaged.ManagedModule.ComputeAndDrawPath(EditorManager.ActiveView, pathShape.StartPoint, pathShape.EndPoint, pathShape.CharacterRadius, pathShape.CharacterHeight, 0.08f * pathShape.CharacterHeight, VisionColors.Get(pathShape.PathColor)); EditorManager.ActiveView.UpdateView(true); Assert.IsTrue(foundPath); // Create a carver shape EditorManager.GetShapeCreatorPluginByName("Nav Mesh Carver").ExecutePlugin(); HavokNavMeshCarverShape carverShape = (HavokAiEditorPlugin.Shapes.HavokNavMeshCarverShape)EditorManager.Scene.FindFirstShapeOfType(typeof(HavokNavMeshCarverShape), true); Assert.IsNotNull(carverShape); // Make the carver block the previous path and test by rebuilding the nav mesh and verifying the path is blocked carverShape.BoxSizeX = 300.0f; carverShape.BoxSizeY = 2000.0f; carverShape.BoxSizeZ = 200.0f; built = navMeshShape.Build(staticGeometries, ref numGeometryVertices, ref numGeometryTriangles); Assert.IsTrue(built); // Add Navmesh to world navMeshShape.AddNavMeshToWorld(); foundPath = HavokAiManaged.ManagedModule.ComputeAndDrawPath(EditorManager.ActiveView, pathShape.StartPoint, pathShape.EndPoint, pathShape.CharacterRadius, pathShape.CharacterHeight, 0.08f * pathShape.CharacterHeight, VisionColors.Get(pathShape.PathColor)); EditorManager.ActiveView.UpdateView(true); Assert.IsFalse(foundPath); // Resize the carver again, this time so that only character's of a certain radius can traverse the path carverShape.BoxSizeY = 1400.0f; built = navMeshShape.Build(staticGeometries, ref numGeometryVertices, ref numGeometryTriangles); Assert.IsTrue(built); // Add Navmesh to world navMeshShape.AddNavMeshToWorld(); foundPath = HavokAiManaged.ManagedModule.ComputeAndDrawPath(EditorManager.ActiveView, pathShape.StartPoint, pathShape.EndPoint, pathShape.CharacterRadius, pathShape.CharacterHeight, 0.08f * pathShape.CharacterHeight, VisionColors.Get(pathShape.PathColor)); EditorManager.ActiveView.UpdateView(true); Assert.IsFalse(foundPath); pathShape.CharacterRadius = 10.0f; foundPath = HavokAiManaged.ManagedModule.ComputeAndDrawPath(EditorManager.ActiveView, pathShape.StartPoint, pathShape.EndPoint, pathShape.CharacterRadius, pathShape.CharacterHeight, 0.08f * pathShape.CharacterHeight, VisionColors.Get(pathShape.PathColor)); EditorManager.ActiveView.UpdateView(true); Assert.IsTrue(foundPath); // Save NavMesh to file bool saved = navMeshShape.SaveNavMeshesToFile(); Assert.IsTrue(saved); }