Exemplo n.º 1
0
        public void FlipY()
        {
            CollisionNode coll = ((CollisionNode)_resource);

            //int i = 0;
            //int j = 0;
            foreach (CollisionObject cObj in coll._objects)
            {
                //++i;
                //Console.WriteLine("COLLISION OBJECT: " + i);
                if (cObj.LinkedBone == null)
                {
                    //j = 0;
                    //Console.WriteLine("   Not linked to a model");
                    cObj.resetFlip();
                    foreach (CollisionPlane p in cObj._planes)
                    {
                        //++j;
                        //Console.WriteLine("      Initiating Plane: " + j);
                        p.flipAcrossPlane('Y');
                    }
                }
            }
            coll.SignalPropertyChange();
        }
Exemplo n.º 2
0
 public NodeFactory()
 {
     builtin["Anchor"]                  = new AnchorNode();
     builtin["Appearance"]              = new AppearanceNode();
     builtin["Background"]              = new BackgroundNode();
     builtin["Box"]                     = new BoxNode();
     builtin["Color"]                   = new ColorNode();
     builtin["Cone"]                    = new ConeNode();
     builtin["Coordinate"]              = new CoordinateNode();
     builtin["CoordinateInterpolator"]  = new CoordinateInterpolatorNode();
     builtin["Cylinder"]                = new CylinderNode();
     builtin["DirectionalLight"]        = new DirectionalLightNode();
     builtin["Extrusion"]               = new ExtrusionNode();
     builtin["Group"]                   = new GroupNode();
     builtin["Collision"]               = new CollisionNode();
     builtin["Switch"]                  = new SwitchNode();
     builtin["IndexedFaceSet"]          = new IndexedFaceSetNode();
     builtin["IndexedLineSet"]          = new IndexedLineSetNode();
     builtin["Material"]                = new MaterialNode();
     builtin["NavigationInfo"]          = new NavigationInfoNode();
     builtin["OrientationInterpolator"] = new OrientationInterpolatorNode();
     builtin["Normal"]                  = new NormalNode();
     builtin["PixelTexture"]            = new PixelTextureNode();
     builtin["PointLight"]              = new PointLightNode();
     builtin["PositionInterpolator"]    = new PositionInterpolatorNode();
     builtin["ScalarInterpolator"]      = new ScalarInterpolationNode();
     builtin["Shape"]                   = new ShapeNode();
     builtin["Sphere"]                  = new SphereNode();
     builtin["TextureCoordinate"]       = new TextureCoordinateNode();
     builtin["TimeSensor"]              = new TimeSensorNode();
     builtin["Transform"]               = new TransformNode();
     builtin["Viewpoint"]               = new ViewpointNode();
     builtin["WorldInfo"]               = new WorldInfoNode();
 }
Exemplo n.º 3
0
 public void CompleteBBox(CollisionNode ent1)
 {
     ent1.BoundingBox = ent1.Meshes
                        .Select(x => x.BoundingBox)
                        .Concat(SelectBoundingBoxList(ent1))
                        .MergeAll();
 }
    public void Convert(Entity entity, EntityManager manager, GameObjectConversionSystem conversionSystem)
    {
        var data = new CollisionNode {
        };

        manager.AddComponentData(entity, data);
    }
Exemplo n.º 5
0
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(0);
            }
            CollisionNode OtherNode = (CollisionNode)obj;

            return((int)Mathf.Sign(CollisionDistance - OtherNode.CollisionDistance));
        }
Exemplo n.º 6
0
            public static CollisionNode Read(BinaryReader br)
            {
                CollisionNode ret = new CollisionNode();

                ret.Type   = (CollisionType)br.ReadUInt16();
                ret.Unk1   = br.ReadUInt16();
                ret.X      = br.ReadInt32();
                ret.Y      = br.ReadInt32();
                ret.Radius = br.ReadUInt32();
                return(ret);
            }
Exemplo n.º 7
0
 public DialogResult ShowDialog(IWin32Window owner, CollisionNode node)
 {
     _node = node;
     try
     {
         return(ShowDialog(owner));
     }
     finally
     {
         _node = null;
     }
 }
Exemplo n.º 8
0
        private void ChangeWallFrame(CollisionNode node)
        {
            switch ((int)node.health.current)
            {
            case 4: node.display.clip.SetFrame(0); break;

            case 3: node.display.clip.SetFrame(1); break;

            case 2: node.display.clip.SetFrame(2); break;

            case 1: node.display.clip.SetFrame(3); break;
            }
        }
