Пример #1
0
void ColorCubePoints::draw()
{
    // Unit cube with wireframe outline
    gl::enableAlphaBlending();
    gl::color(0.0f, 0.0f, 0.0f, 0.5f);
    gl::drawCube(Vec3f(0.5f, 0.5f, 0.5f), Vec3f(1.0f, 1.0f, 1.0f));
    gl::color(0.4f, 0.4f, 0.7f);
    gl::drawStrokedCube(Vec3f(0.5f, 0.5f, 0.5f), Vec3f(1.0f, 1.0f, 1.0f));

    // Scaled RGB color coordinate system    
    AxisAlignedBox3f range = getRangeRGB();
    gl::pushModelView();
    gl::scale(Vec3f(1.0f, 1.0f, 1.0f) / range.getSize());
    gl::translate(-range.getMin());

    // Point history
    gl::enableAdditiveBlending();
    glPointSize(3.0f);
    glBegin(GL_POINTS);
    for (unsigned i = 0; i < mPoints.size(); i++) {
        drawColorPoint(range, mPoints[i]);
    }
    glEnd();

    // Local coordinates for latest point
    Vec4f local = mLineSolver.worldToLocal * Vec4f(getCurrentPoint(), 1.0f);

    // Local coordinates for arbitrary endpoints on the Z axis
    Vec4f zMin(0.0f, 0.0f, range.getMin().z, 1.0f);
    Vec4f zMax(0.0f, 0.0f, range.getMax().z, 1.0f);

    // Convert to world coords and clamp to the AABB to keep the chart tidy
    Ray ray((mLineSolver.localToWorld * zMin).xyz(),
            (mLineSolver.localToWorld * (zMax - zMin)).xyz());
    float intersections[2];
    range.intersect(ray, intersections);

    // Draw a triangle between the Z axis and current point
    gl::color(1.0f, 1.0f, 1.0f);
    gl::drawLine(ray.calcPosition(intersections[0]),
                 ray.calcPosition(intersections[1]));
    gl::color(1.0f, 0.0f, 0.0f);
    gl::drawLine(ray.calcPosition(intersections[0]),
                 (mLineSolver.localToWorld * local).xyz());
    gl::color(0.0f, 1.0f, 0.0f);
    gl::drawLine(ray.calcPosition(intersections[1]),
                 (mLineSolver.localToWorld * local).xyz());

    gl::popModelView();
}
Пример #2
0
void MeshViewApp::setupCamera(bool inTheMiddleOfY)
{
	m_camera.setNearClip(0.1f);
	m_camera.setFarClip(10000.0f);
	AxisAlignedBox3f bbox = m_assimpLoader.getBoundingBox();
	Vec3f size = bbox.getSize();
	float max = size.x;
	max = max < size.y ? size.y : max;
	max = max < size.z ? size.z : max;

	if(inTheMiddleOfY)
	m_camera.setEyePoint(Vec3f(0.0f, size.y / 2, max * 2.0f));
	else
	m_camera.setEyePoint(Vec3f(0.0f, max, max * 2.0f));

	m_camera.setCenterOfInterestPoint(bbox.getCenter());
}
Пример #3
0
void ColorCubePoints::drawColorPoint(const AxisAlignedBox3f& range, Vec3f p)
{
    Vec3f scaled = (p - range.getMin()) / range.getSize();
    gl::color(scaled.x, scaled.y, scaled.z);
    gl::vertex(p);
}