コード例 #1
0
ファイル: Renderer.cpp プロジェクト: qq2377654/foo_chronflow
void Renderer::drawMirrorPass(){
	glVectord mirrorNormal = coverPos.getMirrorNormal();
	glVectord mirrorCenter = coverPos.getMirrorCenter();

	double mirrorDist; // distance from origin
	mirrorDist = mirrorCenter * mirrorNormal;
	glVectord mirrorPos = mirrorDist * mirrorNormal;

	glVectord scaleAxis(1, 0, 0);
	glVectord rotAxis = scaleAxis.cross(mirrorNormal);
	double rotAngle = rad2deg(scaleAxis.intersectAng(mirrorNormal));
	rotAngle = -2*rotAngle;

	if (glFogCoordf){
		GLfloat	fogColor[4] = {GetRValue(cfgPanelBg)/255.0f, GetGValue(cfgPanelBg)/255.0f, GetBValue(cfgPanelBg)/255.0f, 1.0f};
		glFogfv(GL_FOG_COLOR, fogColor);
		glEnable(GL_FOG);
	}

	glPushMatrix();
		glTranslated(2 * mirrorPos.x, 2 * mirrorPos.y, 2 * mirrorPos.z);
		glScalef(-1.0f, 1.0f, 1.0f);
		glRotated(rotAngle, rotAxis.x, rotAxis.y, rotAxis.z);

		drawCovers();
	glPopMatrix();
	
	if (glFogCoordf)
		glDisable(GL_FOG);
}
コード例 #2
0
ファイル: Renderer.cpp プロジェクト: qq2377654/foo_chronflow
void Renderer::drawScene(bool selectionPass)
{
	glLoadIdentity();
	gluLookAt(
		coverPos.getCameraPos().x, coverPos.getCameraPos().y, coverPos.getCameraPos().z,
		coverPos.getLookAt().x, coverPos.getLookAt().y, coverPos.getLookAt().z,
		coverPos.getUpVector().x, coverPos.getUpVector().y, coverPos.getUpVector().z);
	
	pfc::array_t<double> clipEq;

	if (coverPos.isMirrorPlaneEnabled()){
		clipEq = getMirrorClipPlane();
		if (!selectionPass){
			glClipPlane(GL_CLIP_PLANE0, clipEq.get_ptr());
			glEnable(GL_CLIP_PLANE0);
			glPushName(SELECTION_MIRROR);
				drawMirrorPass();
			glPopName();
			glDisable(GL_CLIP_PLANE0);
			drawMirrorOverlay();
		}

		// invert the clip equation
		for (int i=0; i < 4; i++){
			clipEq[i] *= -1;
		}
		
		glClipPlane(GL_CLIP_PLANE0, clipEq.get_ptr());
		glEnable(GL_CLIP_PLANE0);
	}
	
	glPushName(SELECTION_COVERS);
		drawCovers(true);
	glPopName();
	
	if (coverPos.isMirrorPlaneEnabled()){
		glDisable(GL_CLIP_PLANE0);
	}
}
コード例 #3
0
ファイル: engine.cpp プロジェクト: gladky/Four-stroke-engine
void displayObjects(int frame_no, int sceneRotation)
{
	GLfloat mat_diffuse[]    = { lightIntense*0.5, lightIntense*0.5,  lightIntense*0.5, 1.0 };
	glLightfv(GL_LIGHT1, GL_DIFFUSE, mat_diffuse);
	reshape (glutGet (GLUT_WINDOW_WIDTH),glutGet (GLUT_WINDOW_HEIGHT));
	glDepthMask(GL_TRUE);
	glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
    glPushMatrix();																//scene
		//glTranslatef( 0.0, 0.0, -55.0 ); 
		//glRotatef( 180.0, 1.0, 0.0, 0.0 );
		//glRotatef( 90.0, 0.0, 1.0, 0.0 );
		glPushMatrix();															//group 1
			//glRotatef( 45*sin((float)sceneRotation*0.01), 1.0, 0.0, 0.0 );
			//glRotatef( 100.0, 0.0, 1.0, 0.0 );
			//glRotatef( (float)sceneRotation*1.0, 0.0, 1.0, 0.0 );
			glPushMatrix();
				//drawHelpers();
			glPopMatrix();
			glPushMatrix();
				drawRoom();
				drawCrankshaft(frame_no  );
				draw4Pistons( frame_no  );
				putFlywheel(frame_no);
				drawCovers(frame_no + 90, transEnable);
				

				//drawValve();
				//drawCamshaft(); //debug
				//drawCamshaftCoverLeft(); // debug
				//drawTriangle(); // debug
				//drawFlywheel(); // debug
				//drawCamshaftMechanism(); //debug
			glPopMatrix();
		glPopMatrix();															//end of group 1
    glPopMatrix();																//end of scene	 
}