Compare commits

..

1 Commits

14 changed files with 16138 additions and 7 deletions

View File

@ -24,7 +24,7 @@ $(EXECUTABLE): $(SOURCES) all_includes.hh.gch Makefile
@echo "#define _ALL_CPP_">> all.cpp
@$(foreach FILE,$(SOURCES),echo '#include "'"$(FILE)"'"' >> all.cpp;)
@echo "#endif">> all.cpp
$(CXX) all.cpp $(LIBS) $(CFLAGS) -o $@
$(CXX) $(LIBS) $(CFLAGS) all.cpp -o $@
@rm all.cpp
all_includes.hh.gch: $(HEADERS) Makefile

View File

@ -15,3 +15,8 @@ How to run this program ?
=========================
make
How to run the statistics ?
===========================
mkdir -p png && make city && ./city > statistics.plt && pv statistics.plt | tail -n +2 | gnuplot

View File

@ -7,6 +7,7 @@ class Chose;
#include <typeinfo>
#include <iostream>
#include <iomanip> // DEBUG
#include <cstdlib>
#include <cmath>
#include <vector>

View File

@ -26,3 +26,14 @@ Chose* Heap::popIfLessThan(float key) {
}
return NULL;
}
extern int debug_printlod_axis;
std::ostream& operator<<(std::ostream& os, const Heap& h) {
for (std::set<HeapNode>::iterator it = h.bst.begin(); it != h.bst.end(); ++it) {
int i = debug_printlod_axis;
// TODO : put a color instead of "1"
os << it->value->lod.center[i] << ", " << (it->value->lod.splitDistance[i])/(Dimensions::splitFactor) << ", " << 1 << std::endl;
}
return os;
}

View File

@ -24,6 +24,7 @@ public:
Chose* popIfLessThan(float key);
bool lessThan(float a, float b); // Renvoie true ssi a < b dans l'ordre du tas.
void init(int factor); // factor = -1 pour tas Min, 1 pour tas max
friend std::ostream& operator<<(std::ostream& os, const Heap& v);
};
#endif

32
lod.cpp
View File

