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); } }
protected override void Init() { base.Init(); _aimSphere = Children.First(c => c.Id == DisplaySphereId) as Sphere; _aimSphere.Name = "aimSphere"; _aimSphere.Scale = new Vector3(5); _aimSphere.Material.Ambient = new Vector4(1, 0, 0, 0.5f); _aimSphere.Material.TextureName = "ball"; _aimSphere.OnMouseDown += new EventHandler<Engine.Events.MouseButtonDownEvent>(_aimSphere_OnMouseDown); _aimSphere.OnMouseUp += new EventHandler<Engine.Events.MouseButtonUpEvent>(_aimSphere_OnMouseUp); _aimSphere.Visible = false; _arrow2d = Children.First(c => c.Id == Arrow2dId) as Arrow2d; _lightObject = Children.First(c => c.Id == LightObjectId) as LightObject; _lightObject.Visible = false; _lightObject.Enabled = false; _meshComponent = this.Components.First(c => c is MeshComponent) as MeshComponent; _rigidBodyComponent = this.Components.First(c => c is RigidBodyFarseerComponent) as RigidBodyFarseerComponent; var circleCollider = this.Components.First(c => c is CircleColliderFarseerComponent) as CircleColliderFarseerComponent; //circleCollider.Radius = 0.5f; Material.TextureName = "greenball"; _leftEye = this.Children.First(c => c.Id == LeftEyeId) as Plane; _rightEye = this.Children.First(c => c.Id == RightEyeId) as Plane; _leftEye.Material.TextureName = "eye"; _rightEye.Material.TextureName = "eye"; _leftEye.DistanceSorting = true; _rightEye.DistanceSorting = true; _leftEye.Position = -_eyePosition; _rightEye.Position = _eyePosition; _rightEye.Scale = new Vector3(0.1f, 0.1f, 0.1f); _leftEye.Scale = new Vector3(0.1f, 0.1f, 0.1f); }