예제 #1
0
    public void ThisMethodIsntAllowedToBeNamedUpdateByUnity( Constraint constraint, Camera camera )
    {
      if ( constraint == null || State != States.INITIALIZED )
        return;

      if ( constraint.Type == ConstraintType.AngularLockJoint )
        return;

      var sphereRadius           = 0.05f;
      var cylinderRadius         = 0.5f * sphereRadius;
      var distReferenceConnected = Vector3.Distance( constraint.AttachmentPair.ReferenceFrame.Position,
                                                     constraint.AttachmentPair.ConnectedFrame.Position );
      var cameraScale            = Spawner.Utils.FindConstantScreenSizeScale( constraint.AttachmentPair.ReferenceFrame.Position,
                                                                              camera );
      ReferenceSphere.SetActive( true );
      ConnectedSphere.SetActive( true );
      ConnectingCylinder.SetActive( distReferenceConnected > 1.0E-4f );

      Spawner.Utils.SetSphereTransform( ReferenceSphere,
                                        constraint.AttachmentPair.ReferenceFrame.Position,
                                        Quaternion.identity,
                                        cameraScale * sphereRadius );

      Spawner.Utils.SetSphereTransform( ConnectedSphere,
                                        constraint.AttachmentPair.ConnectedFrame.Position,
                                        Quaternion.identity,
                                        cameraScale * sphereRadius );

      Spawner.Utils.SetCylinderTransform( ConnectingCylinder,
                                          constraint.AttachmentPair.ReferenceFrame.Position,
                                          constraint.AttachmentPair.ConnectedFrame.Position,
                                          cameraScale * cylinderRadius );
    }
예제 #2
0
    protected override bool Initialize()
    {
      const string shader = "Standard";

      if ( GetComponent<Constraint>().Type == ConstraintType.AngularLockJoint )
        return true;

      ReferenceSphere    = Spawner.Create( Spawner.Primitive.Sphere, "PHR_ReferenceSphere", HideFlags.HideAndDontSave, shader );
      ConnectedSphere    = Spawner.Create( Spawner.Primitive.Sphere, "PHR_ConnectedSphere", HideFlags.HideAndDontSave, shader );
      ConnectingCylinder = Spawner.Create( Spawner.Primitive.Cylinder, "PHR_ConnectingCylinder", HideFlags.HideAndDontSave, shader );

      ReferenceSphere.transform.SetParent( gameObject.transform );
      ConnectedSphere.transform.SetParent( gameObject.transform );
      ConnectingCylinder.transform.SetParent( gameObject.transform );

      Spawner.Utils.SetColor( ReferenceSphere, PickHandler.ReferenceSphereColor );
      Spawner.Utils.SetColor( ConnectedSphere, PickHandler.ConnectedSphereColor );
      Spawner.Utils.SetColor( ConnectingCylinder, PickHandler.ConnectingCylinderColor );

      // We'll update this active state in the Update method.
      ReferenceSphere.SetActive( false );
      ConnectedSphere.SetActive( false );
      ConnectingCylinder.SetActive( false );

      return true;
    }
예제 #3
0
        public void ThisMethodIsntAllowedToBeNamedUpdateByUnity(Constraint constraint)
        {
            if (constraint == null || State != States.INITIALIZED)
            {
                return;
            }

            if (constraint.Type == ConstraintType.AngularLockJoint)
            {
                return;
            }

            const float sphereRadius           = 0.05f;
            const float cylinderRadius         = 0.5f * sphereRadius;
            float       distReferenceConnected = Vector3.Distance(constraint.AttachmentPair.ReferenceFrame.Position, constraint.AttachmentPair.ConnectedFrame.Position);

            ReferenceSphere.SetActive(true);
            ConnectedSphere.SetActive(true);
            ConnectingCylinder.SetActive(distReferenceConnected > 1.0E-4f);

            Rendering.Spawner.Utils.SetSphereTransform(ReferenceSphere,
                                                       constraint.AttachmentPair.ReferenceFrame.Position,
                                                       Quaternion.identity,
                                                       sphereRadius,
                                                       true);

            Rendering.Spawner.Utils.SetSphereTransform(ConnectedSphere,
                                                       constraint.AttachmentPair.ConnectedFrame.Position,
                                                       Quaternion.identity,
                                                       sphereRadius,
                                                       true);

            Rendering.Spawner.Utils.SetCylinderTransform(ConnectingCylinder,
                                                         constraint.AttachmentPair.ReferenceFrame.Position,
                                                         constraint.AttachmentPair.ConnectedFrame.Position,
                                                         cylinderRadius,
                                                         true);
        }