bool Sphery03::Init() { scene = new Scene(); scene->addObject(genSphere(37, 2.f, "env03")); /* scene->addSpriteGroup(new SpriteGroup(scene->object[0]->nrVertices / 12, 0.03f, 0xcccccc, "sprite01")); for (int i = 0; i < scene->object[0]->nrVertices / 24; i++) { scene->spriteGroup[0]->sprite[i].diffuse = 0x505050; } */ oldObject = genSphere(37, 2.f, NULL); scene->object[0]->finish(true); scene->ambient = 0x202020; scene->addLight(new Light(1.3f, 1.3f, 1.3f, 1)); scene->object[0]->transMode = UNI_ADD; scene->object[0]->setDiffuse(0.8f, 0.8f, 0.8f); return true; }
DrawDebug::DrawDebug() { #if DEBUG auto vecShader = loadProgram("Shaders/_debug/vecvertexShader.glsl", "Shaders/_debug/vecfragmentShader.glsl"); auto meshShader = loadProgram("Shaders/_debug/meshvertexShader.glsl", "Shaders/_debug/meshfragmentShader.glsl"); arrow = loadOBJ("Assets/_debug/arrow.obj"); if (!arrow) { genCone("Assets/_debug/arrow.obj", 8); arrow = loadOBJ("Assets/_debug/arrow.obj"); } sphere = loadOBJ("Assets/_debug/sphere.obj"); if (!sphere) { genSphere("Assets/_debug/sphere.obj", 8); sphere = loadOBJ("Assets/_debug/sphere.obj"); } box = loadOBJ("Assets/_debug/cube.obj"); if (!box) { genCube("Assets/_debug/cube.obj"); box = loadOBJ("Assets/_debug/cube.obj"); } GLattrarr attrSetup; const auto vecSize = sizeof(GLfloat) * FLOATS_PER_VERT; vecVAO.create(); vecVAO.bind(); vecBuffer.create(GL_ARRAY_BUFFER, GL_STREAM_DRAW); vecBuffer.bind(); vecBuffer.data(vecSize * MAX_VECTORS * 4, nullptr); debugVectors.reserve(MAX_VECTORS * 4); attrSetup.add<vec3>(2); attrSetup.apply(); const auto mSetup = [](GLattrarr& attrSetup) { attrSetup.add<vec4>(1, 1); attrSetup.add<mat4>(1, 1); }; arrows = InstMesh<m_MeshData>(arrow.get(), MAX_VECTORS, 1, mSetup); spheres = InstMesh<m_MeshData>(sphere.get(), MAX_SPHERES, 1, mSetup); boxes = InstMesh<m_MeshData>(box.get(), MAX_BOXES, 1, mSetup); vecVAO.unbind(); vecCam = vecShader.getUniform<mat4>("cameraMatrix"); meshCam = meshShader.getUniform<mat4>("cameraMatrix"); vecMat.setShaders(vecShader); vecMat.setTextures(); meshMat.setShaders(meshShader); meshMat.setTextures(); #endif }
bool Sphery01::Init() { scene = new Scene(); scene->addObject(genSphere(26, 2.f, "sphery01")); scene->object[0]->shade = SHADE_ENVMAP; scene->object[0]->optimize(0); oldObject = genSphere(26, 2.f, NULL); scene->object[0]->finish(true); scene->ambient = 0x0; scene->addLight(new Light(1.3f, 1.3f, 1.3f, 1)); currentCam = 1; camTimer1 = 0; ShowLoader(1.0f); return true; }
float3 UnsyncedRNG::RandVector() { #ifdef USE_BOOST_RNG float3 ret(&genSphere()[0]); ret *= RandFloat(); #else float3 ret; do { ret.x = RandFloat() * 2 - 1; ret.y = RandFloat() * 2 - 1; ret.z = RandFloat() * 2 - 1; } while (ret.SqLength() > 1); #endif return ret; }
void Chunk::update() { if (shouldUpdate) { switch (m_genMethod) { case RANDOM: genRand(randBand(randEngine)); break; case SPHERE: genSphere(); break; case ALL: genAll(); break; default: Debug_Log(" ERROR? : genMethod = NONE"); break; } } shouldUpdate = false; }
bool Scape03::Init() { nrSegmentsX = 127; nrSegmentsZ = 127; left = -150; top = -150; right = 150; bottom = 150; scene = new Scene(); scene->addObject(genPlane(nrSegmentsX, 300, "vulcanfinal")); CreateShape(NULL, scene->object[0]->vertex, 4.f, 0.8f, 0); Vertex *vertex = scene->object[0]->vertex; // vulkaan creeeren in het midden for (int y = 0; y < nrSegmentsZ + 1; y++) { for (int x = 0; x < nrSegmentsX + 1; x++) { int index = (y * (nrSegmentsX + 1)) + x; float vx = vertex[index].x; float vy = vertex[index].y; float vz = vertex[index].z; float x = vx - 30.f; float z = vz + 25.f; float length = sqrt((x * x) + (z * z)); float amp = 40.f; if (length < 25.f) { if (length > 10) { vy += sin((25.f - length) * (_PI / 15.f)) * 10.f; } else { vy -= 20.f; } } vertex[index].x = vx; vertex[index].y = vy; vertex[index].z = vz; } } int width, height; // dword *grond1 = loadATSFromMem(ATS_GROUND2, width, height); // dword *grond2 = loadATSFromMem(ATS_GROUND1, width, height); // dword *grond1 = loadATSFromMem(ATS_VULCANGROUND1, width, height); // dword *grond2 = loadATSFromMem(ATS_VULCANGROUND2, width, height); // dword *grond3 = loadATSFromMem(ATS_GROUND3, width, height); // dword *grond4 = loadATSFromMem(ATS_WIT, width, height); dword *grond1 = extraTextures[5];//loadATSFromMem(ATS_VULCANGROUND1, width, height); dword *grond2 = extraTextures[4];//loadATSFromMem(ATS_VULCANGROUND2, width, height); dword *grond3 = extraTextures[0];//loadATSFromMem(ATS_GROUND3, width, height); dword *grond4 = extraTextures[3];//loadATSFromMem(ATS_WIT, width, height); dword *textureFinal = CreateTexture(1024, 1024, grond1, grond2, grond3, grond4, -6.f, 1.8f); uniTextureCreate("vulcanfinal", textureFinal, 1024, 1024, UNI_MIPMAP); // delete [] grond1; // delete [] grond2; // delete [] grond3; // delete [] grond4; scene->fog = true; scene->fogColor = 0x000000; scene->fogStart = 50; scene->fogEnd = 200;//150; scene->fogSprites = true; // scene->camera->farPlane = 220;//170; // scene->ambient = 0x202020; scene->ambient = 0x404040; scene->addLight(new Light(1, 1, 1, 1)); scene->addLight(new Light(0.1f, 0, 0, 1)); scene->light[1]->setLoc(PARTSTARTX, 60, PARTSTARTZ); scene->light[1]->setRange(80); #ifdef NRPARTS scene->addSpriteGroup(new SpriteGroup(NRPARTS, 0.7f, 0xffffffff, "vulcansprite")); for (int i = 0; i < NRPARTS; i++) { float t = rand()%360; float x = sin((t * _PI) / 180.f) * 200.f; float y = 0; float z = cos((t * _PI) / 180.f) * 200.f; parts[i].eindX = x; parts[i].eindY = y; parts[i].eindZ = z; parts[i].time = rand()%12000; parts[i].opzij = false; } #endif #ifdef SCAPE03_NRSMOKEPARTS scene->addSpriteGroup(new SmokeSys(SCAPE03_NRSMOKEPARTS, 15.7f, 0xcccccccc, 10, UniVector(PARTSTARTX, 20, PARTSTARTZ), "smoke01")); scene->addSpriteGroup(new SmokeSys(SCAPE03_NRFIREPARTS, 5.7f, 0xffffffff, 2.8f, UniVector(PARTSTARTX, 20, PARTSTARTZ), "vulcansprite")); #endif #ifdef DO_SPIKEY oldPlane = genPlane(nrSegmentsX, 300, "vulcanfinal"); for (i = 0; i < oldPlane->nrVertices; i++) { oldPlane->vertex[i] = scene->object[0]->vertex[i]; } scene->object[0]->finish(true); #endif currentCam = 1; camTimer1 = 0; camTimer2 = 0; camTimer3 = camTimer4 = camTimer5 = -999999; #ifdef VULCAN_SKY scene2 = new Scene(); scene2->addObject(genSphere(4, 2000.f, "vulcanback")); scene2->object[0]->cull = CULL_ACW; scene2->camera->farPlane = 5000; scene2->object[0]->scaleUV(2, 2); #endif scene->object[0]->finish(false); scene2->object[0]->finish(false); ShowLoader(0.8f); return true; }