Re-correction des poids du LOD.
This commit is contained in:
parent
3572c337d6
commit
5bf518a684
|
@ -120,16 +120,20 @@ void Chose::addBBPoints(const Quad q, float height) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Chose::updateAABB() {
|
void Chose::updateAABB() {
|
||||||
|
float splitFactor = 5.f;
|
||||||
|
float mergeFactor = 6.f;
|
||||||
lod.firstBBPoint = true;
|
lod.firstBBPoint = true;
|
||||||
getBoundingBoxPoints();
|
getBoundingBoxPoints();
|
||||||
float dx = lod.aabb[1] - lod.aabb[0];
|
float size[3];
|
||||||
float dy = lod.aabb[3] - lod.aabb[2];
|
for (int i = 0; i < 3; i++)
|
||||||
float dz = lod.aabb[5] - lod.aabb[4];
|
size[i] = lod.aabb[2*i+1] - lod.aabb[2*i];
|
||||||
// TODO pour la pseudoLength sur l'axe x, utiliser y*z, pseudolength_y = x*z, pseudolength_z = x*y.
|
float areaFacing[3];
|
||||||
float pseudoLength = std::sqrt(dx*dy + dy*dz + dx*dz);
|
for (int i = 0; i < 3; i++)
|
||||||
float splitIncrement = 5 * pseudoLength;
|
areaFacing[i] = size[(i+1)%3]*size[(i+1)%3];
|
||||||
float mergeIncrement = 6 * pseudoLength;
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
|
float pseudoLength = std::max(1.f, std::sqrt(areaFacing[i] + areaFacing[(i+1)%3] / 2.f + areaFacing[(i+1)%3] / 2.f));
|
||||||
|
float splitIncrement = std::min((float)View::backFrustum, splitFactor * pseudoLength);
|
||||||
|
float mergeIncrement = std::min(View::backFrustum * mergeFactor/splitFactor, mergeFactor * pseudoLength);
|
||||||
lod.splitBox[2*i] = lod.aabb[2*i] - splitIncrement;
|
lod.splitBox[2*i] = lod.aabb[2*i] - splitIncrement;
|
||||||
lod.splitBox[2*i+1] = lod.aabb[2*i+1] + splitIncrement;
|
lod.splitBox[2*i+1] = lod.aabb[2*i+1] + splitIncrement;
|
||||||
lod.mergeBox[2*i] = lod.aabb[2*i] - mergeIncrement;
|
lod.mergeBox[2*i] = lod.aabb[2*i] - mergeIncrement;
|
||||||
|
|
2
view.cpp
2
view.cpp
|
@ -24,7 +24,7 @@ void View::initWindow() {
|
||||||
SDL_SetVideoMode(windowWidth, windowHeight, 32, SDL_OPENGL);
|
SDL_SetVideoMode(windowWidth, windowHeight, 32, SDL_OPENGL);
|
||||||
glMatrixMode( GL_PROJECTION );
|
glMatrixMode( GL_PROJECTION );
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluPerspective(70,(double)windowWidth/windowHeight,1,100000); // back frustum : 1km
|
gluPerspective(70,(double)windowWidth/windowHeight,frontFrustum,backFrustum);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glewInit();
|
glewInit();
|
||||||
|
|
||||||
|
|
23
view.hh
23
view.hh
|
@ -3,18 +3,12 @@
|
||||||
|
|
||||||
#include "all_includes.hh"
|
#include "all_includes.hh"
|
||||||
|
|
||||||
// TODO :
|
|
||||||
// flycam : le centre ne bouge pas, la souris contrôle l'angle de vue x & y
|
|
||||||
// les flèches avant/arrière permettent d'avancer/reculer.
|
|
||||||
// Calcul correct des normales dans triangle.cpp
|
|
||||||
// Prendre en compte tous les évènements X en attente avant de relancer le rendu.
|
|
||||||
|
|
||||||
class Camera {
|
class Camera {
|
||||||
public :
|
public :
|
||||||
Vertex cameraCenter;
|
Vertex cameraCenter;
|
||||||
Vertex cameraSight;
|
Vertex cameraSight;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
float xAngle;
|
float xAngle;
|
||||||
float yAngle;
|
float yAngle;
|
||||||
int moveSensitivity;
|
int moveSensitivity;
|
||||||
|
@ -26,7 +20,7 @@ class Camera {
|
||||||
bool pageUp;
|
bool pageUp;
|
||||||
bool pageDown;
|
bool pageDown;
|
||||||
|
|
||||||
public :
|
public :
|
||||||
Camera(Vertex pos, float xA, float yA, int moveSensitivity, float mouseSensitivity);
|
Camera(Vertex pos, float xA, float yA, int moveSensitivity, float mouseSensitivity);
|
||||||
void setCamera();
|
void setCamera();
|
||||||
void mouseMotion(const SDL_MouseMotionEvent &event);
|
void mouseMotion(const SDL_MouseMotionEvent &event);
|
||||||
|
@ -38,19 +32,20 @@ class Camera {
|
||||||
|
|
||||||
|
|
||||||
class View {
|
class View {
|
||||||
private :
|
private :
|
||||||
Chose* root;
|
Chose* root;
|
||||||
|
|
||||||
public :
|
public :
|
||||||
Camera camera;
|
Camera camera;
|
||||||
|
static const int frontFrustum = 1;
|
||||||
|
static const int backFrustum = 100000; // 1km
|
||||||
private:
|
private:
|
||||||
Lod lod;
|
Lod lod;
|
||||||
|
|
||||||
static const int windowWidth = 1024;
|
static const int windowWidth = 1024;
|
||||||
static const int windowHeight = 768;
|
static const int windowHeight = 768;
|
||||||
|
|
||||||
|
public :
|
||||||
public :
|
|
||||||
View(Chose* root);
|
View(Chose* root);
|
||||||
void initWindow();
|
void initWindow();
|
||||||
void mainLoop();
|
void mainLoop();
|
||||||
|
@ -59,7 +54,7 @@ private:
|
||||||
|
|
||||||
static void setColor(unsigned char r, unsigned char g, unsigned char b);
|
static void setColor(unsigned char r, unsigned char g, unsigned char b);
|
||||||
|
|
||||||
private :
|
private :
|
||||||
void setLight();
|
void setLight();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user