Beispiel #1
0
 internal void AddObjects(IEnumerable <LatipiumObject> objects)
 {
     foreach (LatipiumObject obj in objects)
     {
         LatipiumObject type = obj.InvokeFunction <LatipiumObject>("Type");
         if (type != null)
         {
             if (!InitializedTypes.Contains(type))
             {
                 type.InvokeProcedure <Action <IEnumerable <LatipiumObject> > >("Initialize", UpdatedCallback);
             }
             Com.Latipium.Core.Tuple <float[], int[]> data = type.InvokeFunction <Com.Latipium.Core.Tuple <float[], int[]> >("GetPhysicsData");
             if (data != null && data.Object1 != null && data.Object2 != null)
             {
                 List <JVector> points             = new List <JVector>();
                 List <TriangleVertexIndices> tris = new List <TriangleVertexIndices>();
                 for (int i = 0; i < data.Object1.Length - 2; i += 3)
                 {
                     points.Add(new JVector(data.Object1[i], data.Object1[i + 1], data.Object1[i + 2]));
                 }
                 for (int i = 0; i < data.Object2.Length - 2; i += 3)
                 {
                     tris.Add(new TriangleVertexIndices(data.Object2[i], data.Object2[i + 1], data.Object2[i + 2]));
                 }
                 Octree      octree     = new Octree(points, tris);
                 Shape       shape      = new TriangleMeshShape(octree);
                 RigidBody   body       = new RigidBody(shape);
                 Func <bool> UseGravity = type.GetFunction <bool>("UseGravity");
                 body.AffectedByGravity = UseGravity == null || UseGravity();
                 Bodies.Add(obj, body);
                 World.AddBody(body);
             }
         }
     }
 }
        public LatipiumObject Generate()
        {
            if (CreateWorld == null || CreateRealm == null || CreateObject == null)
            {
                return(null);
            }
            LatipiumObject world = CreateWorld();
            LatipiumObject realm = CreateRealm("Com.Latipium.Realms.Default");

            world.InvokeProcedure <LatipiumObject>("AddRealm", realm);
            LatipiumObject cube = CreateObject(GetObject("Com.Latipium.TestingObjects.CubeObject"));

            realm.InvokeProcedure <LatipiumObject>("AddObject", cube);
            return(world);
        }
Beispiel #3
0
 private void LoadObject(LatipiumObject obj)
 {
     obj.InvokeProcedure <Action <IEnumerable <LatipiumObject> > >("Initialize", (IEnumerable <LatipiumObject> o) => {
     });
 }