Exemple #1
0
        public static void generate_generic(
            int dof,
            Spatial parent,
            Vector3 origin)
        {
            configure(dof);
            // Create Static base
            StaticBody base_node = generate_base(new Vector3(0.7F, 0.2F, 0.7F));

            List <Spatial> links  = generate_links();
            List <Joint>   joints = generate_joints();

            parent.AddChild(base_node);
            base_node.GlobalTranslate(origin);
            base_node.GlobalRotate(new Vector3(0F, 1F, 0F), rand.RandfRange(-3.14F, 3.14F));

            Joint base_joint = joints[0];

            base_node.AddChild(base_joint);

            for (int i = 1; i < dof; i++)
            {
                Spatial link  = links[i - 1];
                Joint   joint = joints[i];

                link.AddChild(joint);
                base_joint.AddChild(link);
            }
            base_joint.AddChild(links[dof - 1]);

            transform_all(base_node, base_joint);
            // connect_joints(joints, links, base_node, base_joint, dof);
        }
Exemple #2
0
    private void GenerateNDofArmHelper(int N)
    {
        // Create base
        StaticBody base_node = generate_static(String.Format("{0}_dof_base", N));

        // Create N-1 Rigid Bodies
        List <Spatial> links = create_links(N - 1);

        print_list(links);

        // Create N Joints
        List <Joint> joints = create_joints(N);

        print_list(joints);

        Spatial env_node = RootView.GetNode <Spatial>("main/env");

        env_node.AddChild(base_node);

        base_node.GlobalTranslate(new Vector3(rand.Randfn() * 3F, 0F, rand.Randfn() * 3F));
        base_node.GlobalRotate(new Vector3(0F, 1F, 0F), rand.RandfRange(-3.14F, 3.14F));

        Joint base_joint = joints[0];

        // Add base joint
        base_node.AddChild(base_joint);

        for (int i = 1; i < N; i++)
        {
            Spatial link  = links[i - 1];
            Joint   joint = joints[i];

            link.AddChild(joint);
            base_joint.AddChild(link);
        }
        base_joint.AddChild(links[N - 1]);

        construct_transforms(base_node, base_joint);
        connect_joints(joints, links, base_node, base_joint, N);

        EmitSignal("ArmAdded", base_node);
    }