Beispiel #1
0
        public void AddTestUnitCube(Vector3 vector3)
        {
            ProceduralCube s = new ProceduralCube();

            s.SetColor(Color.White);
            s.Translate(vector3);
            AddAndInitialiseGameObject(GameObjectFactory.CreateRenderableGameObjectFromShape(s, EffectLoader.LoadSM5Effect("flatshaded")));
        }
Beispiel #2
0
        /// <summary>
        /// Sets up default ambient and a single diffuse light for the scene, adds a cube at Vector3.Zero. For scene testing at the start of a project.
        /// </summary>
        public static void SetUpTestCubeAndLighting()
        {
            SystemCore.ActiveScene.SetUpBasicAmbientAndKey();
            ProceduralCube cube = new ProceduralCube();

            cube.SetColor(Color.OrangeRed);
            GameObject.GameObject testObject = GameObjectFactory.CreateRenderableGameObjectFromShape(cube, EffectLoader.LoadSM5Effect("flatshaded"));
            testObject.AddComponent(new RotatorComponent(Vector3.Up, 0.0001f));
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(testObject);
        }
Beispiel #3
0
        public override void OnInitialise()
        {
            SystemCore.CursorVisible = false;
            SystemCore.ActiveScene.SetUpBasicAmbientAndKey();
            SystemCore.ActiveScene.SetDiffuseLightDir(0, new Vector3(1, 1, 1));
            colorScheme = SystemCore.ActiveColorScheme;
            SystemCore.ActiveScene.FogEnabled = false;

            SystemCore.PhysicsSimulation.ForceUpdater.Gravity = new BEPUutilities.Vector3(0, -9.81f, 0);


            mouseCamera = new MouseFreeCamera(new Vector3(10, 10, 10));
            SystemCore.SetActiveCamera(mouseCamera);


            var effect = EffectLoader.LoadSM5Effect("FlatShaded");

            //ground plane
            var groundShape = new ProceduralCuboid(100, 100, 0.5f);

            groundShape.SetColor(colorScheme.Color5);
            var gameObjectPlane = new GameObject();

            gameObjectPlane.AddComponent(new RenderGeometryComponent(BufferBuilder.VertexBufferBuild(groundShape), BufferBuilder.IndexBufferBuild(groundShape), groundShape.PrimitiveCount));
            gameObjectPlane.AddComponent(new EffectRenderComponent(effect));
            var groundPhysicsComponent = new PhysicsComponent(false, true, PhysicsMeshType.box);

            gameObjectPlane.AddComponent(groundPhysicsComponent);


            SystemCore.GameObjectManager.AddAndInitialiseGameObject(gameObjectPlane);
            groundPhysicsComponent.PhysicsEntity.IsAffectedByGravity = false;


            var shape = new ProceduralCube();

            shape.SetColor(colorScheme.Color4);

            for (int i = 0; i < 100; i++)
            {
                AddCube(shape, effect, RandomHelper.GetRandomVector3(new Vector3(-10, 2, -10), new Vector3(10, 20, 10)));
            }

            AddInputBindings();
            base.OnInitialise();
        }
Beispiel #4
0
        public override void OnInitialise()
        {
            SystemCore.CursorVisible = false;

            SystemCore.ActiveScene.AddKeyLight(Vector3.Up, Color.White, 1f, false);
            camera       = new DummyOrthographicCamera(SystemCore.Viewport.Width / 10, SystemCore.Viewport.Height / 10, 0.3f, 50f);
            camera.World = Matrix.CreateWorld(new Vector3(0, 20, 0), new Vector3(0, -1, 0), new Vector3(0, 0, 1));
            camera.View  = Matrix.Invert(camera.World);
            SystemCore.SetActiveCamera(camera);


            for (int i = 1; i < 64 * 32; i++)
            {
                var cube = new ProceduralCube();
                cube.SetColor(RandomHelper.RandomColor);
                var ball = GameObjectFactory.CreateRenderableGameObjectFromShape(cube, EffectLoader.LoadSM5Effect("flatshaded"));

                int column = i % 64;
                int row    = i / 64;

                ball.Transform.SetPosition(new Vector3(-(column - 1), 0, row));


                SystemCore.GameObjectManager.AddAndInitialiseGameObject(ball);
            }

            //var cube = new ProceduralCube();
            //cube.SetColor(Color.White);
            //ball = GameObjectFactory.CreateRenderableGameObjectFromShape(cube, EffectLoader.LoadSM5Effect("flatshaded"));
            //ball.Transform.SetPosition(Vector3.Zero);

            //SystemCore.GameObjectManager.AddAndInitialiseGameObject(ball);


            //Initialise
            InitialiseEmulator();


            //load ROM
            LoadRom("PONG");

            base.OnInitialise();
        }
