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); } } }
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; /* 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); } } }