예제 #1
0
tvector3 CGizmoTransformMove::RayTrace(tvector3& rayOrigin, tvector3& rayDir, tvector3& norm)
{
	tvector3 df,inters;
	m_plan=vector4(m_pMatrix->GetTranslation(), norm);
	m_plan.RayInter(inters,rayOrigin,rayDir);
	ptd = inters;
	df = inters - m_pMatrix->GetTranslation();
	df /=GetScreenFactor();
	m_LockVertex = inters;
	return df;
}
예제 #2
0
void CGizmoTransformMove::Draw()
{
    ComputeScreenFactor();

    Initialize();
    if (m_pMatrix)
    {

        //glDisable(GL_DEPTH_TEST);
        tvector3 orig = GetTranslation();

        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();
        }




        DrawQuad(orig, 0.5f*GetScreenFactor(), (m_MoveTypePredict == MOVE_XZ), axeX, axeZ);
        DrawQuad(orig, 0.5f*GetScreenFactor(), (m_MoveTypePredict == MOVE_XY), axeX, axeY);
        DrawQuad(orig, 0.5f*GetScreenFactor(), (m_MoveTypePredict == MOVE_YZ), axeY, axeZ);

        axeX*=GetScreenFactor();
        axeY*=GetScreenFactor();
        axeZ*=GetScreenFactor();

        static const tvector3 selectedColor(0xff / 255.0, 0xdc / 255.0, 0),
                unitXColor(1, 0x41 / 255.0, 0x36 / 255.0),
                unitYColor(0x2e / 255.0, 0xcc / 255.0, 0x40 / 255.0),
                unitZColor(0, 0x74 / 255.0, 0xd9 / 255.0);

        // plan1
        if (m_MoveTypePredict != MOVE_X) DrawAxis(orig,axeX,axeY,axeZ,0.05f,0.83f,unitXColor);
            else DrawAxis(orig,axeX,axeY,axeZ, 0.05f,0.83f,selectedColor);

        //plan2
        if (m_MoveTypePredict != MOVE_Y) DrawAxis(orig,axeY,axeX,axeZ, 0.05f,0.83f,unitYColor);
            else DrawAxis(orig,axeY,axeX,axeZ, 0.05f,0.83f,selectedColor);

        //plan3
        if (m_MoveTypePredict != MOVE_Z) DrawAxis(orig,axeZ,axeX,axeY, 0.05f,0.83f,unitZColor);
            else DrawAxis(orig,axeZ,axeX,axeY, 0.05f,0.83f,selectedColor);
    }
}
void CGizmoTransformScale::Draw()
{
  if (m_pMatrix)
  {
    ComputeScreenFactor();


    tvector3 orig(m_pMatrix->m16[12],m_pMatrix->m16[13],m_pMatrix->m16[14]);


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

    DrawTri(orig, 0.5f*GetScreenFactor(),((m_ScaleTypePredict==SCALE_XZ)||(m_ScaleTypePredict==SCALE_XYZ)), axeX, axeZ);
    DrawTri(orig, 0.5f*GetScreenFactor(),((m_ScaleTypePredict==SCALE_XY)||(m_ScaleTypePredict==SCALE_XYZ)), axeX, axeY);
    DrawTri(orig, 0.5f*GetScreenFactor(),((m_ScaleTypePredict==SCALE_YZ)||(m_ScaleTypePredict==SCALE_XYZ)), axeY, axeZ);

    axeX*=GetScreenFactor();
    axeY*=GetScreenFactor();
    axeZ*=GetScreenFactor();


    // plan1
    if (m_ScaleTypePredict != SCALE_X)
      DrawAxis(orig,axeX,axeY,axeZ,0.05f,0.83f,vector4(1,0,0,1));
    else
      DrawAxis(orig,axeX,axeY,axeZ,0.05f,0.83f,vector4(1,1,1,1));

    //plan2
    if (m_ScaleTypePredict != SCALE_Y)
      DrawAxis(orig,axeY,axeX,axeZ,0.05f,0.83f,vector4(0,1,0,1));
    else
      DrawAxis(orig,axeY,axeX,axeZ,0.05f,0.83f,vector4(1,1,1,1));

    //plan3
    if (m_ScaleTypePredict != SCALE_Z)
      DrawAxis(orig,axeZ,axeX,axeY,0.05f,0.83f,vector4(0,0,1,1));
    else
      DrawAxis(orig,axeZ,axeX,axeY,0.05f,0.83f,vector4(1,1,1,1));
  }


}
예제 #4
0
bool CGizmoTransformRotate::CheckRotatePlan(tvector3 &vNorm, float factor,
    const tvector3 &rayOrig,const tvector3 &rayDir,int id)
{
    tvector3 df, inters;
    m_Axis2 = vNorm;
    m_plan=vector4(m_pMatrix->GetTranslation(), vNorm);
    m_plan.RayInter(inters,rayOrig,rayDir);
    ptd = inters;
    df = inters - m_pMatrix->GetTranslation();
    df/=GetScreenFactor();

    if ( ((df.Length()/factor) >0.9f) && ( (df.Length()/factor) < 1.1f) )
    {
        m_svgMatrix = *m_pMatrix;

        m_LockVertex = df;
        m_LockVertex.Normalize();

        m_Vtx = m_LockVertex;
        m_Vty.Cross(m_LockVertex,vNorm);
        m_Vty.Normalize();
        m_Vtx *= factor;
        m_Vty *= factor;
        m_Vtz.Cross(m_Vtx,m_Vty);
        m_Ng2 = 0;
        if (id!=-1)
            m_Axis = GetVector(id);

        m_OrigScale.Scaling(GetTransformedVector(0).Length(),
            GetTransformedVector(1).Length(),
            GetTransformedVector(2).Length());

        m_InvOrigScale.Inverse(m_OrigScale);

        return true;
    }
    return false;
}
예제 #5
0
void CGizmoTransformMove::Draw()
{
  ComputeScreenFactor();

  if (m_pMatrix)
  {

    //glDisable(GL_DEPTH_TEST);
    tvector3 orig = m_pMatrix->GetTranslation();

    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();
    }

    DrawQuad(orig, 0.5f*GetScreenFactor(), (m_MoveTypePredict == MOVE_XZ), axeX, axeZ);
    DrawQuad(orig, 0.5f*GetScreenFactor(), (m_MoveTypePredict == MOVE_XY), axeX, axeY);
    DrawQuad(orig, 0.5f*GetScreenFactor(), (m_MoveTypePredict == MOVE_YZ), axeY, axeZ);

    axeX*=GetScreenFactor();
    axeY*=GetScreenFactor();
    axeZ*=GetScreenFactor();

    // plan1
    if (m_MoveTypePredict != MOVE_X) DrawAxis(orig,axeX,axeY,axeZ,0.05f,0.83f,vector4(1,0,0,1));
    else DrawAxis(orig,axeX,axeY,axeZ, 0.05f,0.83f,vector4(1,1,1,1));

    //plan2
    if (m_MoveTypePredict != MOVE_Y) DrawAxis(orig,axeY,axeX,axeZ, 0.05f,0.83f,vector4(0,1,0,1));
    else DrawAxis(orig,axeY,axeX,axeZ, 0.05f,0.83f,vector4(1,1,1,1));

    //plan3
    if (m_MoveTypePredict != MOVE_Z) DrawAxis(orig,axeZ,axeX,axeY, 0.05f,0.83f,vector4(0,0,1,1));
    else DrawAxis(orig,axeZ,axeX,axeY, 0.05f,0.83f,vector4(1,1,1,1));
  }
}
예제 #6
0
void CGizmoTransformMove::Draw()
{
	ComputeScreenFactor();

	if (m_pMatrix)
	{
		CRenderingContext c(Manipulator()->GetRenderer(), true);
		c.UseProgram("model");
		c.SetUniform("bDiffuse", false);

		//glDisable(GL_DEPTH_TEST);
		tvector3 orig = m_pMatrix->GetTranslation();

		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();
        }




		DrawQuad(&c, orig, 0.5f*GetScreenFactor(), (m_MoveTypePredict == MOVE_XZ), axeX, axeZ);
		DrawQuad(&c, orig, 0.5f*GetScreenFactor(), (m_MoveTypePredict == MOVE_XY), axeX, axeY);
		DrawQuad(&c, orig, 0.5f*GetScreenFactor(), (m_MoveTypePredict == MOVE_YZ), axeY, axeZ);

		axeX*=GetScreenFactor();
		axeY*=GetScreenFactor();
		axeZ*=GetScreenFactor();

		// plan1
		if (m_MoveTypePredict != MOVE_X)
			DrawAxis(&c, orig,axeX,axeY,axeZ,0.05f,0.83f,vector4(1,0,0,1));
		else
			DrawAxis(&c, orig,axeX,axeY,axeZ, 0.05f,0.83f,vector4(1,1,1,1));

		//plan2
		if (m_MoveTypePredict != MOVE_Y)
			DrawAxis(&c, orig,axeY,axeX,axeZ, 0.05f,0.83f,vector4(0,1,0,1));
		else
			DrawAxis(&c, orig,axeY,axeX,axeZ, 0.05f,0.83f,vector4(1,1,1,1));

		//plan3
		if (m_MoveTypePredict != MOVE_Z)
			DrawAxis(&c, orig,axeZ,axeX,axeY, 0.05f,0.83f,vector4(0,0,1,1));
		else
			DrawAxis(&c, orig,axeZ,axeX,axeY, 0.05f,0.83f,vector4(1,1,1,1));
#if 0
#ifdef WIN32
    GDD->GetD3D9Device()->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
    GDD->GetD3D9Device()->SetRenderState(D3DRS_CULLMODE , D3DCULL_NONE );
    GDD->GetD3D9Device()->SetRenderState(D3DRS_ZENABLE , D3DZB_TRUE);
	GDD->GetD3D9Device()->SetRenderState(D3DRS_ALPHATESTENABLE , FALSE);
	GDD->GetD3D9Device()->SetRenderState(D3DRS_ZWRITEENABLE , TRUE);
#endif
	extern RenderingState_t GRenderingState;
	GRenderingState.mAlphaTestEnable = 0;
	GRenderingState.mZWriteEnable = 1;
	GRenderingState.mBlending = 0;
	GRenderingState.mCulling = 0;
	GRenderingState.mZTestType = 1;
#endif
/*

PSM_LVERTEX svVts[2];
	svVts[0].x = ptd.x;
    svVts[0].y = ptd.y;
    svVts[0].z = ptd.z;
    svVts[0].diffuse = 0xFFFFFFFF;

	svVts[1].x = ptd.x+10;
    svVts[1].y = ptd.y+10;
    svVts[1].z = ptd.z+10;
    svVts[1].diffuse = 0xFFFFFFFF;


    IDirect3DDevice9 *pDev = ((PSM_D3D9RenderDevice*)PSM_D3D9RenderDevice::GetInterfacePtr())->d3dDevice;
	pDev->DrawPrimitiveUP(D3DPT_LINESTRIP , 1, svVts, sizeof(PSM_LVERTEX));
    */
}
/*
		// debug
		glPointSize(20);
		glBegin(GL_POINTS);
		glVertex3fv(&ptd.x);
		glEnd();

		glEnable(GL_DEPTH_TEST);
*/

}
예제 #7
0
void CGizmoTransformScale::Draw()
{
	if (m_pMatrix)
	{
		ComputeScreenFactor();

		//glDisable(GL_DEPTH_TEST);
		tvector3 orig(m_pMatrix->m16[12],m_pMatrix->m16[13],m_pMatrix->m16[14]);


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

		DrawTri(orig, 0.5f*GetScreenFactor(),((m_ScaleTypePredict==SCALE_XZ)||(m_ScaleTypePredict==SCALE_XYZ)), axeX, axeZ);
		DrawTri(orig, 0.5f*GetScreenFactor(),((m_ScaleTypePredict==SCALE_XY)||(m_ScaleTypePredict==SCALE_XYZ)), axeX, axeY);
		DrawTri(orig, 0.5f*GetScreenFactor(),((m_ScaleTypePredict==SCALE_YZ)||(m_ScaleTypePredict==SCALE_XYZ)), axeY, axeZ);

		axeX*=GetScreenFactor();
		axeY*=GetScreenFactor();
		axeZ*=GetScreenFactor();


		// plan1
		if (m_ScaleTypePredict != SCALE_X)
			DrawAxis(orig,axeX,axeY,axeZ,0.05f,0.83f,vector4(1,0,0,1));
		else
			DrawAxis(orig,axeX,axeY,axeZ,0.05f,0.83f,vector4(1,1,1,1));

		//plan2
		if (m_ScaleTypePredict != SCALE_Y)
			DrawAxis(orig,axeY,axeX,axeZ,0.05f,0.83f,vector4(0,1,0,1));
		else
			DrawAxis(orig,axeY,axeX,axeZ,0.05f,0.83f,vector4(1,1,1,1));

		//plan3
		if (m_ScaleTypePredict != SCALE_Z)
			DrawAxis(orig,axeZ,axeX,axeY,0.05f,0.83f,vector4(0,0,1,1));
		else
			DrawAxis(orig,axeZ,axeX,axeY,0.05f,0.83f,vector4(1,1,1,1));

/*
		// debug
		glPointSize(20);
		glBegin(GL_POINTS);
		glVertex3fv(&ptd.x);
		glEnd();

		glEnable(GL_DEPTH_TEST);
        */
#if 0
#ifdef WIN32
    GDD->GetD3D9Device()->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
    GDD->GetD3D9Device()->SetRenderState(D3DRS_CULLMODE , D3DCULL_NONE );
    GDD->GetD3D9Device()->SetRenderState(D3DRS_ZENABLE , D3DZB_TRUE);
	GDD->GetD3D9Device()->SetRenderState(D3DRS_ALPHATESTENABLE , FALSE);
	GDD->GetD3D9Device()->SetRenderState(D3DRS_ZWRITEENABLE , TRUE);
#endif
	extern RenderingState_t GRenderingState;
	GRenderingState.mAlphaTestEnable = 0;
	GRenderingState.mZWriteEnable = 1;
	GRenderingState.mBlending = 0;
	GRenderingState.mCulling = 0;
	GRenderingState.mZTestType = 1;
#endif
	}


}
예제 #8
0
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);
    }
  }

}
예제 #10
0
/*
            char tmps[512];
            sprintf(tmps, "%5.2f %5.2f %5.2f %5.2f", plCam.x, plCam.y, plCam.z, plCam.w );
            MessageBoxA(NULL, tmps, tmps, MB_OK);
            */