Beispiel #5
0
        public override void OnInitialise()
        {
            base.OnInitialise();

            SystemCore.ActiveScene.SetUpBasicAmbientAndKey();
            mouseCamera.moveSpeed = 0.01f;

            ProceduralCube cube = new ProceduralCube();

            cube.SetColor(Color.OrangeRed);
            testObject = GameObjectFactory.CreateRenderableGameObjectFromShape(cube, EffectLoader.LoadSM5Effect("flatshaded"));
            testObject.AddComponent(new RotatorComponent(Vector3.Up, 0.0001f));
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(testObject);

            ProceduralPlane plane = new ProceduralPlane();

            plane.Scale(10f);
            plane.SetColor(Color.LightBlue);
            planeToDrawOn = GameObjectFactory.CreateRenderTextureSurface(plane,
                                                                         EffectLoader.LoadSM5Effect("rendertexturesurface"));

            planeToDrawOn.Transform.Rotate(Vector3.Forward, MathHelper.ToRadians(90));
            planeToDrawOn.Transform.Rotate(Vector3.Left, MathHelper.ToRadians(-90));
            //planeToDrawOn.Transform.Rotate(Vector3.Up, MathHelper.ToRadians(-90));
            planeToDrawOn.Transform.SetPosition(new Vector3(-5, 0, 0));

            GameObject.InitialiseAllComponents(planeToDrawOn);

            spriteBatch  = new SpriteBatch(SystemCore.GraphicsDevice);
            renderTarget = new RenderTarget2D(SystemCore.GraphicsDevice, 500, 500);

            renderTextureCamera = new DummyCamera();
            renderTextureCamera.SetPositionAndLookDir(new Vector3(-5, 0, 0), Vector3.Zero, Vector3.Up);
            SystemCore.AddCamera("renderTextureCamera", renderTextureCamera);

            var secondCube = GameObjectFactory.CreateRenderableGameObjectFromShape(new ProceduralCube(),
                                                                                   EffectLoader.LoadSM5Effect("flatshaded"));

            secondCube.Transform.SetPosition(new Vector3(-20, 0, 0));
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(secondCube);

            font = SystemCore.ContentManager.Load <SpriteFont>("Fonts/neuropolitical");
        }
Beispiel #6
0
        public MainBase()
        {
            Health = 100;
            Size   = 8;

            ProceduralCube shape = new ProceduralCube();

            shape.Scale(Size);
            shape.SetColor(Color.Blue);
            AddComponent(new RenderGeometryComponent(BufferBuilder.VertexBufferBuild(shape),
                                                     BufferBuilder.IndexBufferBuild(shape), shape.PrimitiveCount));
            AddComponent(new EffectRenderComponent(EffectLoader.LoadSM5Effect("flatshaded")));
            AddComponent(new ShadowCasterComponent());
            var physicsComponent = new PhysicsComponent(false, false, PhysicsMeshType.box);

            AddComponent(physicsComponent);

            SystemCore.GameObjectManager.AddAndInitialiseGameObject(this);
            GetComponent <PhysicsComponent>().PhysicsEntity.CollisionInformation.Events.DetectingInitialCollision += Events_DetectingInitialCollision;
        }
