Exemple #1
0
void Scene3D::drawGeometry(void) const
{
    if(origin)
        drawOrigin();
    for(int i = 0; i < objects.size(); ++i)
        objects[i]->draw();
}
Exemple #2
0
 void line_test()
 {
     alpha=0;
     beta=0;
     float phase_shift=0.0f;
     while (!glfwWindowShouldClose(window))
     {
         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
         glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
         
         glMatrixMode(GL_MODELVIEW);
         glLoadIdentity();
         glTranslatef(0.0, 0.0, -2.0);
         // rotate by beta degrees around the x-axis
         glRotatef(beta, 1.0, 0.0, 0.0);
         // rotate by alpha degrees around the z-axis
         glRotatef(alpha, 0.0, 0.0, 1.0);
         
         drawOrigin();
         
         //gaussianDemo(sigma);
         phase_shift+=0.01f;
         linePlot(phase_shift);
         glfwSwapBuffers(window);
         glfwPollEvents();
     }	
 }
Exemple #3
0
void draw()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );	//Efface le frame buffer et le Z-buffer
    glMatrixMode(GL_MODELVIEW);	//Choisit la matrice MODELVIEW
    glLoadIdentity();	//Réinitialise la matrice
    lookAt(character->getPos(),character->getDir(),character->getUp());

    drawRoom();
    drawOrigin();
    drawScreenSurface();
    drawMouse();

    glutSwapBuffers();
    glutPostRedisplay();

}
void QuaternionDemo::render() 
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    // (AB)-1 === B-1 A-1
    glm::mat4 inverseViewMatrix = glm::translate(glm::mat4(1.0f), -viewTrans) *
        viewRot.inverse().toRotMatrix();
    glm::mat4 projectionMatrix = glm::perspective(70.0f, 1024.0f/768.0f, 0.1f, 100.0f);
    glm::mat4 mvp = projectionMatrix * inverseViewMatrix;

    simpleShader.Use();
    glUniformMatrix4fv(simpleShader["mvp"], 1, GL_FALSE,  glm::value_ptr(mvp));

    
    drawVectors();
    drawOrigin();

    simpleShader.UnUse();
    
    SDL_GL_SwapWindow(mainWindow);
}
Exemple #5
0
GridElement::GridElement( const hydroqguielementutil::GuiElementInfo &guiElementInfo,
                          double                                      wireGridSpacing,
                          double                                      groundPlaneSquareSpacing )
    : GuiElement3d(guiElementInfo),
      wireGridSpacing_(wireGridSpacing),
      groundPlaneSquareSpacing_(groundPlaneSquareSpacing)
{
    root_ = new osg::Group();

    drawGroundPlane();    
    root_->addChild( groundPlaneGeode_.get() );
    
    drawOrigin();
    root_->addChild( originGeode_.get() );

    viewOffset_ = new osg::PositionAttitudeTransform();
    root_->addChild( viewOffset_.get() );

    drawWireGrid();
    viewOffset_->addChild( wireGridGeode_.get() );

//    drawLabels();
}
Exemple #6
0
 void gaussianDemo(){
     //construct a 1000x1000 grid
     float sigma = 0.1f;
     float sign = 1.0f;
     float step_size = 0.005f;
     
     const int grid_x = 400;
     const int grid_y = 400;
     const int num_points = grid_x*grid_y;
     Data *data=(Data*)malloc(sizeof(Data)*num_points);
     int data_counter=0;
     
     while (!glfwWindowShouldClose(window))
     {
         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
         glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
         
         glMatrixMode(GL_MODELVIEW);
         glLoadIdentity();
         glTranslatef(0.0, 0.0, -2.0);
         // rotate by beta degrees around the x-axis
         glRotatef(beta, 1.0, 0.0, 0.0);
         // rotate by alpha degrees around the z-axis
         glRotatef(alpha, 0.0, 0.0, 1.0);
         
         drawOrigin();
         sigma=sigma+sign*step_size;
         //standard deviation
         float sigma2=sigma*sigma;
         //amplitude
         float sigma_const = 10.0f*(sigma2*2.0f*(float)M_PI);
         
         if(sigma>1.0f){
             sign = -1.0f;
         }
         if(sigma<0.1){
             sign = 1.0f;
         }
         data_counter=0;
         for(float x = -grid_x/2.0f; x<grid_x/2.0f; x+=1.0f){
             for(float y = -grid_y/2.0f; y<grid_y/2.0f; y+=1.0f){
                 float x_data = 2.0f*x/grid_x;
                 float y_data = 2.0f*y/grid_y;
                 //compute the height z based on a
                 //2D Gaussian function.
                 float z_data = exp(-0.5f*(x_data*x_data)/(sigma2)
                                    -0.5f*(y_data*y_data)/(sigma2))/sigma_const;
                 data[data_counter].x = x_data;
                 data[data_counter].y = y_data;
                 data[data_counter].z = z_data;
                 data_counter++;
             } }
         //visualize the result using a 2D heat map
         draw2DHeatMap(data, num_points);
         
         //gaussianDemo(sigma);
         glfwSwapBuffers(window);
         glfwPollEvents();
     }
     
     //free(data);
 }