예제 #1
0
        public override void Start()
        {
            var ourPrimitive      = GeometricPrimitive.Cube.New(GraphicsDevice, 1.0f);
            var primitiveMeshDraw = ourPrimitive.ToMeshDraw();

            var newMultiMesh = new PoorMansMultiMesh()
            {
                Mesh = new Mesh()
                {
                    Draw = primitiveMeshDraw
                },
                Material = meshMaterial
            };

            var numInstances = 2048;
            var random       = new Random();

            for (int i = 0; i < numInstances; ++i)
            {
                var randX = random.Next(-64, 64);
                var randY = random.Next(-64, 64);
                var randZ = random.Next(-64, 64);

                var velX = random.NextDouble() * 4.0;
                var velY = random.NextDouble() * 4.0;
                var velZ = random.NextDouble() * 4.0;
                var vel  = new Vector3((float)velX, (float)velY, (float)velZ);

                var rotVelX = random.NextDouble();
                var rotVelY = random.NextDouble();
                var rotVelZ = random.NextDouble();
                var rotVel  = new Vector3((float)rotVelX, (float)rotVelY, (float)rotVelZ);

                var r   = random.NextDouble();
                var g   = random.NextDouble();
                var b   = random.NextDouble();
                var col = new Color4((float)r, (float)g, (float)b);

                var newEntity        = new Entity(new Vector3(randX, randY, randZ));
                var newObjectInSpace = new SomeObjectInSpace()
                {
                    Velocity = vel, RotVelocity = rotVel, Color = col
                };

                newEntity.Add(newObjectInSpace);
                newMultiMesh.AddInstance(newObjectInSpace);
                Entity.AddChild(newEntity);
            }

            Entity.Add(newMultiMesh);
            multiMesh = newMultiMesh;
        }
예제 #2
0
 public bool RemoveInstance(SomeObjectInSpace someObject)
 {
     return(objects.Remove(someObject.Id));
 }
예제 #3
0
 public System.Guid AddInstance(SomeObjectInSpace someObject)
 {
     objects[someObject.Id] = someObject;
     return(someObject.Id);
 }