Example #1
0
void Frog::drawLimb(float * begin, float * length) {
   Sphere joint;
   Cylinder limb;

   float end[3] = {begin[0] + length[0], begin[1] + length[1], begin[2] + length[2]};
   float mag = sqrt(length[0]*length[0] + length[1]*length[1] + length[2]*length[2]);
   float norm[3] = {length[0]/mag, length[1]/mag, length[2]/mag};
   float cross[3] = {norm[2], 0, -1*norm[0]};
   float angle = acos(norm[1]) * 180 / 3.14159f;

   glColor3f(color[0], color[1], color[2]);
   glPushMatrix();
   glTranslatef(begin[0], begin[1], begin[2]);
   glRotatef(angle, cross[0], cross[1], cross[2]);
   glScalef(.1, mag, .1);
   limb.draw();
   glPopMatrix();

   glColor3f(color[0], color[1], color[2]);
   glPushMatrix();
   glTranslatef(begin[0], begin[1], begin[2]);
   glScalef(.1, .1, .1);
   joint.draw();
   glPopMatrix();

   glPushMatrix();
   glTranslatef(end[0], end[1], end[2]);
   glScalef(.1, .1, .1);
   joint.draw();
   glPopMatrix();
}
void GraphicsSubsystem::drawBall(const Sphere &ball)
{
	GLuint ballpr = shaders["ball"];
	glUseProgram(ballpr);

	glm::mat4 modelToWorld = ball.getModelToWorldMat();
	glm::mat3 normWorldMatrix = glm::mat3(glm::transpose(glm::inverse(modelToWorld)));
	glm::mat3 normCamMatrix = glm::mat3(glm::transpose(glm::inverse(worldToCam * modelToWorld)));

	glUniformMatrix4fv(programUniforms[ballpr]["modelToWorldMatrix"], 1, GL_FALSE, glm::value_ptr(modelToWorld));
	glUniformMatrix3fv(programUniforms[ballpr]["normalModelToWorldMatrix"], 1, GL_FALSE, glm::value_ptr(normWorldMatrix));
	glUniformMatrix3fv(programUniforms[ballpr]["normalModelToCameraMatrix"], 1, GL_FALSE, glm::value_ptr(normCamMatrix));

	glm::mat4 worldToLightMatrix = glm::scale(glm::mat4(1.0), glm::vec3(IBLscale)); 
	glm::mat3 worldToLightITMatrix = glm::mat3(glm::transpose(glm::inverse(worldToLightMatrix)));
	glUniformMatrix4fv(programUniforms[ballpr]["worldToLightMatrix"], 1, GL_FALSE, glm::value_ptr(worldToLightMatrix));
	glUniformMatrix3fv(programUniforms[ballpr]["worldToLightITMatrix"], 1, GL_FALSE, glm::value_ptr(worldToLightITMatrix));

	glUniform3f(programUniforms[ballpr]["camPos"], camPos.x, camPos.y, camPos.z);

	glActiveTexture(GL_TEXTURE0 + texUnits["roomBall"]);  
	glBindTexture(GL_TEXTURE_CUBE_MAP, textures["roomBall"]);

	glActiveTexture(GL_TEXTURE0 + texUnits["ball"]);
	glBindTexture(GL_TEXTURE_2D, textures["ball"]);
	glBindSampler(texUnits["ball"], sampler);
	
	ball.draw();
	
	glBindSampler(texUnits["ball"], 0);
	glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
	glBindTexture(GL_TEXTURE_2D, 0);

	glUseProgram(0);
}
Example #3
0
void renderObjects()
{
	// Set Modeling transformation for the reference plane
	modelingTransformation = glm::translate(glm::vec3(0.0f, -3.0f, 0.0f));
	refPlane.draw();

	// Set modeling transformation for the front left pyramid
	modelingTransformation = glm::translate(glm::vec3(-3.5f, -2.5f, 3.5f));
	pyramid.draw(color(0.0f, 0.0f, 1.0f, 1.0f));

	// Set modeling transformation for the back right pyramid
	modelingTransformation = glm::translate(glm::vec3(3.5f, -2.5f, -3.5f));
	pyramid.draw(color(0.0f, 0.0f, 1.0f, 1.0f));

	// Set modeling transformation for the center pyramid
	modelingTransformation = glm::translate(glm::vec3(0.0f, 0.0f, 0.0f)) * glm::rotate(angle, glm::vec3(0.0f, 1.0f, 0.0f));
	pyramid.draw(color(1.0f, 0.0f, 0.0f, 1.0f));

	// Set modeling transformation for the right hand pyramid
	modelingTransformation = glm::translate(glm::vec3(3.0f, 0.0f, 0.0f)) * glm::rotate(angle, glm::vec3(1.0f, 0.0f, 0.0f));
	sphere.draw(color(1.0f, 1.0f, 0.0f, 1.0f));

	// Set modeling transformation for the left hand pyramid
	modelingTransformation = glm::translate(glm::vec3(-3.0f, 0.0f, 0.0f)) * glm::rotate(angle, glm::vec3(0.0f, 0.0f, 1.0f)) * glm::scale(glm::vec3(2.0f, 2.0f, 2.0f));
	pyramid.draw(color(1.0f, 0.0f, 1.0f, 1.0f));

}
Example #4
0
// draws solid Sphere. The wire color is always black
//pre scene camera and an instance of Sphere class exists
//post Sphere is drawn
//usage mySphere.drawSphere(color);
void drawSphere(vec4 color)
{
    glUniform4fv( model_color, 1,color );
    mySphere.draw();
    glUniform4fv( model_color, 1,vec4(0,0,0,1) );
    //myWireCylinder.draw();
}
Example #5
0
int main()
{
  picture(P(-MAX,-MAX),P(MAX,MAX), "6x6in");
  begin();
  camera.at(P(0, 6, 1.25));
 
  revolutions(); // set angle units
  
  pen(Black()); // coordinate grid
  latitude(0, 0, 1);
  pen(Black(0.3)); // coordinate grid
  dashed();
  back_latitude(0, 0, 1);
  solid();
  pen(Black());
  longitude(0.1, 0, 1);
  longitude(0.2, 0, 1);
  longitude(0.3, 0, 1);

  P O=sph(0,0,0);
  P C=sph(1,0.25,0.25);
  
  P G=sph(1,0.7,0.40);
  P SS=sph(1,0.8,0.48);
  P A=sph(1,0.6,0.40);

  Sphere S;
  pen(Black());
  dashed();
  line(O,SS);
  line(O,G);
  line(O,A);
  solid();
  dot(O);dot(C);dot(G);dot(SS);dot(A);

  
  
  font_size("tiny");
  //arc_arrow(C, 1.0, 0.35, 0.19);

  arc_arrow(P(0.,0.,0.5),0.85,0.2,0.3);
  arc_arrow(P(0.,0.,0.55),0.83,0.2,0.1);
  arc_arrow(P(0.,0.,0.7),0.70,0.3,0.1);
  label(C,P(6,6),"P");
  label(G,P(-5,5),"G");
  label(SS,P(-5,5),"S");
  label(A,P(-5,5),"A");
  
  label (sph(1.03,0.65,0.42),P(0,0),"$$H_G$$");
  label (sph(1.03,0.75,0.41),P(0,0),"$$\\delta\\lambda$$");
  label (sph(1.03,0.70,0.37),P(0,0),"$$H_S$$");

  S.draw();

  end();
}
Example #6
0
void CubeMapApp::drawScene()
{
	D3DApp::drawScene();
	
	
	// Restore default states, input layout and primitive topology 
	// because mFont->DrawText changes them.  Note that we can 
	// restore the default states by passing null.
	md3dDevice->OMSetDepthStencilState(0, 0);
	float blendFactor[] = {0.0f, 0.0f, 0.0f, 0.0f};
	md3dDevice->OMSetBlendState(0, blendFactor, 0xffffffff);
	
	md3dDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
	md3dDevice->IASetInputLayout(InputLayout::PosNormalTex);

	// Set per frame constants.
	mfxEyePosVar->SetRawValue(&GetCamera().position(), 0, sizeof(D3DXVECTOR3));
	mfxLightVar->SetRawValue(&mParallelLight, 0, sizeof(Light));
	
	mfxCubeMapVar->SetResource(mEnvMapRV);
	

	D3DXMATRIX view = GetCamera().view();
	D3DXMATRIX proj = GetCamera().proj();

    D3D10_TECHNIQUE_DESC techDesc;
    mTech->GetDesc( &techDesc );

    for(UINT i = 0; i < techDesc.Passes; ++i)
    {
        ID3D10EffectPass* pass = mTech->GetPassByIndex(i);

		//
		// draw center ball
		//
		D3DXMATRIX centerBallWVP = mCenterBallWorld*view*proj;
		mfxWVPVar->SetMatrix((float*)&centerBallWVP);
		mfxWorldVar->SetMatrix((float*)&mCenterBallWorld);
		mfxTexMtxVar->SetMatrix((float*)&mIdentityTexMtx);
		mfxDiffuseMapVar->SetResource(mBallMapRV);
		mfxSpecMapVar->SetResource(mDefaultSpecMapRV);
		mfxCubeMapEnabledVar->SetBool(true);
		mfxReflectMtrlVar->SetFloatVector((float*)&mReflectAll);
		pass->Apply(0);
		mBall.draw();		
    }

	// We specify DT_NOCLIP, so we do not care about width/height of the rect.
	RECT R = {5, 5, 0, 0};
	md3dDevice->RSSetState(0);
	mFont->DrawText(0, mFrameStats.c_str(), -1, &R, DT_NOCLIP, WHITE);

	mSwapChain->Present(0, 0);
}
Example #7
0
int main()
{
  picture(P(-MAX,-MAX),P(MAX,MAX), "6x6in");
  begin();
  camera.at(P(0, 5, 1.25));
 
  degrees(); // set angle units
  pen(Black(0.3)); // coordinate grid
  back_latitude(0, 0, 360);
  pen(Black());
  latitude(0, 0, 360);
  pen(Black(0.3));

  revolutions();
  P O=sph(0,0,0);
  P A=sph(1,0.35,0.1);
  P B=sph(1,0.19,0.03);
  P C=sph(1,0.25,0.25);
  P Aeq=sph(1,0.35,0);
  P Beq=sph(1,0.19,0);

  Sphere S;
  pen(Red());
  bold();
  front_triangle(B,A,C,S);
  plain();
  dashed();
  pen(Black());
  front_arc(B,Beq,S);
  front_arc(A,Aeq,S);
  pen(Black(0.3));
  line(O,Aeq);
  line(O,A);
  solid();
  dot(O);dot(A);dot(B);dot(C);dot(Aeq);dot(Beq);
  pen(Black());
  
  font_size("tiny");
  //arc_arrow(C, 1.0, 0.35, 0.19);
  label(B,P(-8,0),"B");
  label(A,P(8,0),"A");
  label(O,P(30,20),"c");
  label(O,P(-5,-5),"O");
  label(A,P(15,-25),"$\\varphi_A$");
  label(B,P(-8,40),"$\\frac{\\pi}{2}-\\varphi_B$");
  label(A,P(-2,30),"$\\frac{\\pi}{2}-\\varphi_A$");
  label(C,P(0,-8),"$\\delta\\lambda$");
  
  S.draw();

  end();
}
Example #8
0
void Exploder::explode() {
   if (!done) {
      Sphere s;

      explodeSize += 0.7;
      if (explodeSize > maxSize) {
         done = true;
      }

      glPushMatrix();
         glColor3f(0.5, 0.3, 0.05);
         glScalef(explodeSize, explodeSize, explodeSize);
         s.draw();
      glPopMatrix();
   }
}
Example #9
0
/**
* Acts as the display function for the window.
*/
static void RenderSceneCB()
{
	vector<glm::vec4> transformedVertices;

	// Clear the color buffer
	colorBuffer.clearColorBuffer();

	static float angle = glm::radians(45.0f);

	angle += glm::radians(1.0f);

	// Set Modeling transformation for the reference plane
	modelingTransformation = glm::translate(glm::vec3(0.0f, -3.0f, 0.0f));
	refPlane.draw();

	// Set modeling transformation for the front left pyramid
	modelingTransformation = glm::translate(glm::vec3(-3.5f, -2.5f, 3.5f));
	pyramid.draw(color(0.0f, 0.0f, 1.0f, 1.0f));

	// Set modeling transformation for the back right pyramid
	modelingTransformation = glm::translate(glm::vec3(3.5f, -2.5f, -3.5f));
	pyramid.draw(color(0.0f, 0.0f, 1.0f, 1.0f));

	// Set modeling transformation for the center pyramid
	modelingTransformation = glm::translate(glm::vec3(0.0f, 0.0f, 0.0f)) * glm::rotate(angle,glm::vec3(0.0f, 1.0f, 0.0f));
	pyramid.draw(color(1.0f, 0.0f, 0.0f, 1.0f));

	// Set modeling transformation for the right hand pyramid
	modelingTransformation = glm::translate(glm::vec3(3.0f, 0.0f, 0.0f)) * glm::rotate(angle, glm::vec3(1.0f, 0.0f, 0.0f));
	sphere.draw( color(1.0f, 1.0f, 0.0f, 1.0f));

	// Set modeling transformation for the left hand pyramid
	modelingTransformation = glm::translate(glm::vec3(-3.0f, 0.0f, 0.0f)) * glm::rotate(angle, glm::vec3(0.0f, 0.0f, 1.0f)) * glm::scale(glm::vec3(2.0f, 2.0f, 2.0f));
	pyramid.draw( color(1.0f, 0.0f, 1.0f, 1.0f));

	// Set modeling transformation for the orbiting pyramid
	modelingTransformation = glm::rotate(angle, glm::vec3(0.0f, 1.0f, 0.0f))* glm::translate(glm::vec3(10.0f, 3.0f, 0.0f)) *glm::rotate(-angle, glm::vec3(1.0f, 0.0f, 0.0f));
	pyramid.draw( color(1.0f, 1.0f, 1.0f, 1.0f));

	// Display the color buffer
	colorBuffer.showColorBuffer();

} // end RenderSceneCB
Example #10
0
void loop() 
{		
	static float k = 0.0f;
	if (glfwGetKey('V')) 
		k+=1;
	if (glfwGetKey('B')) 
		k-=1;
	vec3 Light = geotocart(0,k,150000000);

	static vec3 position = geotocart(49, 16, 6600);
	static vec3 angles = -normalize(position);//-normalize(position);
	
	static float velocity = 1.0f;
	static float pitch = 0, yaw = 0;


	if (glfwGetKey('Z'))
		velocity += 50;
	if (glfwGetKey('X'))
		velocity -= 50;

	float fact = 0.2f;
	
	if (glfwGetKey('W')) {		
		pitch+=fact;	
	}
	if (glfwGetKey('S')) {
		pitch-=fact;
	}
	if (glfwGetKey('D')) {
		yaw+=fact;
	}
	if (glfwGetKey('A')) {
		yaw-=fact;
	}

	static float texgrad = 1.0f;

	if (glfwGetKey('T'))
		texgrad += 0.01f;
	if (glfwGetKey('G'))
		texgrad -= 0.01f;

	texgrad = texgrad>1.0f?1.0f:texgrad;
	texgrad = texgrad<0.0f?0.0f:texgrad;

	mat4 rot = mat4(1.0f);
	rot = rotate(rot, pitch, vec3(0,1.0f,0));
	rot = rotate(rot, yaw, vec3(1.0f,0,0));
		
	vec3 pom = vec3(normalize(rot * vec4(angles, 0.0f)));
	vec3 direction = vec3(pom);

	vec3 up = vec3(0,1,0);
	vec3 right = up * direction;
	right = normalize(right);
	up = right * direction;


	position += velocity*normalize(direction);

	mat4 Projection = glm::perspective(60.0f, 16.0f/9.0f, 1.0f, 20000.f);

	position = geotocart(49+pitch, 16+yaw, 6600+velocity);
	mat4 View = lookAt(
	position,
	vec3(0),
	vec3(0,0,1)		
		);

	
	mat4 Model      = glm::mat4(1.0f);  

	mat4 MVP = Projection * View * Model;


	glUseProgram(earth? program2 : program);

	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, Texture);
	glUniform1i(TextureID, 0);
	
	glActiveTexture(GL_TEXTURE1);
	glBindTexture(GL_TEXTURE_2D, NightTexture);
	glUniform1i(NightTextureID2, 1);

	glUniformMatrix4fv(earth ? MatrixID2 : MatrixID, 1, GL_FALSE, &MVP[0][0]);
	glUniformMatrix4fv(ModelIDsphere2, 1, GL_FALSE, &Model[0][0]);
	glUniformMatrix4fv(ViewIDsphere2, 1, GL_FALSE, &View[0][0]);
	glUniform3f(LightIDsphere2, Light.x, Light.y, Light.z);	
	glUniform1f(TexGradID, texgrad);

	movemap();

	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	
	vec2 geoPos = carttogeo(normalize(position));
	int c = 20;
	

	Segments->drawAll(LOD, indices, earth? segparlocation2 : segparlocation, center, geoPos.y-c, geoPos.y+c, geoPos.x-c, geoPos.x+c);	

	static Sphere sphere(6371, 50, 50);
	
	static float angx = -270.0f;
	static float angy = 180.0f;
	static float angz = 180.0f;
	Model = scale(mat4(1.0f), vec3(-1.0f, -1.0f, -1.0f));
	Model = rotate(Model, angx, 1.0f, 0.0f, 0.0f);
	Model = rotate(Model, angy, 0.0f, 1.0f, 0.0f);
	Model = rotate(Model, angz, 0.0f, 0.0f, 1.0f);
	MVP = Projection * View * Model;


	glUseProgram(sphereprogram);
	glUniformMatrix4fv(MatrixIDsphere, 1, GL_FALSE, &MVP[0][0]);
	glUniformMatrix4fv(ModelIDsphere, 1, GL_FALSE, &Model[0][0]);
	glUniformMatrix4fv(ViewIDsphere, 1, GL_FALSE, &View[0][0]);
	glUniform3f(LightIDsphere, Light.x, Light.y, Light.z);	

	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, Texture);
	glUniform1i(SphereTextureID, 0);

	glActiveTexture(GL_TEXTURE1);
	glBindTexture(GL_TEXTURE_2D, NightTexture);
	glUniform1i(NightTextureID, 1);

	sphere.draw(0,0,0);

	glfwSwapBuffers();
}
Example #11
0
void Frog::draw () {
   if (animate)
      for (int i = 0; i < 10; ++i)
         nextFrame();

   glPushMatrix();

   glTranslatef(0, 0, pos[2]);

   float specReflection[] = { 0.5f, 0.9f, 0.5f, 1.0f };
   glMaterialfv(GL_FRONT, GL_SPECULAR, specReflection);
   glMateriali(GL_FRONT, GL_SHININESS, 84);

   float joint[3];

   for (int i = 0; i < 4; ++i) {
      joint[0] = 0;
      joint[1] = 0;
      joint[2] = 0;

      joint[0] += legs[i].toe[0];
      joint[1] += legs[i].toe[1];
      joint[2] += legs[i].toe[2];
      drawLimb(joint, legs[i].ankle);

      joint[0] += legs[i].ankle[0];
      joint[1] += legs[i].ankle[1];
      joint[2] += legs[i].ankle[2];
      drawLimb(joint, legs[i].knee);

      joint[0] += legs[i].knee[0];
      joint[1] += legs[i].knee[1];
      joint[2] += legs[i].knee[2];
      drawLimb(joint, legs[i].hip);
   }

   joint[0] += legs[3].hip[0];
   joint[1] += legs[3].hip[1];
   joint[2] += legs[3].hip[2];

   glPopMatrix();

   //specReflection = { 0.3f, 0.3f, 0.3f, 1f };
   specReflection[0] = 0.1f;
   specReflection[1] = 0.8f;
   specReflection[2] = 0.1f;
   glMaterialfv(GL_FRONT, GL_SPECULAR, specReflection);
   glMaterialfv(GL_FRONT, GL_DIFFUSE, specReflection);
   glMateriali(GL_FRONT, GL_SHININESS, 126);

   Sphere body;

   glPushMatrix();
   glTranslatef(0, joint[1], joint[2] - .7);
   glTranslatef(0, 0, pos[2]);
   glRotatef(-20, 1, 0, 0);
   glScalef(.8, .6, 1.2);
   body.draw();
   glPopMatrix();

   glPushMatrix();
   glTranslatef(0, .75 + joint[1], .5 + joint[2]);
   glTranslatef(0, 0, pos[2]);
   glScalef(.7, .7, .7);
   body.draw();
   glPopMatrix();
}
Example #12
0
	void OnDisplay() {

		GLfloat matrix[16];

		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
		float deltaTime = (float)App::GetDeltaTime();

		_angle += _angleInc * deltaTime;
		if(_angle > 360.0f) 
			_angle -=360.0f;

		glPushMatrix();
			glTranslatef(0.0f, 0.0f,_cameraPosition);
			glRotatef(_cameraAngle, 1.0,0.0,0.0);
			glRotatef(_cameraRotation, 0.0, 1.0, 0.0);
			glTranslatef(0.0f, -2.0f,0.0f);

			// First draw the floor into the stencil buffer
			if(_stencil) {
				glDisable(GL_DEPTH_TEST);
				glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
				glDisable(GL_LIGHTING);
				glEnable(GL_STENCIL_TEST);
				glStencilFunc(GL_ALWAYS, 1, 1);
				glStencilOp(GL_REPLACE,GL_REPLACE,GL_REPLACE);
				//////////////////////////////////////////////////////////////////////////
				stencil_floor();  // floor with nothing fancy
				//////////////////////////////////////////////////////////////////////////

				glEnable(GL_LIGHTING);
				glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
				glEnable(GL_DEPTH_TEST);

				// everything set ready for drawing
				// set stencil ready for drawing the cube
				glStencilFunc(GL_EQUAL, 1, 1);
				glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP);
			};

			// now draw the a reflected cube and light under the floor but only 
			// when stencil value is 1
			glPushMatrix();
				// reflect all objects about y=0 plane 
				glScalef(1.0, -1.0, 1.0);	

				// but normals are messed up 
				// and front faces become back faces and visa-versa
				glEnable(GL_NORMALIZE);
				glCullFace(GL_FRONT);

				// includes the light position and the light source

				_light1.setPosition(Vector4f(5.0,5.0,5.0,1.0));
				_light2.setPosition(Vector4f(-5.0,5.0,5.0,1.0));
				_light4.setPosition(Vector4f(0.0,5.0,-5.0,1.0));
				_light5.setPosition(Vector4f(0.0,-1.0,-5.0,1.0));


				glPushMatrix();
					_light3.setPosition(Vector4f(_light3[0],_light3[1],_light3[2],1.0));
					glTranslatef(_light3[0],_light3[1],_light3[2]);
					_material3.apply();
					_sphere1.draw();
				glPopMatrix();
				// now the textured cube
				glPushMatrix();
					glTranslatef(0.0f, 2.0f, 0.0f);
					glRotatef(-_angle, 0.0, 1.0, 0.0);
					_material1.apply();
					texcube();
				glPopMatrix();
				
				// Done this, put things back together again
				glDisable(GL_NORMALIZE);
				glCullFace(GL_BACK);
			glPopMatrix();

			// remember to turn the stencil buffer off for the rest of the image
			if (_stencil) {
				glDisable(GL_STENCIL_TEST);
			}

			// put the lights back
				_light1.setPosition(Vector4f(5.0,5.0,5.0,1.0));
				_light2.setPosition(Vector4f(-5.0,5.0,5.0,1.0));
				_light4.setPosition(Vector4f(0.0,5.0,-5.0,1.0));
				_light5.setPosition(Vector4f(0.0,-1.0,-5.0,1.0));


			glPushMatrix();
				_light3.setPosition(Vector4f(_light3[0],_light3[1],_light3[2],1.0));
				glTranslatef(_light3[0],_light3[1],_light3[2]);
				_material3.apply();
				_sphere1.draw();
			glPopMatrix();
			



			// make the floor semi-transparent
			glEnable(GL_BLEND);
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
			_material2.apply();
			floor();
			glDisable(GL_BLEND);

			// now draw the floor again from below but with no blending
			// switch meaning of front face from anti-clockwise to clockwise
			glFrontFace(GL_CW);
			floor();
			// undo the meaning of front face
			glFrontFace(GL_CCW);


			glPushMatrix();
				glTranslatef(0.0f, 2.0f, 0.0f);
				glRotatef(-_angle, 0.0, 1.0, 0.0);
				_material1.apply();
				texcube();
			glPopMatrix();


		glPopMatrix();

		SwapBuffers();
	}
