⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 proppage.cpp

📁 liu7788414
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	CPropertyPage::UpdateData(FALSE);

	UpdateView();
}

extern CMatrix44 m_viewMat;
extern CMatrix44 m_HorMat;
extern CMatrix44 m_VerMat;
extern void CompMatrix();

void CPropPage::OnKillfocusEyeX() 
{
	// TODO: Add your control notification handler code here
	CPropertyPage::UpdateData();
	
	Vector4s eye = pG3D->GetEye();
	eye.x = m_EyeX;
	
	{
		int x,y,z,deltaX;
		Vector4s vet;
		Vector4s lookat;

		CMatrix44 mat(&m_viewMat);
		mat.Inverse();
		x=mat.get(0,3);
		y=mat.get(1,3);
		z=mat.get(2,3);

		vet=mat.Transform(Vector4s(0,0,1024));
		lookat = vet-Vector4s(x,y,z);

		deltaX = eye.x - x;

		//move camera into range
		if( deltaX == 0 )
		{
			pG3D->SetEye(&eye);
			CompMatrix();
			UpdateView();
			UpdateModel();
			Invalidate();
			return;
		}

		//DBGPRINTF("======Begin===========");
		//DBGPRINTF("%d %d %d",x,y,z);
		//DBGPRINTF("%d %d %d",deltaX,deltaY,0);

		CMatrix44 mat2(&m_viewMat);
		int x1,y1;

		int len = 1024;//sqrt(lookat.x*lookat.x + lookat.y*lookat.y);
		x1 = y1 = 0;
		int absX = abs(lookat.x);
		int absY = abs(lookat.y);

		if( deltaX )
		{
			if( deltaX == 1 )
				deltaX++;
			else if( deltaX == -1 )
				deltaX--;

			if( lookat.x >= 0 && lookat.y >= 0 )
			{
				x1 -= ( deltaX <<4) * absY / len;
				y1 -= ( deltaX <<4) * absX / len;
			}
			else if( lookat.x > 0 && lookat.y < 0 )
			{
				x1 += (deltaX <<4) * absY / len;
				y1 -= (deltaX <<4) * absX / len;
			}
			else if( lookat.x < 0 && lookat.y > 0 )
			{
				x1 -= (deltaX <<4) * absY / len;
				y1 += (deltaX <<4) * absX / len;
			}
			else
			{
				x1 += (deltaX <<4) * absY / len;
				y1 += (deltaX <<4) * absX / len;
			}
		}

		x1=(x1>>4);
		y1=(y1>>4);
		mat2.DefTranslate(x1, 0, y1);
		mat2.PostMultiply(&m_HorMat); 
		CMatrix44 m_tmpHorMat(m_HorMat);
		m_HorMat=mat2;

	}

	//SetViewMatrix();
	CompMatrix();
	{
		int x,y,z;
		CMatrix44 mat(&m_viewMat);
		mat.Inverse();
		x=mat.get(0,3);
		y=mat.get(1,3);
		z=mat.get(2,3);
		eye.x = x;
	}
	pG3D->SetEye(&eye);

	UpdateView();
	UpdateModel();
	Invalidate();
}

void CPropPage::OnKillfocusEyeY() 
{
	// TODO: Add your control notification handler code here
	CPropertyPage::UpdateData();
	
	Vector4s eye = pG3D->GetEye();
	eye.y = m_EyeY;

	{
		int x,y,z,deltaY;
		Vector4s vet;
		Vector4s lookat;

		CMatrix44 mat(&m_viewMat);
		mat.Inverse();
		x=mat.get(0,3);
		y=mat.get(1,3);
		z=mat.get(2,3);

		vet=mat.Transform(Vector4s(0,0,1024));
		lookat = vet-Vector4s(x,y,z);

		deltaY = eye.y - y;

		//move camera into range
		if( deltaY == 0 )
		{
			pG3D->SetEye(&eye);

			//SetViewMatrix();
			CompMatrix();
			UpdateView();
			UpdateModel();
			Invalidate();
			return;
		}

		//DBGPRINTF("======Begin===========");
		//DBGPRINTF("%d %d %d",x,y,z);
		//DBGPRINTF("%d %d %d",deltaX,deltaY,0);

		CMatrix44 mat2(&m_viewMat);
		int x1,y1;

		int len = 1024;//sqrt(lookat.x*lookat.x + lookat.y*lookat.y);
		x1 = y1 = 0;
		int absX = abs(lookat.x);
		int absY = abs(lookat.y);

		if( deltaY )
		{
			if( deltaY == 1 )
				deltaY++;
			else if( deltaY == -1 )
				deltaY--;

			if( lookat.x >= 0 && lookat.y >= 0 )
			{
				x1 += (deltaY <<4) * absX / len;
				y1 -= (deltaY <<4) * absY / len;
			}
			else if( lookat.x > 0 && lookat.y < 0 )
			{
				x1 += (deltaY <<4) * absX / len;
				y1 += (deltaY <<4) * absY / len;
			}
			else if( lookat.x < 0 && lookat.y > 0 )
			{
				x1 -= (deltaY <<4) * absX / len;
				y1 -= (deltaY <<4) * absY / len;
			}
			else
			{
				x1 -= (deltaY <<4) * absX / len;
				y1 += (deltaY <<4) * absY / len;
			}
		}

		x1=(x1>>4);
		y1=(y1>>4);
		mat2.DefTranslate(x1, 0, y1);
		mat2.PostMultiply(&m_HorMat); 
		CMatrix44 m_tmpHorMat(m_HorMat);
		m_HorMat=mat2;

	}
	
	pG3D->SetEye(&eye);
	
//	SetViewMatrix();
	CompMatrix();
	UpdateView();
	UpdateModel();
	Invalidate();
	
}

