void PointCloudApp::setupMesh()
{
	try
	{
		mShaderObj = gl::GlslProg::create(loadAsset("pointcloud_vert.glsl"), loadAsset("pointcloud_frag.glsl"));
	}
	catch (const gl::GlslProgExc &e)
	{
		console() << e.what() << endl;
	}

	mPoints.clear();
	for (int vy = 0; vy < mDepthDims.y; vy++)
	{
		for (int vx = 0; vx < mDepthDims.x; vx++)
		{
			mPoints.push_back(CloudPoint(vec3(0), vec2(0)));
		}
	}

	mBufferObj = gl::Vbo::create(GL_ARRAY_BUFFER, mPoints, GL_DYNAMIC_DRAW);
	mAttribObj.append(geom::POSITION, 3, sizeof(CloudPoint), offsetof(CloudPoint, PPosition));
	mAttribObj.append(geom::TEX_COORD_0, 2, sizeof(CloudPoint), offsetof(CloudPoint, PTexCoord));

	mMeshObj = gl::VboMesh::create(mPoints.size(), GL_POINTS, { { mAttribObj, mBufferObj } });
	mDrawObj = gl::Batch::create(mMeshObj, mShaderObj);

	mTexRgb = gl::Texture2d::create(mRgbDims.x, mRgbDims.y);
}
Esempio n. 2
0
void RandomSpawn::setupParticles()
{
    mPointsParticles.clear();
    mDataInstance_P = gl::Vbo::create(GL_ARRAY_BUFFER, mPointsParticles, GL_DYNAMIC_DRAW);
    mAttribsInstance_P.append(geom::CUSTOM_0, 16, sizeof(CloudParticle), offsetof(CloudParticle, PModelMatrix), 1);
    mAttribsInstance_P.append(geom::CUSTOM_1, 1, sizeof(CloudParticle), offsetof(CloudParticle, PSize), 1);
    mAttribsInstance_P.append(geom::CUSTOM_2, 4, sizeof(CloudParticle), offsetof(CloudParticle, PColor), 1);

    mMesh_P = gl::VboMesh::create(geom::Icosahedron());
    mMesh_P->appendVbo(mAttribsInstance_P, mDataInstance_P);

    mShader_P = gl::GlslProg::create(loadAsset("shaders/particle.vert"), loadAsset("shaders/particle.frag"));
    mBatch_P = gl::Batch::create(mMesh_P, mShader_P, { { geom::CUSTOM_0, "iModelMatrix" }, { geom::CUSTOM_1, "iSize" }, { geom::CUSTOM_2, "iColor" } });

    mPerlin = Perlin();
}