Example #13
0
//--------------------------------------------------------------
void ofApp::draw() {
	#pragma region Gestion - Interface
	//////////////////////////////////////////////////
	m_selectedMenu.draw();

	ofSetColor(0, 0, 0);
	ofDrawBitmapString("F1 - Afficher l'interface", 10, (ofGetHeight() - 35));
	ofDrawBitmapString("Clic droit - Afficher le menu (et sous-menu)", 10, (ofGetHeight() - 15));
	//////////////////////////////////////////////////
	#pragma endregion

	//Primitives
	list<Primitive*>::iterator it = this->primitives.begin();

	for (it = this->primitives.begin(); it != this->primitives.end(); ++it)
	{
		string nomClasse = typeid(**it).name();

		if(nomClasse == "class _Line")
		{
			Primitive *Lparent = (*it);
			_Line *Lenfant = (dynamic_cast<_Line *>(Lparent));
			Lenfant->draw();
		}
		else if(nomClasse == "class Triangle")
		{
			Primitive *Tparent = (*it);
			Triangle *Tenfant = (dynamic_cast<Triangle *>(Tparent));
			Tenfant->draw();
		}
		else
			cout << "Mauvais typage sur Primitive";
	}

	//Formes
	list<Form*>::iterator it2 = this->forms.begin();

	for (it2 = this->forms.begin(); it2 != this->forms.end(); ++it2)
	{
		string nomClasse = typeid(**it2).name();

		if (nomClasse == "class Cube")
		{
			Form *Cparent = (*it2);
			Cube *Cenfant = (dynamic_cast<Cube *>(Cparent));
			if (Cenfant->GetTexture() != NULL)
			{
				Cenfant->drawOnCube();
			}
			else
			{
				Cenfant->draw();
			}
			
		}
		else if (nomClasse == "class Sphere")
		{
			Form *Sparent = (*it2);
			Sphere *Senfant = (dynamic_cast<Sphere *>(Sparent));
			if (Senfant->GetTexture() != NULL)
			{
				Senfant->drawWithTexture();
			}
			else
			{
				Senfant->draw();
			}
		}
		else if (nomClasse == "class Modele3D")
		{
			Form *Mparent = (*it2);
			Modele3D *Menfant = (dynamic_cast<Modele3D *>(Mparent));
			Menfant->draw();
		}
		else
			cout << "Mauvais typage sur Forme";
	}
}