/* -------------------------------------------------------------------------- */ void LensFlare::update() { if (mHidden || !mLightNode) return; /// If the Light is out of the Camera field Of View, the lensflare is hidden. if (!mCamera->isVisible(getLightPosition())) { mHaloSet->setVisible(false); mBurstSet->setVisible(false); return; } Vector3 lightToCamera = mCamera->getDerivedPosition() - getLightPosition(); Vector3 CameraVect = lightToCamera.length() * mCamera->getDerivedDirection(); CameraVect += mCamera->getDerivedPosition(); // The LensFlare effect takes place along this vector. Vector3 LFvect = (CameraVect - getLightPosition()); // LFvect += Vector3(-64,-64,0); // sprite dimension (to be adjusted, but not necessary) // The different sprites are placed along this line. mHaloSet->getBillboard(0)->setPosition( LFvect); mHaloSet->getBillboard(1)->setPosition( LFvect*0.725); mHaloSet->getBillboard(2)->setPosition( LFvect*0.250); mBurstSet->getBillboard(0)->setPosition( LFvect*0.833); mBurstSet->getBillboard(1)->setPosition( LFvect*0.500); mBurstSet->getBillboard(2)->setPosition( LFvect*0.320); // We redraw the lensflare (in case it was previouly out of the camera field, and hidden) this->setVisible(true); }
/* Makes perlin-noise clouds! Uses Ken Perlin's PerlinNoise3D function, taken from http://local.wasp.uwa.edu.au/~pbourke/texture_colour/perlin */ void perlin_clouds(double level, double scale, double deg) { int x, z; GLfloat *light = getLightPosition(); clouds_flag = 1; level = bounds(level, 0, WORLDY-1); for(x = 0; x < WORLDX; x++) { for(z = 0; z < WORLDZ; z++) { /* Overwrite whatever was here before, as long as it isn't the sun. */ if(!((float)x == light[0] && level == light[1] && (float)z == light[2])) world[x][(int)level][z] = EMPTY; /* Using deg (from update) as the y-axis, step through slices of smooth volumetric noise to get realistic looking clouds. */ if((PerlinNoise3D(x/76.0, z/76.0, deg/108.0, 1.99, 2.1, 4) * scale) > 0) world[x][(int)level][z] = WHITE; } } }
int send_stuff_to_clients() { float px, py, pz, rx, ry, rz; int i, j; char buf[MESSAGE_LENGTH]; Stack s; new_stack(&s); for(i = 0; i < PLAYER_COUNT; i++) { if(player_flag[i]) { player_flag[i] = 0; if(i == 0) { getViewPosition(&px,&py,&pz); getViewOrientation(&rx,&ry,&rz); sprintf(buf, "player %f %f %f %d %d", px, py, pz, (int)ry, 0); } else { sprintf(buf, "player %f %f %f %d %d", playerPosition[i][0], playerPosition[i][1], playerPosition[i][2], (int)playerPosition[i][3], i); } push(s, buf); } } if(sun_flag) { sun_flag = 0; getLightPosition(&px,&py,&pz); sprintf(buf, "sun %d %d %d", (int)px, (int)py, (int)pz); push(s, buf); } if(clouds_flag) { clouds_flag = 0; for(i = 0; i < WORLDX; i++) for(j = 0; j < WORLDZ; j++) if(world[i][96][j] == WHITE) { sprintf(buf, "cloud %d 90 %d %d", i, j, WHITE); push(s, buf); } } for(i = 0; i < MOB_COUNT; i++) if(mobflag[i]) { mobflag[i] = 0; sprintf(buf, "mob %f %f %f %d %d", mobPosition[i][0], mobPosition[i][1], mobPosition[i][2], (int)mobPosition[i][3], i); push(s, buf); } if(digflag[0]) { digflag[0] = 0; sprintf(buf, "dig %d %d %d", digflag[1], digflag[2], digflag[3]); push(s, buf); } while(pop(s, buf) == 0) { for(i = 0; i < num_clients; i++) { sendall(fdlist[i], buf, MESSAGE_LENGTH); } } sendall(fdlist[i], "done", MESSAGE_LENGTH); kill_stack(&s); return 0; }