示例#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;
}