Exemplo n.º 9
0
        public CollisionNode NewCollision()
        {
            CollisionNode node = new CollisionNode {
                FileType = ARCFileType.MiscData
            };

            _resource.AddChild(node);

            BaseWrapper w = FindResource(node, false);

            w.EnsureVisible();
            w.TreeView.SelectedNode = w;
            return(node);
        }
        public RectangleTargetNode(string label)
        {
            Label = label;

            RectangleSize = new Vector2F(100.0f, 100.0f);

            var collider = new RectangleCollider {
                Size = RectangleSize
            };

            var collisionNode = new CollisionNode <RectangleTargetNode>(this, collider);

            AddChildNode(collisionNode);
        }
Exemplo n.º 11
0
        public CircleTargetNode(string label)
        {
            Label = label;

            Radius  = 50.0f;
            VertNum = 32;

            var collider = new CircleCollider {
                Radius = Radius
            };

            var collisionNode = new CollisionNode <CircleTargetNode>(this, collider);

            AddChildNode(collisionNode);
        }
        public MouseNode()
        {
            Radius  = 10.0f;
            VertNum = 32;

            // 円形コライダーを作成
            var collider = new CircleCollider
            {
                Radius = Radius,
            };

            // CollisionNodeを作成する。
            _collisionNode = new CollisionNode <MouseNode>(this, collider);

            // CollisionNodeを子ノードとして追加する。
            AddChildNode(_collisionNode);
        }
Exemplo n.º 13
0
    // TODO: When a line hits a border the border should track the collision
    public VerticesAndMeshes getListOfConnectingGameObjects(List <CollisionNode> graph, List <CollisionNode> pathStarters)
    {
        List <Vector2>    collisionPoints = new List <Vector2>();
        List <GameObject> meshes          = new List <GameObject>();

        CollisionNode collisionNode = pathStarters[0];

        while (collisionNode != null)
        {
            collisionPoints.Add(collisionNode.CollisionPoint);
            foreach (GameObject mesh in collisionNode.objs)
            {
                if (!meshes.Exists(m => m.GetInstanceID() == mesh.GetInstanceID()))
                {
                    meshes.Add(mesh);
                }
            }
            collisionNode = collisionNode.parentNode;
        }

        collisionNode = pathStarters[1];
        List <Vector2> secondHalfPath = new List <Vector2>();

        while (collisionNode.parentNode != null)
        {
            secondHalfPath.Add(collisionNode.CollisionPoint);
            collisionNode = collisionNode.parentNode;
        }

        secondHalfPath.Reverse();
        collisionPoints.AddRange(secondHalfPath);

        Vector3[] pathArray = new Vector3[collisionPoints.Count];
        for (int i = 0; i < collisionPoints.Count; i++)
        {
            pathArray[i] = new Vector3(collisionPoints[i].x, collisionPoints[i].y, 0);
        }

        VerticesAndMeshes vAndM = new VerticesAndMeshes();

        vAndM.vertices = pathArray;
        vAndM.meshes   = meshes;

        return(vAndM);
    }
Exemplo n.º 14
0
        public override ResourceNode Duplicate()
        {
            if (_resource._parent == null)
            {
                return(null);
            }
            _resource.Rebuild();
            CollisionNode newNode  = NodeFactory.FromAddress(null, _resource.WorkingUncompressed.Address, _resource.WorkingUncompressed.Length) as CollisionNode;
            int           newIndex = _resource.Index + 1;

            _resource._parent.InsertChild(newNode, true, newIndex);
            newNode.Populate();
            newNode.FileType      = ((CollisionNode)_resource).FileType;
            newNode.FileIndex     = ((CollisionNode)_resource).FileIndex;
            newNode.RedirectIndex = ((CollisionNode)_resource).RedirectIndex;
            newNode.GroupID       = ((CollisionNode)_resource).GroupID;
            return(newNode);
        }
