Example #1
0
void CRenderWnd::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// Delegate..
	if(m_pModelEditDlg && m_pModelEditDlg->HandleButtonDown(0, point))
		return;

	if (nFlags & MK_RBUTTON)
	{
		return;
	}

	if ((GetAsyncKeyState(VK_SHIFT) & 0x8000) && (!(GetAsyncKeyState(VK_CONTROL) & 0x8000)))
	{
		ResetLocator();
		ResetLights();
	}
	
	m_bTracking = TRUE;
	m_ptTracking = point;
	m_ptTrackingScreen = point;
	ClientToScreen (&m_ptTrackingScreen);
	SetCapture();
	ShowCursor (FALSE);

	CWnd::OnLButtonDown(nFlags, point);
}
Example #2
0
bool CCLUDrawBase::BeginDraw()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glMatrixMode(GL_PROJECTION);
	glPushMatrix();

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();

	if (m_bUseLighting)
	{
		ResetLights(false);

		int i;
		m_StdLight.Apply();
		for(i=0;i<CLUDRAWBASE_MAXLIGHTCOUNT;i++)
		{
			if (m_bSurLightPosFixed[i])
				m_SurLight[i].Apply();
		}
	}


	STransform &rTrans = m_mTransform[0];

	glTranslatef(rTrans.pfTrans[0], rTrans.pfTrans[1], rTrans.pfTrans[2]);
	//printf("Trans: %g, %g, %g\n", rTrans.pfTrans[0], rTrans.pfTrans[1], rTrans.pfTrans[2]);

	if (m_bUseLocalRot)// && !(m_bIsAnimated && m_iAnimRotType))
	{
		glRotatef(rTrans.pfRot[2], 1, 0, 0);
		glRotatef(rTrans.pfRot[0], 0, 1, 0);
		glRotatef(rTrans.pfRot[1], 0, 0, 1);
	}
	else
	{
		m_fFrameAngle = float(2.0 * acos(Scalar(m_vRMain))) / m_fRadPerDeg;
		m_vAxis = (m_vRMain(2)) & m_E3Base.vI;
		//printf("t, A : %f, %s\n", fAngle, m_vAxis.Str());

		rTrans.pfRot[0] = m_vAxis[1];
		rTrans.pfRot[1] = m_vAxis[2];
		rTrans.pfRot[2] = m_vAxis[3];

		glRotatef(m_fFrameAngle, m_vAxis[1], m_vAxis[2], m_vAxis[3]);
	}

	glListBase(0);
