예제 #1
0
파일: TestScene.cs 프로젝트: pdeparcq/iGL
        public override void Load()
        {
            /* create camera */

            _testCamera = new Camera(MathHelper.DegreesToRadians(45.0f), 3.0f / 2.0f, 1.00f, 1000.0f);
            _testCamera.Position = new Vector3(0.0f, 10.0f, 10.0f);

            AddGameObject(_testCamera);
            SetCurrentCamera(_testCamera.CameraComponent);

            ShaderProgram.SetAmbientColor(new Vector4(0.5f, 0.5f, 0.5f, 1.0f));

            /* add a point light */

            var pointlight = new PointLight();
            pointlight.Ambient = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
            pointlight.Diffuse = new Vector4(1.0f, 1.0f, 0.8f, 1.0f);

            _testLight = new LightObject(pointlight);
            _testLight.Position = new Vector3(0, 500, 0);
            AddGameObject(_testLight);

            SetCurrentLight(_testLight.LightComponent);

            /* add some test cubes */

            _testCube = new Cube(1.0f, 1.0f, 1.0f);
            _testCube.Material.Ambient = new Vector4(0.1f, 0.1f, 0.1f, 0.0f);
            _testCube.Material.Diffuse = new Vector4(1.0f, 0.0f, 0.0f, 0.0f);
            _testCube.Position = new Vector3(0.0f, 0.0f, 0.0f);

            AddGameObject(_testCube);

            /* let the camera follow the testcube */
            _testCamera.CameraComponent.Target = _testCube.Position;

            var floor = new Cube(10.0f, 1.0f, 10.0f);
            floor.Position = new Vector3(0.0f, -1.0f, 0.0f);
            floor.Material.Ambient = new Vector4(0.1f, 0.1f, 0.1f, 0.0f);
            floor.Material.Diffuse = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);

            AddGameObject(floor);

            for (int i = 0; i < 10; i++)
            {
                var cube = new Cube(1.0f, 1.0f, 1.0f);
                cube.Material.Ambient = new Vector4(0.1f, 0.1f, 0.1f, 0);
                cube.Material.Diffuse = new Vector4(i / 10.0f, i / 10.0f, i / 10.0f, 0);

                cube.Position = new Vector3(4.5f, 0.0f, -4.5f + i);

                AddGameObject(cube);
            }
        }
예제 #2
0
        protected override void Init()
        {
            base.Init();

            _rigidBodyComponent = this.Components.Single(c => c is RigidBodyFarseerComponent) as RigidBodyFarseerComponent;
            _meshComponent = this.Components.Single(c => c is MeshComponent) as MeshComponent;

            _rigidBodyComponent.IsGravitySource = true;
            _rigidBodyComponent.GravityRange = 1.0f;
            _rigidBodyComponent.IsStatic = true;
            _rigidBodyComponent.Mass = 1000;

            _selectionCube = this.Children.Single(c => c.Id == SelectionCubeId) as Cube;
            _selectionCube.OnMouseDown += SphereMagnet_OnMouseDown;
            _selectionCube.Visible = false;

            _haloPlane = this.Children.Single(c => c.Id == HaloPlaneId) as MagnetHalo;
            _haloPlane.Material.TextureName = "MagnetHalo";

            this.OnScale += new EventHandler<Engine.Events.ScaleEvent>(SphereMagnet_OnScale);
        }