Exemple #1
0
        public void Init()
        {
            /*initialize canvas element*/
            CanvasElementGl canvasElem = Document.GetElementById("mainCanvas").As<CanvasElementGl>();
            if (canvasElem == null)
                throw new Exception("No canvas element found!");

            /*create and initialize the engine*/
            this._engine = new Engine();
            this._graphics = new WebGLGraphics(canvasElem);

            this._engine.Graphics = this._graphics;
            this._engine.ActiveGame = new Demo();
            this._engine.Library = new Library();
            this._graphics.Library = this._engine.Library;

            /*create empty world*/
            this._engine.World = new World();
            this._graphics.World = this._engine.World;

            this._engine.Library.AddConverter(new LightConverter());
            this._engine.Library.AddConverter(new MeshConverter(this._graphics));
            this._engine.Library.AddConverter(new NodeConverter());
            this._engine.Library.AddConverter(new MaterialConverter());
            this._engine.Library.AddConverter(new TextureConverter(this._graphics));

            /*Initialize the environment*/
            this.InitEnvironment((CanvasElement)(Object)canvasElem);

            /*startup engine*/
            this._engine.Run();

            CollisionComponent c = new CollisionComponent();
        }
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        protected override void BindParent()
        {
            /*geomerty nodes*/
            _mechNode = this.Parent.FindChild("mech", true);
            _headNode = this.Parent.FindChild("head", true);
            _bodyNode = this.Parent.FindChild("body", true);

            _ulegLeftNode = _bodyNode.FindChild("ulegl", true);
            _ulegRightNode = _bodyNode.FindChild("ulegr", true);

            _llegLeftNode = _ulegLeftNode.FindChild("llegl", true);
            _llegRightNode = _ulegRightNode.FindChild("llegr", true);

            _footLeftNode = _llegLeftNode.FindChild("footl", true);
            _footRightNode = _llegRightNode.FindChild("footr", true);

            /*animation*/
            this._animation.Animations.Add(_bodyNode.Animation);

            this._animation.Animations.Add(_ulegLeftNode.Animation);
            this._animation.Animations.Add(_ulegRightNode.Animation);

            this._animation.Animations.Add(_llegLeftNode.Animation);
            this._animation.Animations.Add(_llegRightNode.Animation);

            this._animation.Animations.Add(_footLeftNode.Animation);
            this._animation.Animations.Add(_footRightNode.Animation);

            this._animation.SetRange(0, 48, true);

            /*collision*/
            Node coll = _mechNode.FindChild("__cs_mech", true);
            this._collision = (CollisionComponent) coll.Components[Component.CollisionComponent];
        }