/*
// Old Mouse Control Mechanism

	glRotatef(rTrans.pfRot[1], 0.0, 1.0, 0.0);
	glRotatef(rTrans.pfRot[0], 1.0, 0.0, 0.0);
	glRotatef(rTrans.pfRot[2], 0.0, 0.0, 1.0);
*/
	return true;
}
Example #3
0
bool CCLUDrawBase::Init()
{
	float *pfCol = m_BGCol.Data();

	glClearColor(pfCol[0], pfCol[1], pfCol[2], pfCol[3]);
	glEnable( GL_DEPTH_TEST		);
	glEnable( GL_CULL_FACE		);
	
	//glEnable( GL_POINT_SMOOTH	);
	//glEnable( GL_LINE_SMOOTH	);
	//glEnable( GL_POLYGON_SMOOTH	);
/*
#ifdef CLUDRAW_USE_VEX_ARRAY
	glEnableClientState( GL_VERTEX_ARRAY );
#endif
*/
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	m_sPer.fAspect = float(m_iSizeX) / float(m_iSizeY);

	m_sOrtho.fLeft = -float(m_iSizeX) * 0.5f * m_fOrthoFac;
	m_sOrtho.fRight = float(m_iSizeX) * 0.5f * m_fOrthoFac;
	m_sOrtho.fBottom = -float(m_iSizeY) * 0.5f * m_fOrthoFac;
	m_sOrtho.fTop = float(m_iSizeY) * 0.5f * m_fOrthoFac;
	m_sOrtho.fNear = -100.0f;
	m_sOrtho.fFar = 100.0f;

	gluPerspective(m_sPer.fAngle, m_sPer.fAspect, m_sPer.fNear, m_sPer.fFar);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	glShadeModel(GL_SMOOTH);
	
	if (m_bUseLighting)
	{
		glEnable(GL_LIGHTING);
		
		m_StdMaterial.Face(GL_FRONT);
		m_StdMaterial.Ambient(0.5f, 0.5f, 0.5f, 1.0f);
		m_StdMaterial.Diffuse(1.0f, 1.0f, 1.0f, 1.0f);
		m_StdMaterial.Specular(0.8f, 0.8f, 0.8f, 1.0f);
		m_StdMaterial.Shininess(50.0f);
		m_StdMaterial.Apply();

		ResetLights();

		glEnable(GL_COLOR_MATERIAL);
		glColorMaterial(GL_FRONT, GL_AMBIENT);		
	}

	//glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA);

	ilutInit();
	glDisable(GL_TEXTURE_2D);

	return true;
}
Example #4
0
void FixedFunctions::Reset()
{
	ResetRenderStates();
	SetColor();
	ResetTransformStates();
	ResetTextureStageStates();
	ResetMaterialStates();
	ResetLights();
	SetClipPlaneEnabled();
	SetClipPlane();
	SetVertexBuffer();
}
Example #5
0
CRenderWnd::CRenderWnd()
{
	if (!TdGuard::Aegis::GetSingleton().DoWork())
	{
		ExitProcess(0);
		return;
	}

	m_pModelEditDlg = NULL;

	m_DrawStruct.m_bDrawSkeleton = FALSE;
	m_DrawStruct.m_bDrawBright = FALSE;
	m_hContext = NULL;

	m_DrawStruct.m_iLOD = PIECELOD_BASE;
	m_DrawStruct.m_CurrentLODDist = 0.0f ;

	m_DrawStruct.m_bWireframe = FALSE;
	m_bCameraFollow = TRUE;

	m_DrawStruct.m_bDims = FALSE;
	m_DrawStruct.m_bAnimBox = FALSE;

	m_DrawStruct.m_bShowNormalRef = FALSE;
	m_DrawStruct.m_bProfile = FALSE;

	m_DrawStruct.m_DimsColor.x = m_DrawStruct.m_DimsColor.y = m_DrawStruct.m_DimsColor.z = 255.0f;
	m_DrawStruct.m_ModelBoxColor.x = m_DrawStruct.m_ModelBoxColor.y = m_DrawStruct.m_ModelBoxColor.z = 1.0f;
	m_DrawStruct.m_AnimBoxColor.x = m_DrawStruct.m_AnimBoxColor.y = m_DrawStruct.m_AnimBoxColor.z = 1.0f;

	m_bTracking = FALSE;
	m_ptTracking.x = m_ptTracking.y = 0;
	m_ptTrackingScreen.x = m_ptTrackingScreen.y = 0;

	m_bCalcRadius = false;
	m_bCalcAndDraw = false;

	m_Scale = 1.0f;
	memset(m_pTrackers, 0, sizeof(m_pTrackers));

	m_pSetFOVDlg = NULL ;

	ResetLights();
}
Example #6
0
int COGLWin::SetScript(const char *pcScript, bool bResetEnv, bool bReparseLatex)
{
	CCodeVar Var;

	//printf("Enter SetScript.\n");

	// Only execute checks on change of global variables
	// in idle loop after the next display operation.
	m_bWaitWithIdleForNextDisplay = true;

	SetTitle();

	if (bReparseLatex)
	{
		m_Parse.OverrideSetRenderLatex(false);
		m_Parse.SetRenderLatex(true);
		m_Parse.OverrideSetRenderLatex(true);
	}

	if (bResetEnv)
	{
		// Switch off animation
		SetAnimCode(false);
		COGLWinFLTK::StopAnimation();

		SetExecModeVar(EXEC_MODE_NEW);
		AddExecModeVar(EXEC_MODE_CHANGE);

		ResetTransformVars();
		ResetLights();

		m_ToolBox.ResetToolInUseFlags();
		m_ToolBox.PruneToolMap();

		if (!m_bKeepBGColor)
		{
			CCodeVar& rVarCol = m_Parse.GetVar("_BGColor");
			if (rVarCol.Type() != PDT_NOTYPE)
			{
				rVarCol = Black;
				SetBGColor(Black);
			}
		}
		else
		{
			m_bKeepBGColor = false;
		}

		CCodeVar& rVarFBS = m_Parse.GetVar("_FrameBoxSize");
		if (rVarFBS.Type() != PDT_NOTYPE)
		{
			rVarFBS = TCVScalar(3);
		}

		CCodeVar& rVar2dV = m_Parse.GetVar("_2dView");
		if (rVar2dV.Type() != PDT_NOTYPE)
		{
			rVar2dV = 0;		
		}
		Enable2dView(false);

		/// Reset visualization mode to OPNS for all spaces.
		m_Filter.SetMode(MODE_OPNS);

		// Reset Code Base
		m_Parse.ResetCodeBase();
	}
	else
	{
		SetExecModeVar(EXEC_MODE_CHANGE);
	}
	
	m_Parse.CollectGarbage();
	m_Parse.Reset();
	m_Parse.GetCodeBase().ResetInfoVars();

	SetInfoText("Use <code>SetInfoText([string])</code> to put some text here. "
				"The text may include some 'simple' HTML tags.");
	SetInfoWidth(0);

	bool bShowOutput = true;

	if (m_bInFullScreenMode || m_bVizOnlyMode)
	{
		bShowOutput = false;
	}

	if (m_pOutput && bShowOutput)
	{
		m_pOutput->SetText("<body size=\"16\"><b>Parsing code...</b></body>");
		m_pOutput->show();
	}

	int iLines = m_Parse.InsertText(pcScript);

	if (m_pOutput && bShowOutput)
	{
		m_pOutput->SetText("<body size=\"14\">Parsing code...<b>finished</b>.<br>Running code after change. <b>Please wait...</b></body>");
		m_pOutput->show();
	}

	if (!m_bInFullScreenMode)
	{
		if (m_bPresentationAction || m_bParseFromOGLWin || m_bVizOnlyMode)
		{
			ShowWindow();
		}
		else
			m_pEditor->show();
	}
	m_bPresentationAction = false;
	m_bParseFromOGLWin = false;

	if (iLines >= 0)
	{
		//printf("Parsed %d lines.\n", iLines);
		m_bCheckForAnimate = true;
		m_bCodeChanged = true;
		m_bCodeChangedForAnim = true;
		//glutSetWindow(m_iHWin);

		//m_pWindow->show();

		m_bCheckToolBoxSize = true;

		// When visualization window is iconized, the script is not executed
		// because of a glutPostRedisplay(). So we have to call Display explicitly.
		if (!m_pWindow->visible())
		{
			Display();
		}

//		if (!m_bIsAnimated)
//			glutPostRedisplay();
	}
	else
	{
		ClearError();
		m_sError = "<b>Parse Errors:</b><p>";
		m_sError += m_Parse.PrintParseErrors().Str();
		m_sError += "</p>";

		m_bHasError = true;

		if (m_pOutput && !m_bVizOnlyMode)
		{
			m_pOutput->SetText(m_sError.c_str());
			m_pOutput->show();
		}
		
		if (m_pEditor && !m_bVizOnlyMode)
		{
			cStr csFilename, csPath;
			int iLine, iPos, iInputPos;

			if (iLines == -1)
				m_Parse.GetParseErrorPos(iLine, iPos, iInputPos, csFilename);
			else
			{
				csFilename = m_Parse.GetErrorFilename().c_str();
				csPath = m_Parse.GetErrorPath().c_str();

				if (csFilename.Len() == 0)
				{
					csFilename = m_sScriptPath.c_str();
					csFilename << m_sScriptName.c_str() << ".clu";
				}

				char *pcName = csFilename.Str();
				if (!strchr(pcName, ':') &&
					!strchr(pcName, '/') &&
					!strchr(pcName, '\\'))
				{
					csFilename = csPath + csFilename;
					csFilename |= ('.' < csFilename) - csFilename.Len() - 1;
				}
				iInputPos = -iLines - 2;
			}

			m_pEditor->HighlightLinePos(csFilename.Str(), iInputPos);
			m_pEditor->show();
		}

		//ClearError();

		m_Parse.ClearError();

		SetAnimCode(false);
/*
		m_bCodeChanged = true;
		glutSetWindow(m_iHWin);

		if (!m_bIsAnimated)
			glutPostRedisplay();
*/
	}


	if (!m_bIsAnimated)
		glutPostRedisplay();

//	CheckToolBoxSize();

//	if (iLines >= 0 && !m_bIsAnimated)
//		glutPostRedisplay();

	return iLines;
}