Example #1
0
void __fastcall TfrmMain::UpdateCaption(TJvFullColorLabel* ALabel)
{
  unsigned int Index;
  TColor LColor;

  TJvColorSpace* cspace = ColorSpaceManager()->ColorSpace[ColorSpaceManager()->GetColorSpaceID(ALabel->LabelColor)];
//  with ColorSpaceManager, ColorSpace[GetColorSpaceID(ALabel.LabelColor)] do
    if (cspace->ID == csDEF)
    {
      //with TJvDEFColorSpace(ColorSpace[csDEF]) do
      TJvDEFColorSpace* defcspace = dynamic_cast<TJvDEFColorSpace*>(ColorSpaceManager()->ColorSpace[csDEF]);
      {
        LColor = defcspace->ConvertToColor(ALabel->LabelColor);
        for (Index = 0; Index < defcspace->ColorCount; Index++)
        {
          if (defcspace->ColorValue[Index]==LColor)
          {
            ALabel->Caption = Format("%s : %s",ARRAYOFCONST((defcspace->ShortName,defcspace->ColorPrettyName[Index])));
            break;
          }

          if (Index == defcspace->ColorCount)
            ALabel->Caption = defcspace->ShortName+" : Invalid color";
        }
      }
    }
    else
      ALabel->Caption = Format("%s : %s=%d ; %s=%d ; %s=%d",
            ARRAYOFCONST((cspace->ShortName,
            cspace->AxisName[axIndex0],
            GetAxisValue(ALabel->LabelColor,axIndex0),
            cspace->AxisName[axIndex1],
            GetAxisValue(ALabel->LabelColor,axIndex1),
            cspace->AxisName[axIndex2],
            GetAxisValue(ALabel->LabelColor,axIndex2))));
}
void iPhysicsController::Update(float afTimeStep)
{
    if(mbActive==false || mbPaused) return;
    if(mpBody==NULL) return;

    cVector3f vInput = GetInputValue(mInputType);
    //Get the local input.
    if(	mbUseInputMatrixFix == false ||
            (mInputType != ePhysicsControllerInput_JointAngle && mInputType != ePhysicsControllerInput_JointDist) )
        {
            vInput = cMath::MatrixMul(cMath::MatrixInverse(mpBody->GetLocalMatrix().GetRotation()),vInput);
        }


    float fValue = GetAxisValue(mInputAxis, vInput);
    float fError = mfDestValue - fValue;

    float fOutput = GetOutputValue(fError,fValue,afTimeStep);

    if(mfMaxOutput>0)
        {
            if(fOutput>0)
                fOutput = cMath::Min(fOutput, mfMaxOutput);
            else
                fOutput = cMath::Max(fOutput, -mfMaxOutput);
        }

    if(mbLogInfo)
        Log("%s | Input: %f Dest: %f Error: %f OutPut: %f\n",msName.c_str(),fValue,mfDestValue,fError,fOutput);

    AddOutputValue(mOutputType,mOutputAxis,fOutput);

    ////////////////////////////////////////
    //Check if dest vale is reached
    if(mEndType == ePhysicsControllerEnd_OnDest && mpJoint)
        {
            if(std::abs(fValue - mfDestValue) < kEpsilonf)
                {
                    mbActive = false;
                    iPhysicsController *pNext = mpJoint->GetController(msNextController);
                    if(pNext) pNext->SetActive(true);
                }
        }
}