Starting on environment bits.

This commit is contained in:
Andrzej Kapolka 2013-05-06 13:30:07 -07:00
parent 4d33c462fe
commit b4dd6b57aa
6 changed files with 155 additions and 0 deletions

View file

@ -0,0 +1,12 @@
//
// Environment.cpp
// interface
//
// Created by Andrzej Kapolka on 5/6/13.
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
#include "Environment.h"
void Environment::render() {
}

View file

@ -0,0 +1,24 @@
//
// Environment.h
// interface
//
// Created by Andrzej Kapolka on 5/16/13.
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
#ifndef __interface__Environment__
#define __interface__Environment__
#include "EnvironmentData.h"
class Environment : public EnvironmentData {
public:
void render();
private:
};
#endif /* defined(__interface__Environment__) */

View file

@ -74,6 +74,7 @@
#include <AgentList.h>
#include <AgentTypes.h>
#include "VoxelSystem.h"
#include "Environment.h"
#include "Oscilloscope.h"
#include "UDPSocket.h"
#include "SerialInterface.h"
@ -136,6 +137,8 @@ VoxelSystem voxels;
bool wantToKillLocalVoxels = false;
Environment environment;
#ifndef _WIN32
Audio audio(&audioScope, &myAvatar);
@ -1645,6 +1648,9 @@ void* networkReceive(void* args) {
case PACKET_HEADER_ERASE_VOXEL:
voxels.parseData(incomingPacket, bytesReceived);
break;
case PACKET_HEADER_ENVIRONMENT_DATA:
environment.parseData(incomingPacket, bytesReceived);
break;
case PACKET_HEADER_BULK_AVATAR_DATA:
AgentList::getInstance()->processBulkAgentData(&senderAddress,
incomingPacket,

View file

@ -23,5 +23,6 @@ const char PACKET_HEADER_ERASE_VOXEL = 'E';
const char PACKET_HEADER_VOXEL_DATA = 'V';
const char PACKET_HEADER_BULK_AVATAR_DATA = 'X';
const char PACKET_HEADER_TRANSMITTER_DATA = 't';
const char PACKET_HEADER_ENVIRONMENT_DATA = 'e';
#endif

View file

@ -0,0 +1,69 @@
//
// EnvironmentData.cpp
// interface
//
// Created by Andrzej Kapolka on 5/6/13.
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
#include <cstring>
#include "EnvironmentData.h"
#include "PacketHeaders.h"
int EnvironmentData::getBroadcastData(unsigned char* destinationBuffer) const {
unsigned char* bufferStart = destinationBuffer;
memcpy(destinationBuffer, &_atmosphereCenter, sizeof(_atmosphereCenter));
destinationBuffer += sizeof(_atmosphereCenter);
memcpy(destinationBuffer, &_atmosphereInnerRadius, sizeof(_atmosphereInnerRadius));
destinationBuffer += sizeof(_atmosphereInnerRadius);
memcpy(destinationBuffer, &_atmosphereOuterRadius, sizeof(_atmosphereOuterRadius));
destinationBuffer += sizeof(_atmosphereOuterRadius);
memcpy(destinationBuffer, &_rayleighScattering, sizeof(_rayleighScattering));
destinationBuffer += sizeof(_rayleighScattering);
memcpy(destinationBuffer, &_mieScattering, sizeof(_mieScattering));
destinationBuffer += sizeof(_mieScattering);
memcpy(destinationBuffer, &_sunLocation, sizeof(_sunLocation));
destinationBuffer += sizeof(_sunLocation);
memcpy(destinationBuffer, &_sunBrightness, sizeof(_sunBrightness));
destinationBuffer += sizeof(_sunBrightness);
return destinationBuffer - bufferStart;
}
int EnvironmentData::parseData(unsigned char* sourceBuffer, int numBytes) {
// increment to push past the packet header
sourceBuffer++;
unsigned char* startPosition = sourceBuffer;
memcpy(&_atmosphereCenter, sourceBuffer, sizeof(_atmosphereCenter));
sourceBuffer += sizeof(_atmosphereCenter);
memcpy(&_atmosphereInnerRadius, sourceBuffer, sizeof(_atmosphereInnerRadius));
sourceBuffer += sizeof(_atmosphereInnerRadius);
memcpy(&_atmosphereOuterRadius, sourceBuffer, sizeof(_atmosphereOuterRadius));
sourceBuffer += sizeof(_atmosphereOuterRadius);
memcpy(&_rayleighScattering, sourceBuffer, sizeof(_rayleighScattering));
sourceBuffer += sizeof(_rayleighScattering);
memcpy(&_mieScattering, sourceBuffer, sizeof(_mieScattering));
sourceBuffer += sizeof(_mieScattering);
memcpy(&_sunLocation, sourceBuffer, sizeof(_sunLocation));
sourceBuffer += sizeof(_sunLocation);
memcpy(&_sunBrightness, sourceBuffer, sizeof(_sunBrightness));
sourceBuffer += sizeof(_sunBrightness);
return sourceBuffer - startPosition;
}

View file

@ -0,0 +1,43 @@
//
// EnvironmentData.h
// interface
//
// Created by Andrzej Kapolka on 5/16/13.
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
#ifndef __interface__EnvironmentData__
#define __interface__EnvironmentData__
#include <glm/glm.hpp>
class EnvironmentData {
public:
void setAtmosphereCenter(const glm::vec3& center);
void setAtmosphereInnerRadius(float radius);
void setAtmosphereOuterRadius(float radius);
void setRayleighScattering(float scattering);
void setMieScattering(float scattering);
void setSunLocation(const glm::vec3 location);
void setSunBrightness(float brightness);
int getBroadcastData(unsigned char* destinationBuffer) const;
int parseData(unsigned char* sourceBuffer, int numBytes);
private:
glm::vec3 _atmosphereCenter;
float _atmosphereInnerRadius;
float _atmosphereOuterRadius;
float _rayleighScattering;
float _mieScattering;
glm::vec3 _sunLocation;
float _sunBrightness;
};
#endif /* defined(__interface__EnvironmentData__) */