コード例 #1
0
        public SortedList <double, Bone> GetBoneSelection(Ray ray)
        {
            SortedList <double, Bone> selected = new SortedList <double, Bone>(new DuplicateKeyComparer <double>());

            if (VBN != null)
            {
                Vector3 closest = Vector3.Zero;
                foreach (Bone b in VBN.bones)
                {
                    if (ray.CheckSphereHit(Vector3.TransformPosition(Vector3.Zero, b.transform), 1, out closest))
                    {
                        selected.Add(ray.Distance(closest), b);
                    }
                }
            }
            return(selected);
        }
コード例 #2
0
        private void Pick(SBTreeNode treeNode, Ray ray)
        {
            Vector3 close;

            if (treeNode.Tag is SBBone bone)
            {
                if (ray.CheckSphereHit(Vector3.TransformPosition(Vector3.Zero, bone.AnimatedWorldTransform), 0.5f, out close))
                {
                    BoneList.SelectedNode = treeNode;
                    return;
                }
            }

            foreach (var child in treeNode.Nodes)
            {
                Pick((SBTreeNode)child, ray);
            }
        }
コード例 #3
0
        public SortedList <double, BYAML.PathPoint> GetByamPointSelection(Ray ray)
        {
            SortedList <double, BYAML.PathPoint> selected = new SortedList <double, BYAML.PathPoint>(new DuplicateKeyComparer <double>());

            if (targetByaml != null)
            {
                Vector3 closest = Vector3.Zero;
                foreach (BYAML.GenericPathGroup path in targetByaml.EnemyPaths.Nodes)
                {
                    foreach (BYAML.PathPoint pt in path.Nodes)
                    {
                        if (ray.CheckSphereHit(pt.translate, 44, out closest))
                        {
                            selected.Add(ray.Distance(closest), pt);
                        }
                    }
                }
            }
            return(selected);
        }
コード例 #4
0
        public void RenderPositionTool(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.mouseX - PrevPoint.X) / 100;
                float sy = (Ray.mouseY - PrevPoint.Y) / 100;
                float s  = sx + sy;
                b.pos = b.pos + new Vector3(_hiX ? s : 0, _hiY ? s : 0, _hiZ ? s * -1 : 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.Vertex3(2, 0, 0);
            GL.Vertex3(1.5f, 0, 0.25f);
            GL.Vertex3(2, 0, 0);
            GL.Vertex3(1.5f, 0, -0.25f);
            GL.Color3(_hiY ? Color.Yellow : Color.Green);
            GL.Vertex3(0, 0, 0);
            GL.Vertex3(0, 2, 0);
            GL.Vertex3(0, 2, 0);
            GL.Vertex3(0.25f, 1.5f, 0);
            GL.Vertex3(0, 2, 0);
            GL.Vertex3(-0.25f, 1.5f, 0);
            GL.Color3(_hiZ ? Color.Yellow : Color.Blue);
            GL.Vertex3(0, 0, 0);
            GL.Vertex3(0, 0, 2);
            GL.Vertex3(0, 0, 2);
            GL.Vertex3(0.25f, 0, 1.5f);
            GL.Vertex3(0, 0, 2);
            GL.Vertex3(-0.25f, 0, 1.5f);
            GL.End();
            GL.PopMatrix();
        }