gl::Color, getting batch transformations to work


#1

I’m having trouble getting at least color transformation to work.

for (int x = 0; x < xdim; ++x) {
	for (int y = 0; y < ydim; ++y) {
		for (int z = 0; z < zdim; ++z) {
			gl::ScopedModelMatrix scpModelMtx;
			int point = x*zdim*ydim + y * zdim + z;
			gl::color(ColorA(CM_HSV, float(status[point]) / 2.0, 1, 1,0.5));
			mSlices[point]->draw();
		}
	}
}

I produced the cubes on setup with the following code:

auto lambert = gl::ShaderDef().lambert().color();
gl::GlslProgRef	shader = gl::getStockShader(lambert);
for (int x = 0; x < xdim; ++x) {
	for (int y = 0; y < ydim; ++y) {
		for (int z = 0; z < zdim; ++z) {
			auto slice = geom::Cube().size(0.9, 0.9, 0.9);
			auto trans = geom::Translate(x, y, z);
			auto color = geom::Constant(geom::COLOR,
				ColorA(CM_HSV, 0.5, 1, 1,0.5));
			int point = x*y*z% ydim*zdim + y*z% zdim + z;
			point = x*zdim*ydim + y*zdim + z;
			mSlices[point ] = gl::Batch::create(slice >> trans >> color, shader);
		}
	}
}
mCam.lookAt(vec3(20, 20, 20), vec3(0, 0, 0));

Thanks!


#2

Can you describe what you expected to happen and what happened instead?


#3

I fixed it by removing

auto color = geom::Constant(geom::COLOR, ColorA(CM_HSV, 0.5, 1, 1,0.5));

cinder1
became
image