Beispiel #1
0
        protected override void Init()
        {
            ShowUniformSphere = true;
            YDirectionArrow = new GameObject("yDirectionArrow");
            ZDirectionArrow = new GameObject("zDirectionArrow");
            XDirectionArrow = new GameObject("xDirectionArrow");

            AddChild(XDirectionArrow);
            AddChild(YDirectionArrow);
            AddChild(ZDirectionArrow);

            _xDirection = new Cube() { Name = "xDirection" };
            _yDirection = new Cube() { Name = "yDirection" };
            _zDirection = new Cube() { Name = "zDirection" };

            AddChild(_xDirection);
            AddChild(_yDirection);
            AddChild(_zDirection);

            UniformSphere = new Sphere() { Scale = new Vector3(2.0f) };

            AddChild(UniformSphere);

            ArrowLength = 7.0f;

            RenderQueuePriority = -1;
            ClearsZBuffer = true;

            foreach (var child in Children)
            {
                child.RenderQueuePriority = RenderQueuePriority - 1;
                child.Designer = true;
            }
        }
        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);
        }