void CGizmoTransformRotate::Draw()
{
    if (m_pMatrix)
    {

        ComputeScreenFactor();

        tvector3 right,up,frnt,dir;

        //glDisable(GL_DEPTH_TEST);
        tvector3 orig(m_pMatrix->GetTranslation());
        
        tvector3 plnorm(m_CamSrc-orig);
            

        plnorm.Normalize();





        tplane plCam = vector4(plnorm,0);


        dir = orig-m_CamSrc;
        dir.Normalize();

        right.Cross(dir,GetTransformedVector(1));
        right.Normalize();

        up.Cross(dir,right);
        up.Normalize();

        right.Cross(dir,up);
        right.Normalize();

        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();
        }

        // Twin
        if (mMask&AXIS_TRACKBALL)
        {

            if (m_RotateTypePredict != ROTATE_TWIN)
                DrawCircle(orig, 0.2f,0.2f,0.2f,right*GetScreenFactor(),up*GetScreenFactor());
            else
                DrawCircle(orig, 1,1,1,right*GetScreenFactor(),up*GetScreenFactor());
        }

        // Screen
        if (mMask&AXIS_SCREEN)
        {
            if (m_RotateTypePredict != ROTATE_SCREEN)
                DrawCircle(orig, 1.0f,0.3f,1.0f,up*1.2f*GetScreenFactor(),right*1.2f*GetScreenFactor());
            else
                DrawCircle(orig, 1,1,1,up*1.2f*GetScreenFactor(),right*1.2f*GetScreenFactor());
        }

        // X
        right.Cross(dir, axeX);
        right.Normalize();
        frnt.Cross(right, axeX);

        frnt.Normalize();

        if (mMask&AXIS_X)
        {
            if (m_RotateTypePredict != ROTATE_X)
                DrawCircleHalf(orig, 1,0,0,right*GetScreenFactor(),frnt*GetScreenFactor(),plCam);
            else
                DrawCircleHalf(orig, 1,1,1,right*GetScreenFactor(),frnt*GetScreenFactor(),plCam);
        }

        // Y

        right.Cross(dir, axeY);
        right.Normalize();
        frnt.Cross(right, axeY);

        frnt.Normalize();

        if (mMask&AXIS_Y)
        {

            if (m_RotateTypePredict != ROTATE_Y)
                DrawCircleHalf(orig, 0,1,0,right*GetScreenFactor(),frnt*GetScreenFactor(),plCam);
            else
                DrawCircleHalf(orig, 1,1,1,right*GetScreenFactor(),frnt*GetScreenFactor(),plCam);
        }

        // Z
        right.Cross(dir, axeZ);
        right.Normalize();
        frnt.Cross(right, axeZ);

        frnt.Normalize();

        if (mMask&AXIS_Z)
        {
            if (m_RotateTypePredict != ROTATE_Z)
                DrawCircleHalf(orig, 0,0,1,right*GetScreenFactor(),frnt*GetScreenFactor(),plCam);
            else
                DrawCircleHalf(orig, 1,1,1,right*GetScreenFactor(),frnt*GetScreenFactor(),plCam);
        }
        // camembert
        if ( (m_RotateType != ROTATE_NONE) && (m_RotateType != ROTATE_TWIN ) )
            DrawCamem(orig,m_Vtx*GetScreenFactor(),m_Vty*GetScreenFactor(),-m_Ng2);
        /*
        // debug
        glPointSize(20);
        glBegin(GL_POINTS);
        glVertex3fv(&ptd.x);
        glEnd();

        glEnable(GL_DEPTH_TEST);
        */
#if 0
#ifdef WIN32
        GDD->GetD3D9Device()->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
        GDD->GetD3D9Device()->SetRenderState(D3DRS_CULLMODE , D3DCULL_NONE );
        GDD->GetD3D9Device()->SetRenderState(D3DRS_ZENABLE , D3DZB_TRUE);
        GDD->GetD3D9Device()->SetRenderState(D3DRS_ALPHATESTENABLE , FALSE);
        GDD->GetD3D9Device()->SetRenderState(D3DRS_ZWRITEENABLE , TRUE);
#endif
        extern RenderingState_t GRenderingState;
        GRenderingState.mAlphaTestEnable = 0;
        GRenderingState.mZWriteEnable = 1;
        GRenderingState.mBlending = 0;
        GRenderingState.mCulling = 0;
        GRenderingState.mZTestType = 1;
#endif
    }


}
예제 #11
0
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);
		}
	}

}