Exemple #1
0
 public virtual void OnHotspotChanged(CGizmo oGizmo, EEditMode eEditMode, EHotSpotOp eHotSpotOp)
 {
     switch (eEditMode) {
         case EEditMode.Move:			//###NOTE: We don't process rotation as the game only supports 0 or 180 Y rotation
             transform.position = oGizmo.transform.position;
             break;
     }
 }
Exemple #2
0
 //public void OnPropSet_BtnUpdateBody(float nValueOld, float nValueNew) {		//###BROKEN#11
 //    Debug.Log("CBody: Rebuilding body " + _oBodyBase._sBodyPrefix);
 //    //Pose_Save("TEMP");				// Save the current pose to a temp file so we can restore body as it was right after rebuild
 //    CGame.INSTANCE.CreateBody(_oBodyBase._nBodyID);		// Will destroy 'this' and rebuild entire new tree of objects & meshes all the way from Blender
 //    //Pose_Load("TEMP");				// Restore pose saved earlier
 //    CGame.INSTANCE.Scene_Reload();		//###HACK?  ###DESIGN: Reload whole scene to re-init position of newly created body
 //}
 //--------------------------------------------------------------------------	IHotspot interface
 public void OnHotspotChanged(CGizmo oGizmo, EEditMode eEditMode, EHotSpotOp eHotSpotOp)
 {
 }
Exemple #3
0
 //---------------------------------------------------------------------------	EVENTS
 public virtual void OnHotspotChanged(CGizmo oGizmo, EEditMode eEditMode, EHotSpotOp eHotSpotOp)
 {
     if (_iHotSpotMgr != null)
         _iHotSpotMgr.OnHotspotChanged(oGizmo, eEditMode, eHotSpotOp);		// Notify our manager that we have changed.
 }
Exemple #4
0
    public override void OnHotspotChanged(CGizmo oGizmo, EEditMode eEditMode, EHotSpotOp eHotSpotOp)
    {
        if (eEditMode != EEditMode.Move)				//###DESIGN!!!!: Can rotate?
            return;

        base.OnHotspotChanged(oGizmo, eEditMode, eHotSpotOp);		// Will set our position, properties and script record.
        Vector3 vecPosHotspotG = oGizmo.transform.position;
        Vector3 vecPosHotspotL = transform.parent.worldToLocalMatrix.MultiplyPoint(vecPosHotspotG);		// Convert the global hotspot position to the position relative to our parent (ActorEmpty) (Done so our animation is stored relative to our parent so user can drag parent while animating)

        if (oGizmo._bMiddleClickOp) {				// Left mouse button editing moves sex, middle mouse button animates

            switch (eHotSpotOp) {
                case EHotSpotOp.First:
                    _oCurveAnimY = new AnimationCurve();				// Create the animation curves to store the (independant) Y & Z coordinates
                    _oCurveAnimZ = new AnimationCurve();
                    _nAnimStartRec = Time.time;							// Store the time of clip recording so we can determine clip length for 0-based curves.
                    _vecPosStart = _vecPosLast = vecPosHotspotL;
                    _nDistTravelled = 0;
                    CGame.INSTANCE._nAnimMult_Pos = 1;				//###CHECK
                    CGame.INSTANCE._nAnimMult_Time = 1;
                    _eAnimMode = EAnimMode.Record;
                    break;

                case EHotSpotOp.Middle:
                    float nAnimTime = Time.time - _nAnimStartRec;
                    Vector3 vecPosFromStart = vecPosHotspotL - _vecPosStart;
                    _oCurveAnimY.AddKey(nAnimTime, vecPosFromStart.y);
                    _oCurveAnimZ.AddKey(nAnimTime, vecPosFromStart.z);
                    _nDistTravelled += (vecPosHotspotL - _vecPosLast).magnitude;		// Add the distance travelled this last frame
                    _vecPosLast = vecPosHotspotL;									// Remember where we are now for next distance travelled adder
                    //CGame.INSTANCE._sGuiString_Dev_DEBUG = string.Format("Rec {0:F1}  Dist: {1:F2}", nAnimTime, _nDistTravelled);
                    break;

                case EHotSpotOp.Last:		// End recording by adding one last data point to return to start position at an appropriately calculated time.
                    _nAnimStartPlay = Time.time;
                    _nAnimClipLength = _nAnimStartPlay - _nAnimStartRec;
                    _nAnimStartRec = 0;
                    float nVelocityAvg = _nDistTravelled / _nAnimClipLength;				// The average velocity of travel for this curve
                    float nDistStartPtToEndPt = (vecPosHotspotL - _vecPosStart).magnitude;	// The distance between the start and end point we must travel to to close the loop
                    float nTimeToReturnToStartPt = nDistStartPtToEndPt / nVelocityAvg;		// The time needed to return to starting point at average velocity
                    _nAnimStartPlay = Time.time - _nAnimClipLength;							// Set the current pointer to play to where we are at now in the curve.  (This will make us return to starting point smoothly)
                    _nAnimClipLength += nTimeToReturnToStartPt;								// Add the time to travel to the last point to the total clip time.
                    _oCurveAnimY.AddKey(_nAnimClipLength, 0);								// Add the starting point position at the end-of-clip time.
                    _oCurveAnimZ.AddKey(_nAnimClipLength, 0);

                    //=== Find the other body (if it exists) and slow-down or speed up our clip if our clip time is nearby the cliptime of the other body
                    //###BROKEN#11
                    //CBody oBodyOther = null;
                    //foreach (CBody oBody in CGame.INSTANCE._aBodyBases) {
                    //	if (oBody != _oBody) {
                    //		oBodyOther = oBody;
                    //		break;
                    //	}
                    //}
                    //if (oBodyOther != null && oBodyOther._oActor_Pelvis != null) {			// If another body with a sex actor exists...
                    //	if ((_nAnimClipLength <= oBodyOther._oActor_Pelvis._nAnimClipLength * 1.2f) && (_nAnimClipLength >= oBodyOther._oActor_Pelvis._nAnimClipLength * 0.8f)) {		//... and has nearly the same lenght as ours...	###TUNE
                    //		oBodyOther._oActor_Pelvis._nTimeRatioToMatchOtherBody = oBodyOther._oActor_Pelvis._nAnimClipLength / _nAnimClipLength;	// We set the other body's time because we could be facing a long return to first position as inserted above
                    //		//Debug.Log("Anim: _nTimeRatioToMatchOtherBody = " + oBodyOther._oActor_Pelvis._nTimeRatioToMatchOtherBody);
                    //	}
                    //}
                    _nTimeRatioToMatchOtherBody = 1;
                    //CGame.INSTANCE._sGuiString_Dev_DEBUG = "";
                    _eAnimMode = EAnimMode.Play;
                    break;

            }
        } else {
            _eAnimMode = EAnimMode.Stopped;				// If user moves with left mouse button we stop previously recorded animation
        }
    }
