mirror of
https://github.com/overte-org/overte.git
synced 2025-08-16 15:11:10 +02:00
Merge branch 'master' of https://github.com/worklist/hifi
This commit is contained in:
commit
ca939fb6b8
8 changed files with 148 additions and 25 deletions
|
@ -36,6 +36,7 @@ bool includeBorderTracer = true;
|
|||
bool includeMovingBug = true;
|
||||
bool includeBlinkingVoxel = false;
|
||||
bool includeDanceFloor = true;
|
||||
bool buildStreet = false;
|
||||
|
||||
|
||||
const int ANIMATION_LISTEN_PORT = 40107;
|
||||
|
@ -616,6 +617,61 @@ static void sendBillboard() {
|
|||
}
|
||||
}
|
||||
|
||||
bool roadInitialized = false;
|
||||
const int ROAD_WIDTH_METERS = 3.0f;
|
||||
const int BRICKS_ACROSS_ROAD = 32;
|
||||
const float ROAD_BRICK_SIZE = 0.125f/TREE_SCALE; //(ROAD_WIDTH_METERS / TREE_SCALE) / BRICKS_ACROSS_ROAD; // in voxel units
|
||||
const int ROAD_LENGTH = 1.0f / ROAD_BRICK_SIZE; // in bricks
|
||||
const int ROAD_WIDTH = BRICKS_ACROSS_ROAD; // in bricks
|
||||
glm::vec3 roadPosition(0.5f - (ROAD_BRICK_SIZE * BRICKS_ACROSS_ROAD), 0.0f, 0.0f);
|
||||
const int BRICKS_PER_PACKET = 32; // guessing
|
||||
const int PACKETS_PER_ROAD = VOXELS_PER_PACKET / (ROAD_LENGTH * ROAD_WIDTH);
|
||||
|
||||
void doBuildStreet() {
|
||||
if (roadInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
PACKET_TYPE message = PACKET_TYPE_SET_VOXEL_DESTRUCTIVE; // we're a bully!
|
||||
static VoxelDetail details[BRICKS_PER_PACKET];
|
||||
unsigned char* bufferOut;
|
||||
int sizeOut;
|
||||
|
||||
for (int z = 0; z < ROAD_LENGTH; z++) {
|
||||
for (int x = 0; x < ROAD_WIDTH; x++) {
|
||||
|
||||
int nthVoxel = ((z * ROAD_WIDTH) + x);
|
||||
int item = nthVoxel % BRICKS_PER_PACKET;
|
||||
|
||||
glm::vec3 brick = roadPosition + glm::vec3(x * ROAD_BRICK_SIZE, 0, z * ROAD_BRICK_SIZE);
|
||||
|
||||
details[item].s = ROAD_BRICK_SIZE;
|
||||
details[item].x = brick.x;
|
||||
details[item].y = brick.y;
|
||||
details[item].z = brick.z;
|
||||
|
||||
unsigned char randomTone = randIntInRange(118,138);
|
||||
details[item].red = randomTone;
|
||||
details[item].green = randomTone;
|
||||
details[item].blue = randomTone;
|
||||
|
||||
if (item == BRICKS_PER_PACKET - 1) {
|
||||
if (createVoxelEditMessage(message, 0, BRICKS_PER_PACKET, (VoxelDetail*)&details, bufferOut, sizeOut)){
|
||||
::packetsSent++;
|
||||
::bytesSent += sizeOut;
|
||||
if (true || ::shouldShowPacketsPerSecond) {
|
||||
printf("building road sending packet of size=%d\n", sizeOut);
|
||||
}
|
||||
NodeList::getInstance()->broadcastToNodes(bufferOut, sizeOut, &NODE_TYPE_VOXEL_SERVER, 1);
|
||||
delete[] bufferOut;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
roadInitialized = true;
|
||||
}
|
||||
|
||||
|
||||
double start = 0;
|
||||
|
||||
|
||||
|
@ -645,6 +701,10 @@ void* animateVoxels(void* args) {
|
|||
sendDanceFloor();
|
||||
}
|
||||
|
||||
if (::buildStreet) {
|
||||
doBuildStreet();
|
||||
}
|
||||
|
||||
uint64_t end = usecTimestampNow();
|
||||
uint64_t elapsedSeconds = (end - ::start) / 1000000;
|
||||
if (::shouldShowPacketsPerSecond) {
|
||||
|
@ -688,6 +748,9 @@ int main(int argc, const char * argv[])
|
|||
const char* NO_DANCE_FLOOR = "--NoDanceFloor";
|
||||
::includeDanceFloor = !cmdOptionExists(argc, argv, NO_DANCE_FLOOR);
|
||||
|
||||
const char* BUILD_STREET = "--BuildStreet";
|
||||
::buildStreet = cmdOptionExists(argc, argv, BUILD_STREET);
|
||||
|
||||
// Handle Local Domain testing with the --local command line
|
||||
const char* showPPS = "--showPPS";
|
||||
::shouldShowPacketsPerSecond = cmdOptionExists(argc, argv, showPPS);
|
||||
|
@ -700,6 +763,11 @@ int main(int argc, const char * argv[])
|
|||
nodeList->setDomainIPToLocalhost();
|
||||
}
|
||||
|
||||
const char* domainIP = getCmdOption(argc, argv, "--domain");
|
||||
if (domainIP) {
|
||||
NodeList::getInstance()->setDomainIP(domainIP);
|
||||
}
|
||||
|
||||
nodeList->linkedDataCreateCallback = NULL; // do we need a callback?
|
||||
nodeList->startSilentNodeRemovalThread();
|
||||
|
||||
|
|
|
@ -77,8 +77,10 @@ static char STAR_CACHE_FILE[] = "cachedStars.txt";
|
|||
|
||||
static const int BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH = 6; // farther dragged clicks are ignored
|
||||
|
||||
const glm::vec3 START_LOCATION(4.f, 0.f, 5.f); // Where one's own node begins in the world
|
||||
// (will be overwritten if avatar data file is found)
|
||||
// Where one's own Avatar begins in the world (will be overwritten if avatar data file is found)
|
||||
// this is basically in the center of the ground plane. Slightly adjusted. This was asked for by
|
||||
// Grayson as he's building a street around here for demo dinner 2
|
||||
const glm::vec3 START_LOCATION(0.485f * TREE_SCALE, 0.f, 0.5f * TREE_SCALE);
|
||||
|
||||
const int IDLE_SIMULATE_MSECS = 16; // How often should call simulate and other stuff
|
||||
// in the idle loop? (60 FPS is default)
|
||||
|
@ -2936,6 +2938,27 @@ void Application::displayOculus(Camera& whichCamera) {
|
|||
glPopMatrix();
|
||||
}
|
||||
|
||||
void Application::setupWorldLight(Camera& whichCamera) {
|
||||
|
||||
// Setup 3D lights (after the camera transform, so that they are positioned in world space)
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
|
||||
|
||||
glm::vec3 relativeSunLoc = glm::normalize(_environment.getClosestData(whichCamera.getPosition()).getSunLocation() -
|
||||
whichCamera.getPosition());
|
||||
GLfloat light_position0[] = { relativeSunLoc.x, relativeSunLoc.y, relativeSunLoc.z, 0.0 };
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
|
||||
GLfloat ambient_color[] = { 0.7, 0.7, 0.8 };
|
||||
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color);
|
||||
GLfloat diffuse_color[] = { 0.8, 0.7, 0.7 };
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color);
|
||||
GLfloat specular_color[] = { 1.0, 1.0, 1.0, 1.0};
|
||||
glLightfv(GL_LIGHT0, GL_SPECULAR, specular_color);
|
||||
|
||||
glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color);
|
||||
glMateriali(GL_FRONT, GL_SHININESS, 96);
|
||||
}
|
||||
|
||||
void Application::displaySide(Camera& whichCamera) {
|
||||
// transform by eye offset
|
||||
|
||||
|
@ -2965,22 +2988,7 @@ void Application::displaySide(Camera& whichCamera) {
|
|||
glTranslatef(-whichCamera.getPosition().x, -whichCamera.getPosition().y, -whichCamera.getPosition().z);
|
||||
|
||||
// Setup 3D lights (after the camera transform, so that they are positioned in world space)
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
|
||||
|
||||
glm::vec3 relativeSunLoc = glm::normalize(_environment.getClosestData(whichCamera.getPosition()).getSunLocation() -
|
||||
whichCamera.getPosition());
|
||||
GLfloat light_position0[] = { relativeSunLoc.x, relativeSunLoc.y, relativeSunLoc.z, 0.0 };
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
|
||||
GLfloat ambient_color[] = { 0.7, 0.7, 0.8 };
|
||||
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color);
|
||||
GLfloat diffuse_color[] = { 0.8, 0.7, 0.7 };
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color);
|
||||
GLfloat specular_color[] = { 1.0, 1.0, 1.0, 1.0};
|
||||
glLightfv(GL_LIGHT0, GL_SPECULAR, specular_color);
|
||||
|
||||
glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color);
|
||||
glMateriali(GL_FRONT, GL_SHININESS, 96);
|
||||
setupWorldLight(whichCamera);
|
||||
|
||||
if (_renderStarsOn->isChecked()) {
|
||||
if (!_stars.getFileLoaded()) {
|
||||
|
@ -3046,7 +3054,7 @@ void Application::displaySide(Camera& whichCamera) {
|
|||
glDisable(GL_FOG);
|
||||
glDisable(GL_NORMALIZE);
|
||||
|
||||
renderGroundPlaneGrid(EDGE_SIZE_GROUND_PLANE, _audio.getCollisionSoundMagnitude());
|
||||
//renderGroundPlaneGrid(EDGE_SIZE_GROUND_PLANE, _audio.getCollisionSoundMagnitude());
|
||||
}
|
||||
// Draw voxels
|
||||
if (_renderVoxels->isChecked()) {
|
||||
|
@ -3075,7 +3083,7 @@ void Application::displaySide(Camera& whichCamera) {
|
|||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
|
||||
_myAvatar.renderScreenTint(SCREEN_TINT_BEFORE_AVATARS);
|
||||
_myAvatar.renderScreenTint(SCREEN_TINT_BEFORE_AVATARS, whichCamera);
|
||||
|
||||
if (_renderAvatarsOn->isChecked()) {
|
||||
// Render avatars of other nodes
|
||||
|
@ -3111,6 +3119,8 @@ void Application::displaySide(Camera& whichCamera) {
|
|||
}
|
||||
}
|
||||
|
||||
_myAvatar.renderScreenTint(SCREEN_TINT_AFTER_AVATARS, whichCamera);
|
||||
|
||||
if (_renderParticleSystemOn->isChecked()) {
|
||||
if (_particleSystemInitialized) {
|
||||
_particleSystem.render();
|
||||
|
|
|
@ -120,6 +120,7 @@ public:
|
|||
TextureCache* getTextureCache() { return &_textureCache; }
|
||||
|
||||
void resetSongMixMenuItem();
|
||||
void setupWorldLight(Camera& whichCamera);
|
||||
|
||||
virtual void nodeAdded(Node* node);
|
||||
virtual void nodeKilled(Node* node);
|
||||
|
|
|
@ -1160,6 +1160,10 @@ void Avatar::render(bool lookingInMirror, bool renderAvatarBalls) {
|
|||
glPopMatrix();
|
||||
}
|
||||
|
||||
if (Application::getInstance()->getAvatar()->getHand().isRaveGloveActive()) {
|
||||
_hand.setRaveLights(RAVE_LIGHTS_AVATAR);
|
||||
}
|
||||
|
||||
// render a simple round on the ground projected down from the avatar's position
|
||||
renderDiskShadow(_position, glm::vec3(0.0f, 1.0f, 0.0f), _scale * 0.1f, 0.2f);
|
||||
|
||||
|
@ -1221,13 +1225,19 @@ void Avatar::render(bool lookingInMirror, bool renderAvatarBalls) {
|
|||
}
|
||||
}
|
||||
|
||||
void Avatar::renderScreenTint(ScreenTintLayer layer) {
|
||||
void Avatar::renderScreenTint(ScreenTintLayer layer, Camera& whichCamera) {
|
||||
|
||||
if (layer == SCREEN_TINT_BEFORE_AVATARS) {
|
||||
if (_hand.isRaveGloveActive()) {
|
||||
_hand.renderRaveGloveStage();
|
||||
}
|
||||
}
|
||||
else if (layer == SCREEN_TINT_BEFORE_AVATARS) {
|
||||
if (_hand.isRaveGloveActive()) {
|
||||
// Restore the world lighting
|
||||
Application::getInstance()->setupWorldLight(whichCamera);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Avatar::resetBodyBalls() {
|
||||
|
|
|
@ -117,7 +117,7 @@ enum ScreenTintLayer
|
|||
SCREEN_TINT_BEFORE_LANDSCAPE = 0,
|
||||
SCREEN_TINT_BEFORE_AVATARS,
|
||||
SCREEN_TINT_BEFORE_MY_AVATAR,
|
||||
SCREEN_TINT_AFTER_MY_AVATAR,
|
||||
SCREEN_TINT_AFTER_AVATARS,
|
||||
NUM_SCREEN_TINT_LAYERS
|
||||
};
|
||||
|
||||
|
@ -136,7 +136,7 @@ public:
|
|||
void addBodyYaw(float bodyYaw) {_bodyYaw += bodyYaw;};
|
||||
void addBodyYawDelta(float bodyYawDelta) {_bodyYawDelta += bodyYawDelta;}
|
||||
void render(bool lookingInMirror, bool renderAvatarBalls);
|
||||
void renderScreenTint(ScreenTintLayer layer);
|
||||
void renderScreenTint(ScreenTintLayer layer, Camera& whichCamera);
|
||||
|
||||
//setters
|
||||
void setMousePressed (bool mousePressed ) { _mousePressed = mousePressed;}
|
||||
|
|
|
@ -145,6 +145,9 @@ void Hand::render(bool lookingInMirror) {
|
|||
|
||||
if (_raveGloveInitialized) {
|
||||
updateRaveGloveEmitters(); // do this after calculateGeometry
|
||||
|
||||
// Use normal lighting for the particles
|
||||
setRaveLights(RAVE_LIGHTS_PARTICLES);
|
||||
_raveGloveParticleSystem.render();
|
||||
}
|
||||
}
|
||||
|
@ -161,6 +164,31 @@ void Hand::render(bool lookingInMirror) {
|
|||
}
|
||||
}
|
||||
|
||||
void Hand::setRaveLights(RaveLightsSetting setting) {
|
||||
if (setting == RAVE_LIGHTS_AVATAR) {
|
||||
// Set some mood lighting
|
||||
GLfloat ambient_color[] = { 0.0, 0.0, 0.0 };
|
||||
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color);
|
||||
GLfloat diffuse_color[] = { 0.4, 0.0, 0.0 };
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color);
|
||||
GLfloat specular_color[] = { 0.0, 0.0, 0.0, 0.0};
|
||||
glLightfv(GL_LIGHT0, GL_SPECULAR, specular_color);
|
||||
glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color);
|
||||
glMateriali(GL_FRONT, GL_SHININESS, 0);
|
||||
}
|
||||
else if (setting == RAVE_LIGHTS_PARTICLES) {
|
||||
// particles use a brighter light setting
|
||||
GLfloat ambient_color[] = { 0.7, 0.7, 0.8 };
|
||||
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color);
|
||||
GLfloat diffuse_color[] = { 0.8, 0.7, 0.7 };
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color);
|
||||
GLfloat specular_color[] = { 1.0, 1.0, 1.0, 1.0};
|
||||
glLightfv(GL_LIGHT0, GL_SPECULAR, specular_color);
|
||||
glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color);
|
||||
glMateriali(GL_FRONT, GL_SHININESS, 96);
|
||||
}
|
||||
}
|
||||
|
||||
void Hand::renderRaveGloveStage() {
|
||||
if (_owningAvatar && _owningAvatar->isMyAvatar()) {
|
||||
Head& head = _owningAvatar->getHead();
|
||||
|
|
|
@ -20,6 +20,11 @@
|
|||
#include <SharedUtil.h>
|
||||
#include <vector>
|
||||
|
||||
enum RaveLightsSetting {
|
||||
RAVE_LIGHTS_AVATAR = 0,
|
||||
RAVE_LIGHTS_PARTICLES
|
||||
};
|
||||
|
||||
class Avatar;
|
||||
class ProgramObject;
|
||||
|
||||
|
@ -42,6 +47,7 @@ public:
|
|||
void simulate(float deltaTime, bool isMine);
|
||||
void render(bool lookingInMirror);
|
||||
void renderRaveGloveStage();
|
||||
void setRaveLights(RaveLightsSetting setting);
|
||||
|
||||
void setBallColor (glm::vec3 ballColor ) { _ballColor = ballColor; }
|
||||
void updateRaveGloveParticles(float deltaTime);
|
||||
|
|
|
@ -215,7 +215,6 @@ bool createVoxelEditMessage(unsigned char command, short int sequence,
|
|||
|
||||
bool success = true; // assume the best
|
||||
int messageSize = MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE; // just a guess for now
|
||||
int actualMessageSize = 3;
|
||||
unsigned char* messageBuffer = new unsigned char[messageSize];
|
||||
|
||||
int numBytesPacketHeader = populateTypeAndVersion(messageBuffer, command);
|
||||
|
@ -223,6 +222,7 @@ bool createVoxelEditMessage(unsigned char command, short int sequence,
|
|||
|
||||
*sequenceAt = sequence;
|
||||
unsigned char* copyAt = &messageBuffer[numBytesPacketHeader + sizeof(sequence)];
|
||||
int actualMessageSize = numBytesPacketHeader + sizeof(sequence);
|
||||
|
||||
for (int i = 0; i < voxelCount && success; i++) {
|
||||
// get the coded voxel
|
||||
|
@ -232,7 +232,7 @@ bool createVoxelEditMessage(unsigned char command, short int sequence,
|
|||
int lengthOfVoxelData = bytesRequiredForCodeLength(*voxelData)+SIZE_OF_COLOR_DATA;
|
||||
|
||||
// make sure we have room to copy this voxel
|
||||
if (actualMessageSize+lengthOfVoxelData > MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE) {
|
||||
if (actualMessageSize + lengthOfVoxelData > MAXIMUM_EDIT_VOXEL_MESSAGE_SIZE) {
|
||||
success = false;
|
||||
} else {
|
||||
// add it to our message
|
||||
|
|
Loading…
Reference in a new issue