Esempio n. 1
0
        public override void Init()
        {
            IKSolver ikSolver;
            World    world;

            AddSystems(new FpsCounter(updatesPerSec: 10),
                       world    = new World(),
                       ikSolver = new IKSolver(),
                       new Renderer());

            base.Init();

            CreateIKChain(ikSolver, Quaternion.Identity, 1.0f, new Vector3(0.0f, 0.0f, 0.0f));
            //CreateIKChain(ikSolver, Quaternion.CreateFromAxisAngle(Vector3.Backward, MathHelper.ToRadians(0.0f)), 1.0f, new Vector3(-0.6f, 0.0f, 0.0f));
            //CreateIKChain(ikSolver, Quaternion.CreateFromAxisAngle(Vector3.Backward, MathHelper.ToRadians(-0.0f)), 1.0f, new Vector3(0.6f, 0.0f, 0.0f));

            InitScene(Vector3.Zero);

            world.Bounds = new BoundingBox(-3.5f * new Vector3(1.0f, 0.0f, 1.0f), 3.5f * Vector3.One);
        }
Esempio n. 2
0
        private void CreateIKChain(IKSolver ikSolver, Quaternion rot, float scale, Vector3 pos)
        {
            ikbc = ikSolver.CreateBoneChain();

            var t = 0.15f;

            ikbc.AddBone(0.2f * scale, Color.Gray, new Vector3(0.0f, 0.5f, 0.0f) + pos, t);
            for (var i = 0; i < 2; i++)
            {
                t *= 0.8f;
                ikbc.AddBone(0.3f * scale, Color.Gray, null, t);
                t *= 0.8f;
                ikbc.AddBone(0.3f * scale, Color.Gray, null, t);
            }

            t *= 0.8f;
            ikbc.AddBone(0.3f * scale, Color.Red, null, t);

            ikbc.mBones[0].BaseRot = rot;

            ikbc.DropPos1 = new Vector3(-0.6f, 1.1f, 0.8f);
            ikbc.DropPos2 = new Vector3(0.6f, 1.1f, 0.8f);

            var g = Program.Inst.GraphicsDevice;

            var stoolColor     = Color.Red;
            var stoolTransform = Matrix.CreateScale(0.5f * Vector3.One) * Matrix.CreateTranslation(0.25f * Vector3.Up + pos);
            var stoolMesh      = MeshGen.Disc(0.4f, 1.0f).FlipNormals().Transform(stoolTransform).Color(stoolColor);

            AddEntity(new EcsEntity(new CAabb {
                Aabb = stoolMesh.Aabb()
            },
                                    new CMesh {
                Mesh = stoolMesh.Gpu(g)
            }));
        }