Esempio n. 1
0
    public void Init()
    {
        Vector3 position = new Vector3(x, y, z);

        //ставим в начало координат на нижнюю грань и устанавливаем размеры
        //можно ставить в любое место, всё должно посчитаться
        transform.position   = new Vector3(position.x, position.y + height / 2, position.z);
        transform.localScale = new Vector3(width, height, width);

        //следующее звено
        HingeJoint       hinge        = GetComponent <HingeJoint>();
        GameObject       next         = hinge.connectedBody.gameObject;
        rotatingplatform nextbehavior = hinge.connectedBody.GetComponent <rotatingplatform>();

        //размещаем следующее звено
        next.transform.localScale = new Vector3(nextbehavior.diameter, nextbehavior.width, nextbehavior.diameter);
        next.transform.position   = new Vector3(transform.position.x, transform.position.y + (height + /*mul 2 for cylinder*/ 2 * nextbehavior.width) / 2, transform.position.z);

        //якорь шарнира
        hinge.anchor = new Vector3(0.0f, 0.5f, 0.0f);

        //настраиваем привод шарнира
        drive.Attach(gameObject, next);
        drive.AngleRange.SetLimits(angle0, angle1);
        drive.AngleRange.SetTarget(angle0);

        //инициализируем следующие звенья
        nextbehavior.Init(position, angle);

        //поворачиваем вокруг вертикальной оси
        transform.RotateAround(position, Vector3.down, angle);
    }
Esempio n. 2
0
    public void Init(Vector3 position, float angle)
    {
        //следующее звено
        HingeJoint           hinge        = GetComponent <HingeJoint>();
        GameObject           next         = hinge.connectedBody.gameObject;
        armhingemanipulator2 nextbehavior = hinge.connectedBody.GetComponent <armhingemanipulator2>();

        //размещаем следующее звено
        next.transform.localScale = new Vector3(nextbehavior.diameter, nextbehavior.width, nextbehavior.diameter);
        next.transform.position   = new Vector3(transform.position.x, transform.position.y + (length + nextbehavior.diameter) / 2, transform.position.z);

        //якорь шарнира
        hinge.anchor = new Vector3(0.0f, 0.5f + nextbehavior.diameter / length / 2, 0.0f);

        //настраиваем привод шарнира
        drive.Attach(gameObject, next);
        drive.AngleRange.SetLimits(-90 + angle0, -90 + angle1);
        drive.AngleRange.SetTarget(-90 + angle0);

        //инициализируем следующие звенья
        nextbehavior.Init(position, angle);

        //поворачиваем вокруг вертикальной оси
        transform.RotateAround(position, Vector3.down, angle);
    }
Esempio n. 3
0
    public void Init(capture1 device)
    {
        GetComponent <Rigidbody>().mass       = device.config.ClampMass / 2;
        GetComponent <Rigidbody>().useGravity = device.config.UseGravity;

        transform.localScale = new Vector3(device.config.ClampDiameter, device.config.ClampWidth / 2 / CylinderFullHeight, device.config.ClampDiameter);
        transform.position   = pivotObject.transform.rotation * (Vector3.down * device.config.ClampWidth / 2) + pivotObject.transform.position;
        transform.rotation   = pivotObject.transform.rotation;

        joint.Config(pivotObject, gameObject, device.config.ClampConnectorKinematic, JointPhysics.Hinge);

        drive.KinematicAngularVelocity = device.config.ClampConnectorKinematicAngularVelocity;
        drive.Proportional             = device.config.ClampConnectorACSProportional;
        drive.Integral     = device.config.ClampConnectorACSIntegral;
        drive.Differential = device.config.ClampConnectorACSDifferential;
        drive.Attach(joint);
        drive.AngleRange.SetLimits(device.config.ClampConnectorAngle0, device.config.ClampConnectorAngle1);
        drive.AngleRange.SetTarget(device.config.ClampConnectorAngle0);
    }
Esempio n. 4
0
    public void Init(finger1 device)
    {
        GetComponent <Rigidbody>().mass       = device.config.SectionMass / 2;
        GetComponent <Rigidbody>().useGravity = device.config.UseGravity;

        transform.localScale = new Vector3(device.config.SectionThick, device.config.SectionWidth / CylinderFullHeight, device.config.SectionThick);
        transform.position   = pivotObject.transform.rotation * (Vector3.down * (isFirst ? device.config.ConnectorHeight : device.config.SectionHeight) / 2) + pivotObject.transform.position;
        transform.rotation   = pivotObject.transform.rotation * Quaternion.AngleAxis(90, Vector3.right);

        joint.Config(pivotObject, gameObject, device.config.Kinematic, JointPhysics.Hinge);

        drive.KinematicAngularVelocity = device.config.SectionKinematicAngularVelocity;
        drive.Proportional             = device.config.SectionACSProportional;
        drive.Integral     = device.config.SectionACSIntegral;
        drive.Differential = device.config.SectionACSDifferential;
        drive.Attach(joint);
        drive.AngleRange.SetLimits(device.config.SectionAngle0, device.config.SectionAngle1);
        drive.AngleRange.SetTarget(device.config.SectionAngle0);
    }