public void Draw() { // first calcuate the point and draw a point if (IsSelected) { GL.Color3(Color.Red); } else { GL.Color3(Color.GreenYellow); } Vector3 pos_c = Vector3.Transform(Vector3.Zero, transform); RenderTools.drawCube(pos_c, .1f); // now draw line between parent GL.Color3(Color.LightBlue); GL.LineWidth(2f); GL.Begin(PrimitiveType.Lines); if (Parent != null && Parent is Bone) { Vector3 pos_p = Vector3.Transform(Vector3.Zero, ((Bone)Parent).transform); GL.Vertex3(pos_c); GL.Color3(Color.Blue); GL.Vertex3(pos_p); } GL.End(); }
public void Draw() { Vector3 pos_c = Vector3.Transform(Vector3.Zero, transform); // first calcuate the point and draw a point if (IsSelected) { /*GL.Color3(Color.Red); * RenderTools.drawCircleOutline(pos_c, 2f, 30, Matrix4.CreateRotationX(0)); * GL.Color3(Color.Green); * RenderTools.drawCircleOutline(pos_c, 2f, 30, Matrix4.CreateRotationX(rot90)); * GL.Color3(Color.Gold); * RenderTools.drawCircleOutline(pos_c, 2f, 30, Matrix4.CreateRotationY(rot90));*/ GL.Color3(Color.Red); } else { GL.Color3(Color.GreenYellow); } RenderTools.drawCube(pos_c, .1f); // now draw line between parent GL.Color3(Color.LightBlue); GL.LineWidth(2f); GL.Begin(PrimitiveType.Lines); if (Parent != null && Parent is Bone) { Vector3 pos_p = Vector3.Transform(Vector3.Zero, ((Bone)Parent).transform); GL.Vertex3(pos_c); GL.Color3(Color.Blue); GL.Vertex3(pos_p); } GL.End(); }
public void RenderScaleTool(Camera Camera, Ray Ray) { Matrix4 mat = b.transform.ClearScale(); // Matrix4.CreateTranslation(b.transform.ExtractTranslation()); Vector3 center = Vector3.TransformPosition(Vector3.Zero, mat); if (state == 0) { _hiX = false; _hiY = false; _hiZ = false; Vector3 close; if (Ray.CheckSphereHit(center, 0.5f, out close)) { _hiX = true; _hiY = true; _hiZ = true; } else if (Ray.CheckSphereHit(Vector3.TransformPosition(new Vector3(2, 0, 0), mat), 0.5f, out close)) { _hiX = true; } else if (Ray.CheckSphereHit(Vector3.TransformPosition(new Vector3(0, 2, 0), mat), 0.5f, out close)) { _hiY = true; } else if (Ray.CheckSphereHit(Vector3.TransformPosition(new Vector3(0, 0, 2), mat), 0.5f, out close)) { _hiZ = true; } hit = true; if (!_hiX && !_hiZ && !_hiY) { hit = false; } } if (state == 1) { float sx = (Ray.mouse_x - PrevPoint.X) / 100; float sy = (Ray.mouse_y - PrevPoint.Y) / 100; float s = sx + sy; b.sca = b.sca + new Vector3(_hiX ? s : 0, _hiY ? s : 0, _hiZ ? s : 0); b.vbnParent.update(); } GL.PushMatrix(); GL.MultMatrix(ref mat); GL.LineWidth(2f); GL.Begin(PrimitiveType.Lines); GL.Color3(_hiX ? Color.Yellow : Color.Red); GL.Vertex3(0, 0, 0); GL.Vertex3(2, 0, 0); GL.Color3(_hiY ? Color.Yellow : Color.Green); GL.Vertex3(0, 0, 0); GL.Vertex3(0, 2, 0); GL.Color3(_hiZ ? Color.Yellow : Color.Blue); GL.Vertex3(0, 0, 0); GL.Vertex3(0, 0, 2); GL.End(); GL.Color3(_hiX ? Color.Yellow : Color.Red); RenderTools.drawCube(new Vector3(2, 0, 0), 0.25f); GL.Color3(_hiY ? Color.Yellow : Color.Green); RenderTools.drawCube(new Vector3(0, 2, 0), 0.25f); GL.Color3(_hiZ ? Color.Yellow : Color.Blue); RenderTools.drawCube(new Vector3(0, 0, 2), 0.25f); GL.PopMatrix(); }
public static void DrawVBN(VBN vbn) { if (vbn != null && Runtime.renderBones) { foreach (Bone bone in vbn.bones) { // first calcuate the point and draw a point if (bone == BoneTreePanel.selectedBone) { GL.Color3(Color.Red); } else { GL.Color3(Color.GreenYellow); } Vector3 pos_c = Vector3.Transform(Vector3.Zero, bone.transform); RenderTools.drawCube(pos_c, .085f); // if swing bones then draw swing radius if (vbn.swingBones.bones.Count > 0 && Runtime.renderSwag) { SB.SBEntry sb = null; vbn.swingBones.TryGetEntry(bone.boneId, out sb); if (sb != null) { // draw if (bone.ParentBone != null) { int i = bone.parentIndex; float degtorad = (float)(Math.PI / 180); Vector3 pos_sb = Vector3.Transform(Vector3.Zero, Matrix4.CreateTranslation(new Vector3(3, 3, 3)) * Matrix4.CreateScale(bone.sca) * Matrix4.CreateFromQuaternion(VBN.FromEulerAngles(sb.rx1 * degtorad, sb.ry1 * degtorad, sb.rz1 * degtorad)) * Matrix4.CreateTranslation(bone.pos) * vbn.bones[i].transform); Vector3 pos_sb2 = Vector3.Transform(Vector3.Zero, Matrix4.CreateTranslation(new Vector3(3, 3, 3)) * Matrix4.CreateScale(bone.sca) * Matrix4.CreateFromQuaternion(VBN.FromEulerAngles(sb.rx2 * degtorad, sb.ry2 * degtorad, sb.rz2 * degtorad)) * Matrix4.CreateTranslation(bone.pos) * vbn.bones[i].transform); GL.Color3(Color.ForestGreen); GL.Begin(PrimitiveType.LineLoop); GL.Vertex3(pos_c); GL.Vertex3(pos_sb); GL.Vertex3(pos_sb2); GL.End(); } } } // now draw line between parent GL.Color3(Color.LightBlue); GL.LineWidth(2f); GL.Begin(PrimitiveType.Lines); if (bone.ParentBone != null) { Vector3 pos_p = Vector3.Transform(Vector3.Zero, bone.ParentBone.transform); GL.Vertex3(pos_c); GL.Color3(Color.Blue); GL.Vertex3(pos_p); } GL.End(); } } }