コード例 #1
0
ANGLE3D CModelInstance::GetOffsetRot()
{
  ANGLE3D aRot;
  FLOATmatrix3D mat;
  mi_qvOffset.qRot.ToMatrix(mat);
  DecomposeRotationMatrix(aRot,mat);
  return aRot;
}
コード例 #2
0
// mirror a placement of one entity
static void MirrorAndStretchPlacement(CPlacement3D &pl)
{
  ASSERT(_wmtMirror==WMT_X||_wmtMirror==WMT_Y||_wmtMirror==WMT_Z||_wmtMirror==WMT_NONE);

  // if there should be mirror
  if (_wmtMirror!=WMT_NONE) {
    // make rotation matrix for the placement
    FLOATmatrix3D m;
    MakeRotationMatrix(m, pl.pl_OrientationAngle);
    // get row vectors, with object x flipped
    FLOAT3D vX(-m(1,1),m(1,2),m(1,3));
    FLOAT3D vY(-m(2,1),m(2,2),m(2,3));
    FLOAT3D vZ(-m(3,1),m(3,2),m(3,3));

    // flip needed axis
    switch(_wmtMirror) {
    case WMT_X: 
      pl.pl_PositionVector(1) = -pl.pl_PositionVector(1);
      vX = -vX; 
      break;
    case WMT_Y: 
      pl.pl_PositionVector(2) = -pl.pl_PositionVector(2);
      vY = -vY; 
      break;
    case WMT_Z: 
      pl.pl_PositionVector(3) = -pl.pl_PositionVector(3);
      vZ = -vZ; 
      break;
    default: ASSERT(FALSE);
    }

    // compose matrix back from the vectors
    m(1,1) = vX(1); m(2,1) = vY(1); m(3,1) = vZ(1);
    m(1,2) = vX(2); m(2,2) = vY(2); m(3,2) = vZ(2);
    m(1,3) = vX(3); m(2,3) = vY(3); m(3,3) = vZ(3);
    // decompose matrix into angles
    DecomposeRotationMatrix(pl.pl_OrientationAngle, m);
  }

  pl.pl_PositionVector*=_fStretch;
}
コード例 #3
0
/////////////////////////////////////////////////////////////////////////////
// value changed in some text box
void CTextBox::ValueChanged() 
{
  CSeriousSkaStudioDoc *pDoc = theApp.GetDocument();

  wchar_t wstrText[32];
  // get value from text box
  GetWindowText(wstrText,31);
  CTString strText = CStringA(wstrText);
  CModelTreeCtrl &m_TreeCtrl = theApp.m_dlgBarTreeView.m_TreeCtrl;
  // get selected item in tree view
  HTREEITEM hSelected = m_TreeCtrl.GetSelectedItem();
  if(hSelected == NULL) return;
  if(pmiSelected == NULL) return;

  INDEX iSelected = m_TreeCtrl.GetItemData(hSelected);
  INDEX iParent;
  // get parent of selected item in tree view
  HTREEITEM hParent = m_TreeCtrl.GetParentItem(hSelected);
  // if no parent set iParent to = 1 
  if(hParent == NULL) iParent = -1;
  else iParent = m_TreeCtrl.GetItemData(hParent);

  NodeInfo &niSelected = theApp.aNodeInfo[iSelected];

  FLOATmatrix3D mat;
  FLOAT3D &vPos = pmiSelected->mi_qvOffset.vPos;
  ANGLE3D aRot;
  pmiSelected->mi_qvOffset.qRot.ToMatrix(mat);
  DecomposeRotationMatrix(aRot,mat);
  // colison
  ColisionBox *pcb = NULL;
  if(pmiSelected->mi_iCurentBBox >= 0 && pmiSelected->mi_iCurentBBox < pmiSelected->mi_cbAABox.Count()) {
    pcb = &pmiSelected->mi_cbAABox[pmiSelected->mi_iCurentBBox];
  }
  if(niSelected.ni_iType == NT_ALLFRAMESBBOX) {
    pcb = &pmiSelected->mi_cbAllFramesBBox;
  }


  FLOAT fOffset[6] = {vPos(1),vPos(2),vPos(3),aRot(1),aRot(2),aRot(3)};

  INDEX ictrlID = GetDlgCtrlID();
  switch(ictrlID)
  {
    case IDC_TB_OFFSET_POSX:
      fOffset[0] = atof(strText);
      // set offset of selected object
      pmiSelected->SetOffset(fOffset);
    break;
    case IDC_TB_OFFSET_POSY:
      fOffset[1] = atof(strText);
      // set offset of selected object
      pmiSelected->SetOffset(fOffset);
    break;
    case IDC_TB_OFFSET_POSZ:
      fOffset[2] = atof(strText);
      // set offset of selected object
      pmiSelected->SetOffset(fOffset);
    break;
    case IDC_TB_OFFSET_ROTH:
      fOffset[3] = atof(strText);
      // set offset of selected object
      pmiSelected->SetOffset(fOffset);
      // refresh all text boxes for colision 
      theApp.m_dlgBarTreeView.SelItemChanged(hSelected);
    break;
    case IDC_TB_OFFSET_ROTP:
      fOffset[4] = atof(strText);
      // set offset of selected object
      pmiSelected->SetOffset(fOffset);
      // refresh all text boxes for colision 
      theApp.m_dlgBarTreeView.SelItemChanged(hSelected);
    break;
    case IDC_TB_OFFSET_ROTB:
      fOffset[5] = atof(strText);
      // set offset of selected object
      pmiSelected->SetOffset(fOffset);
      // refresh all text boxes for colision 
      theApp.m_dlgBarTreeView.SelItemChanged(hSelected);
    break;
    case IDC_EB_DISTANCE:
    {
      // set lod distance
      if(niSelected.ni_iType == NT_SKELETONLOD)
      {
        // if no parent return
        if(iParent < 0) return;
        NodeInfo &niParent   = theApp.aNodeInfo[iParent];
        // get references to objects
        CSkeleton *psk = (CSkeleton*)niParent.ni_pPtr;
        SkeletonLOD *slod = (SkeletonLOD*)niSelected.ni_pPtr;
        // change slods max distance
        slod->slod_fMaxDistance = atof(strText);
        theApp.UpdateRootModelInstance();
      }
      else if(niSelected.ni_iType == NT_MESHLOD)
      {
        // if no parent return
        if(iParent < 0) return;
        NodeInfo &niParent = theApp.aNodeInfo[iParent];
        // get references to objects
        MeshInstance *pmshi = (MeshInstance*)niParent.ni_pPtr;
        MeshLOD *pmlod = (MeshLOD*)niSelected.ni_pPtr;
        CMesh *pmesh = pmshi->mi_pMesh;
        // change mlods max distance
        pmlod->mlod_fMaxDistance = atof(strText);
        theApp.UpdateRootModelInstance();
      }
    }
    break;
    case IDC_EB_TRESHOLD:
    {
      if(niSelected.ni_iType == NT_ANIMATION)
      {
        // if no parent return
        if(iParent < 0) return;
        NodeInfo &niParent = theApp.aNodeInfo[iParent];
        // get references to objects
        CAnimSet *pas = (CAnimSet*)niParent.ni_pPtr;
        Animation *pan = (Animation*)niSelected.ni_pPtr;
        // remember old treshold
        FLOAT fOldTreshold = pan->an_fTreshold;
        pan->an_fTreshold = atof(strText);
        // convert only one animation in animset
        if(!theApp.ConvertAnimationInAnimSet(pas,pan)) {
          pan->an_fTreshold = fOldTreshold;
        }
        // update model instance
        theApp.UpdateRootModelInstance();
      }
    }
    break;
    case IDC_TB_COLWIDTH:
    {
      // change width of colision box
      if(pcb!=NULL)
      {
        FLOAT fWidth = atof(strText);
        FLOAT fPosX = (pcb->Max()(1)+pcb->Min()(1)) / 2;
        pcb->Min()(1) = -(fWidth/2) + fPosX;
        pcb->Max()(1) = (fWidth/2) + fPosX;
      }
    }
    break;
    case IDC_TB_COLHEIGHT:
    {
      // change height of colision box
      if(pcb!=NULL)
      {
        FLOAT fHeight = atof(strText);
        FLOAT fPosY = pcb->Min()(2);
        pcb->Min()(2) = fPosY;
        pcb->Max()(2) = fHeight + fPosY;
      }
    }
    break;
    case IDC_TB_COLLENGTH:
    {                  
      // change length of colision box
      if(pcb!=NULL)
      {
        FLOAT fLength = atof(strText);
        FLOAT fPosZ = (pcb->Max()(3)+pcb->Min()(3)) / 2;
        pcb->Min()(3) = -(fLength/2) + fPosZ;
        pcb->Max()(3) = (fLength/2) + fPosZ;
      }
    }
    break;
    case IDC_TB_COLPOSX:
    {
      // change pos x of colision box
      if(pcb!=NULL)
      {
        FLOAT fPosX = atof(strText);
        FLOAT fWidth = (pcb->Max()(1)-pcb->Min()(1));
        pcb->Min()(1) = -(fWidth/2) + fPosX;
        pcb->Max()(1) = (fWidth/2) + fPosX;
      }
    }
    break;
    case IDC_TB_COLPOSY:
    {
      // change pos y of colision box
      if(pcb!=NULL)
      {
        FLOAT fPosY = atof(strText);
        FLOAT fHeight = (pcb->Max()(2)-pcb->Min()(2));
        fPosY += fHeight/2;
        pcb->Min()(2) = -(fHeight/2) + fPosY;
        pcb->Max()(2) = (fHeight/2) + fPosY;
      }
    }
    break;
    case IDC_TB_COLPOSZ:
    {
      // change pos z of colision box
      if(pcb!=NULL)
      {
        FLOAT fPosZ = atof(strText);
        FLOAT fLength = (pcb->Max()(3)-pcb->Min()(3));
        pcb->Min()(3) = -(fLength/2) + fPosZ;
        pcb->Max()(3) = (fLength/2) + fPosZ;
      }
    }
    break;
    case IDC_TB_COLNAME:
    {
      // change name of colision box
      if(pcb!=NULL) {
        pcb->SetName(strText);
        m_TreeCtrl.SetItemText(hSelected, CString(strText));
      }
    }
    break;
    // change animation speed
    case IDC_EB_SECPERFRAME:
    {
      // if no parent return
      if(iParent < 0) return;
      NodeInfo &niParent = theApp.aNodeInfo[iParent];
      Animation *pan = (Animation*)niSelected.ni_pPtr;
      CAnimSet *pas = (CAnimSet*)niParent.ni_pPtr;
      pan->an_fSecPerFrame = atof(strText);
      if(pan->an_fSecPerFrame == 0) pan->an_fSecPerFrame = 0.00001f;
      // update model instance
      theApp.UpdateRootModelInstance();
    }
    break;
    // change animation walk speed 
    case IDC_TB_WALKSPEED:
    {
      pDoc->m_fSpeedZ = atof(strText);
      return; // do not mark doc as channged
    }
    break;
    // change animation walk loop
    case IDC_TB_WALKLOOP:
    {
      pDoc->m_fLoopSecends = atof(strText);
      return; // do not mark doc as channged
    }
    break;
    case IDC_EB_TEXTURENAME:
    {
      TextureInstance *pti = (TextureInstance*)niSelected.ni_pPtr;
      pti->SetName(CTString(strText));
      // update model instance
      theApp.UpdateRootModelInstance();
    }
    break;
    case IDC_TB_MI_NAME:
    {
      NodeInfo &ni = theApp.m_dlgBarTreeView.GetSelectedNodeInfo();
      CModelInstance &mi = *(CModelInstance*)ni.ni_pPtr;
      mi.SetName(strText);
      // update model instance
      theApp.UpdateRootModelInstance();
    }
    break;
    default:
    {
      // check if this text box is in shader dialog
      if((ictrlID>FIRSTSHADEID) && (ictrlID<LASTSHADEID))
      {
        // control is in shader dialog
        theApp.m_dlgBarTreeView.ChangeFloatOnSelectedSurfaces(m_strID,atof(strText));
      }
    }
    break;
  }
  pDoc->MarkAsChanged();
}