public override void Draw(GL_ControlModern control, Pass pass, EditorSceneBase editorScene) { if (!ObjectRenderState.ShouldBeDrawn(this) || pass != Pass.OPAQUE) { return; } bool hovered = editorScene.Hovered == this; if (!CanPick) { control.SkipPickingColors(1); Selected = false; hovered = false; if (pass == Pass.PICKING) { return; } } Matrix3 rotMtx = GlobalRotation; Vector4 highlightColor = Vector4.Zero; if (Selected && hovered) { highlightColor = hoverSelectColor; } else if (Selected) { highlightColor = selectColor; } else if (hovered) { highlightColor = hoverColor; } bool positionChanged = false; Vector3 position = !Selected ? GlobalPosition : editorScene.CurrentAction.NewPos(GlobalPosition, out positionChanged); if (positionChanged && editorScene.CurrentAction is TranslateAction) { var newPosition = OnPositionChanged(position); if (newPosition != position) { ((TranslateAction)editorScene.CurrentAction).SetAxisXZ(); } position = newPosition; } control.UpdateModelMatrix( Matrix4.CreateScale((Selected ? editorScene.CurrentAction.NewScale(GlobalScale, rotMtx) : GlobalScale)) * new Matrix4(Selected ? editorScene.CurrentAction.NewRot(rotMtx) : rotMtx) * Matrix4.CreateTranslation(position)); DrawModel(control, editorScene, pass, highlightColor); }
public override int GetPickableSpan() { if (!ObjectRenderState.ShouldBeDrawn(this)) { return(0); } else { return(1); } }
public override void Draw(GL_ControlLegacy control, Pass pass, EditorSceneBase editorScene) { if (pass == Pass.TRANSPARENT) { return; } if (!ObjectRenderState.ShouldBeDrawn(this)) { return; } }
public override int GetPickableSpan() { if (!ObjectRenderState.ShouldBeDrawn(this)) { return(0); } int i = 0; foreach (RenderablePathPoint point in PathPoints) { i += point.GetPickableSpan(); } return(i); }
public override int GetPickableSpan() { //Disable pciking pass for selected objects that are hovering over another //So we can pick the hovered object instead if (isHoverPickPass && IsSelected()) { return(0); } //Make sure the point can be drawn for picking if (ObjectRenderState.ShouldBeDrawn(this)) { return(1); } else { return(0); } }
public override void Draw(GL_ControlModern control, Pass pass, EditorSceneBase editorScene) { if (!ObjectRenderState.ShouldBeDrawn(this)) { return; } bool hovered = editorScene.Hovered == this; if (XRayMode && pass != Pass.PICKING) { GL.Disable(EnableCap.DepthTest); } if (pass == Pass.OPAQUE && !XRayMode || pass == Pass.TRANSPARENT && XRayMode) { Vector3 offset = new Vector3(0, LineOffset, 0); List <Vector3> points = new List <Vector3>(); foreach (var path in PathPoints) { if (!path.Visible) { continue; } foreach (var nextPt in path.Children) { points.Add((path.Translate + offset)); points.Add((nextPt.Translate + offset)); } } if (LineRenderer == null) { LineRenderer = new LineRenderer(); LineRenderer.Width = LineWidth; LineRenderer.Prepare(control); } LineRenderer.UpdateVertexData(control, points, new Vector3(1, 1, 1)); LineRenderer.Color = LineColor; LineRenderer.Draw(control, pass); foreach (var path in PathPoints) { if (!path.Visible) { continue; } foreach (var nextPt in path.Children) { var dir = (nextPt.Translate - path.Translate); Vector3 scale = new Vector3(ArrowScale); if (path.Translate.Length != 0 && ScaleByCamera) { scale *= 1 + ((control.CameraTarget.Length / nextPt.Translate.Length) * CameraScaleFactor); } var rotation = RotationFromTo(new Vector3(0, 0, 1), dir.Normalized()); Matrix4 offsetMat = Matrix4.CreateTranslation(new Vector3(0, 0, -25)); Matrix4 translateMat = Matrix4.CreateTranslation(nextPt.Translate); if (IsArrowCentered) { offsetMat = Matrix4.Identity; translateMat = Matrix4.CreateTranslation((path.Translate + (dir / 2f))); } control.UpdateModelMatrix( offsetMat * Matrix4.CreateScale(scale) * rotation * translateMat); ColorConeRenderer.Draw(control, pass, ColorUtility.ToVector4(ArrowColor), new Vector4(1, 1, 1, 1), Vector4.Zero, XRayMode); } } } int part = 0; foreach (var drawable in PathPoints) { if (drawable.GetPickableSpan() == 0) { continue; } drawable.Hovered = hovered && (editorScene.HoveredPart == part); drawable.Draw(control, pass, editorScene); part++; } if (XRayMode && pass != Pass.PICKING) { GL.Enable(EnableCap.DepthTest); } }
public override void Draw(GL_ControlModern control, Pass pass, EditorSceneBase editorScene) { if (pass != Pass.OPAQUE || ShaderProgram == null) { return; } if (!ObjectRenderState.ShouldBeDrawn(this)) { return; } bool hovered = editorScene.Hovered == this; CheckBuffers(); if (pass == Pass.PICKING && CanPick) { int part = 0; foreach (var drawable in PathPoints) { if (drawable.GetPickableSpan() == 0) { continue; } drawable.Color = ColorUtility.ToVector4(SphereColor); drawable.Hovered = hovered && (editorScene.HoveredPart == part); drawable.Draw(control, pass, editorScene); part++; } return; } if (pass != Pass.PICKING) { control.CurrentShader = ShaderProgram; ShaderProgram.EnableVertexAttributes(); ShaderProgram.SetMatrix4x4("rotation", ref prismRotation); int part = 0; Matrix4 modelMatrix = Matrix4.Identity; foreach (BonePoint pickObject in PathPoints) { STBone bone = pickObject.Bone; if (pickObject.GetPickableSpan() == 0) { continue; } pickObject.Hovered = hovered && (editorScene.HoveredPart == part); var boneColor = ColorUtility.ToVector4(this.SphereColor); if (pickObject.Hovered && pickObject.IsSelected()) { boneColor = hoverSelectColor; } else if (pickObject.IsSelected()) { boneColor = selectColor; } else if (pickObject.Hovered) { boneColor = hoverColor; } ShaderProgram.SetVector4("boneColor", boneColor); ShaderProgram.SetFloat("scale", Runtime.BonePointSize * PointSize); ShaderProgram.SetMatrix4x4("ModelMatrix", ref modelMatrix); Matrix4 transform = bone.Transform; ShaderProgram.SetMatrix4x4("bone", ref transform); ShaderProgram.SetBoolToInt("hasParent", bone.ParentIndex != -1); if (bone.ParentIndex != -1) { var transformParent = bone.Parent.Transform; ShaderProgram.SetMatrix4x4("parent", ref transformParent); } Draw(ShaderProgram); ShaderProgram.SetInt("hasParent", 0); Draw(ShaderProgram); part++; } ShaderProgram.DisableVertexAttributes(); control.CurrentShader = null; GL.UseProgram(0); GL.Enable(EnableCap.CullFace); GL.Enable(EnableCap.DepthTest); } }
public override void Draw(GL_ControlModern control, Pass pass, EditorSceneBase editorScene) { if ((isHoverPickPass && IsSelected())) { return; } if (!ObjectRenderState.ShouldBeDrawn(this)) { return; } bool hovered = this.Hovered; Matrix3 rotMtx = GlobalRotation; bool positionChanged = false; var position = Position; var scale = Scale; if (editorScene.ExclusiveAction != NoAction && hovered) { position = editorScene.ExclusiveAction.NewPos(Position, out positionChanged); scale = editorScene.ExclusiveAction.NewScale(Scale, rotMtx); } else if (Selected && editorScene.CurrentAction != NoAction) { position = editorScene.CurrentAction.NewPos(Position, out positionChanged); scale = editorScene.CurrentAction.NewScale(Scale, rotMtx); } //Not necessary to update position on picking pass //That will only cause more slowdown if (positionChanged && pass != Pass.PICKING) { var newPosition = OnPositionChanged(position); if (newPosition != position) { /* if (editorScene.ExclusiveAction is TranslateAction) * ((TranslateAction)editorScene.ExclusiveAction).SetAxisXZ(); * if (editorScene.CurrentAction is TranslateAction) * ((TranslateAction)editorScene.CurrentAction).SetAxisXZ();*/ } position = newPosition; } if (position != Translate) { Translate = position; } if (hovered) { scale *= 1.2f; } if (position.Length != 0 && RenderableConnectedPath.ScaleByCamera) { scale *= 1 + ((control.CameraTarget.Length / position.Length) * RenderableConnectedPath.CameraScaleFactor); } control.UpdateModelMatrix( Matrix4.CreateScale(scale * BoxScale) * new Matrix4(Selected ? editorScene.CurrentAction.NewRot(rotMtx) : rotMtx) * Matrix4.CreateTranslation(position)); Vector4 blockColor; Vector4 lineColor; if (hovered && Selected) { lineColor = hoverSelectColor; } else if (Selected) { lineColor = selectColor; } else if (hovered) { lineColor = hoverColor; } else { lineColor = Color; } if (hovered && Selected) { blockColor = Color * 0.5f + hoverSelectColor * 0.5f; } else if (Selected) { blockColor = Color * 0.5f + selectColor * 0.5f; } else if (hovered) { blockColor = Color * 0.5f + hoverColor * 0.5f; } else { blockColor = Color; } if (IsPointOver) { blockColor = Color * 0.5f + hoverSelectColor * 0.5f; } DrawModel(control, editorScene, pass, blockColor, lineColor); }
public override void Draw(GL_ControlModern control, Pass pass, EditorSceneBase editorScene) { if (pass == Pass.TRANSPARENT) { return; } if (!ObjectRenderState.ShouldBeDrawn(this)) { return; } bool hovered = editorScene.Hovered == this; Matrix3 rotMtx = GlobalRotation; CurrentPosition = Selected ? editorScene.CurrentAction.NewPos(Position) : Position; control.UpdateModelMatrix( Matrix4.CreateScale((Selected ? editorScene.CurrentAction.NewScale(Scale, rotMtx) : Scale) * BoxScale) * new Matrix4(Selected ? editorScene.CurrentAction.NewRot(rotMtx) : rotMtx) * Matrix4.CreateTranslation(CurrentPosition)); Vector4 blockColor; Vector4 lineColor; if (hovered && Selected) { lineColor = hoverSelectColor; } else if (Selected) { lineColor = selectColor; } else if (hovered) { lineColor = hoverColor; } else { lineColor = Color; } if (hovered && Selected) { blockColor = Color * 0.5f + hoverSelectColor * 0.5f; } else if (Selected) { blockColor = Color * 0.5f + selectColor * 0.5f; } else if (hovered) { blockColor = Color * 0.5f + hoverColor * 0.5f; } else { blockColor = Color; } Renderers.ColorBlockRenderer.Draw(control, pass, blockColor, lineColor, control.NextPickingColor()); }