public void Render(ViewControl vc, Matrix4F normWorld) { float s = Util.CalcAxisScale(vc.Camera, normWorld.Translation, Manipulator.AxisLength, vc.Height); Color xcolor = (m_hitRegion == HitRegion.XAxis || m_hitRegion == HitRegion.XYSquare || m_hitRegion == HitRegion.XZSquare) ? Color.Gold : Manipulator.XAxisColor; Color ycolor = (m_hitRegion == HitRegion.YAxis || m_hitRegion == HitRegion.XYSquare || m_hitRegion == HitRegion.YZSquare) ? Color.Gold : Manipulator.YAxisColor; Color Zcolor = (m_hitRegion == HitRegion.ZAxis || m_hitRegion == HitRegion.XZSquare || m_hitRegion == HitRegion.YZSquare) ? Color.Gold : Manipulator.ZAxisColor; Color XYx = m_hitRegion == HitRegion.XYSquare ? Color.Gold : Manipulator.XAxisColor; Color XYy = m_hitRegion == HitRegion.XYSquare ? Color.Gold : Manipulator.YAxisColor; Color XZx = m_hitRegion == HitRegion.XZSquare ? Color.Gold : Manipulator.XAxisColor; Color XZz = m_hitRegion == HitRegion.XZSquare ? Color.Gold : Manipulator.ZAxisColor; Color YZy = m_hitRegion == HitRegion.YZSquare ? Color.Gold : Manipulator.YAxisColor; Color YZz = m_hitRegion == HitRegion.YZSquare ? Color.Gold : Manipulator.ZAxisColor; var axisScale = new Matrix4F(); axisScale.Scale(new Vec3F(s * Manipulator.AxisThickness, s * (1 - ConeHeight), s * Manipulator.AxisThickness)); var axisrot = new Matrix4F(); // Draw X axis axisrot.RotZ(-MathHelper.PiOver2); Matrix4F scaleRot = axisScale * axisrot; Matrix4F axisXform = scaleRot * normWorld; Util3D.DrawCylinder(axisXform, xcolor); // draw y axisXform = axisScale * normWorld; Util3D.DrawCylinder(axisXform, ycolor); // draw z axisrot.RotX(MathHelper.PiOver2); scaleRot = axisScale * axisrot; axisXform = scaleRot * normWorld; Util3D.DrawCylinder(axisXform, Zcolor); // draw center cube. Matrix4F cubeScale = new Matrix4F(); cubeScale.Scale(CenterCube * s); var cubexform = cubeScale * normWorld; Util3D.DrawCube(cubexform, Color.White); Matrix4F arrowHead = ComputeXhead(normWorld, s); Util3D.DrawCone(arrowHead, xcolor); arrowHead = ComputeYhead(normWorld, s); Util3D.DrawCone(arrowHead, ycolor); arrowHead = ComputeZhead(normWorld, s); Util3D.DrawCone(arrowHead, Zcolor); // draw xy rect. Matrix4F scale = new Matrix4F(); scale.Scale(s * Manipulator.AxisThickness, s * SquareLength, s * Manipulator.AxisThickness); Matrix4F trans = new Matrix4F(); trans.Translation = new Vec3F(0, s * SquareLength, 0); Matrix4F rot = new Matrix4F(); rot.RotZ(-MathHelper.PiOver2); Matrix4F squareXform = scale * rot * trans * normWorld; Util3D.DrawCylinder(squareXform, XYy); trans.Translation = new Vec3F(s * SquareLength, 0, 0); squareXform = scale * trans * normWorld; Util3D.DrawCylinder(squareXform, XYx); // draw xz rect. trans.Translation = new Vec3F(0, 0, s * SquareLength); rot.RotZ(-MathHelper.PiOver2); squareXform = scale * rot * trans * normWorld; Util3D.DrawCylinder(squareXform, XZz); trans.Translation = new Vec3F(s * SquareLength, 0, 0); rot.RotX(MathHelper.PiOver2); squareXform = scale * rot * trans * normWorld; Util3D.DrawCylinder(squareXform, XZx); // draw yz trans.Translation = new Vec3F(0, s * SquareLength, 0); rot.RotX(MathHelper.PiOver2); squareXform = scale * rot * trans * normWorld; Util3D.DrawCylinder(squareXform, YZy); trans.Translation = new Vec3F(0, 0, s * SquareLength); squareXform = scale * trans * normWorld; Util3D.DrawCylinder(squareXform, YZz); }
public void Render(Matrix4F normWorld, float s) { BasicRendererFlags solid = BasicRendererFlags.Solid | BasicRendererFlags.DisableDepthTest; BasicRendererFlags wire = BasicRendererFlags.WireFrame | BasicRendererFlags.DisableDepthTest; Color xcolor = (m_hitRegion == HitRegion.XAxis || m_hitRegion == HitRegion.XYSquare || m_hitRegion == HitRegion.XZSquare) ? Color.Gold : Color.Red; Color ycolor = (m_hitRegion == HitRegion.YAxis || m_hitRegion == HitRegion.XYSquare || m_hitRegion == HitRegion.YZSquare) ? Color.Gold : Color.Green; Color Zcolor = (m_hitRegion == HitRegion.ZAxis || m_hitRegion == HitRegion.XZSquare || m_hitRegion == HitRegion.YZSquare) ? Color.Gold : Color.Blue; Color XYx = m_hitRegion == HitRegion.XYSquare ? Color.Gold : Color.Red; Color XYy = m_hitRegion == HitRegion.XYSquare ? Color.Gold : Color.Green; Color XZx = m_hitRegion == HitRegion.XZSquare ? Color.Gold : Color.Red; Color XZz = m_hitRegion == HitRegion.XZSquare ? Color.Gold : Color.Blue; Color YZy = m_hitRegion == HitRegion.YZSquare ? Color.Gold : Color.Green; Color YZz = m_hitRegion == HitRegion.YZSquare ? Color.Gold : Color.Blue; Vec3F axScale = new Vec3F(s, s, s); Matrix4F axisXform = ComputeAxis(normWorld, axScale); Util3D.RenderFlag = wire; Util3D.DrawX(axisXform, xcolor); Util3D.DrawY(axisXform, ycolor); Util3D.DrawZ(axisXform, Zcolor); Matrix4F arrowHead = ComputeXhead(normWorld, s); Util3D.RenderFlag = solid; Util3D.DrawCone(arrowHead, xcolor); arrowHead = ComputeYhead(normWorld, s); Util3D.DrawCone(arrowHead, ycolor); arrowHead = ComputeZhead(normWorld, s); Util3D.DrawCone(arrowHead, Zcolor); Util3D.RenderFlag = wire; // draw xy rect. Matrix4F scale = new Matrix4F(); scale.Scale(axScale * SquareLength); Matrix4F trans = new Matrix4F(); trans.Translation = new Vec3F(0, s * SquareLength, 0); Matrix4F squareXform = scale * trans * normWorld; Util3D.DrawX(squareXform, XYy); trans.Translation = new Vec3F(s * SquareLength, 0, 0); squareXform = scale * trans * normWorld; Util3D.DrawY(squareXform, XYx); // draw xz rect. trans.Translation = new Vec3F(0, 0, s * SquareLength); squareXform = scale * trans * normWorld; Util3D.DrawX(squareXform, XZz); trans.Translation = new Vec3F(s * SquareLength, 0, 0); squareXform = scale * trans * normWorld; Util3D.DrawZ(squareXform, XZx); // draw yz trans.Translation = new Vec3F(0, s * SquareLength, 0); squareXform = scale * trans * normWorld; Util3D.DrawZ(squareXform, YZy); trans.Translation = new Vec3F(0, 0, s * SquareLength); squareXform = scale * trans * normWorld; Util3D.DrawY(squareXform, YZz); }