@ -13,6 +13,8 @@ Lod::Lod(Vertex _camera, Chose* root) {
setCamera(_camera);
}
int debug_printlod_axis;
void Lod::setCamera(Vertex newCamera) {
this->camera[0] = newCamera.x;
this->camera[1] = newCamera.y;
@ -55,14 +57,40 @@ void Lod::setCamera(Vertex newCamera) {
splitOut[i].insert(c->lod.splitBox[i], c);
}
}
// Statistics
Heap* heaps[3] = { merge, splitIn, splitOut };
const char* heapNames[3] = { "merge", "splitIn", "splitOut" };
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 3; j++) {
debug_printlod_axis = i/2;
std::cout << "set term png" << std::endl
<< "set output 'png/"
<< heapNames[j] << " " << ((i & 1) ? '+' : '-') << (char)('x' + debug_printlod_axis) << " frame " << std::setfill('0') << std::setw(5) << Camera::debug_frame
<< ".png'" << std::endl
<< "unset arrow" << std::endl
<< "set arrow from "
<< camera[debug_printlod_axis] << "," << 0 <<" to "
<< (camera[debug_printlod_axis] + 10000000*((i & 1) ? -1 : 1)) << "," << 10000000*(Dimensions::splitFactor)
<< " nohead linecolor rgb 'blue'" << std::endl
<< "plot '-' title '"
<< heapNames[j] << " " << ((i & 1) ? '+' : '-') << (char)('x' + debug_printlod_axis) << " frame " << std::setfill('0') << std::setw(5) << Camera::debug_frame
<< "' with dots linecolor variable" << std::endl
<< "0, 0, 0" << std::endl
<< heaps[j][i]
<< "end" << std::endl;
}
// std::cout << "merge[" << i << "] = {" << merge[i] << "}" << std::endl;
// std::cout << "splitIn[" << i << "] = {" << splitIn[i] << "}" << std::endl;
// std::cout << "splitOut[" << i << "] = {" << splitOut[i] << "}" << std::endl;
}
}
void Lod::doSplit(Chose* c) {
c->split();
std::vector<Chose*>::iterator it;
////bool mergeCube = false; // Started to work again on the project, a new warning detected this.
bool mergeCube = false;
for (it = c->children.begin(); it != c->children.end(); ++it) {
////mergeCube = true; // Started to work again on the project, a new warning detected this.
mergeCube = true;
(*it)->triangulation();
(*it)->updateAABB();
// (*it)->drawAABB();

2
lod.hh
View File

@ -26,6 +26,8 @@ struct LodNode {
float mergeBox[6];
int inCounter;
bool firstBBPoint;
float splitDistance[3];
float center[3];
};
#endif

16077
points/test.plt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -163,6 +163,8 @@ void Chose::updateAABB() {
lod.splitBox[2*i+1] = center[i] + splitDistance;
lod.mergeBox[2*i] = center[i] - mergeDistance;
lod.mergeBox[2*i+1] = center[i] + mergeDistance;
lod.splitDistance[i] = splitDistance; // TODO : Remove, this is here just for Statistics
lod.center[i] = center[i]; // TODO : Remove, this is here just for Statistics
}
}

View File

@ -30,7 +30,7 @@ protected :
virtual void getBoundingBoxPoints() = 0;
virtual float LODFactor();
Chose();
virtual ~Chose();
~Chose();
inline void addEntropy(unsigned int x1) {
seed = hash2(seed, x1);
}

View File

@ -2,7 +2,7 @@
const unsigned int Couleurs::fog = mix(cielHaut, cielBas, 0.5);
const float Dimensions::splitFactor = 3.f;
const float Dimensions::mergeFactor = 4.f;
const float Dimensions::splitFactor = 1.f;
const float Dimensions::mergeFactor = 1.25f;
const float Dimensions::frontFrustum = 1.f;
const float Dimensions::backFrustum = 4000 * 100; // 4km

View File

@ -45,7 +45,7 @@ void MurQuad::split() {
Quad righth = Quad(windowPosh[NW],windowPosh[SW],ch[SW],ch[NW]);
Quad left = Quad(c[NE],c[SE],windowPos[SE],windowPos[NE]);
Quad lefth = Quad(ch[NE],ch[SE],windowPosh[SE],windowPosh[NE]);
////Quad top = Quad(windowPosh[NE],windowPosh[NW],windowPosh[SW],windowPosh[SE]); // Started to work again on the project, a new warning detected this.
Quad top = Quad(windowPosh[NE],windowPosh[NW],windowPosh[SW],windowPosh[SE]);
if (!door) addChild(new MurQuad(c,windowPos,false, true, false));
addChild(new MurQuad(windowPosh,ch, false, false, true));

View File

@ -144,6 +144,7 @@ void View::renderScene(int lastTime, int currentTime) {
camera.animation(std::min(100, currentTime-lastTime));
camera.setCamera();
// std::cout << std::endl << "lod.setCamera(" << camera.cameraCenter << ")" << std::endl;
lod.setCamera(camera.cameraCenter);
setLight();
@ -351,9 +352,11 @@ void Camera::keyboard(const SDL_KeyboardEvent &eventKey) {
}
}
int Camera::debug_frame = 0;
void Camera::animation(int elapsedTime) {
static unsigned int frame = 0;
frame++;
Camera::debug_frame = frame;
float diff = ((float)(elapsedTime+1)/1000.f)*(float)moveSensitivity;
if (autoPilot) {

View File

@ -22,6 +22,7 @@ private :
bool autoPilot;
public :
static int debug_frame;
Camera(Vertex pos, float xA, float yA, int moveSensitivity, float mouseSensitivity);
void setCamera();
void mouseMotion(const SDL_MouseMotionEvent &event);