Exemplo n.º 1
0
    void Render(double time)
    {
        gl.Clear().ColorBuffer().DepthBuffer();
        //
        // set the matrix for camera orbiting the origin
        camera_matrix.Set(
            CamMatrixf::LookingAt(
                cam_path.Position(time / 9.0),
                tgt_path.Position(time / 7.0)
            )
        );

        // draw the points
        gl.DrawArrays(PrimitiveType::Points, 0, node_count * 3);
        // draw the edges
        gl.DrawElements(
            PrimitiveType::Lines,
            edge_count,
            DataType::UnsignedInt
        );
    }
Exemplo n.º 2
0
	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		// set the matrix for camera orbiting the origin
		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(0.0f, 0.5f, 0.0f),
				6.5,
				Degrees(time * 35),
				Degrees(55 - SineWave(time / 20.0) * 30)
			)
		);
		light_pos.Set(light_path.Position(time / 10.0));

		plane.Bind();
		plane_instr.Draw(plane_indices);
	}
Exemplo n.º 3
0
	// Spawns a new particle if the time is right
	bool SpawnParticle(
		double time,
		Vec3f& position,
		Vec3f& direction,
		float& age
	)
	{
		float new_age = time - spawn_time - spawn_interval;
		if(new_age >= 0.0f)
		{
			spawn_time += spawn_interval;
			direction = NewDirection();
			Vec3f emitter_pos = path.Position(spawn_time/cycle_time);
			position = emitter_pos + direction;
			age = new_age;
			return true;
		}
		return false;
	}
Exemplo n.º 4
0
    void Render(double time)
    {
        gl.Clear().ColorBuffer().DepthBuffer();

        auto lightPos = light_path.Position(time * 0.05);
        auto cameraMatrix = CamMatrixf::Orbiting(
                                Vec3f(),
                                4.5f,
                                Degrees(0),
                                Degrees(SineWave(time / 20.0) * 80)
                            );

        light.Bind();
        light_prog.Use();

        Uniform<Vec3f>(light_prog, "LightPos").Set(lightPos);
        Uniform<Mat4f>(light_prog, "CameraMatrix").Set(cameraMatrix);

        sphere_instr.Draw(sphere_indices);

        clouds.Bind();
        cloud_prog.Use();

        Uniform<Vec3f>(cloud_prog, "LightPos").Set(lightPos);
        Uniform<Mat4f>(cloud_prog, "CameraMatrix").Set(cameraMatrix);
        Uniform<Vec4f>(cloud_prog, "ViewX").Set(cameraMatrix.Row(0));
        Uniform<Vec4f>(cloud_prog, "ViewY").Set(cameraMatrix.Row(1));
        Uniform<Vec4f>(cloud_prog, "ViewZ").Set(cameraMatrix.Row(2));
        for(std::size_t i=0, n=positions.size(); i!=n; ++i)
        {
            cloud_tex[i].Bind(Texture::Target::_3D);
            gl.DrawArraysInstanced(
                PrimitiveType::Points,
                i, 1,
                samples
            );
        }
    }