void hypnomixDraw(struct hypnomix *hyp) { glEnable(GL_DEPTH_TEST); glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); hyp->lights.nb = 1; vec3Set(hyp->lights.pos[0], 0.0, 0.0, 1.0); vec3Set(hyp->lights.dir[0], 0.0, 0.0, -1.0); vec3Set(hyp->lights.clr[0], 1.0, 1.0, 1.0); vec3Set(hyp->lights.ambient, 0.25, 0.25, 0.25); hyp->lights.shininess = 2.0; hyp->lights.strength = 0.6; glUseProgram(hyp->pg.id); glUniform3fv(hyp->pg.lightpos, hyp->lights.nb, hyp->lights.pos[0]); glUniform3fv(hyp->pg.lightdir, hyp->lights.nb, hyp->lights.dir[0]); glUniform3fv(hyp->pg.lightclr, hyp->lights.nb, hyp->lights.clr[0]); glUniform1i(hyp->pg.nblights, hyp->lights.nb); glUniform3fv(hyp->pg.ambient, 1, hyp->lights.ambient); glUniform1f(hyp->pg.strength, hyp->lights.strength); glUniform1f(hyp->pg.shininess, hyp->lights.shininess); if(hyp->mod != NULL) { (*(hyp->mod->draw))(hyp); } glDisable(GL_DEPTH_TEST); }
void Cross3(vec3_t vOut, const vec3_t a, const vec3_t b) { vec3Set(vOut, (a[1] * b[2]) - (a[2] * b[1]), (a[2] * b[0]) - (a[0] * b[2]), (a[0] * b[1]) - (a[1] * b[0])); }
void gGlVertex3f(float x, float y, float z) { if (vertexCount > kVertexCount) return; vec3Set(vertex.xyz, x, y, z); vertices[vertexCount] = vertex; vertexCount++; }
//=========================================================================== model* Scene::addModel(vec3* position, int vertexIndex, int vertexCount, int polyIndex, int polyCount) { manta_assert(modelCount < MAX_SCENE_MODELS, "Error, attempting to add too many Models!\n"); model* newModel = &sceneModels[modelCount++]; newModel->vertexIndex = vertexIndex; newModel->vertexCount = vertexCount; newModel->polyCount = polyCount; newModel->polyIndex = polyIndex; matrixIdent(&newModel->rotation); vec3 up, dir; vec3Set(&up, 1.f, 0.f, 0.f); vec3Set(&dir, 0.f, 0.f, 1.f); rotMatrixFromVec3(&newModel->rotation, &dir, &up); vec3Cpy(&newModel->position, position); return newModel; }
//=========================================================================== int Scene::addPolygon(int* inVerts) { manta_assert(polyCount < MAX_SCENE_POLYS, "Error, attempting to add too many Polygons!\n"); color3f white; vec3Set(&white, 1.f, 1.f, 1.f); vec3 edgeA, edgeB, normal; vec3* verts[3]; verts[0] = &sceneVertices[inVerts[0]]; verts[1] = &sceneVertices[inVerts[1]]; verts[2] = &sceneVertices[inVerts[2]]; vec3Sub(&edgeA, verts[0], verts[1]); vec3Sub(&edgeB, verts[0], verts[2]); vec3Cross(&normal, &edgeB, &edgeA); vec3Unit(&normal); scenePolygons[polyCount].pointIndex[0] = inVerts[0]; scenePolygons[polyCount].pointIndex[1] = inVerts[1]; scenePolygons[polyCount].pointIndex[2] = inVerts[2]; debugBuildPoly(&scenePolygons[polyCount++], verts[0], verts[1], verts[2], &normal, &white); return polyCount-1; }
void Normalize3(vec3_t vOut, const vec3_t vec) { float f; double temp; temp = (double)(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]); temp = 1.0 / sqrt(temp); f = (float)temp; vec3Set(vOut, vec[0] * f, vec[1] * f, vec[2] * f); }
static void add(struct particle_emitter *emit, struct pool *pool) { struct particle p; vec3Copy(emit->loc, p.loc); vec3Copy(emit->dir, p.dir); p.tex[0] = 0.0; p.tex[1] = 0.0; vec4Copy(emit->clr, p.clr); // vec4Set(p.clr, 1.0, 2.0, 3.0, 4.0); vec3Set(p.acc, 0.0, 0.0, 0.0); vec3Set(p.vel, 0.0, 0.0, 0.0); p.life = emit->life; p.mass = emit->mass; poolAdd(pool, &p); /* fprintf(stderr, "EMIT %d\n", pool->id); particlesDump(pool); */ }