예제 #1
0
파일: ViewWindow.cpp 프로젝트: cpzhang/zen
void renderAxisXYZ()
{
	//光照默认打开
	getRenderContex()->getDxDevice()->SetRenderState(D3DRS_LIGHTING, FALSE);
	getRenderContex()->SetTransform(D3DTS_WORLD, &Matrix::Identity);
	getRenderContex()->applyViewMatrix();
	getRenderContex()->applyProjectionMatrix();
	getRenderContex()->setVertexDeclaration(sVDT_PositionColor::getType());
	//x
	renderAxis(Colour::Red, Vector3::AxisX);
	//y
	Matrix m;
	Quaternion q;
	q.fromAngleAxis(HalfPI, Vector3::AxisZ);
	m.make(Vector3::Zero, Vector3::One, q);
	getRenderContex()->SetTransform(D3DTS_WORLD, &m);
	renderAxis(Colour::Green, Vector3::AxisX);
	//z
	q.fromAngleAxis(-HalfPI, Vector3::AxisY);
	m.make(Vector3::Zero, Vector3::One, q);
	getRenderContex()->SetTransform(D3DTS_WORLD, &m);
	renderAxis(Colour::Blue, Vector3::AxisX);
	//
	getRenderContex()->SetTransform(D3DTS_WORLD, &Matrix::Identity);
}
예제 #2
0
void
ScaleTool::render()
{
    if ( m_active ) {

        if ( !hasVBO() ) buildVBO();

        glPushAttrib( GL_DEPTH_BUFFER_BIT );
        glDisable( GL_DEPTH_TEST );
        glPushAttrib( GL_LIGHTING_BIT );
        glDisable( GL_LIGHTING );
        glPushAttrib( GL_COLOR_BUFFER_BIT );
        glEnable( GL_BLEND );
        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
        glEnable( GL_LINE_SMOOTH );
        glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
        for ( unsigned int i = 0; i < 3; ++i ) {
            glColor3fv( getAxialColor((i==m_axisSelection)?3:i).data );
            renderAxis( i );
        }
        glColor3fv( getAxialColor(3).data );
        renderCenter();
        glPopAttrib();
        glPopAttrib();
        glPopAttrib();
    }
}
예제 #3
0
파일: Axis3d.cpp 프로젝트: gitrider/wxsj2
    void
    AxisRenderable::_updateRenderQueue(Ogre::RenderQueue* queue)
    {   
        renderAxis();
        renderAxisText();

		queue->addRenderable( this, Ogre::RENDER_QUEUE_OVERLAY, 500); 
    }
예제 #4
0
//--------------------------------------------------------------------------------------------------
/// Set up camera/viewport and render
//--------------------------------------------------------------------------------------------------
void OverlayNavigationCube::render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software, const Mat4d& viewMatrix)
{
    if (size.x() <= 0 || size.y() <= 0)
    {
        return;
    }

    if (m_axis.isNull()) 
    {
        createAxisGeometry(software);
    }

    if (m_cubeGeos.size() == 0)
    {
        createCubeGeos();

        // Create the shader for the cube geometry
        ShaderProgramGenerator gen("CubeGeoShader", ShaderSourceProvider::instance());
        gen.configureStandardHeadlightColor();
        m_cubeGeoShader = gen.generate();
        m_cubeGeoShader->linkProgram(oglContext);
    }

    // Position the camera far enough away to make the axis and the text fit within the viewport
    Mat4d axisMatrix = viewMatrix;
    axisMatrix.setTranslation(Vec3d(0, 0, -2.0));

    // Setup camera
    Camera cam;
    cam.setProjectionAsPerspective(40.0, 0.05, 100.0);
    cam.setViewMatrix(axisMatrix);
    cam.setViewport(position.x(), position.y(), size.x(), size.y());

    // Setup viewport
    cam.viewport()->applyOpenGL(oglContext, Viewport::CLEAR_DEPTH);
    cam.applyOpenGL();


    // Do the actual rendering
    // -----------------------------------------------
    MatrixState matrixState(cam);
    if (software)
    {
        renderAxisImmediateMode(oglContext, matrixState);
    }
    else
    {
        renderAxis(oglContext, matrixState);
    }

    renderCubeGeos(oglContext, software, matrixState);

    renderAxisLabels(oglContext, software, matrixState);
}
예제 #5
0
 void Compass::renderAxisOutline(RenderContext& renderContext, const Mat4x4f& transformation, const Color& color) {
     glAssert(glDepthMask(GL_FALSE));
     glAssert(glLineWidth(3.0f));
     glAssert(glPolygonMode(GL_FRONT, GL_LINE));
     
     ActiveShader shader(renderContext.shaderManager(), Shaders::CompassOutlineShader);
     shader.set("Color", color);
     renderAxis(renderContext, transformation);
     
     glAssert(glDepthMask(GL_TRUE));
     glAssert(glLineWidth(1.0f));
     glAssert(glPolygonMode(GL_FRONT, GL_FILL));
 }
예제 #6
0
 void Compass::renderSolidAxis(RenderContext& renderContext, const Mat4x4f& transformation, const Color& color) {
     ActiveShader shader(renderContext.shaderManager(), Shaders::CompassShader);
     shader.set("CameraPosition", Vec3f(0.0f, 500.0f, 0.0f));
     shader.set("LightDirection", Vec3f(0.0f, 0.5f, 1.0f).normalized());
     shader.set("LightDiffuse", Color(1.0f, 1.0f, 1.0f, 1.0f));
     shader.set("LightSpecular", Color(0.3f, 0.3f, 0.3f, 1.0f));
     shader.set("GlobalAmbient", Color(0.2f, 0.2f, 0.2f, 1.0f));
     shader.set("MaterialShininess", 32.0f);
     
     shader.set("MaterialDiffuse", color);
     shader.set("MaterialAmbient", color);
     shader.set("MaterialSpecular", color);
     
     renderAxis(renderContext, transformation);
 }