Exemplo n.º 15
0
            private IEnumerable <BoundingBoxInt16> SelectBoundingBoxList(CollisionNode ent1)
            {
                if (ent1.Child1 != -1)
                {
                    yield return(coct.Nodes[ent1.Child1].BoundingBox);

                    if (ent1.Child2 != -1)
                    {
                        yield return(coct.Nodes[ent1.Child2].BoundingBox);

                        if (ent1.Child3 != -1)
                        {
                            yield return(coct.Nodes[ent1.Child3].BoundingBox);

                            if (ent1.Child4 != -1)
                            {
                                yield return(coct.Nodes[ent1.Child4].BoundingBox);

                                if (ent1.Child5 != -1)
                                {
                                    yield return(coct.Nodes[ent1.Child5].BoundingBox);

                                    if (ent1.Child6 != -1)
                                    {
                                        yield return(coct.Nodes[ent1.Child6].BoundingBox);

                                        if (ent1.Child7 != -1)
                                        {
                                            yield return(coct.Nodes[ent1.Child7].BoundingBox);

                                            if (ent1.Child8 != -1)
                                            {
                                                yield return(coct.Nodes[ent1.Child8].BoundingBox);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
Exemplo n.º 16
0
 public bool CollidesWith(CollisionNode other)
 {
     return(Universe.instance.Distance(position, other.position) < radius + other.radius);
 }
Exemplo n.º 17
0
 public DialogResult ShowDialog(IWin32Window owner, CollisionNode node)
 {
     _node = node;
     try { return(ShowDialog(owner)); }
     finally { _node.SignalPropertyChange(); _node = null; }
 }
Exemplo n.º 18
0
    public void generateMesh(SceneManager.CollisionPoint startPoint)
    {
        List <CollisionNode> collisionGraph = new List <CollisionNode>();

        // TODO: do the same search for collision tracker2
        CollisionNode collisionNode1 = new CollisionNode();

        collisionNode1.objs           = startPoint.objects;
        collisionNode1.CollisionPoint = startPoint.point;

        collisionGraph.Add(collisionNode1);

        List <GameObject> exploredObjects = new List <GameObject>();

        List <CollisionNode>[] completeRoutes = new List <CollisionNode> [2];

        // breadth first search for graph creation
        int i = 0;

        while (i < collisionGraph.Count)
        {
            List <CollisionNode> collisionsAlreadyInGraph = new List <CollisionNode>();
            // loop through both of the objects of the node
            foreach (GameObject exploringObj in collisionGraph[i].objs)
            {
                // if the object looking into has already been explored, then there is no need to explore it
                if (exploredObjects.Exists(n => n.GetInstanceID() == exploringObj.GetInstanceID()))
                {
                    continue;
                }

                // find the objects the current node object is colliding with. Add it to the collision graph if it does not exist yet
                foreach (SceneManager.CollisionPoint collisionPoint in SceneManager.instance.collisionPoints)
                {
                    // we only want to explore the collisions that involve the object we are currently exploring
                    if (!Array.Exists(collisionPoint.objects, o => o.GetInstanceID() == exploringObj.GetInstanceID()))
                    {
                        continue;
                    }

                    // if the collision already exists in our collision graph then we do not want to add it again
                    if (collisionGraph.Exists(n => n.CollisionPoint == collisionPoint.point) && collisionGraph.Count >= 4)
                    {
                        collisionsAlreadyInGraph.Add(collisionGraph.Find(n => n.CollisionPoint == collisionPoint.point));

                        // while exploring an object, if at least 2 of the collisions for that obejct are already in the collision graph then the graph has circled and a mesh can be made
                        // TODO: What happens when collisionsAlreadyInGraph has more than 2 count
                        if (collisionsAlreadyInGraph.Count == 2)
                        {
                            VerticesAndMeshes vAndM   = getListOfConnectingGameObjects(collisionGraph, collisionsAlreadyInGraph);
                            GameObject        meshObj = Instantiate(topMesh, Vector3.zero, Quaternion.identity);
                            TopMesh           mesh    = meshObj.GetComponent <TopMesh>();
                            bool wasMeshCreated       = mesh.generateMesh(vAndM.vertices);

                            // if the mesh intersects one of the sweets, delete it.
                            // otherwise merge it with the meshes that it intersects with and break because it is only possible for 1 top mesh to be successfully created

                            if (wasMeshCreated)
                            {
                                Debug.Log("Merging Meshes");

                                // remove any border corner collisions that are covered by the topmesh
                                foreach (SceneManager.CollisionPoint point in SceneManager.instance.collisionPoints)
                                {
                                    if (Array.Exists(vAndM.vertices, v => new Vector2(v.x, v.y) == point.point) && point.isBorder == true)
                                    {
                                        Debug.Log(SceneManager.instance.collisionPoints.RemoveAll(cp => cp.point == point.point));
                                    }
                                }
                                Debug.Log("done");
                                mergeMeshes(vAndM.meshes, topMesh);

                                // it is only possible for one top mesh to be generated successfully. So if it was generated then there is no need to continue
                                return;
                            }


                            // }
                        }
                        continue;
                    }

                    // the object that the object we are exploring is colliding with
                    GameObject childObj = Array.Find(collisionPoint.objects, o => o.GetInstanceID() != exploringObj.GetInstanceID());

                    // create a new node and add it to the graph
                    CollisionNode newNode = new CollisionNode();
                    newNode.objs           = collisionPoint.objects;
                    newNode.parentNode     = collisionGraph[i];
                    newNode.CollisionPoint = collisionPoint.point;
                    collisionGraph.Add(newNode);
                }
                exploredObjects.Add(exploringObj);
            }
            i++;
        }

        // if a top mesh was not generated, then merge the two growing lines
        foreach (SceneManager.CollisionPoint collisionPoint in SceneManager.instance.collisionPoints)
        {
            // if (collisionPoint.objects.con)
        }
    }
Exemplo n.º 19
0
 public CollisionNode CompleteAndAdd(CollisionNode it)
 {
     buildHelper.CompleteBBox(it);
     Nodes.Add(it);
     return(it);
 }