示例#1
0
    MyWindow()
	:	nav(Vec3d(0,0,-2), 0.8)
	{
		lens.fovy(90);	// set field of view angle
		
		add(new StandardWindowKeyControls);
		add(new NavInputControl(nav));

		// create some shapes to draw
		shapes.primitive(gl.TRIANGLES);
		
		for(int j=0; j<1000; ++j){
			int Nv = addCube(shapes);

			Mat4f xfm;
			xfm.setIdentity();
			xfm.scale(rnd::uniform(2.,0.2));
			xfm.translate(Vec3f(rnd::uniformS(20.), rnd::uniformS(20.), rnd::uniformS(20.)));
			shapes.transform(xfm, shapes.vertices().size()-Nv);

			for(int i=0; i<Nv; ++i){
				float v = float(i)/Nv;
				shapes.color(HSV(0.2*v, 1-v*0.5, 1));
			}
		}
	}
示例#2
0
int main(){

	for(int i=0; i<800; ++i){
		int Nv = rnd::prob(0.5)
					? (rnd::prob(0.5) ? addCube(shapes) : addDodecahedron(shapes))
					: addIcosahedron(shapes);
		
		Mat4f xfm;
		xfm.setIdentity();
		xfm.scale(Vec3f(rnd::uniform(1.,0.1), rnd::uniform(1.,0.1), rnd::uniform(1.,0.1)));
		xfm.translate(Vec3f(rnd::uniformS(8.), rnd::uniformS(8.), rnd::uniformS(8.)));
		//xfm.rotate(rnd::uniform(), rnd::uniform(), rnd::uniform());
		
		shapes.transform(xfm, shapes.vertices().size()-Nv);

		for(int i=0; i<Nv; ++i){
			float f = float(i)/Nv;
			shapes.color(HSV(f*0.1+0.2,1,1));
		}
	}

	shapes.primitive(Graphics::TRIANGLES);
	shapes.decompress();
	shapes.generateNormals();


	win1.add(new StandardWindowKeyControls);

	win1.create(Window::Dim(800, 600));

	MainLoop::start();
	return 0;
}
示例#3
0
void ModelTransformation::translate(const Vec3f &translation, GLdouble dt)
{
  Mat4f* val = (Mat4f*)modelMat_->clientDataPtr();
  val->translate(translation);
  modelMat_->nextStamp();
  updateVelocity(dt);
  if(isAudioSource()) { updateAudioSource(); }
}
        void PointHandleHighlightFigure::render(Vbo& vbo, RenderContext& context) {
            float factor = context.camera().distanceTo(m_position) * m_scalingFactor;
            
            Mat4f billboardMatrix = context.camera().billboardMatrix();
            Mat4f matrix = Mat4f::Identity;
            matrix.translate(m_position);
            matrix *= billboardMatrix;
            matrix.scale(Vec3f(factor, factor, 0.0f));
            ApplyMatrix applyBillboard(context.transformation(), matrix);

            ActivateShader shader(context.shaderManager(), Shaders::HandleShader);
            shader.currentShader().setUniformVariable("Color", m_color);
            
            CircleFigure circle(Axis::AZ, 0.0f, 2.0f * Math::Pi, 2.0f * m_radius, 16, false);
            circle.render(vbo, context);
        }