bool CGizmoTransformRotate::GetOpType(ROTATETYPE &type, unsigned int x, unsigned int y) { tvector3 rayOrigin,rayDir, axis; tvector3 dir = m_pMatrix->GetTranslation()-m_CamSrc; dir.Normalize(); BuildRay(x, y, rayOrigin, rayDir); if (mMask&AXIS_TRACKBALL) if (CheckRotatePlan(dir,1.0f,rayOrigin,rayDir,-1)) { tmatrix mt = *m_pMatrix; mt.NoTrans(); //mt.Inverse(); //m_Axis = m_Axis2 = dir; m_Axis.TransformPoint(mt); /* m_Axis *=tvector3(GetTransformedVector(0).Length(), GetTransformedVector(1).Length(), GetTransformedVector(2).Length()); */ type = ROTATE_TWIN; return true; } // plan 1 : X/Z m_Axis = GetTransformedVector(0); if (mMask&AXIS_X) if (CheckRotatePlan(m_Axis,1.0f,rayOrigin,rayDir,0)) { type = ROTATE_X; return true; } m_Axis = GetTransformedVector(1); if (mMask&AXIS_Y) if (CheckRotatePlan(m_Axis,1.0f,rayOrigin,rayDir,1)) { type = ROTATE_Y; return true; } m_Axis = GetTransformedVector(2); if (mMask&AXIS_Z) if (CheckRotatePlan(m_Axis,1.0f,rayOrigin,rayDir,2)) { type = ROTATE_Z; return true; } //m_Axis = GetTransformedVector(dir); if (mMask&AXIS_SCREEN) if (CheckRotatePlan(dir,1.2f,rayOrigin,rayDir,-1)) { tmatrix mt = *m_pMatrix; mt.NoTrans(); mt.Inverse(); m_Axis = m_Axis2 = dir; m_Axis.TransformPoint(mt); m_Axis *=tvector3(GetTransformedVector(0).Length(), GetTransformedVector(1).Length(), GetTransformedVector(2).Length()); type = ROTATE_SCREEN; return true; } type = ROTATE_NONE; return false; }
bool CGizmoTransformMove::GetOpType(MOVETYPE &type, unsigned int x, unsigned int y) { tvector3 rayOrigin, rayDir, df; BuildRay(x, y, rayOrigin, rayDir); m_svgMatrix = *m_pMatrix; tvector3 trss(GetTransformedVector(0).Length(), GetTransformedVector(1).Length(), GetTransformedVector(2).Length()); tmatrix mt; if (mLocation == LOCATE_LOCAL) { mt = *m_pMatrix; mt.V4.position += vector4(m_Offset, 0.0f); mt.Inverse(); } else { // world tvector4 pos = m_pMatrix->V4.position; pos += vector4(m_Offset, 0.0f); mt.Translation(-pos); } // plan 1 : X/Z df = RayTrace2(rayOrigin, rayDir, GetTransformedVector(1), mt, trss, false); if ( ( df.x >= 0 ) && (df.x <= 1) && ( fabs(df.z) < 0.1f ) ) { type = MOVE_X; return true; } else if ( ( df.z >= 0 ) && (df.z <= 1) && ( fabs(df.x) < 0.1f ) ){ type = MOVE_Z; return true; } else if ( (df.x<0.5f) && (df.z<0.5f) && (df.x>0) && (df.z>0)) { type = MOVE_XZ; return true; } else { //plan 2 : X/Y df = RayTrace2(rayOrigin, rayDir, GetTransformedVector(2), mt, trss, false); if ( ( df.x >= 0 ) && (df.x <= 1) && ( fabs(df.y) < 0.1f ) ) { type = MOVE_X; return true; } if ( ( df.y >= 0 ) && (df.y <= 1) && ( fabs(df.x) < 0.1f ) ) { type = MOVE_Y; return true; } else if ( (df.x<0.5f) && (df.y<0.5f) && (df.x>0) && (df.y>0)) { type = MOVE_XY; return true; } else { //plan 3: Y/Z df = RayTrace2(rayOrigin, rayDir, GetTransformedVector(0), mt, trss, false); if ( ( df.y >= 0 ) && (df.y <= 1) && ( fabs(df.z) < 0.1f ) ) { type = MOVE_Y; return true; } else if ( ( df.z >= 0 ) && (df.z <= 1) && ( fabs(df.y) < 0.1f ) ) { type = MOVE_Z; return true; } else if ( (df.y<0.5f) && (df.z<0.5f) && (df.y>0) && (df.z>0)) { type = MOVE_YZ; return true; } } } type = MOVE_NONE; return false; }
bool CGizmoTransformScale::GetOpType(SCALETYPE &type, unsigned int x, unsigned int y) { // init tvector3 trss(GetTransformedVector(0).Length(), GetTransformedVector(1).Length(), GetTransformedVector(2).Length()); m_LockX = x; m_svgMatrix = *m_pMatrix; tmatrix mt; mt = *m_pMatrix; mt.NoTrans(); mt.Inverse(); // ray casting tvector3 rayOrigin,rayDir,df2; BuildRay(x, y, rayOrigin, rayDir); // plan 1 : X/Z df2 = RayTrace2(rayOrigin, rayDir, GetTransformedVector(1), mt, trss); if ( (df2.x<0.2f) && (df2.z<0.2f) && (df2.x>0) && (df2.z>0)) { type = SCALE_XYZ; return true; } else if ( ( df2.x >= 0 ) && (df2.x <= 1) && ( fabs(df2.z) < 0.1f ) ) { type = SCALE_X; return true; } else if ( ( df2.z >= 0 ) && (df2.z <= 1) && ( fabs(df2.x) < 0.1f ) ) { type = SCALE_Z; return true; } else if ( (df2.x<0.5f) && (df2.z<0.5f) && (df2.x>0) && (df2.z>0)) { type = SCALE_XZ; return true; } else { //plan 2 : X/Y df2 = RayTrace2(rayOrigin, rayDir, GetTransformedVector(2), mt, trss); if ( (df2.x<0.2f) && (df2.y<0.2f) && (df2.x>0) && (df2.y>0)) { type = SCALE_XYZ; return true; } else if ( ( df2.x >= 0 ) && (df2.x <= 1) && ( fabs(df2.y) < 0.1f ) ) { type = SCALE_X; return true; } else if ( ( df2.y >= 0 ) && (df2.y <= 1) && ( fabs(df2.x) < 0.1f ) ) { type = SCALE_Y; return true; } else if ( (df2.x<0.5f) && (df2.y<0.5f) && (df2.x>0) && (df2.y>0)) { type = SCALE_XY; return true; } else { //plan 3: Y/Z df2 = RayTrace2(rayOrigin, rayDir, GetTransformedVector(0), mt, trss); if ( (df2.y<0.2f) && (df2.z<0.2f) && (df2.y>0) && (df2.z>0)) { type = SCALE_XYZ; return true; } else if ( ( df2.y >= 0 ) && (df2.y <= 1) && ( fabs(df2.z) < 0.1f ) ) { type = SCALE_Y; return true; } else if ( ( df2.z >= 0 ) && (df2.z <= 1) && ( fabs(df2.y) < 0.1f ) ) { type = SCALE_Z; return true; } else if ( (df2.y<0.5f) && (df2.z<0.5f) && (df2.y>0) && (df2.z>0)) { type = SCALE_YZ; return true; } } } type = SCALE_NONE; return false; }
bool CGizmoTransformMove::GetOpType(MOVETYPE &type, unsigned int x, unsigned int y) { tvector3 rayOrigin, rayDir, df; BuildRay(x, y, rayOrigin, rayDir); m_svgMatrix = *m_pMatrix; tvector3 trss(GetTransformedVector(0).Length(), GetTransformedVector(1).Length(), GetTransformedVector(2).Length()); tmatrix mt; mt = *m_pMatrix; mt.NoTrans(); mt.Inverse(); // plan 1 : X/Z df = RayTrace2(rayOrigin, rayDir, GetTransformedVector(1), mt, trss, false); if ( ( df.x >= 0 ) && (df.x <= 1) && ( fabs(df.z) < 0.1f ) ) { type = MOVE_X; return true; } else if ( ( df.z >= 0 ) && (df.z <= 1) && ( fabs(df.x) < 0.1f ) ){ type = MOVE_Z; return true; } else if ( (df.x<0.5f) && (df.z<0.5f) && (df.x>0) && (df.z>0)) { type = MOVE_XZ; return true; } else { //plan 2 : X/Y df = RayTrace2(rayOrigin, rayDir, GetTransformedVector(2), mt, trss, false); if ( ( df.x >= 0 ) && (df.x <= 1) && ( fabs(df.y) < 0.1f ) ) { type = MOVE_X; return true; } if ( ( df.y >= 0 ) && (df.y <= 1) && ( fabs(df.x) < 0.1f ) ) { type = MOVE_Y; return true; } else if ( (df.x<0.5f) && (df.y<0.5f) && (df.x>0) && (df.y>0)) { type = MOVE_XY; return true; } else { //plan 3: Y/Z df = RayTrace2(rayOrigin, rayDir, GetTransformedVector(0), mt, trss, false); if ( ( df.y >= 0 ) && (df.y <= 1) && ( fabs(df.z) < 0.1f ) ) { type = MOVE_Y; return true; } else if ( ( df.z >= 0 ) && (df.z <= 1) && ( fabs(df.y) < 0.1f ) ) { type = MOVE_Z; return true; } else if ( (df.y<0.5f) && (df.z<0.5f) && (df.y>0) && (df.z>0)) { type = MOVE_YZ; return true; } } } type = MOVE_NONE; return false; }
void CGizmoTransformMove::OnMouseMove(unsigned int x, unsigned int y) { if (m_MoveType != MOVE_NONE) { tvector3 rayOrigin,rayDir,df, inters; BuildRay(x, y, rayOrigin, rayDir); m_plan.RayInter(inters,rayOrigin,rayDir); tvector3 axeX(1,0,0),axeY(0,1,0),axeZ(0,0,1); if (mLocation == LOCATE_LOCAL) { axeX.TransformVector(*m_pMatrix); axeY.TransformVector(*m_pMatrix); axeZ.TransformVector(*m_pMatrix); axeX.Normalize(); axeY.Normalize(); axeZ.Normalize(); } df = inters - m_LockVertex; switch (m_MoveType) { case MOVE_XZ: df = tvector3(df.Dot(axeX) , 0,df.Dot(axeZ)); break; case MOVE_X: df = tvector3(df.Dot(axeX) , 0,0); break; case MOVE_Z: df = tvector3(0, 0,df.Dot(axeZ)); break; case MOVE_XY: df = tvector3(df.Dot(axeX) ,df.Dot(axeY), 0); break; case MOVE_YZ: df = tvector3(0,df.Dot(axeY) ,df.Dot(axeZ)); break; case MOVE_Y: df = tvector3(0,df.Dot(axeY), 0); break; } tvector3 adf; tmatrix mt; if (m_bUseSnap) { SnapIt(df.x,m_MoveSnap.x); SnapIt(df.y,m_MoveSnap.y); SnapIt(df.z,m_MoveSnap.z); } adf = df.x*axeX + df.y*axeY + df.z*axeZ; mt.Translation(adf); *m_pMatrix = m_svgMatrix; m_pMatrix->Multiply(mt); //if (mTransform) mTransform->Update(); if (mEditPos) *mEditPos = m_pMatrix->V4.position; } else { // predict move if (m_pMatrix) { GetOpType(m_MoveTypePredict, x, y); } } }
void CGizmoTransformScale::OnMouseMove(unsigned int x, unsigned int y) { if (m_ScaleType != SCALE_NONE) { tvector3 rayOrigin,rayDir,df, inters, machin; tvector3 scVect,scVect2; BuildRay(x, y, rayOrigin, rayDir); m_plan.RayInter(inters,rayOrigin,rayDir); switch (m_ScaleType) { case SCALE_XZ: scVect = tvector3(1,0,1); break; case SCALE_X: scVect = tvector3(1,0,0); break; case SCALE_Z: scVect = tvector3(0,0,1); break; case SCALE_XY: scVect = tvector3(1,1,0); break; case SCALE_YZ: scVect = tvector3(0,1,1); break; case SCALE_Y: scVect = tvector3(0,1,0); break; case SCALE_XYZ:scVect = tvector3(1,1,1); break; } df = inters-m_pMatrix->GetTranslation(); df/=GetScreenFactor(); scVect2 = tvector3(1,1,1) - scVect; if (m_ScaleType == SCALE_XYZ) { int difx = x - m_LockX; float lng2 = 1.0f + ( float(difx) / 200.0f); SnapScale(lng2); scVect *=lng2; } else { float lng2 = ( df.Dot(m_LockVertex)/ m_Lng); if (lng2 < 1) { if (lng2<=-4) lng2 = 0.001f; else { lng2+=4; lng2/=5; } } SnapScale(lng2); scVect *= lng2; scVect += scVect2; } tmatrix mt,mt2; mt.Scaling(scVect); mt2.Identity(); mt2.SetLine(0,GetTransformedVector(0)); mt2.SetLine(1,GetTransformedVector(1)); mt2.SetLine(2,GetTransformedVector(2)); //mt2.Translation(0,0,0); //mt.Multiply(mt2); if (mLocation == LOCATE_WORLD) { mt2 = m_svgMatrix * mt; } else { mt2 = mt * m_svgMatrix;//.Multiply(m_svgMatrix); } *m_pMatrix = mt2; //if (mTransform) mTransform->Update(); } else { // predict move if (m_pMatrix) { GetOpType(m_ScaleTypePredict, x, y); } } }
void CGizmoTransformScale::OnMouseMove(unsigned int x, unsigned int y) { if (m_ScaleType != SCALE_NONE) { tvector3 rayOrigin,rayDir,df, inters, machin; tvector3 scVect,scVect2; BuildRay(x, y, rayOrigin, rayDir); m_plan.RayInter(inters,rayOrigin,rayDir); switch (m_ScaleType) { case SCALE_XZ: scVect = tvector3(1,0,1); break; case SCALE_X: scVect = tvector3(1,0,0); break; case SCALE_Z: scVect = tvector3(0,0,1); break; case SCALE_XY: scVect = tvector3(1,1,0); break; case SCALE_YZ: scVect = tvector3(0,1,1); break; case SCALE_Y: scVect = tvector3(0,1,0); break; case SCALE_XYZ:scVect = tvector3(1,1,1); break; } df = inters-m_pMatrix->GetTranslation(); df/=GetScreenFactor(); scVect2 = tvector3(1,1,1) - scVect; if (m_ScaleType == SCALE_XYZ) { int difx = x - m_LockX; float lng2 = 1.0f + ( float(difx) / 200.0f); SnapScale(lng2); scVect *=lng2; } else { int difx = x - m_LockX; int dify = y - m_LockY; float len = sqrtf( (float)(difx*difx) + (float)(dify*dify) ); float lng2 = len /100.f; SnapScale(lng2); scVect *= lng2; scVect += scVect2; } tmatrix mt,mt2; mt.Scaling(scVect); mt2.Identity(); mt2.SetLine(0,GetTransformedVector(0)); mt2.SetLine(1,GetTransformedVector(1)); mt2.SetLine(2,GetTransformedVector(2)); if (mLocation == LOCATE_WORLD) { mt2 = mt * m_svgMatrix; } else { mt2 = mt * m_svgMatrix;//.Multiply(m_svgMatrix); } *m_pMatrix = mt2; } else { // predict move if (m_pMatrix) { GetOpType(m_ScaleTypePredict, x, y); } } }
bool System::mouseMoved( const OIS::MouseEvent &arg ) { if(!m_bEnableInput){ return true; } Ray ray = BuildRay(arg.state.X.abs,arg.state.Y.abs); switch(m_CM){ case enCM_Select:{ m_bIsControl = false; UpdateRayCastPoint(ray); }break; case enCM_Move:{ if(m_bIsControl){ if(m_MoveType!=Engine::eMRCT_None&&!m_lstSelectObj.empty()){ Engine::Camera* pCam = GameSystem::GetSingleton()->GetCurrentSection()->GetScene()->GetMainCamera(); Float3 vRight = pCam->GetRealRightDirection(); Float3 vUp = pCam->GetRealUpDirection(); Float3 vRealDir = vRight*(arg.state.X.abs - m_MoveDir.x)+vUp*(m_MoveDir.y-arg.state.Y.abs); Engine::MeshEntity* pMesh = *(m_lstSelectObj.begin()); Float3 v = m_OldPos; v[m_MoveType-1]+=vRealDir[m_MoveType-1]*0.1; pMesh->GetParentSceneNode()->SetPosition(v); Float44 mat; Float3 scale(1,1,1); Float4 q; pMesh->GetParentSceneNode()->Update(mat,q,scale,false); m_pObjController->SetPosition(v); m_pObjController->SetSelectObjectBoundingBox(pMesh->GetWorldBoundingBox()); } }else{ //m_MoveType = m_pObjController->ChangeType(ray.m_vStart,ray.m_vDirection); //Engine::Scene* pScene = GameSystem::GetSingleton()->GetCurrentSection()->GetScene(); //Float44 matVPInv = pScene->GetMainCamera()->GetViewMatrix(); ////matVPInv.Inverse(); //Float3 vProjPos = matVPInv*m_pObjController->GetParentSceneNode()->GetPosition(); //Float2 vUV = Float2(vProjPos.x,vProjPos.y)*Float2(2,-2)+Float2(-1,1); m_MoveType = m_pObjController->ChangeType(ray.m_vStart,ray.m_vDirection); } break;} case enCM_Rotate:{ if(m_bIsControl){ if(m_MoveType!=Engine::eMRCT_None&&!m_lstSelectObj.empty()){ Engine::MeshEntity* pMesh = *(m_lstSelectObj.begin()); Float2 dir = Float2(arg.state.X.abs,arg.state.Y.abs) - m_MoveDir; float fAngle = dir.y; if(m_MoveType==Engine::eMRCT_Y){ fAngle = dir.x; } Float3 vAxis; vAxis[m_MoveType-1] = 1; Float4 q(vAxis,fAngle*0.1); pMesh->GetParentSceneNode()->SetQuat(m_OldQuat*q); Float44 mat; Float3 scale(1,1,1); q = Float4(0,0,0,1); pMesh->GetParentSceneNode()->Update(mat,q,scale,false); } }else{ m_MoveType = m_pObjController->ChangeType(ray.m_vStart,ray.m_vDirection); } break;} case enCM_Scale:{ if(m_bIsControl){ if(m_MoveType!=Engine::eMRCT_None&&!m_lstSelectObj.empty()){ Engine::Camera* pCam = GameSystem::GetSingleton()->GetCurrentSection()->GetScene()->GetMainCamera(); Float3 vRight = pCam->GetRealRightDirection(); Float3 vUp = pCam->GetRealUpDirection(); Float3 vRealDir = vRight*(arg.state.X.abs - m_MoveDir.x)+vUp*(m_MoveDir.y-arg.state.Y.abs); Engine::MeshEntity* pMesh = *(m_lstSelectObj.begin()); Float3 v = m_OldPos; v[m_MoveType-1]+=vRealDir[m_MoveType-1]*0.1; pMesh->GetParentSceneNode()->SetScale(v); Float44 mat; Float3 scale(1,1,1); Float4 q; pMesh->GetParentSceneNode()->Update(mat,q,scale,false); //m_pObjController->SetPosition(v); m_pObjController->SetSelectObjectBoundingBox(pMesh->GetWorldBoundingBox()); } }else{ m_MoveType = m_pObjController->ChangeType(ray.m_vStart,ray.m_vDirection); } break;} default:{ m_bIsControl = false; //UpdateRayCastPoint(ray); break;} } return true; }
bool System::mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id ) { if(!m_bEnableInput){ return true; } if(id==OIS::MB_Left){ Engine::Scene* pScene = GameSystem::GetSingleton()->GetCurrentSection()->GetScene(); switch(m_CM){ case enCM_Select:{ Ray ray = BuildRay(arg.state.X.abs,arg.state.Y.abs); Engine::MovableObject* pObj=NULL; if(pScene->GetStaticSceneNode()->RayCast(ray,pObj)){ m_pRayCastMesh = dynamic_cast<Engine::MeshEntity*>(pObj); S8* pKey = Engine::GetGlobalSetting().m_pInputSystem->m_KeyArray; if( pKey[OIS::KC_LCONTROL] == 0 && pKey[OIS::KC_RCONTROL] == 0) { m_lstSelectObj.clear(); } if(m_pRayCastMesh!=NULL){ m_lstSelectObj.push_back(m_pRayCastMesh); Engine::SceneNode* pNode = m_pRayCastMesh->GetParentSceneNode(); if(pNode!=NULL){ const Float3 vObjPos = pNode->GetGlobalPosition(); m_pObjController->SetPosition(pNode->GetGlobalPosition()); } m_pObjController->SetSelectObjectBoundingBox( m_pRayCastMesh->GetWorldBoundingBox()); }else { Engine::SceneNode* pNode = pObj->GetParentSceneNode(); if(pNode!=NULL){ m_lstSelectObj.push_back(m_pRayCastMesh); m_pObjController->SetPosition(pNode->GetGlobalPosition()); m_pObjController->SetSelectObjectBoundingBox(pObj->GetWorldBoundingBox()); } } } break;} case enCM_SelectList:{ break;} case enCM_Move: case enCM_Rotate: case enCM_Scale:{ m_bIsControl = false; m_MoveType = Engine::eMRCT_None; m_MoveDir = Float2(arg.state.X.abs,arg.state.Y.abs); break;} case enCM_Create:{ Ray ray = BuildRay(arg.state.X.abs,arg.state.Y.abs); Engine::MovableObject* pObj=NULL; float fDis=999999.0f; if(pScene->GetStaticSceneNode()->RayCast(ray,pObj,&fDis)){ m_vRayCastPoint = ray.m_vStart + ray.m_vDirection*fDis; switch(m_CT){ case enCT_Object:{ AddObject(m_strCreateObjectName,m_vRayCastPoint); }break; case enCT_Actor:{ AddActor(m_strCreateObjectName,m_vRayCastPoint); }break; } } break;} } } return true; }
void CGizmoTransformRotate::OnMouseMove(unsigned int x, unsigned int y) { tvector3 rayOrigin, rayDir, axis; BuildRay(x, y, rayOrigin, rayDir); if (m_RotateType != ROTATE_NONE) { if (m_RotateType == ROTATE_TWIN) { tvector3 inters; tvector3 dir = m_pMatrix->GetTranslation()-m_CamSrc; dir.Normalize(); m_plan=vector4(m_pMatrix->GetTranslation(), dir); m_plan.RayInter(inters,rayOrigin,rayDir); ptd = inters; tvector3 df = inters - m_pMatrix->GetTranslation(); df/=GetScreenFactor(); float lng1 = df.Length(); if (lng1 >= 1.0f) lng1 = 0.9f; float height = (float)sin(acos(lng1)); tvector3 m_CamRealUp,camRight; camRight.Cross(m_Axis,m_CamUp); m_CamRealUp.Cross(camRight,dir); tvector3 idt = height*dir; idt+=df; //ptd = idt; idt= m_LockVertex-idt; tmatrix mt,mt2; mt.LookAtLH(tvector3(0,0,0),idt,m_CamRealUp); mt.Multiply(m_InvOrigScale); mt.Multiply(m_svgMatrix); mt2 = m_OrigScale; mt2.Multiply(mt); *m_pMatrix=mt2; /* if (mEditQT) { *mEditQT = tquaternion(mt2); } */ } else { Rotate1Axe(rayOrigin, rayDir); } //if (mTransform) mTransform->Update(); } else { // predict move if (m_pMatrix) { GetOpType(m_RotateTypePredict, x, y); } } }
void CGizmoTransformScale::OnMouseMove(unsigned int x, unsigned int y) { if (m_ScaleType != SCALE_NONE) { tvector3 rayOrigin,rayDir,df, inters, machin; tvector3 scVect,scVect2; BuildRay(x, y, rayOrigin, rayDir); m_plan.RayInter(inters,rayOrigin,rayDir); switch (m_ScaleType) { case SCALE_XZ: scVect = tvector3(1,0,1); break; case SCALE_X: scVect = tvector3(1,0,0); break; case SCALE_Z: scVect = tvector3(0,0,1); break; case SCALE_XY: scVect = tvector3(1,1,0); break; case SCALE_YZ: scVect = tvector3(0,1,1); break; case SCALE_Y: scVect = tvector3(0,1,0); break; case SCALE_XYZ:scVect = tvector3(1,1,1); break; } df = inters-m_pMatrix->GetTranslation(); df/=GetScreenFactor(); scVect2 = tvector3(1,1,1) - scVect; if (m_ScaleType == SCALE_XYZ) { int difx = x - m_LockX; float lng2 = 1.0f + ( float(difx) / 200.0f); SnapScale(lng2); scVect *=lng2; } else { int difx = x - m_LockX; int dify = y - m_LockY; float len = sqrtf( (float)(difx*difx) + (float)(dify*dify) ); float lng2 = len /100.f; /* float lng2 = ( df.Dot(m_LockVertex)); char tmps[512]; sprintf(tmps, "%5.4f\n", lng2 ); OutputDebugStringA( tmps ); if (lng2 < 1.f) { if ( lng2<= 0.001f ) lng2 = 0.001f; else { //lng2+=4.f; lng2/=5.f; } } else { int a = 1; } */ SnapScale(lng2); scVect *= lng2; scVect += scVect2; } tmatrix mt,mt2; mt.Scaling(scVect); mt2.Identity(); mt2.SetLine(0,GetTransformedVector(0)); mt2.SetLine(1,GetTransformedVector(1)); mt2.SetLine(2,GetTransformedVector(2)); //mt2.Translation(0,0,0); //mt.Multiply(mt2); if (mLocation == LOCATE_WORLD) { mt2 = mt * m_svgMatrix; } else { mt2 = mt * m_svgMatrix;//.Multiply(m_svgMatrix); } *m_pMatrix = mt2; //if (mTransform) mTransform->Update(); } else { // predict move if (m_pMatrix) { GetOpType(m_ScaleTypePredict, x, y); } } }