예제 #1
0
std::vector <glm::vec3> Mesh::getVertices(const std::string& data)
{
	IndexedModel model = OBJModel(data).ToIndexedModel();
	InitMesh(model);

	return model.positions;
}
예제 #2
0
파일: main.cpp 프로젝트: jogojapan/simul
 Mesh(const std::string &filename)
 {
     IndexedModel model = OBJModel(filename).ToIndexedModel();
     init_mesh(model);
 }
예제 #3
0
Mesh::Mesh(const std::string& fileName):
m_isSkybox(false)
{
	InitMesh(OBJModel(fileName).ToIndexedModel());
}
예제 #4
0
Mesh::Mesh(const std::string& fileName)
{
	IndexedModel model = OBJModel(fileName).ToIndexedModel();
	InitMesh(model);
}
예제 #5
0
Mesh::Mesh(const std::string& data)
{
	IndexedModel model = OBJModel(data).ToIndexedModel();
	InitMesh(model);
}
예제 #6
0
Mesh::Mesh(const std::string& fileName)
{
	InitMesh(OBJModel(fileName).ToIndexedModel());
}
예제 #7
0
Mesh::Mesh(std::vector <int> indices, std::vector <glm::vec3> points, glm::vec2 tpoint, std::vector <glm::vec3> tnormal, int faceamount)
{
	IndexedModel model = OBJModel(indices, points, tpoint, tnormal, faceamount).ToIndexedModel();
	InitMesh(model);
}
예제 #8
0
파일: mesh.cpp 프로젝트: e-dant/ogle-0-4-3
Mesh::Mesh(const std::string& fileName, int flag){
    InitTexMesh(OBJModel(fileName).ToIndexedModel());
}
예제 #9
0
파일: maya.cpp 프로젝트: rfstudios/3Dengine
Maya::Maya(const std::string& fileName)
{
    IndexedModel modelo = OBJModel(fileName).ToIndexedModel();
    InitMesh(modelo);

}
예제 #10
0
// Initialize all your OpenGL objects here
void MainWindow::initialize()
{
    // Initialize important variables and the MVP matrices
    mouseClick = QPoint(0,0);
    eye = QVector3D(0,0,-4);
    center = QVector3D(0,0,0) ;
    up = QVector3D(0,1,0);
    FoV = 60;
    model.setToIdentity();
    view.lookAt(eye, center, up);
    calculateProjection();

    qDebug() << "MainWindow::initialize()";
    QString glVersion;
    glVersion = reinterpret_cast<const char*>(glGetString(GL_VERSION));
    qDebug() << "Using OpenGL" << qPrintable(glVersion);

    // Initialize the shaders
    m_shaderProgram = new QOpenGLShaderProgram(this);
    // Use the ":" to load from the resources files (i.e. from the resources.qrc)
    m_shaderProgram->addShaderFromSourceFile(QOpenGLShader::Vertex, ":/shaders/vertex.glsl");
    m_shaderProgram->addShaderFromSourceFile(QOpenGLShader::Fragment, ":/shaders/fragment.glsl");
    m_shaderProgram->link();


    // Shaders are initialized
    // You can retrieve the locations of the uniforms from here


    // Initialize your objects and buffers
    QVector<QVector3D> objectVectors;
    QVector<QVector3D> generatedColors;

    OBJModel cube = OBJModel(":/models/cube.obj");

    objectVectors = cube.vertices;
    vectorsNumber = objectVectors.length();

    // Calculate the random colours using the color seed
    for(int i = 0; i < vectorsNumber/3; i++){
        float colorArray[3] = {0,0,0};
        for(unsigned int j = 0; j < 3; j++){
            srand(COLOR_SEED*(j+1)*(i+1));
            colorArray[j] = ((double)rand()/RAND_MAX);
        }
        printf("color %d, %f %f %f\n", i, colorArray[0],colorArray[1],colorArray[2] );
        generatedColors.append(QVector3D(colorArray[0], colorArray[1], colorArray[2]));
        generatedColors.append(QVector3D(colorArray[0], colorArray[1], colorArray[2]));
        generatedColors.append(QVector3D(colorArray[0], colorArray[1], colorArray[2]));
    }

    // generate VAO and bind it
    m_funcs->glGenVertexArrays(1, &VAO);
    m_funcs->glBindVertexArray(VAO);

    // generate color and vertice buffers
    m_funcs->glGenBuffers(1, &vertices);
    m_funcs->glGenBuffers(1, &colors);

    // bind vertice buffer and fill it with the vertices
    m_funcs->glBindBuffer(GL_ARRAY_BUFFER, vertices);
    m_funcs->glBufferData(GL_ARRAY_BUFFER, sizeof(QVector3D) * objectVectors.length(),objectVectors.data(), GL_STATIC_DRAW);

    m_funcs->glEnableVertexAttribArray(0);
    m_funcs->glVertexAttribPointer(0,3, GL_FLOAT, GL_FALSE, 0,0);

    // Bind color buffer, fill it with the generated colors
    m_funcs->glBindBuffer(GL_ARRAY_BUFFER, colors);
    m_funcs->glBufferData(GL_ARRAY_BUFFER, sizeof(QVector3D) * generatedColors.length(), generatedColors.data(), GL_STATIC_DRAW);

    m_funcs->glEnableVertexAttribArray(1);
    m_funcs->glVertexAttribPointer(1,3, GL_FLOAT, GL_FALSE, 0,0);

    // Create your Vertex Array Object (VAO) and Vertex Buffer Objects (VBO) here.



    // Set OpenGL to use Filled triangles (can be used to render points, or lines)
    m_funcs->glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );

    // Enable Z-buffering
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LESS);
    qDebug() << "Depth Buffer size:" <<  this->format().depthBufferSize() << "bits";

    // Function for culling, removing faces which don't face the camera
    //glEnable(GL_CULL_FACE);
    //glCullFace(GL_BACK);

    // Set the clear color to be black (color used for resetting the screen)
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
}
예제 #11
0
// Initialize all your OpenGL objects here
void MainWindow::initialize()
{
    rotate = false;
    qDebug() << "MainWindow::initialize()";
    QString glVersion;
    glVersion = reinterpret_cast<const char*>(glGetString(GL_VERSION));
    qDebug() << "Using OpenGL" << qPrintable(glVersion);

    // Initialize the shaders
    m_shaderProgram = new QOpenGLShaderProgram(this);
    // Use the ":" to load from the resources files (i.e. from the resources.qrc)
    m_shaderProgram->addShaderFromSourceFile(QOpenGLShader::Vertex, ":/shaders/vertex.glsl");
    m_shaderProgram->addShaderFromSourceFile(QOpenGLShader::Fragment, ":/shaders/fragment.glsl");
    m_shaderProgram->link();

    // Shaders are initialized
    // Initialize objects and buffers

    OBJModel sphere = OBJModel(":/models/sphere.obj");
    QVector<QVector3D> vertices = sphere.vertices;

    nVertices = vertices.length();

    QVector<QVector3D> normals = sphere.normals;

    QVector<QVector3D> colors;
    for (int i = 0; i < sphere.indices.length(); i += 3){
        QVector3D c = QVector3D((double) rand() / RAND_MAX, (double) rand() / RAND_MAX, (double) rand() / RAND_MAX);
        colors.append(c);
        colors.append(c);
        colors.append(c);
    }

    // Create your Vertex Array Object (VAO) and Vertex Buffer Objects (VBO) here.
    object.create();
    object.bind();
    
    coordinates = new QOpenGLBuffer(QOpenGLBuffer::VertexBuffer);
    coordinates->create();
    coordinates->bind();

    coordinates->allocate(vertices.data(), vertices.length() * sizeof(QVector3D));
	glVertexAttribPointer(0,3,GL_FLOAT,GL_FALSE,0,0);
	
    normal_buffer = new QOpenGLBuffer(QOpenGLBuffer::VertexBuffer);
    normal_buffer->create();
    normal_buffer->bind();
    
    normal_buffer->allocate(normals.data(), normals.length() * sizeof(QVector3D));
    glVertexAttribPointer(2,3,GL_FLOAT,GL_FALSE,0,0);

    m_shaderProgram->setUniformValue("normal", normal);
    
   // for (int index = 0; index < sphere.indices.length(); index++)
        glEnableVertexAttribArray(0);
        glEnableVertexAttribArray(2);
		
	object.release();

    // Set OpenGL to use Filled triangles (can be used to render points, or lines)
    glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );

    // Enable Z-buffering
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LESS);
    qDebug() << "Depth Buffer size:" <<  this->format().depthBufferSize() << "bits";

    // Set the clear color to be black (color used for resetting the screen)
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);



}
예제 #12
0
void MorphTargets::LoadAnimations(void)
{
    double time = glfwGetTime();

    static const char *folder = "Resources/Animations/";
    char currentIndex[256] = "";

    std::vector<OBJModel> idle;
    for (unsigned int i = 1; i <= 10; ++i)
    {
        char filePath[256] = "";

        //Load the file
        strcat_s(filePath, folder);
        strcat_s(filePath, "IdleAnimation/idle");
        _itoa_s(i, currentIndex, 10);
        strcat_s(filePath, currentIndex);
        strcat_s(filePath,".obj");

        idle.push_back(OBJModel(filePath, false));
    }

    animations.push_back(idle);

    std::vector<OBJModel> move;
    for (unsigned int i = 1; i <= 10; ++i)
    {
        char filePath[256] = "";

        //Load the file
        strcat_s(filePath, folder);
        strcat_s(filePath, "RunAnimation/run");
        _itoa_s(i, currentIndex, 10);
        strcat_s(filePath, currentIndex);
        strcat_s(filePath, ".obj");

        move.push_back(OBJModel(filePath, false));
    }

    animations.push_back(move);

    std::vector<OBJModel> punch;
    for (unsigned int i = 1; i <= 10; ++i)
    {
        char filePath[256] = "";

        //Load the file
        strcat_s(filePath, folder);
        strcat_s(filePath, "PunchAnimation/punch");
        _itoa_s(i, currentIndex, 10);
        strcat_s(filePath, currentIndex);
        strcat_s(filePath, ".obj");

        punch.push_back(OBJModel(filePath, false));
    }

    animations.push_back(punch);

    std::vector<OBJModel> block;
    for (unsigned int i = 1; i <= 10; ++i)
    {
        char filePath[256] = "";

        //Load the file
        strcat_s(filePath, folder);
        strcat_s(filePath, "BlockAnimation/block");
        _itoa_s(i, currentIndex, 10);
        strcat_s(filePath, currentIndex);
        strcat_s(filePath, ".obj");

        block.push_back(OBJModel(filePath, false));
    }

    animations.push_back(block);

    std::vector<OBJModel> stagger;
    for (unsigned int i = 1; i <= 10; ++i)
    {
        char filePath[256] = "";

        //Load the file
        strcat_s(filePath, folder);
        strcat_s(filePath, "StaggerAnimation/stagger");
        _itoa_s(i, currentIndex, 10);
        strcat_s(filePath, currentIndex);
        strcat_s(filePath, ".obj");

        stagger.push_back(OBJModel(filePath, false));
    }

    animations.push_back(stagger);

    std::vector<OBJModel> groundKick;
    for (unsigned int i = 1; i <= 10; ++i)
    {
        char filePath[256] = "";

        //Load the file
        strcat_s(filePath, folder);
        strcat_s(filePath, "GroundKickAnimation/groundkick");
        _itoa_s(i, currentIndex, 10);
        strcat_s(filePath, currentIndex);
        strcat_s(filePath, ".obj");

        groundKick.push_back(OBJModel(filePath, false));
    }

    animations.push_back(groundKick);

    std::vector<OBJModel> airKick;
    for (unsigned int i = 1; i <= 10; ++i)
    {
        char filePath[256] = "";

        //Load the file
        strcat_s(filePath, folder);
        strcat_s(filePath, "DiveKickAnimation/divekick");
        _itoa_s(i, currentIndex, 10);
        strcat_s(filePath, currentIndex);
        strcat_s(filePath, ".obj");

        airKick.push_back(OBJModel(filePath, false));
    }

    animations.push_back(airKick);
}