예제 #7
0
unsigned int
ScaleTool::getAxisPick() const
{
    unsigned int pick = Picker::NO_PICK;
    if ( m_active ) {
        m_panel->m_viewport->loadPickMatrices( UserInput::mousePos(), 1.f );
        Picker picker( 4 );
        for ( unsigned int i = 0; i < 3; ++i ) {
            picker.setObjectIndex( i );
            renderAxis( i );
        }
        picker.setObjectIndex( 3 );
        renderCenter();
        pick = picker.getPick();
        m_panel->m_viewport->popMatrices();
    }
    return pick;
}
예제 #8
0
void draw() {
  int i, j;
  IplImage* frame;
  char c;
  float pose[16];

  videoLoop();
  
  // Initialize OpenGL camera
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  // Load projection matrix
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glFrustum(0, 1, -1, 0, 1, 10);

  // Construct model pose matrix
  for (i = 0; i < 16; i += 1) {
    pose[i] = 0;
  }
  if (headPose->status == TRACKING) {
    for (i = 0; i < 3; i += 1) {
      for (j = 0; j < 3; j += 1) {
        pose[i + j*4] = headPose->rotationMatrix[j + i*3];
      }
    }
    pose[12] = headPose->translationVector[0];
    pose[13] = headPose->translationVector[1];
    pose[14] = headPose->translationVector[2];
    pose[15] = 1.0;
  }
  
  // Draw head pose
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();  
  gluLookAt(0,0,0, 0,0,+1, 0,-2,0);
  glMultMatrixf(pose);
  renderAxis(1);
  
  glutSwapBuffers();
}
예제 #9
0
        void RotateHandle::render(Model::RotateHandleHit* hit, Renderer::Vbo& vbo, Renderer::RenderContext& renderContext, float angle) {
            Preferences::PreferenceManager& prefs = Preferences::PreferenceManager::preferences();
            const float distance = renderContext.camera().distanceTo(position());
            const float factor = prefs.getFloat(Preferences::HandleScalingFactor) * distance;

            const Mat4f matrix = translationMatrix(position()) * scalingMatrix(factor);
            Renderer::ApplyModelMatrix applyTranslation(renderContext.transformation(), matrix);

            glDisable(GL_DEPTH_TEST);
            glDisable(GL_CULL_FACE);
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

            Renderer::SetVboState activateVbo(vbo, Renderer::Vbo::VboActive);
            if (hit != NULL) {
                renderAxis(hit, vbo, renderContext);
                renderRing(hit, vbo, renderContext, angle);
            } else {
                Vec3f xAxis, yAxis, zAxis;
                axes(renderContext.camera().position(), xAxis, yAxis, zAxis);

                Renderer::ActivateShader coloredShader(renderContext.shaderManager(), Renderer::Shaders::ColoredHandleShader);

                Renderer::AxisFigure axisFigure(m_axisLength);
                axisFigure.setAxes(true, true, true);
                axisFigure.setXColor(prefs.getColor(Preferences::XColor));
                axisFigure.setYColor(prefs.getColor(Preferences::YColor));
                axisFigure.setZColor(prefs.getColor(Preferences::ZColor));
                axisFigure.render(vbo, renderContext);

                Renderer::ActivateShader shader(renderContext.shaderManager(), Renderer::Shaders::HandleShader);
                shader.setUniformVariable("Color", Color(1.0f, 1.0f, 1.0f, 0.25f));

                Renderer::RingFigure(Axis::AX, yAxis, zAxis, m_ringRadius, m_ringThickness, 8).render(vbo, renderContext);
                Renderer::RingFigure(Axis::AY, xAxis, zAxis, m_ringRadius, m_ringThickness, 8).render(vbo, renderContext);
                Renderer::RingFigure(Axis::AZ, xAxis, yAxis, m_ringRadius, m_ringThickness, 8).render(vbo, renderContext);
            }

            glEnable(GL_CULL_FACE);
            glEnable(GL_DEPTH_TEST);
        }
예제 #10
0
/*
	render():
	Renders the Game
*/
void GAME::render()
{
	/* Render each viewport */
	for (int i=0; i<_playerCount; i++)
		render(_players[i]);

	/* Disable Lighting */
	glDisable(GL_LIGHTING);


	/* Render Game World Axis */
	glDisable(GL_DEPTH_TEST);
	if (_displayAxis)
		renderAxis(50, 10, 50);
	glEnable(GL_DEPTH_TEST);





	/* Font Rendering */
	int x = 0;
	int y = 18;
	int w = glutGet(GLUT_WINDOW_WIDTH);
	int h = glutGet(GLUT_WINDOW_HEIGHT);

	/* Set Viewport */
	glViewport(0, 0, w, h);

	/* Push Matrices */
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glOrtho(0, w, h, 0, -1, 1);

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();


	/* Disable Depth Tests */
	glDisable(GL_DEPTH_TEST);
	


	glTranslatef(0.0f, 0.0f, -1.0f );

	glColor3f(1.0f, 1.0f, 1.0f); 
	

	char s[80];

	sprintf(s, "FPS: %d", _fps);
	renderText(s, x, y);

	/* Re-enable Depth Tests */
	glEnable(GL_DEPTH_TEST);

	/* Pop Matrices */
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();

	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
}