Exemple #5
0
    public virtual void OnHotspotChanged(CGizmo oGizmo, EEditMode eEditMode, EHotSpotOp eHotSpotOp)
    {
        _oBody.SelectBody();			// Manipulating a body's hotspot automatically selects this body.

        switch (eEditMode) {
            case EEditMode.Move:
                Vector3 vecPosG = oGizmo.transform.position;		//###NOTE: Upon hotspot movement we have to set not only our transform properties but CProp as well.
                Vector3 vecPosL;
                if (transform.name == "Base")				// If the base actor is moving we set the global position otherwise we move the child actor relatve to the base actor  ###IMPROVE: Test by type isntead of string!
                    vecPosL = vecPosG;
                else
                    vecPosL = transform.parent.worldToLocalMatrix.MultiplyPoint(vecPosG);		// Convert the global hotspot position to be relative to the actor's parent (Usually 'Base' or 'Torso')
                _oObj.PropSet(EActorNode.PosX, vecPosL.x);		//###NOTE: Setting EActorNode for all actors (all have same enum index for same pin properties)
                _oObj.PropSet(EActorNode.PosY, vecPosL.y);
                _oObj.PropSet(EActorNode.PosZ, vecPosL.z);
                transform.localPosition = vecPosL;
                break;
            case EEditMode.Rotate:
                Quaternion quatRotG = oGizmo.transform.rotation;			//###DESIGN???: Problem with rotation?
                transform.rotation = quatRotG;		//###WEAK!!  ###OPT!  Some work duplication with PropSet below setting our transform!
                Quaternion quatRotL = transform.localRotation;
                _oObj.PropSet(EActorNode.RotX, quatRotL.x);
                _oObj.PropSet(EActorNode.RotY, quatRotL.y);
                _oObj.PropSet(EActorNode.RotZ, quatRotL.z);
                _oObj.PropSet(EActorNode.RotW, quatRotL.w);
                break;
        }
    }