overte/interface/src/VoxelSystem.h
ZappoMan accda966d5 Add LOD culling to the server protocol.
- Add LOD/distance culling to VoxelTree:encodeTreeBitstreamRecursion()
  and VoxelTree::searchForColoredNodesRecursion()
- added new levels to boundaryDistanceForRenderLevel()
- added more spheres to the scene to get a better sense of LOD behavior
2013-04-29 17:38:52 -07:00

92 lines
3 KiB
C++

//
// Cube.h
// interface
//
// Created by Philip on 12/31/12.
// Copyright (c) 2012 High Fidelity, Inc. All rights reserved.
//
#ifndef __interface__Cube__
#define __interface__Cube__
#include "InterfaceConfig.h"
#include <glm/glm.hpp>
#include <UDPSocket.h>
#include <AgentData.h>
#include <VoxelTree.h>
#include <ViewFrustum.h>
#include "Avatar.h"
#include "Camera.h"
#include "Util.h"
#include "world.h"
const int NUM_CHILDREN = 8;
class VoxelSystem : public AgentData {
public:
VoxelSystem();
~VoxelSystem();
int parseData(unsigned char* sourceBuffer, int numBytes);
VoxelSystem* clone() const;
void init();
void simulate(float deltaTime);
void render();
void setVoxelsRendered(int v) {voxelsRendered = v;};
int getVoxelsRendered() {return voxelsRendered;};
void setViewerAvatar(Avatar *newViewerAvatar) { _viewerAvatar = newViewerAvatar; };
void setCamera(Camera* newCamera) { _camera = newCamera; };
void loadVoxelsFile(const char* fileName,bool wantColorRandomizer);
void createSphere(float r,float xc, float yc, float zc, float s, bool solid, bool wantColorRandomizer);
long int getVoxelsCreated();
long int getVoxelsColored();
long int getVoxelsBytesRead();
float getVoxelsCreatedPerSecondAverage();
float getVoxelsColoredPerSecondAverage();
float getVoxelsBytesReadPerSecondAverage();
// Methods that recurse tree
void randomizeVoxelColors();
void falseColorizeRandom();
void trueColorize();
void falseColorizeInView(ViewFrustum* viewFrustum);
void falseColorizeDistanceFromView(ViewFrustum* viewFrustum);
private:
// Operation functions for tree recursion methods
static int _nodeCount;
static bool randomColorOperation(VoxelNode* node, bool down, void* extraData);
static bool falseColorizeRandomOperation(VoxelNode* node, bool down, void* extraData);
static bool trueColorizeOperation(VoxelNode* node, bool down, void* extraData);
static bool falseColorizeInViewOperation(VoxelNode* node, bool down, void* extraData);
static bool falseColorizeDistanceFromViewOperation(VoxelNode* node, bool down, void* extraData);
static bool getDistanceFromViewRangeOperation(VoxelNode* node, bool down, void* extraData);
// these are kinda hacks, used by getDistanceFromViewRangeOperation() probably shouldn't be here
static float _maxDistance;
static float _minDistance;
int voxelsRendered;
Avatar* _viewerAvatar;
Camera* _camera;
VoxelTree *tree;
GLfloat *readVerticesArray;
GLubyte *readColorsArray;
GLfloat *readVerticesEndPointer;
GLfloat *writeVerticesArray;
GLubyte *writeColorsArray;
GLfloat *writeVerticesEndPointer;
GLuint vboVerticesID;
GLuint vboNormalsID;
GLuint vboColorsID;
GLuint vboIndicesID;
pthread_mutex_t bufferWriteLock;
int treeToArrays(VoxelNode *currentNode, const glm::vec3& nodePosition);
void setupNewVoxelsForDrawing();
void copyWrittenDataToReadArrays();
};
#endif