private unsafe void RenderCatchCollision(Vector3 cam) { ResourceNode[] bl = _model._linker.BoneCache; int boneindex = _parameters[1]; int size = HitboxSize; Root.GetBoneIndex(ref boneindex); if (boneindex == 0) // if a hitbox is on TopN, make it follow TransN { if (Root.Data != null) { boneindex = Root.Data._misc._boneRefs[4].boneIndex; Root.GetBoneIndex(ref boneindex); } else { int transindex = 0; foreach (MDL0BoneNode bn in bl) { if (bn.Name.Equals("TransN")) { break; } transindex++; } if (transindex != bl.Length) { boneindex = transindex; } } } MDL0BoneNode b = bl[boneindex] as MDL0BoneNode; Matrix r = b.Matrix.GetRotationMatrix(); FrameState state = b.Matrix.Derive(); Vector3 bonePos = state._translate; Vector3 pos = new Vector3(Util.UnScalar(_parameters[3]), Util.UnScalar(_parameters[4]), Util.UnScalar(_parameters[5])) / state._scale; Vector3 globalPos = r.Multiply(pos); Matrix m = Matrix.TransformMatrix(new Vector3(1), state._rotate, globalPos + bonePos); Vector3 resultPos = m.GetPoint(); m = Matrix.TransformMatrix(new Vector3(Util.UnScalar(size)), new Vector3(), resultPos); GL.PushMatrix(); GL.MultMatrix((float *)&m); int res = 16; double drawangle = 360.0 / res; Vector3 color = Util.GetTypeColor(Util.HitboxType.Throwing); GL.Color4((color._x / 255.0f), (color._y / 225.0f), (color._z / 255.0f), 0.375f); GLDisplayList spheres = TKContext.GetSphereList(); spheres.Call(); GL.PopMatrix(); }
public unsafe override void modelPanel1_PostRender(GLPanel sender) { GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Disable(EnableCap.Lighting); GL.Disable(EnableCap.DepthTest); Attributes.PostRender(); //Render hurtboxes if (chkHurtboxes.Checked) { for (int i = 0; i < listPanel.lstHurtboxes.Items.Count; i++) { if (listPanel.lstHurtboxes.GetItemChecked(i)) { ((MiscHurtBox)listPanel.lstHurtboxes.Items[i]).Render(SelectedHurtbox != null && SelectedHurtbox.Index == i, Scriptor._hurtBoxType); } } } //Render hitboxes if (chkHitboxes.Checked && Manager.Moveset != null) { GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); GLDisplayList c = TKContext.GetRingList(); GLDisplayList s = TKContext.GetSphereList(); foreach (HitBox e in RunTime._hitBoxes) { e.Render(modelPanel.Camera.GetPoint()); } } base.modelPanel1_PostRender(sender); }
private unsafe void modelPanel1_PostRender(object sender, TKContext context) { //GL.LineWidth(2.0f); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Disable(EnableCap.Lighting); GL.Disable(EnableCap.DepthTest); //Attributes.PostRender(); //Render hurtboxes if (chkHurtboxes.Checked) { for (int i = 0; i < listPanel.lstHurtboxes.Items.Count; i++) { if (listPanel.lstHurtboxes.GetItemChecked(i)) { ((MiscHurtBox)listPanel.lstHurtboxes.Items[i]).Render(SelectedHurtbox != null && SelectedHurtbox.Index == i, Scriptor._hurtBoxType); } } } //Render hitboxes if (chkHitboxes.Checked && Manager.Moveset != null) { GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); GLDisplayList c = context.GetRingList(); GLDisplayList s = context.GetSphereList(); foreach (HitBox e in RunTime._hitBoxes) { e.Render(context, modelPanel._camera.GetPoint()); } } GL.Enable(EnableCap.DepthTest); //Show the user where the light source is if (_renderLightDisplay) { GL.PushAttrib(AttribMask.AllAttribBits); GL.Color4(Color.Blue); GL.Disable(EnableCap.Lighting); GL.Disable(EnableCap.DepthTest); GL.Scale(modelPanel.LightPosition._x, modelPanel.LightPosition._x, modelPanel.LightPosition._x); GL.Rotate(90.0f, 1, 0, 0); float azimuth = modelPanel.LightPosition._y.Clamp180Deg(); float elevation = modelPanel.LightPosition._z.Clamp180Deg(); if (Math.Abs(azimuth) == Math.Abs(elevation) && azimuth % 180.0f == 0 && elevation % 180.0f == 0) { azimuth = 0; elevation = 0; } int i; float x; float e = azimuth; bool flip = false; if (e < 0) { e = -e; flip = true; GL.Rotate(180.0f, 1, 0, 0); } float f = (float)((int)e); float diff = (float)Math.Round(e - f, 1); GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Lines); for (i = 0; i < f; i++) { GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf)); GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf)); } for (x = 0; x < diff; x += 0.1f) { GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf)); GL.Vertex2(Math.Cos((x + 0.1f + (float)i) * Maths._deg2radf), Math.Sin((x + 0.1f + (float)i) * Maths._deg2radf)); } GL.End(); if (flip) { GL.Rotate(-180.0f, 1, 0, 0); } GL.Rotate(90.0f, 0, 1, 0); GL.Rotate(90.0f, 0, 0, 1); GL.Rotate(180.0f, 1, 0, 0); GL.Rotate(90.0f - azimuth, 0, 1, 0); e = elevation; if (e < 0) { e = -e; GL.Rotate(180.0f, 1, 0, 0); } f = (float)((int)e); diff = (float)Math.Round(e - f, 1); GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Lines); for (i = 0; i < f; i++) { GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf)); GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf)); } for (x = 0; x < diff; x += 0.1f) { GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf)); GL.Vertex2(Math.Cos((x + 0.1f + (float)i) * Maths._deg2radf), Math.Sin((x + 0.1f + (float)i) * Maths._deg2radf)); } GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf)); GL.Color4(Color.Orange); GL.Vertex3(0, 0, 0); GL.End(); GL.PopAttrib(); } GL.Clear(ClearBufferMask.DepthBufferBit); RenderTransformControl(context); if (!modelPanel._grabbing && !modelPanel._scrolling && !_playing) { GL.Color4(Color.Black); GL.ColorMask(false, false, false, false); if (RenderBones) { //Render invisible depth orbs GLDisplayList list = context.GetSphereList(); if (_editingAll) { foreach (MDL0Node m in _targetModels) { foreach (MDL0BoneNode bone in m._linker.BoneCache) { if (bone != SelectedBone) { RenderOrb(bone, list); } } } } else if (TargetModel != null && TargetModel._linker != null && TargetModel._linker.BoneCache != null) { foreach (MDL0BoneNode bone in _targetModel._linker.BoneCache) { if (bone != SelectedBone) { RenderOrb(bone, list); } } } } //Render invisible depth planes for translation and scale controls if (_editType != 0 && SelectedBone != null && RenderBones) { #region Axis Selection Display List GLDisplayList selList = new GLDisplayList(); selList.Begin(); GL.Begin(BeginMode.Quads); //X Axis //XY quad GL.Vertex3(0.0f, -_axisSelectRange, 0.0f); GL.Vertex3(0.0f, _axisSelectRange, 0.0f); GL.Vertex3(_axisLDist, _axisSelectRange, 0.0f); GL.Vertex3(_axisLDist, -_axisSelectRange, 0.0f); //XZ quad GL.Vertex3(0.0f, 0.0f, -_axisSelectRange); GL.Vertex3(0.0f, 0.0f, _axisSelectRange); GL.Vertex3(_axisLDist, 0.0f, _axisSelectRange); GL.Vertex3(_axisLDist, 0.0f, -_axisSelectRange); //Y Axis //YX quad GL.Vertex3(-_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, _axisLDist, 0.0f); GL.Vertex3(-_axisSelectRange, _axisLDist, 0.0f); //YZ quad GL.Vertex3(0.0f, 0.0f, -_axisSelectRange); GL.Vertex3(0.0f, 0.0f, _axisSelectRange); GL.Vertex3(0.0f, _axisLDist, _axisSelectRange); GL.Vertex3(0.0f, _axisLDist, -_axisSelectRange); //Z Axis //ZX quad GL.Vertex3(-_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, _axisLDist); GL.Vertex3(-_axisSelectRange, 0.0f, _axisLDist); //ZY quad GL.Vertex3(0.0f, -_axisSelectRange, 0.0f); GL.Vertex3(0.0f, _axisSelectRange, 0.0f); GL.Vertex3(0.0f, _axisSelectRange, _axisLDist); GL.Vertex3(0.0f, -_axisSelectRange, _axisLDist); GL.End(); selList.End(); #endregion if (_editType != 0 && SelectedBone != null) { Matrix m = Matrix.TransformMatrix(new Vector3(OrbRadius), new Vector3(), BoneLoc); GL.PushMatrix(); GL.MultMatrix((float *)&m); selList.Call(); if (_editType == TransformType.Translation) { GL.Begin(BeginMode.Quads); //XY GL.Vertex3(0.0f, _axisSelectRange, 0.0f); GL.Vertex3(_axisHalfLDist, _axisSelectRange, 0.0f); GL.Vertex3(_axisHalfLDist, _axisHalfLDist, 0.0f); GL.Vertex3(0.0f, _axisHalfLDist, 0.0f); //YZ GL.Vertex3(0.0f, 0.0f, _axisSelectRange); GL.Vertex3(0.0f, _axisHalfLDist, _axisSelectRange); GL.Vertex3(0.0f, _axisHalfLDist, _axisHalfLDist); GL.Vertex3(0.0f, 0.0f, _axisHalfLDist); //XZ GL.Vertex3(_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, _axisHalfLDist); GL.Vertex3(_axisHalfLDist, 0.0f, _axisHalfLDist); GL.Vertex3(_axisHalfLDist, 0.0f, 0.0f); GL.End(); } else { GL.Begin(BeginMode.Triangles); //XY GL.Vertex3(0.0f, _axisSelectRange, 0.0f); GL.Vertex3(_scaleHalf2LDist, _axisSelectRange, 0.0f); GL.Vertex3(0.0f, _scaleHalf2LDist, 0.0f); //YZ GL.Vertex3(0.0f, 0.0f, _axisSelectRange); GL.Vertex3(0.0f, _scaleHalf2LDist, _axisSelectRange); GL.Vertex3(0.0f, 0.0f, _scaleHalf2LDist); //XZ GL.Vertex3(_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, _scaleHalf2LDist); GL.Vertex3(_scaleHalf2LDist, 0.0f, 0.0f); GL.End(); } GL.PopMatrix(); } } GL.ColorMask(true, true, true, true); } }
public virtual unsafe void RenderDepth(ModelPanelViewport v) { if (v._grabbing || v._scrolling || _playing) { return; } GL.Enable(EnableCap.DepthTest); GL.DepthFunc(DepthFunction.Always); GL.Color4(Color.Black); #if DEBUG GL.ColorMask(_renderDepth, false, false, false); #else GL.ColorMask(false, false, false, false); #endif if (v._renderAttrib._renderVertices) { if (EditingAll && _targetModels != null) { foreach (IModel m in _targetModels) { m.RenderVertices(true, SelectedBone, v.Camera); } } else { TargetModel?.RenderVertices(true, SelectedBone, v.Camera); } } if (v._renderAttrib._renderBones) { //Render invisible depth orbs GLDisplayList list = TKContext.GetSphereList(); bool doScale = v._renderAttrib._scaleBones; if (EditingAll) { foreach (IModel m in _targetModels) { foreach (IBoneNode bone in m.BoneCache) { if (bone != SelectedBone) { RenderOrb(bone, list, v, doScale); } } } } else if (TargetModel != null) { foreach (IBoneNode bone in _targetModel.BoneCache) { if (bone != SelectedBone) { RenderOrb(bone, list, v, doScale); } } } } GL.ColorMask(true, true, true, true); }
public static unsafe void OnRenderLightDisplay(ModelPanelViewport v) { GL.PushAttrib(AttribMask.AllAttribBits); GL.MatrixMode(MatrixMode.Modelview); GL.PushMatrix(); GL.Color4(Color.Blue); GL.Disable(EnableCap.Lighting); //GL.Disable(EnableCap.DepthTest); Vector4 lightPos = v.LightPosition; if (!v.LightDirectional) { GL.Enable(EnableCap.DepthTest); Vector3 pos = (Vector3)v._posLight; GLDisplayList list = TKContext.GetSphereList(); GL.Translate((OpenTK.Vector3)pos); GL.Color4(Color.FromArgb(120, 100, 100, 255)); //Matrix m = CameraFacingRotationMatrix(v.Camera, pos); //GL.MultMatrix((float*)&m); GL.Scale(lightPos._x, lightPos._x, lightPos._x); list.Call(); } else { GL.Disable(EnableCap.DepthTest); GL.Scale(lightPos._x, lightPos._x, lightPos._x); GL.Rotate(90.0f, 1, 0, 0); float azimuth = lightPos._y.RemapToRange(-180.0f, 180.0f), elevation = lightPos._z.RemapToRange(-180.0f, 180.0f); if (Math.Abs(azimuth) == Math.Abs(elevation) && azimuth % 180.0f == 0 && elevation % 180.0f == 0) { azimuth = 0; elevation = 0; } int i; float e = azimuth, x; bool flip = false; if (e < 0) { e = -e; flip = true; GL.Rotate(180.0f, 1, 0, 0); } float f = (int)e; float diff = (float)Math.Round(e - f, 1); GL.Begin(BeginMode.Lines); for (i = 0; i < f; i++) { GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf)); GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf)); } for (x = 0; x < diff; x += 0.1f) { GL.Vertex2(Math.Cos((x + i) * Maths._deg2radf), Math.Sin((x + i) * Maths._deg2radf)); GL.Vertex2(Math.Cos((x + 0.1f + i) * Maths._deg2radf), Math.Sin((x + 0.1f + i) * Maths._deg2radf)); } GL.End(); if (flip) { GL.Rotate(-180.0f, 1, 0, 0); } GL.Rotate(90.0f, 0, 1, 0); GL.Rotate(90.0f, 0, 0, 1); GL.Rotate(180.0f, 1, 0, 0); GL.Rotate(90.0f - azimuth, 0, 1, 0); e = elevation; if (e < 0) { e = -e; GL.Rotate(180.0f, 1, 0, 0); } f = (int)e; diff = (float)Math.Round(e - f, 1); GL.Begin(BeginMode.Lines); for (i = 0; i < f; i++) { GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf)); GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf)); } for (x = 0; x < diff; x += 0.1f) { GL.Vertex2(Math.Cos((x + i) * Maths._deg2radf), Math.Sin((x + i) * Maths._deg2radf)); GL.Vertex2(Math.Cos((x + 0.1f + i) * Maths._deg2radf), Math.Sin((x + 0.1f + i) * Maths._deg2radf)); } GL.Vertex2(Math.Cos((x + i) * Maths._deg2radf), Math.Sin((x + i) * Maths._deg2radf)); GL.Color4(Color.Orange); GL.Vertex3(0, 0, 0); GL.End(); GL.Scale(0.01f, 0.01f, 0.01f); GL.Rotate(azimuth, 0, 1, 0); GL.Enable(EnableCap.DepthTest); GL.PopAttrib(); GL.PopMatrix(); } }
private unsafe void RenderOffensiveCollision(Vector3 cam) { MovesetNode node = Root; ResourceNode[] bl = _model._linker.BoneCache; int boneindex = (int)_parameters[0] >> 16; int size = HitboxSize; int angle = _parameters[2]; node.GetBoneIndex(ref boneindex); if (boneindex == 0) //If a hitbox is on TopN, make it follow TransN { //Use assigned references if (node.Data != null) { boneindex = node.Data._misc._boneRefs[4].boneIndex; node.GetBoneIndex(ref boneindex); } else //Search manually { int transindex = 0; foreach (MDL0BoneNode bn in bl) { if (bn.Name.Equals("TransN")) { break; } transindex++; } if (transindex != bl.Length) { boneindex = transindex; } } } MDL0BoneNode b; b = bl[boneindex] as MDL0BoneNode; Matrix r = b.Matrix.GetRotationMatrix(); FrameState state = b.Matrix.Derive(); Vector3 bonePos = state._translate; Vector3 globalPos = r.Multiply(new Vector3(Util.UnScalar(_parameters[6]), Util.UnScalar(_parameters[7]), Util.UnScalar(_parameters[8])) / state._scale); Matrix m = Matrix.TransformMatrix(new Vector3(1), state._rotate, globalPos + bonePos); Vector3 resultPos = m.GetPoint(); int id = (int)_parameters[0] & 0xFFFF; RunTime.MainWindow.ModelPanel.CurrentViewport.ScreenText[id.ToString()] = RunTime.MainWindow.ModelPanel.CurrentViewport.Camera.Project(resultPos); m = Matrix.TransformMatrix(new Vector3(Util.UnScalar(size)), new Vector3(), resultPos); GL.PushMatrix(); GL.MultMatrix((float *)&m); int res = 16; double drawAngle = 360.0 / res; Vector3 color = Util.GetTypeColor(flags.Type); GL.Color4((color._x / 255.0f), (color._y / 225.0f), (color._z / 255.0f), 0.5f); GLDisplayList spheres = TKContext.GetSphereList(); spheres.Call(); //Angle indicator double rangle = angle / 180.0 * Math.PI; //Apply color color = Util.GetEffectColor(flags.Effect); GL.Color4((color._x / 255.0f), (color._y / 225.0f), (color._z / 255.0f), 0.75f); GL.PushMatrix(); if (angle == 361) //Sakurai angle { m = Matrix.TransformMatrix(new Vector3(0.5f), (globalPos + bonePos).LookatAngles(cam) * Maths._rad2degf, new Vector3(0)); GL.MultMatrix((float *)&m); GL.Begin(BeginMode.Quads); for (int i = 0; i < 16; i += 2) { GL.Vertex3(Math.Cos((i - 1) * Math.PI / 8) * 0.5, Math.Sin((i - 1) * Math.PI / 8) * 0.5, 0); GL.Vertex3(Math.Cos(i * Math.PI / 8), Math.Sin(i * Math.PI / 8), 0); GL.Vertex3(Math.Cos((i + 1) * Math.PI / 8) * 0.5, Math.Sin((i + 1) * Math.PI / 8) * 0.5, 0); GL.Vertex3(0, 0, 0); } GL.End(); } else { long a = -angle; //Otherwise 90 would point down int angleflip = 0; if (resultPos._z < 0) { angleflip = 180; } m = Matrix.TransformMatrix(new Vector3(1), new Vector3(a, angleflip, 0), new Vector3()); GL.MultMatrix((float *)&m); GL.Begin(BeginMode.Quads); // left face GL.Vertex3(0.1, 0.1, 0); GL.Vertex3(0.1, 0.1, 1); GL.Vertex3(0.1, -0.1, 1); GL.Vertex3(0.1, -0.1, 0); // right face GL.Vertex3(-0.1, -0.1, 0); GL.Vertex3(-0.1, -0.1, 1); GL.Vertex3(-0.1, 0.1, 1); GL.Vertex3(-0.1, 0.1, 0); // top face GL.Vertex3(-0.1, 0.1, 0); GL.Vertex3(-0.1, 0.1, 1); GL.Vertex3(0.1, 0.1, 1); GL.Vertex3(0.1, 0.1, 0); // bottom face GL.Vertex3(0.1, -0.1, 0); GL.Vertex3(0.1, -0.1, 1); GL.Vertex3(-0.1, -0.1, 1); GL.Vertex3(-0.1, -0.1, 0); // front face GL.Vertex3(-0.1, -0.1, 1); GL.Vertex3(0.1, -0.1, 1); GL.Vertex3(0.1, 0.1, 1); GL.Vertex3(-0.1, 0.1, 1); // back face GL.Vertex3(-0.1, 0.1, 0); GL.Vertex3(0.1, 0.1, 0); GL.Vertex3(0.1, -0.1, 0); GL.Vertex3(-0.1, -0.1, 0); GL.End(); } GL.PopMatrix(); // border GLDisplayList rings = TKContext.GetRingList(); for (int i = -5; i <= 5; i++) { GL.PushMatrix(); m = Matrix.TransformMatrix(new Vector3(1 + 0.0025f * i), (globalPos + bonePos).LookatAngles(cam) * Maths._rad2degf, new Vector3()); GL.MultMatrix((float *)&m); if (flags.Clang) { rings.Call(); } else { for (double j = 0; j < 360 / (drawAngle / 2); j += 2) { double ang1 = (j * (drawAngle / 2)) / 180 * Math.PI; double ang2 = ((j + 1) * (drawAngle / 2)) / 180 * Math.PI; GL.Begin(BeginMode.LineStrip); GL.Vertex3(Math.Cos(ang1), Math.Sin(ang1), 0); GL.Vertex3(Math.Cos(ang2), Math.Sin(ang2), 0); GL.End(); } } GL.PopMatrix(); } GL.PopMatrix(); GL.PopMatrix(); }
private unsafe void modelPanel1_PostRender(object sender, TKContext context) { GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Disable(EnableCap.Lighting); GL.Enable(EnableCap.DepthTest); if (RenderVertices) { if (_editingAll && _targetModels != null) { foreach (MDL0Node m in _targetModels) { m.RenderVertices(context, false); } } else if (TargetModel != null) { TargetModel.RenderVertices(context, false); } } if (RenderNormals) { if (_editingAll && _targetModels != null) { foreach (MDL0Node m in _targetModels) { m.RenderNormals(context); } } else if (TargetModel != null) { TargetModel.RenderNormals(context); } } //Show the user where the light source is if (_renderLightDisplay) { GL.Color4(Color.Blue); GL.Disable(EnableCap.Lighting); GL.Disable(EnableCap.DepthTest); GL.Scale(ModelPanel.LightPosition._x, ModelPanel.LightPosition._x, ModelPanel.LightPosition._x); GL.Rotate(90.0f, 1, 0, 0); float azimuth = ModelPanel.LightPosition._y.Clamp180Deg(); float elevation = ModelPanel.LightPosition._z.Clamp180Deg(); if (Math.Abs(azimuth) == Math.Abs(elevation) && azimuth % 180.0f == 0 && elevation % 180.0f == 0) { azimuth = 0; elevation = 0; } int i; float x; float e = azimuth; bool flip = false; if (e < 0) { e = -e; flip = true; GL.Rotate(180.0f, 1, 0, 0); } float f = (float)((int)e); float diff = (float)Math.Round(e - f, 1); GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Lines); for (i = 0; i < f; i++) { GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf)); GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf)); } for (x = 0; x < diff; x += 0.1f) { GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf)); GL.Vertex2(Math.Cos((x + 0.1f + (float)i) * Maths._deg2radf), Math.Sin((x + 0.1f + (float)i) * Maths._deg2radf)); } GL.End(); if (flip) { GL.Rotate(-180.0f, 1, 0, 0); } GL.Rotate(90.0f, 0, 1, 0); GL.Rotate(90.0f, 0, 0, 1); GL.Rotate(180.0f, 1, 0, 0); GL.Rotate(90.0f - azimuth, 0, 1, 0); e = elevation; if (e < 0) { e = -e; GL.Rotate(180.0f, 1, 0, 0); } f = (float)((int)e); diff = (float)Math.Round(e - f, 1); GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Lines); for (i = 0; i < f; i++) { GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf)); GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf)); } for (x = 0; x < diff; x += 0.1f) { GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf)); GL.Vertex2(Math.Cos((x + 0.1f + (float)i) * Maths._deg2radf), Math.Sin((x + 0.1f + (float)i) * Maths._deg2radf)); } GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf)); GL.Color4(Color.Orange); GL.Vertex3(0, 0, 0); GL.End(); } GL.Clear(ClearBufferMask.DepthBufferBit); RenderSCN0Controls(context); RenderTransformControl(context); if (!ModelPanel._grabbing && !ModelPanel._scrolling && !_playing) { GL.Color4(Color.Black); GL.ColorMask(false, false, false, false); if (RenderVertices) { if (_editingAll && _targetModels != null) { foreach (MDL0Node m in _targetModels) { m.RenderVertices(context, true); } } else if (TargetModel != null) { TargetModel.RenderVertices(context, true); } } if (RenderBones) { //Render invisible depth orbs GLDisplayList list = context.GetSphereList(); if (_editingAll) { foreach (MDL0Node m in _targetModels) { foreach (MDL0BoneNode bone in m._linker.BoneCache) { if (bone != SelectedBone) { RenderOrb(bone, list); } } } } else if (TargetModel != null && TargetModel._linker != null && TargetModel._linker.BoneCache != null) { foreach (MDL0BoneNode bone in _targetModel._linker.BoneCache) { if (bone != SelectedBone) { RenderOrb(bone, list); } } } } //Render invisible depth planes for translation and scale controls if (_editType != TransformType.Rotation && ((SelectedBone != null && RenderBones) || (VertexLoc != null && RenderVertices))) { #region Axis Selection Display List GLDisplayList selList = new GLDisplayList(); selList.Begin(); GL.Begin(BeginMode.Quads); //X Axis //XY quad GL.Vertex3(0.0f, -_axisSelectRange, 0.0f); GL.Vertex3(0.0f, _axisSelectRange, 0.0f); GL.Vertex3(_axisLDist, _axisSelectRange, 0.0f); GL.Vertex3(_axisLDist, -_axisSelectRange, 0.0f); //XZ quad GL.Vertex3(0.0f, 0.0f, -_axisSelectRange); GL.Vertex3(0.0f, 0.0f, _axisSelectRange); GL.Vertex3(_axisLDist, 0.0f, _axisSelectRange); GL.Vertex3(_axisLDist, 0.0f, -_axisSelectRange); //Y Axis //YX quad GL.Vertex3(-_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, _axisLDist, 0.0f); GL.Vertex3(-_axisSelectRange, _axisLDist, 0.0f); //YZ quad GL.Vertex3(0.0f, 0.0f, -_axisSelectRange); GL.Vertex3(0.0f, 0.0f, _axisSelectRange); GL.Vertex3(0.0f, _axisLDist, _axisSelectRange); GL.Vertex3(0.0f, _axisLDist, -_axisSelectRange); //Z Axis //ZX quad GL.Vertex3(-_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, _axisLDist); GL.Vertex3(-_axisSelectRange, 0.0f, _axisLDist); //ZY quad GL.Vertex3(0.0f, -_axisSelectRange, 0.0f); GL.Vertex3(0.0f, _axisSelectRange, 0.0f); GL.Vertex3(0.0f, _axisSelectRange, _axisLDist); GL.Vertex3(0.0f, -_axisSelectRange, _axisLDist); GL.End(); selList.End(); #endregion if (_editType != TransformType.Rotation && SelectedBone != null) { Matrix m = Matrix.TransformMatrix(new Vector3(OrbRadius), new Vector3(), BoneLoc); GL.PushMatrix(); GL.MultMatrix((float *)&m); selList.Call(); if (_editType == TransformType.Translation) { GL.Begin(BeginMode.Quads); //XY GL.Vertex3(0.0f, _axisSelectRange, 0.0f); GL.Vertex3(_axisHalfLDist, _axisSelectRange, 0.0f); GL.Vertex3(_axisHalfLDist, _axisHalfLDist, 0.0f); GL.Vertex3(0.0f, _axisHalfLDist, 0.0f); //YZ GL.Vertex3(0.0f, 0.0f, _axisSelectRange); GL.Vertex3(0.0f, _axisHalfLDist, _axisSelectRange); GL.Vertex3(0.0f, _axisHalfLDist, _axisHalfLDist); GL.Vertex3(0.0f, 0.0f, _axisHalfLDist); //XZ GL.Vertex3(_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, _axisHalfLDist); GL.Vertex3(_axisHalfLDist, 0.0f, _axisHalfLDist); GL.Vertex3(_axisHalfLDist, 0.0f, 0.0f); GL.End(); } else { GL.Begin(BeginMode.Triangles); //XY GL.Vertex3(0.0f, _axisSelectRange, 0.0f); GL.Vertex3(_scaleHalf2LDist, _axisSelectRange, 0.0f); GL.Vertex3(0.0f, _scaleHalf2LDist, 0.0f); //YZ GL.Vertex3(0.0f, 0.0f, _axisSelectRange); GL.Vertex3(0.0f, _scaleHalf2LDist, _axisSelectRange); GL.Vertex3(0.0f, 0.0f, _scaleHalf2LDist); //XZ GL.Vertex3(_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, _scaleHalf2LDist); GL.Vertex3(_scaleHalf2LDist, 0.0f, 0.0f); GL.End(); } GL.PopMatrix(); } if (VertexLoc != null && RenderVertices) { Matrix m = Matrix.TransformMatrix(new Vector3(VertexOrbRadius), new Vector3(), ((Vector3)VertexLoc)); GL.PushMatrix(); GL.MultMatrix((float *)&m); selList.Call(); GL.Begin(BeginMode.Quads); //XY GL.Vertex3(0.0f, _axisSelectRange, 0.0f); GL.Vertex3(_axisHalfLDist, _axisSelectRange, 0.0f); GL.Vertex3(_axisHalfLDist, _axisHalfLDist, 0.0f); GL.Vertex3(0.0f, _axisHalfLDist, 0.0f); //YZ GL.Vertex3(0.0f, 0.0f, _axisSelectRange); GL.Vertex3(0.0f, _axisHalfLDist, _axisSelectRange); GL.Vertex3(0.0f, _axisHalfLDist, _axisHalfLDist); GL.Vertex3(0.0f, 0.0f, _axisHalfLDist); //XZ GL.Vertex3(_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, _axisHalfLDist); GL.Vertex3(_axisHalfLDist, 0.0f, _axisHalfLDist); GL.Vertex3(_axisHalfLDist, 0.0f, 0.0f); GL.End(); GL.PopMatrix(); } } GL.ColorMask(true, true, true, true); } }
private unsafe void modelPanel1_PostRender(object sender, TKContext context) { GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Disable(EnableCap.Lighting); GL.Enable(EnableCap.DepthTest); if (RenderVertices) if (_editingAll && _targetModels != null) foreach (MDL0Node m in _targetModels) m.RenderVertices(context, false); else if (TargetModel != null) TargetModel.RenderVertices(context, false); if (RenderNormals) if (_editingAll && _targetModels != null) foreach (MDL0Node m in _targetModels) m.RenderNormals(context); else if (TargetModel != null) TargetModel.RenderNormals(context); //Show the user where the light source is if (_renderLightDisplay) { GL.Color4(Color.Blue); GL.Disable(EnableCap.Lighting); GL.Disable(EnableCap.DepthTest); GL.Scale(ModelPanel.LightPosition._x, ModelPanel.LightPosition._x, ModelPanel.LightPosition._x); GL.Rotate(90.0f, 1, 0, 0); float azimuth = ModelPanel.LightPosition._y.Clamp180Deg(); float elevation = ModelPanel.LightPosition._z.Clamp180Deg(); if (Math.Abs(azimuth) == Math.Abs(elevation) && azimuth % 180.0f == 0 && elevation % 180.0f == 0) { azimuth = 0; elevation = 0; } int i; float x; float e = azimuth; bool flip = false; if (e < 0) { e = -e; flip = true; GL.Rotate(180.0f, 1, 0, 0); } float f = (float)((int)e); float diff = (float)Math.Round(e - f, 1); GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Lines); for (i = 0; i < f; i++) { GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf)); GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf)); } for (x = 0; x < diff; x += 0.1f) { GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf)); GL.Vertex2(Math.Cos((x + 0.1f + (float)i) * Maths._deg2radf), Math.Sin((x + 0.1f + (float)i) * Maths._deg2radf)); } GL.End(); if (flip) GL.Rotate(-180.0f, 1, 0, 0); GL.Rotate(90.0f, 0, 1, 0); GL.Rotate(90.0f, 0, 0, 1); GL.Rotate(180.0f, 1, 0, 0); GL.Rotate(90.0f - azimuth, 0, 1, 0); e = elevation; if (e < 0) { e = -e; GL.Rotate(180.0f, 1, 0, 0); } f = (float)((int)e); diff = (float)Math.Round(e - f, 1); GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Lines); for (i = 0; i < f; i++) { GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf)); GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf)); } for (x = 0; x < diff; x += 0.1f) { GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf)); GL.Vertex2(Math.Cos((x + 0.1f + (float)i) * Maths._deg2radf), Math.Sin((x + 0.1f + (float)i) * Maths._deg2radf)); } GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf)); GL.Color4(Color.Orange); GL.Vertex3(0, 0, 0); GL.End(); } GL.Clear(ClearBufferMask.DepthBufferBit); RenderSCN0Controls(context); RenderTransformControl(context); if (!ModelPanel._grabbing && !ModelPanel._scrolling && !_playing) { GL.Color4(Color.Black); GL.ColorMask(false, false, false, false); if (RenderVertices) if (_editingAll && _targetModels != null) foreach (MDL0Node m in _targetModels) m.RenderVertices(context, true); else if (TargetModel != null) TargetModel.RenderVertices(context, true); if (RenderBones) { //Render invisible depth orbs GLDisplayList list = context.GetSphereList(); if (_editingAll) { foreach (MDL0Node m in _targetModels) foreach (MDL0BoneNode bone in m._linker.BoneCache) if (bone != SelectedBone) RenderOrb(bone, list); } else if (TargetModel != null && TargetModel._linker != null && TargetModel._linker.BoneCache != null) foreach (MDL0BoneNode bone in _targetModel._linker.BoneCache) if (bone != SelectedBone) RenderOrb(bone, list); } //Render invisible depth planes for translation and scale controls if (_editType != TransformType.Rotation && ((SelectedBone != null && RenderBones) || (VertexLoc != null && RenderVertices))) { #region Axis Selection Display List GLDisplayList selList = new GLDisplayList(); selList.Begin(); GL.Begin(BeginMode.Quads); //X Axis //XY quad GL.Vertex3(0.0f, -_axisSelectRange, 0.0f); GL.Vertex3(0.0f, _axisSelectRange, 0.0f); GL.Vertex3(_axisLDist, _axisSelectRange, 0.0f); GL.Vertex3(_axisLDist, -_axisSelectRange, 0.0f); //XZ quad GL.Vertex3(0.0f, 0.0f, -_axisSelectRange); GL.Vertex3(0.0f, 0.0f, _axisSelectRange); GL.Vertex3(_axisLDist, 0.0f, _axisSelectRange); GL.Vertex3(_axisLDist, 0.0f, -_axisSelectRange); //Y Axis //YX quad GL.Vertex3(-_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, _axisLDist, 0.0f); GL.Vertex3(-_axisSelectRange, _axisLDist, 0.0f); //YZ quad GL.Vertex3(0.0f, 0.0f, -_axisSelectRange); GL.Vertex3(0.0f, 0.0f, _axisSelectRange); GL.Vertex3(0.0f, _axisLDist, _axisSelectRange); GL.Vertex3(0.0f, _axisLDist, -_axisSelectRange); //Z Axis //ZX quad GL.Vertex3(-_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, _axisLDist); GL.Vertex3(-_axisSelectRange, 0.0f, _axisLDist); //ZY quad GL.Vertex3(0.0f, -_axisSelectRange, 0.0f); GL.Vertex3(0.0f, _axisSelectRange, 0.0f); GL.Vertex3(0.0f, _axisSelectRange, _axisLDist); GL.Vertex3(0.0f, -_axisSelectRange, _axisLDist); GL.End(); selList.End(); #endregion if (_editType != TransformType.Rotation && SelectedBone != null) { Matrix m = Matrix.TransformMatrix(new Vector3(OrbRadius), new Vector3(), BoneLoc); GL.PushMatrix(); GL.MultMatrix((float*)&m); selList.Call(); if (_editType == TransformType.Translation) { GL.Begin(BeginMode.Quads); //XY GL.Vertex3(0.0f, _axisSelectRange, 0.0f); GL.Vertex3(_axisHalfLDist, _axisSelectRange, 0.0f); GL.Vertex3(_axisHalfLDist, _axisHalfLDist, 0.0f); GL.Vertex3(0.0f, _axisHalfLDist, 0.0f); //YZ GL.Vertex3(0.0f, 0.0f, _axisSelectRange); GL.Vertex3(0.0f, _axisHalfLDist, _axisSelectRange); GL.Vertex3(0.0f, _axisHalfLDist, _axisHalfLDist); GL.Vertex3(0.0f, 0.0f, _axisHalfLDist); //XZ GL.Vertex3(_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, _axisHalfLDist); GL.Vertex3(_axisHalfLDist, 0.0f, _axisHalfLDist); GL.Vertex3(_axisHalfLDist, 0.0f, 0.0f); GL.End(); } else { GL.Begin(BeginMode.Triangles); //XY GL.Vertex3(0.0f, _axisSelectRange, 0.0f); GL.Vertex3(_scaleHalf2LDist, _axisSelectRange, 0.0f); GL.Vertex3(0.0f, _scaleHalf2LDist, 0.0f); //YZ GL.Vertex3(0.0f, 0.0f, _axisSelectRange); GL.Vertex3(0.0f, _scaleHalf2LDist, _axisSelectRange); GL.Vertex3(0.0f, 0.0f, _scaleHalf2LDist); //XZ GL.Vertex3(_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, _scaleHalf2LDist); GL.Vertex3(_scaleHalf2LDist, 0.0f, 0.0f); GL.End(); } GL.PopMatrix(); } if (VertexLoc != null && RenderVertices) { Matrix m = Matrix.TransformMatrix(new Vector3(VertexOrbRadius), new Vector3(), ((Vector3)VertexLoc)); GL.PushMatrix(); GL.MultMatrix((float*)&m); selList.Call(); GL.Begin(BeginMode.Quads); //XY GL.Vertex3(0.0f, _axisSelectRange, 0.0f); GL.Vertex3(_axisHalfLDist, _axisSelectRange, 0.0f); GL.Vertex3(_axisHalfLDist, _axisHalfLDist, 0.0f); GL.Vertex3(0.0f, _axisHalfLDist, 0.0f); //YZ GL.Vertex3(0.0f, 0.0f, _axisSelectRange); GL.Vertex3(0.0f, _axisHalfLDist, _axisSelectRange); GL.Vertex3(0.0f, _axisHalfLDist, _axisHalfLDist); GL.Vertex3(0.0f, 0.0f, _axisHalfLDist); //XZ GL.Vertex3(_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, _axisHalfLDist); GL.Vertex3(_axisHalfLDist, 0.0f, _axisHalfLDist); GL.Vertex3(_axisHalfLDist, 0.0f, 0.0f); GL.End(); GL.PopMatrix(); } } GL.ColorMask(true, true, true, true); } }
private unsafe void RenderSpecialOffensiveCollision(TKContext c, Vector3 cam) { if (_event != 0x06150F00) //Special Offensive Collision { return; } ResourceNode[] bl = _model._linker.BoneCache; int boneindex = (int)_parameters[0] >> 16; int size = HitboxSize; int angle = _parameters[2]; Root.GetBoneIndex(ref boneindex); if (boneindex == 0) //If a hitbox is on TopN, make it follow TransN { if (Root.Data != null) { boneindex = Root.Data._misc._boneRefs[4].boneIndex; Root.GetBoneIndex(ref boneindex); } else { int transindex = 0; foreach (MDL0BoneNode bn in bl) { if (bn.Name.Equals("TransN")) { break; } transindex++; } if (transindex != bl.Length) { boneindex = transindex; } } } MDL0BoneNode b; b = bl[boneindex] as MDL0BoneNode; Matrix r = b.Matrix.GetRotationMatrix(); FrameState state = b.Matrix.Derive(); Vector3 bonePos = state._translate; Vector3 pos = new Vector3(Util.UnScalar(_parameters[6]), Util.UnScalar(_parameters[7]), Util.UnScalar(_parameters[8])) / state._scale; Vector3 globalPos = r.Multiply(pos); Matrix m = Matrix.TransformMatrix(new Vector3(1), state._rotate, globalPos + bonePos); Vector3 resultPos = m.GetPoint(); int id = (int)_parameters[0] & 0xFFFF; RunTime.MainWindow.ModelPanel.ScreenText[id.ToString()] = RunTime.MainWindow.ModelPanel.Project(resultPos); m = Matrix.TransformMatrix(new Vector3(Util.UnScalar(size)), new Vector3(), resultPos); GL.PushMatrix(); GL.MultMatrix((float *)&m); int res = 16; double drawangle = 360.0 / res; Vector3 color = Util.GetTypeColor(flags.Type); GL.Color4((color._x / 255.0f), (color._y / 225.0f), (color._z / 255.0f), 0.5f); GLDisplayList spheres = c.GetSphereList(); spheres.Call(); if (specialFlags.Stretches) { GL.PushMatrix(); m = Matrix.TransformMatrix(new Vector3(1), state._rotate, new Vector3()); GL.MultMatrix((float *)&m); Vector3 reversepos = new Vector3(-pos._x / Util.UnScalar(size), -pos._y / Util.UnScalar(size), -pos._z / Util.UnScalar(size)); color = Util.GetEffectColor(flags.Effect); GL.Color4((color._x / 255.0f), (color._y / 225.0f), (color._z / 255.0f), 0.5f); GL.Translate(reversepos._x, reversepos._y, reversepos._z); GL.Begin(BeginMode.Lines); // stretch lines GL.Vertex3(1, 0, 0); GL.Vertex3(1 - reversepos._x, 0 - reversepos._y, 0 - reversepos._z); GL.Vertex3(-1, 0, 0); GL.Vertex3(-1 - reversepos._x, 0 - reversepos._y, 0 - reversepos._z); GL.Vertex3(0, 1, 0); GL.Vertex3(0 - reversepos._x, 1 - reversepos._y, 0 - reversepos._z); GL.Vertex3(0, -1, 0); GL.Vertex3(0 - reversepos._x, -1 - reversepos._y, 0 - reversepos._z); GL.Vertex3(0, 0, 1); GL.Vertex3(0 - reversepos._x, 0 - reversepos._y, 1 - reversepos._z); GL.Vertex3(0, 0, -1); GL.Vertex3(0 - reversepos._x, 0 - reversepos._y, -1 - reversepos._z); GL.End(); color = Util.GetTypeColor(flags.Type); GL.Color4((color._x / 255.0f), (color._y / 225.0f), (color._z / 255.0f), 0.25f); spheres.Call(); // root sphere GL.Translate(-reversepos._x, -reversepos._y, -reversepos._z); GL.PopMatrix(); } // angle indicator double rangle = angle / 180.0 * Math.PI; Vector3 effectcolour = Util.GetEffectColor(flags.Effect); GL.Color4((effectcolour._x / 255.0f), (effectcolour._y / 225.0f), (effectcolour._z / 255.0f), 0.75f); GL.PushMatrix(); if (angle == 361) { m = Matrix.TransformMatrix(new Vector3(0.5f), (globalPos + bonePos).LookatAngles(cam) * Maths._rad2degf, new Vector3(0)); GL.MultMatrix((float *)&m); GL.Begin(BeginMode.Quads); for (int i = 0; i < 16; i += 2) { GL.Vertex3(Math.Cos((i - 1) * Math.PI / 8) * 0.5, Math.Sin((i - 1) * Math.PI / 8) * 0.5, 0); GL.Vertex3(Math.Cos(i * Math.PI / 8), Math.Sin(i * Math.PI / 8), 0); GL.Vertex3(Math.Cos((i + 1) * Math.PI / 8) * 0.5, Math.Sin((i + 1) * Math.PI / 8) * 0.5, 0); GL.Vertex3(0, 0, 0); } GL.End(); } else { long a = -angle; // otherwise 90 would point down int angleflip = 0; if (resultPos._z < 0) { angleflip = 180; } m = Matrix.TransformMatrix(new Vector3(1), new Vector3(a, angleflip, 0), new Vector3()); GL.MultMatrix((float *)&m); GL.Begin(BeginMode.Quads); // left face GL.Vertex3(0.1, 0.1, 0); GL.Vertex3(0.1, 0.1, 1); GL.Vertex3(0.1, -0.1, 1); GL.Vertex3(0.1, -0.1, 0); // right face GL.Vertex3(-0.1, -0.1, 0); GL.Vertex3(-0.1, -0.1, 1); GL.Vertex3(-0.1, 0.1, 1); GL.Vertex3(-0.1, 0.1, 0); // top face GL.Vertex3(-0.1, 0.1, 0); GL.Vertex3(-0.1, 0.1, 1); GL.Vertex3(0.1, 0.1, 1); GL.Vertex3(0.1, 0.1, 0); // bottom face GL.Vertex3(0.1, -0.1, 0); GL.Vertex3(0.1, -0.1, 1); GL.Vertex3(-0.1, -0.1, 1); GL.Vertex3(-0.1, -0.1, 0); // front face GL.Vertex3(-0.1, -0.1, 1); GL.Vertex3(0.1, -0.1, 1); GL.Vertex3(0.1, 0.1, 1); GL.Vertex3(-0.1, 0.1, 1); // back face GL.Vertex3(-0.1, 0.1, 0); GL.Vertex3(0.1, 0.1, 0); GL.Vertex3(0.1, -0.1, 0); GL.Vertex3(-0.1, -0.1, 0); GL.End(); } GL.PopMatrix(); // border GLDisplayList rings = c.GetRingList(); for (int i = -5; i <= 5; i++) { GL.PushMatrix(); m = Matrix.TransformMatrix(new Vector3(1 + 0.0025f * i), (globalPos + bonePos).LookatAngles(cam) * Maths._rad2degf, new Vector3()); GL.MultMatrix((float *)&m); if (flags.Clang) { rings.Call(); } else { for (double j = 0; j < 360 / (drawangle / 2); j += 2) { double ang1 = (j * (drawangle / 2)) / 180 * Math.PI; double ang2 = ((j + 1) * (drawangle / 2)) / 180 * Math.PI; int q = 0; GL.Begin(BeginMode.LineStrip); GL.Vertex3(Math.Cos(ang1), Math.Sin(ang1), 0); GL.Vertex3(Math.Cos(ang2), Math.Sin(ang2), 0); GL.End(); } } GL.PopMatrix(); } GL.PopMatrix(); GL.PopMatrix(); }
private unsafe void modelPanel1_PostRender(object sender, TKContext context) { //GL.LineWidth(2.0f); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Disable(EnableCap.Lighting); GL.Disable(EnableCap.DepthTest); //Attributes.PostRender(); //Render hurtboxes if (chkHurtboxes.Checked) for (int i = 0; i < listPanel.lstHurtboxes.Items.Count; i++) if (listPanel.lstHurtboxes.GetItemChecked(i)) ((MiscHurtBox)listPanel.lstHurtboxes.Items[i]).Render(SelectedHurtbox != null && SelectedHurtbox.Index == i, Scriptor._hurtBoxType); //Render hitboxes if (chkHitboxes.Checked && Manager.Moveset != null) { GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); GLDisplayList c = context.GetRingList(); GLDisplayList s = context.GetSphereList(); foreach (HitBox e in RunTime._hitBoxes) e.Render(context, modelPanel._camera.GetPoint()); } GL.Enable(EnableCap.DepthTest); //Show the user where the light source is if (_renderLightDisplay) { GL.PushAttrib(AttribMask.AllAttribBits); GL.Color4(Color.Blue); GL.Disable(EnableCap.Lighting); GL.Disable(EnableCap.DepthTest); GL.Scale(modelPanel.LightPosition._x, modelPanel.LightPosition._x, modelPanel.LightPosition._x); GL.Rotate(90.0f, 1, 0, 0); float azimuth = modelPanel.LightPosition._y.Clamp180Deg(); float elevation = modelPanel.LightPosition._z.Clamp180Deg(); if (Math.Abs(azimuth) == Math.Abs(elevation) && azimuth % 180.0f == 0 && elevation % 180.0f == 0) { azimuth = 0; elevation = 0; } int i; float x; float e = azimuth; bool flip = false; if (e < 0) { e = -e; flip = true; GL.Rotate(180.0f, 1, 0, 0); } float f = (float)((int)e); float diff = (float)Math.Round(e - f, 1); GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Lines); for (i = 0; i < f; i++) { GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf)); GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf)); } for (x = 0; x < diff; x += 0.1f) { GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf)); GL.Vertex2(Math.Cos((x + 0.1f + (float)i) * Maths._deg2radf), Math.Sin((x + 0.1f + (float)i) * Maths._deg2radf)); } GL.End(); if (flip) GL.Rotate(-180.0f, 1, 0, 0); GL.Rotate(90.0f, 0, 1, 0); GL.Rotate(90.0f, 0, 0, 1); GL.Rotate(180.0f, 1, 0, 0); GL.Rotate(90.0f - azimuth, 0, 1, 0); e = elevation; if (e < 0) { e = -e; GL.Rotate(180.0f, 1, 0, 0); } f = (float)((int)e); diff = (float)Math.Round(e - f, 1); GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Lines); for (i = 0; i < f; i++) { GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf)); GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf)); } for (x = 0; x < diff; x += 0.1f) { GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf)); GL.Vertex2(Math.Cos((x + 0.1f + (float)i) * Maths._deg2radf), Math.Sin((x + 0.1f + (float)i) * Maths._deg2radf)); } GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf)); GL.Color4(Color.Orange); GL.Vertex3(0, 0, 0); GL.End(); GL.PopAttrib(); } GL.Clear(ClearBufferMask.DepthBufferBit); RenderTransformControl(context); if (!modelPanel._grabbing && !modelPanel._scrolling && !_playing) { GL.Color4(Color.Black); GL.ColorMask(false, false, false, false); if (RenderBones) { //Render invisible depth orbs GLDisplayList list = context.GetSphereList(); if (_editingAll) { foreach (MDL0Node m in _targetModels) foreach (MDL0BoneNode bone in m._linker.BoneCache) if (bone != SelectedBone) RenderOrb(bone, list); } else if (TargetModel != null && TargetModel._linker != null && TargetModel._linker.BoneCache != null) foreach (MDL0BoneNode bone in _targetModel._linker.BoneCache) if (bone != SelectedBone) RenderOrb(bone, list); } //Render invisible depth planes for translation and scale controls if (_editType != 0 && SelectedBone != null && RenderBones) { #region Axis Selection Display List GLDisplayList selList = new GLDisplayList(); selList.Begin(); GL.Begin(BeginMode.Quads); //X Axis //XY quad GL.Vertex3(0.0f, -_axisSelectRange, 0.0f); GL.Vertex3(0.0f, _axisSelectRange, 0.0f); GL.Vertex3(_axisLDist, _axisSelectRange, 0.0f); GL.Vertex3(_axisLDist, -_axisSelectRange, 0.0f); //XZ quad GL.Vertex3(0.0f, 0.0f, -_axisSelectRange); GL.Vertex3(0.0f, 0.0f, _axisSelectRange); GL.Vertex3(_axisLDist, 0.0f, _axisSelectRange); GL.Vertex3(_axisLDist, 0.0f, -_axisSelectRange); //Y Axis //YX quad GL.Vertex3(-_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, _axisLDist, 0.0f); GL.Vertex3(-_axisSelectRange, _axisLDist, 0.0f); //YZ quad GL.Vertex3(0.0f, 0.0f, -_axisSelectRange); GL.Vertex3(0.0f, 0.0f, _axisSelectRange); GL.Vertex3(0.0f, _axisLDist, _axisSelectRange); GL.Vertex3(0.0f, _axisLDist, -_axisSelectRange); //Z Axis //ZX quad GL.Vertex3(-_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, _axisLDist); GL.Vertex3(-_axisSelectRange, 0.0f, _axisLDist); //ZY quad GL.Vertex3(0.0f, -_axisSelectRange, 0.0f); GL.Vertex3(0.0f, _axisSelectRange, 0.0f); GL.Vertex3(0.0f, _axisSelectRange, _axisLDist); GL.Vertex3(0.0f, -_axisSelectRange, _axisLDist); GL.End(); selList.End(); #endregion if (_editType != 0 && SelectedBone != null) { Matrix m = Matrix.TransformMatrix(new Vector3(OrbRadius), new Vector3(), BoneLoc); GL.PushMatrix(); GL.MultMatrix((float*)&m); selList.Call(); if (_editType == TransformType.Translation) { GL.Begin(BeginMode.Quads); //XY GL.Vertex3(0.0f, _axisSelectRange, 0.0f); GL.Vertex3(_axisHalfLDist, _axisSelectRange, 0.0f); GL.Vertex3(_axisHalfLDist, _axisHalfLDist, 0.0f); GL.Vertex3(0.0f, _axisHalfLDist, 0.0f); //YZ GL.Vertex3(0.0f, 0.0f, _axisSelectRange); GL.Vertex3(0.0f, _axisHalfLDist, _axisSelectRange); GL.Vertex3(0.0f, _axisHalfLDist, _axisHalfLDist); GL.Vertex3(0.0f, 0.0f, _axisHalfLDist); //XZ GL.Vertex3(_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, _axisHalfLDist); GL.Vertex3(_axisHalfLDist, 0.0f, _axisHalfLDist); GL.Vertex3(_axisHalfLDist, 0.0f, 0.0f); GL.End(); } else { GL.Begin(BeginMode.Triangles); //XY GL.Vertex3(0.0f, _axisSelectRange, 0.0f); GL.Vertex3(_scaleHalf2LDist, _axisSelectRange, 0.0f); GL.Vertex3(0.0f, _scaleHalf2LDist, 0.0f); //YZ GL.Vertex3(0.0f, 0.0f, _axisSelectRange); GL.Vertex3(0.0f, _scaleHalf2LDist, _axisSelectRange); GL.Vertex3(0.0f, 0.0f, _scaleHalf2LDist); //XZ GL.Vertex3(_axisSelectRange, 0.0f, 0.0f); GL.Vertex3(_axisSelectRange, 0.0f, _scaleHalf2LDist); GL.Vertex3(_scaleHalf2LDist, 0.0f, 0.0f); GL.End(); } GL.PopMatrix(); } } GL.ColorMask(true, true, true, true); } }