コード例 #1
0
ファイル: Flake.cpp プロジェクト: OpenWerkplek/VirtualAwesome
Flake::Flake( Storm* storm ) {
	_storm = storm;

    _trail = new va::VertexShape();
    _trail->setMode(GL_TRIANGLE_STRIP);
    addChild(_trail);
    
    setPosition(va::random(600,700), va::random(600,700),0);    
    _loc = getPosition();
    _vel.set(va::random(0.001,0.01), va::random(0.001,0.01),0);    
	
    // adding 40 vertices
	for (unsigned int i=0; i<20; ++i) {
        _trail->addVertex(i, 0, 0);
        _trail->addVertex(i, 10, 0);
    }

    // adding 40 vertex colors
	for (unsigned int i=0; i<20; ++i) {
        _trail->addVertexColor(0, 0, 0, 1-(i/20.0f));
        _trail->addVertexColor(0, 0, 0, 1-(i/20.0f));
    }
        
    disableDepthTest();
    disableLighting();
    enableBlending();
    
    _maxvelocity = 10.0;
    _maxsteer = 3.0;
    _r = 10;
}
コード例 #2
0
ファイル: open_gl.cpp プロジェクト: Leopardob/como
void OpenGL::setShadingMode( ShadingMode shadingMode )
{
    LOCK

    currentShadingMode_ = shadingMode;

    switch( shadingMode ){
        case ShadingMode::SOLID_LIGHTING_AND_TEXTURING:
            setProgram( ShaderProgramType::DEFAULT );
            enableLighting();
            enableTexturing();
        break;
        case ShadingMode::SOLID_LIGHTING:
            setProgram( ShaderProgramType::DEFAULT );
            enableLighting();
            disableTexturing();
        break;
        case ShadingMode::SOLID_PLAIN:
            setProgram( ShaderProgramType::DEFAULT );
            disableLighting();
            disableTexturing();
        break;
        case ShadingMode::NORMALS:
            setProgram( ShaderProgramType::NORMALS );
        break;
    }
}
コード例 #3
0
void BlendShapeViewer::paintGL() {
	makeCurrent();

	glClearColor(1, 1, 1, 0);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glEnable(GL_DEPTH_TEST);
	glDepthMask(GL_TRUE);

	glEnable(GL_CULL_FACE);
	glCullFace(GL_BACK);
	glPushMatrix();
	
	// setup the viewing matrices
	setupViewingParameters();
	
	enableLighting();

	glColor4f(0, 0.5, 1.0, 1.0);
	mesh.draw();
	//drawGenreatedMesh();

	glColor4f(0, 0, 0, 0.25);
	targetMesh.drawFrame();

	if( showLandmarks )
		drawLandmarks();

	disableLighting();

	//drawMeshToFBO();

	glPopMatrix();
	glDisable(GL_CULL_FACE);
}
コード例 #4
0
ファイル: main.cpp プロジェクト: AlexBeach/CGG
//------------------------------------------------------------------------------------------------------------------------------------
// called when we want to draw the 3D data in our app.
//------------------------------------------------------------------------------------------------------------------------------------
void draw3D()
{
	// draw the grid on the floor
	setColour(0.25f, 0.25f, 0.25f);
	for(float i = -10.0f; i <= 10.1f; i += 1.0f)
	{
		Vec3 zmin(i, 0, -10);
		Vec3 zmax(i, 0,  10);
		Vec3 xmin(-10, 0, i);
		Vec3 xmax(10, 0, i);
		drawLine(xmin, xmax);
		drawLine(zmin, zmax);
	}

	// If using the GPU to compute the lighting (which is what you want to do!)
	if(!g_manualLighting)
	{
		// turn on lighting
		enableLighting();

		// set the diffuse material colour (this will be modulated by the effect of the lighting)
		setColour(1.0f, 1.0f, 1.0f);

		// draw the cube geometry
		drawPrimitives(g_pointsVN, 24, kQuads);

		// turn off lighting
		disableLighting();
	}
	else
	{
		// otherwise, compute the lighting manually. Don't ever do this in practice! It's insane! (But it may be useful for educational purposes)

		// The direction from the vertex to the light (effectively sunlight in this case!).
		Vec3 L(-0.6f, 1.0f, -0.2f);

		// make sure L has been normalised!
		L = normalize(L);

		// start drawing some quads
		begin(kQuads);

		// loop through each vertex normal
		for(int i = 0; i < 24; ++i)
		{
			// compute N.L
			// Make sure we clamp this to zero (so that we ignore any negative values).
			float N_dot_L = std::max(dot(L, g_pointsVN[i].n), 0.0f);

			// the ambient material colour (always gets added to the final colour)
			Vec3 Ka(0.2f, 0.2f, 0.2f);

			// the diffuse material colour
			Vec3 Kd(1.0f, 1.0f, 1.0f);

			// Compute the final colour
			Vec3 colour = Ka + (Kd * N_dot_L);

			// set the vertex colour 
			setColour(colour);

			// specify the vertex
			addVertex(g_pointsVN[i].v);
		}

		// finish drawing our quads
		end();
	}

	// if we are displaying normals
	if(g_displayNormals)
	{
		// make colour pink
		setColour(1.0f, 0.0f, 1.0f);

		// loop through each vertex
		for(int i = 0; i < 24; ++i)
		{
			// compute an offset (along the normal direction) from the vertex
			Vec3 pn = g_pointsVN[i].v + (g_pointsVN[i].n * 0.2f);

			// draw a line to show the normal
			drawLine(g_pointsVN[i].v, pn);
		}
	}
}