void CPropPage::OnKillfocusEyeZ() 
{
	// TODO: Add your control notification handler code here
	CPropertyPage::UpdateData();
	
	Vector4s eye = pG3D->GetEye();

	{
		int dis;
		CMatrix44 mat;

		dis = eye.z - m_EyeZ;
		mat.DefTranslate(0,dis,0);
		mat.PostMultiply(&m_origin);
		CMatrix44 m_tmpOrigin(&m_origin);
		m_origin=mat;
	}

	eye.z = m_EyeZ;
	pG3D->SetEye(&eye);
	
	SetViewMatrix();
	UpdateView();
	UpdateModel();
	Invalidate();
	
}

void CPropPage::OnKillfocusLookatX() 
{
	// TODO: Add your control notification handler code here
	CPropertyPage::UpdateData();
	Vector4s eye = pG3D->GetEye();

	GetCurLookAt();
	{
		int angle0 = Atan2i(m_lookat.y-eye.y, m_lookat.x-eye.x);
		int angle1 = Atan2i(m_lookat.y-eye.y, m_LookatX-eye.x);
		int angle = angle1 - angle0;

		CMatrix44 mat;
		mat.DefRotateY(-angle);
		mat.PostMultiply(&m_HorMat); 
		CMatrix44 m_tmpHorMat(m_HorMat);
		m_HorMat=mat;

		CompMatrix();

	}

	m_lookat.x = m_LookatX;
	
	SetViewMatrix();
	UpdateView();
	UpdateModel();
	Invalidate();
	
}

void CPropPage::OnKillfocusLookatY() 
{
	// TODO: Add your control notification handler code here
	CPropertyPage::UpdateData();
	Vector4s eye = pG3D->GetEye();
	
	GetCurLookAt();
	{
		int angle0 = Atan2i(m_lookat.y-eye.y, m_lookat.x-eye.x);
		int angle1 = Atan2i(m_LookatY-eye.y, m_lookat.x-eye.x);
		int angle = angle1 - angle0;

		CMatrix44 mat;
		mat.DefRotateY(angle);
		mat.PostMultiply(&m_HorMat); 
		CMatrix44 m_tmpHorMat(m_HorMat);
		m_HorMat=mat;

		CompMatrix();
	}
	m_lookat.y = m_LookatY;
	
	SetViewMatrix();
	UpdateView();
	UpdateModel();
	Invalidate();
	
}

void CPropPage::OnKillfocusLookatZ() 
{
	// TODO: Add your control notification handler code here
	CPropertyPage::UpdateData();
	
	m_lookat.z = m_LookatZ;
	
	SetViewMatrix();
	UpdateView();
	
}

void CPropPage::OnKillfocusUpX() 
{
	// TODO: Add your control notification handler code here
	CPropertyPage::UpdateData();
	
	m_up.x = m_UpX;
	
	SetViewMatrix();
	UpdateView();
	
}

void CPropPage::OnKillfocusUpY() 
{
	// TODO: Add your control notification handler code here
	CPropertyPage::UpdateData();
	
	m_up.y = m_UpY;
	
	SetViewMatrix();
	UpdateView();
	
}

void CPropPage::OnKillfocusUpZ() 
{
	// TODO: Add your control notification handler code here
	CPropertyPage::UpdateData();
	
	m_up.z = m_UpZ;
	
	SetViewMatrix();
	UpdateView();
	
}

void CPropPage::OnResetCamera() 
{
	// TODO: Add your control notification handler code here
	pG3D->SetEye(&Vector4s(0,-500,100,0));
	m_lookat = Vector4s(0,100,0,0);
	m_up = Vector4s(0,0,1024,0);
	m_origin.LookAt(Vector4s(0,-500,100),Vector4s(0,100,0),Vector4s(0,0,100));

	SetViewMatrix();

	UpdateModel();
	UpdateView();
}

void CPropPage::OnKillfocusZoom() 
{
	// TODO: Add your control notification handler code here
	CPropertyPage::UpdateData();
	
	if( m_Zoom < 1 )
		m_Zoom = 1;
	else if( m_Zoom > 1000 )
		m_Zoom = 1000;

	iZoomValue = m_Zoom;

	CPropertyPage::UpdateData(FALSE);
	UpdateView();
}

void CPropPage::OnKillfocusFov1() 
{
	// TODO: Add your control notification handler code here
	CPropertyPage::UpdateData();

	if( m_FOV < 2 )
		m_FOV = 2;
	else if( m_FOV > 682 )
		m_FOV = 682;

	cur_fov = m_FOV;
	pG3D->setZDist(cur_fov);

	CPropertyPage::UpdateData(FALSE);
	UpdateView();
}

void CPropPage::RemoveAll()
{
	int count;
	
	count = m_SelectModelCombo.GetCount(); 
	while( count )
	{
		for( int i=0; i<count; i++ )
			m_SelectModelCombo.DeleteString(i);
		count = m_SelectModelCombo.GetCount(); 
	}
}

void CPropPage::OnKillfocusCameraStep() 
{
	// TODO: Add your control notification handler code here
	CPropertyPage::UpdateData();
	
	m_CameraAdjustStep = m_CameraStep;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -