mercredi 23 septembre 2020

Can't I call rand() multy times in a line?

for (int i = 0; i < 12; i++) {
        Vertex v;
        v.pos = (glm::vec3)((GLfloat)(rand() % 100) / 50 - 1, (GLfloat)(rand() % 100) / 50 - 1, (GLfloat)(rand() % 100) / 50 - 1);
        v.col = (glm::vec3)((GLfloat)(rand() % 100) / 100, (GLfloat)(rand() % 100) / 100, (GLfloat)(rand() % 100) / 100);
        tri4.objData.vertices.push_back(v);
        std::cout << tri4.objData.vertices.at(i).pos.x <<"\t" <<i4.objData.vertices.at(i).pos.y<<"\t"<< tri4.objData.vertices.at(i).pos.z << "\n\n";
        std::cout << tri4.objData.vertices.at(i).col.x << "\t" << tri4.objData.vertices.at(i).col.y << "\t" << tri4.objData.vertices.at(i).col.z << "\n\n";

        tri4.objData.indices.push_back(i);
        std::cout << tri4.objData.indices.at(i) << '\n';
    }

this is my GL codes in tihis case, pos.x and pos.y are same.. those three rand()s are return same at 'v.pos=' line or 'v.col=' line.. I did't use srand(time) or something. does rand()s return same values on one line? or vec3 has problem with it?




Aucun commentaire:

Enregistrer un commentaire