Beispiel #7
0
        public override void OnInitialise()
        {
            SystemCore.CursorVisible = false;

            SystemCore.ActiveScene.AddKeyLight(Vector3.Up, Color.White, 1f, false);
            camera       = new DummyOrthographicCamera(SystemCore.Viewport.Width / 10, SystemCore.Viewport.Height / 10, 0.3f, 50f);
            camera.World = Matrix.CreateWorld(new Vector3(0, 20, 0), new Vector3(0, -1, 0), new Vector3(0, 0, 1));
            camera.View  = Matrix.Invert(camera.World);
            SystemCore.SetActiveCamera(camera);


            var cube = new ProceduralCube();

            cube.SetColor(Color.White);
            ball = GameObjectFactory.CreateRenderableGameObjectFromShape(cube, EffectLoader.LoadSM5Effect("flatshaded"));
            ball.Transform.SetPosition(Vector3.Zero);

            SystemCore.GameObjectManager.AddAndInitialiseGameObject(ball);

            base.OnInitialise();
        }
Beispiel #8
0
        public void AddVoxel(Color color)
        {
            if (!RenderGrid)
            {
                return;
            }

            if (currentbuildPoint.X < -modellingAreaSize / 2 || currentbuildPoint.X > modellingAreaSize / 2)
            {
                return;
            }
            if (currentbuildPoint.Y < -modellingAreaSize / 2 || currentbuildPoint.Y > modellingAreaSize / 2)
            {
                return;
            }
            if (currentbuildPoint.Z < -modellingAreaSize / 2 || currentbuildPoint.Z > modellingAreaSize / 2)
            {
                return;
            }

            ProceduralCube c = new ProceduralCube();

            c.SetColor(color);

            //this object is for visualisation in the editor only. The procedural shape will be
            //cached and used to bake the final shape for serialization
            var tempObject = GameObjectFactory.CreateRenderableGameObjectFromShape(c,
                                                                                   EffectLoader.LoadSM5Effect("flatshaded"));

            tempObject.AddComponent(new PhysicsComponent(false, false, PhysicsMeshType.box));

            SystemCore.GameObjectManager.AddAndInitialiseGameObject(tempObject);
            tempObject.Transform.SetPosition(currentbuildPoint);

            //shape is translated
            c.Translate(currentbuildPoint);
            shapesToBake.Add(tempObject, c);
        }
Beispiel #9
0
        public DuneBuggy(PlayerIndex player, Color color, Microsoft.Xna.Framework.Vector3 position)
        {
            this.playerIndex = player;

            this.vehicle = VehicleFactory.Create(position.ToBepuVector());
            SystemCore.PhysicsSimulation.Add(vehicle);

            var shape = new ProceduralCuboid(2.5f / 2, 4.5f / 2, .75f / 2);

            shape.SetColor(color);
            BuggyObject = GameObjectFactory.CreateRenderableGameObjectFromShape(shape, EffectLoader.LoadSM5Effect("flatshaded"));
            BuggyObject.AddComponent(new ShadowCasterComponent());

            SystemCore.GameObjectManager.AddAndInitialiseGameObject(BuggyObject);

            wheels = new List <GameObject>();
            foreach (Wheel w in vehicle.Wheels)
            {
                var cube = new ProceduralCube();
                cube.SetColor(Color.Maroon);
                var wheel = GameObjectFactory.CreateRenderableGameObjectFromShape(cube, EffectLoader.LoadSM5Effect("flatshaded"));
                wheel.AddComponent(new ShadowCasterComponent());

                var particles = new SquareParticleSystem();

                wheel.AddComponent(particles);

                SystemCore.GameObjectManager.AddAndInitialiseGameObject(wheel);

                particles.settings.Duration = TimeSpan.FromSeconds(2f);

                wheels.Add(wheel);
            }

            uprightSpringConstraint = new UprightSpring(vehicle.Body, BEPUutilities.Vector3.Up, 0.1f, (float)Math.PI, 1000f);
            SystemCore.PhysicsSimulation.Add(uprightSpringConstraint);
        }