Esempio n. 1
0
bool CCameraHandler::LoadView(const std::string& name)
{
	if (name.empty())
		return false;

	const auto it = viewDataMap.find(name);

	if (it == viewDataMap.end())
		return false;

	const ViewData& saved = it->second;

	ViewData current;
	GetState(current);

	if (saved == current) {
		// load a view twice to return to old settings
		// safety: should not happen, but who knows?
		if (name != "__old_view")
			return LoadView("__old_view");

		return false;
	}

	if (name != "__old_view")
		SaveView("__old_view");

	return LoadViewData(saved);
}
Esempio n. 2
0
bool CCameraHandler::LoadView(const std::string& name)
{
	if (name.empty()) {
		return false;
	}

	std::map<std::string, ViewData>::const_iterator it = views.find(name);
	if (it == views.end()) {
		return false;
	}
	const ViewData& saved = it->second;

	ViewData current;
	GetState(current);

	if (saved == current) { // load a view twice to return to old settings
		if (name != "__old_view") { // safety: should not happen, but who knows?
			return LoadView("__old_view");
		} else {
			return false;
		}
	} else {
		if (name != "__old_view") {
			SaveView("__old_view");
		}
		return LoadViewData(saved);
	}
}
Esempio n. 3
0
VOID KG3DBaseCoordImp::RenderIntersectMesh(RepresentData& RpData, const D3DXMATRIX& matView, const D3DXMATRIX& matProj)
{
	//检查其它Drawer是否正确
#if 0
	g_CheckFrameDrawers(RpData.vecPos, GetSelectorRingRadius(RpData));
#endif

	GraphicsStruct::RenderState rs1(D3DRS_AMBIENT, 0xffffffff);
	GraphicsStruct::RenderState rs2(D3DRS_ZENABLE, D3DZB_FALSE);

	GraphicsStruct::RenderState rs3(D3DRS_ALPHABLENDENABLE, TRUE);
	GraphicsStruct::RenderState rs4(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
	GraphicsStruct::RenderState rs5(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

	GraphicsStruct::RenderState rs6(D3DRS_CULLMODE, D3DCULL_NONE);
	GraphicsStruct::RenderState rs7(D3DRS_SPECULARENABLE, TRUE);
	GraphicsStruct::RenderState rs8(D3DRS_FILLMODE, D3DFILL_SOLID);
	GraphicsStruct::RenderState rs9(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);


	GraphicsStruct::SaveMatrix SaveWorld(D3DTS_WORLD);
	GraphicsStruct::SaveMatrix SaveView(D3DTS_VIEW);
	GraphicsStruct::SaveMatrix SaveProj(D3DTS_PROJECTION);

	g_pd3dDevice->SetTransform(D3DTS_VIEW, &matView);
	g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &matProj);

	GraphicsStruct::TextureStageState	tssColorOp0(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
	GraphicsStruct::TextureStageState	tssColorOp1(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
	GraphicsStruct::TextureStageState	tssColorArg0(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
	GraphicsStruct::TextureStageState	tssAlphaOp0(0,D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
	GraphicsStruct::TextureStageState	tssAlphaArg1(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR);
	g_pd3dDevice->SetRenderState(D3DRS_TEXTUREFACTOR, 0xffffffff);

	D3DXMATRIX matUse;
	{
		D3DXMATRIX vMatScaling;
		FLOAT fScale = GetSelectorRingRadius(RpData) / em_mesh_range;
		D3DXMatrixScaling(&vMatScaling, fScale, fScale, fScale);
		D3DXMATRIX vMatTrans;
		D3DXMatrixTranslation(&vMatTrans, RpData.vecPos.x, RpData.vecPos.y, RpData.vecPos.z);
		matUse = vMatScaling * vMatTrans;
	}
	g_pd3dDevice->SetTransform(D3DTS_WORLD, &matUse);

	_ASSERTE(_countof(RpData.MeshForAxis) == _countof(RpData.MeshForPlane));
	for (size_t i = 0; i < _countof(RpData.MeshForAxis); ++i)
	{
		if(NULL != RpData.MeshForAxis[i])
			RpData.MeshForAxis[i]->DrawSubset(0);

		if(NULL != RpData.MeshForPlane[i])
			RpData.MeshForPlane[i]->DrawSubset(0);
	}
	if(NULL != RpData.MeshForIntegration)
		RpData.MeshForIntegration->DrawSubset(0);
}
Esempio n. 4
0
void CCameraHandler::PushAction(const Action& action)
{
	const std::string cmd = action.command;

	if (cmd == "viewfps") {
		SetCameraMode(CAMERA_MODE_FIRSTPERSON);
	}
	else if (cmd == "viewta") {
		SetCameraMode(CAMERA_MODE_OVERHEAD);
	}
	else if (cmd == "viewspring") {
		SetCameraMode(CAMERA_MODE_SPRING);
	}
	else if (cmd == "viewrot") {
		SetCameraMode(CAMERA_MODE_ROTOVERHEAD);
	}
	else if (cmd == "viewfree") {
		SetCameraMode(CAMERA_MODE_FREE);
	}
	else if (cmd == "viewov") {
		SetCameraMode(CAMERA_MODE_OVERVIEW);
	}

	else if (cmd == "viewtaflip") {
		COverheadController* taCam = dynamic_cast<COverheadController*>(camControllers[CAMERA_MODE_OVERHEAD]);

		if (taCam) {
			if (!action.extra.empty()) {
				taCam->flipped = !!atoi(action.extra.c_str());
			} else {
				taCam->flipped = !taCam->flipped;
			}
			taCam->Update();
		}
	}
	else if (cmd == "viewsave") {
		if (!action.extra.empty()) {
			SaveView(action.extra);
			LOG("Saved view: %s", action.extra.c_str());
		}
	}
	else if (cmd == "viewload") {
		if (!LoadView(action.extra)) {
			LOG_L(L_WARNING, "Loading view failed!");
		}
	}
	else if (cmd == "toggleoverview") {
		ToggleOverviewCamera();
	}
	else if (cmd == "togglecammode") {
		ToggleState();
	}
}
Esempio n. 5
0
void CCameraHandler::PushAction(const Action& action)
{
	const std::string cmd = action.command;

	if (cmd == "viewfps") {
		SetCameraMode(CAMERA_MODE_FIRSTPERSON);
	}
	else if (cmd == "viewta") {
		SetCameraMode(CAMERA_MODE_OVERHEAD);
	}
	else if (cmd == "viewtw") {
		SetCameraMode(CAMERA_MODE_TOTALWAR);
	}
	else if (cmd == "viewrot") {
		SetCameraMode(CAMERA_MODE_ROTOVERHEAD);
	}
	else if (cmd == "viewfree") {
		SetCameraMode(CAMERA_MODE_FREE);
	}
	else if (cmd == "viewov") {
		SetCameraMode(CAMERA_MODE_OVERVIEW);
	}
	else if (cmd == "viewlua") {
		SetCameraMode(CAMERA_MODE_SMOOTH); // ?
	}
	else if (cmd == "vieworbit") {
		SetCameraMode(CAMERA_MODE_ORBIT);
	}

	else if (cmd == "viewtaflip") {
		COverheadController* taCam = dynamic_cast<COverheadController*>(camControllers[CAMERA_MODE_OVERHEAD]);
		SmoothController* smCam = dynamic_cast<SmoothController*>(camControllers[CAMERA_MODE_SMOOTH]);

		if (taCam) {
			if (!action.extra.empty()) {
				taCam->flipped = !!atoi(action.extra.c_str());
			} else {
				taCam->flipped = !taCam->flipped;
			}
		}
		if (smCam) {
			if (!action.extra.empty()) {
				smCam->flipped = !!atoi(action.extra.c_str());
			} else {
				smCam->flipped = !smCam->flipped;
			}
		}
	}
	else if (cmd == "viewsave") {
		if (!action.extra.empty()) {
			SaveView(action.extra);
			logOutput.Print("Saved view: " + action.extra);
		}
	}
	else if (cmd == "viewload") {
		if (!LoadView(action.extra))
			logOutput.Print("Loading view failed!");
	}
	else if (cmd == "toggleoverview") {
		ToggleOverviewCamera();
	}
	else if (cmd == "togglecammode") {
		ToggleState();
	}
}