Commit 59b49075 authored by Emeric Verschuur's avatar Emeric Verschuur

Beaucoup de correction d'erreur. Ajout de LrEntityList, LrOctreeList dans config.h

parent 5dc3f272
......@@ -18,6 +18,7 @@
#include "LrOctree.h"
#include "LrVector.h"
#include "LrEntity.h"
#include <list>
#define MAX_DIV 4
......@@ -25,15 +26,13 @@ class LrBinder
{
private :
ListObject m_liste_objets;//la liste d'objet
LrEntityList m_liste_objets;//la liste d'objet
public :
typedef list<LrEntity *> ListObject;
LrBinder();
LrBinder(const LrBinder & source);
LrBinder(ListObject l);
LrBinder(LrEntityList l);
virtual ~LrBinder() = 0;
......@@ -41,4 +40,3 @@ class LrBinder
virtual bool getIntersection(LrRay &ray, LrHit & hit);
};
#endif
\ No newline at end of file
......@@ -57,9 +57,9 @@ LrCamera::LrCamera(const LrPoint &position, const LrVector &vertical, const LrVe
m_horizontal = m_direction ^ m_vertical;
// Normalisation des vecteurs
m_vertical.normaliser();
m_horizontal.normaliser();
m_direction.normaliser();
m_vertical.normalize();
m_horizontal.normalize();
m_direction.normalize();
}
LrCamera::~LrCamera() {
......
......@@ -95,7 +95,7 @@ public:
* Note : le contenu de l'image sera effacé,
* et l'image sera remplie en bleue
*/
void LrImage::setSize(int width, int height);
void setSize(int width, int height);
/**
* @brief Retourne la largeur de l'image
......
......@@ -112,15 +112,15 @@ operator == (const LrOctree &lhs, const LrOctree &rhs)
if((lhs.m_listeObj.size() != rhs.m_listeObj.size()) || (lhs.m_listeOct.size() != rhs.m_listeOct.size())) return false;
EntityList::iterator itObj_rhs = rhstemp.m_listeObj.begin();
for(EntityList::iterator itObj_lhs = lhstemp.m_listeObj.begin(); itObj_lhs != lhstemp.m_listeObj.end(); itObj_lhs++)
LrEntityList::iterator itObj_rhs = rhstemp.m_listeObj.begin();
for(LrEntityList::iterator itObj_lhs = lhstemp.m_listeObj.begin(); itObj_lhs != lhstemp.m_listeObj.end(); itObj_lhs++)
{
res = res && (*itObj_lhs == *itObj_rhs);
itObj_rhs++;
}
OctreeSonList::iterator itOct_rhs = rhstemp.m_listeOct.begin();
OctreeSonList::iterator itOct_lhs;
LrOctreeList::iterator itOct_rhs = rhstemp.m_listeOct.begin();
LrOctreeList::iterator itOct_lhs;
for( itOct_lhs = lhstemp.m_listeOct.begin(); itOct_lhs != lhstemp.m_listeOct.end(); itOct_lhs++)
{
res = res && (*itOct_lhs == *itOct_rhs);
......@@ -180,7 +180,7 @@ const LrOctree* LrOctree::getOctree(int index) const
{
if(index < 8)
{
OctreeSonList::iterator it = ((LrOctree *)this)->m_listeOct.begin();
LrOctreeList::iterator it = ((LrOctree *)this)->m_listeOct.begin();
int i = 0;
while(i !=index) it++;
......@@ -203,7 +203,7 @@ LrEntity* LrOctree::getObject(int index) const
{
if(index < m_listeObj.size())
{
EntityList::iterator it = ((LrOctree *)this)->m_listeObj.begin();
LrEntityList::iterator it = ((LrOctree *)this)->m_listeObj.begin();
int i = 0;
while(i !=index) it++;
return *it;
......
......@@ -31,13 +31,10 @@ class LrOctree
const LrOctree *m_parent;
LrVector m_pos;
Real m_taille;
list<LrEntity *> m_listeObj;
list<LrOctree *> m_listeOct;
LrEntityList m_listeObj;
LrEntityList m_listeOct;
public:
typedef std::list<LrEntity *> EntityList;
typedef std::list<LrOctree *> OctreeSonList;
// constructors and destructor
// ***************************
......
......@@ -35,7 +35,7 @@ LrPoint::LrPoint()
}
LrPoint::LrPoint(const LrPoint &source)
:x(source.x), m_y(source.y), m_z(source.z)
:x(source.x), y(source.y), z(source.z)
{
}
......
......@@ -42,15 +42,10 @@ LrScene::LrScene(const LrScene &source)
{
}
LrScene* LrScene::clone() const
{
return new LrScene(*this);
}
LrScene::LrScene(TabEntities &entities,
LrScene::LrScene(const LrEntityList &entities,
LrBinder *binder,
LrImage &image,
LrCamera &camera)
LrImage *image,
LrCamera *camera)
:
m_entities(entities),
m_binder(binder),
......@@ -94,7 +89,7 @@ void LrScene::setBinder(const LrBinder* binder)
m_binder = binder;
}
*/
TabEntities LrScene::getEntities() const
const LrEntityList &LrScene::getEntities() const
{
return m_entities;
}
......@@ -104,22 +99,22 @@ void LrScene::setEntities(const TabEntites entities)
m_entities = entities;
}
*/
LrImage LrScene::getImage() const
LrImage *LrScene::getImage() const
{
return m_image;
}
void LrScene::setDirection(const LrImage &image)
void LrScene::setImage(LrImage *image)
{
m_image = image;
}
LrCamera LrScene::getCamera() const
LrCamera *LrScene::getCamera() const
{
return m_camera;
}
void LrScene::setCamera(const LrCamera &camera)
void LrScene::setCamera(LrCamera *camera)
{
m_camera = camera;
}
......
......@@ -29,8 +29,6 @@
*
* Cette classe est une classe abstraite permettant la génération de scènes.
*/
typedef vector<LrEntity *> TabEntities;
class LrScene
{
......@@ -51,7 +49,7 @@ class LrScene
* @brief Méthode de clonage de LrScene.
* @return LrScene object.
*/
LrScene * clone() const;
virtual LrScene * clone()=0;
/**
* @brief Constructeur personnel de LrScene.
......@@ -60,10 +58,10 @@ class LrScene
* @param image Reference sur un objet LrImage.
* @param camera Reference sur un objet LrCamera.
*/
LrScene(TabEntities &entities,
LrScene(const LrEntityList &entities,
LrBinder *binder,
LrImage &image,
LrCamera &camera);
LrImage *image,
LrCamera *camera);
/**
* @brief Destructeur de LrScene.
......@@ -81,21 +79,21 @@ class LrScene
LrBinder* getBinder() const;
// void setBinder(const LrBinder *binder);
TabEntites getEntities() const;
const LrEntityList &getEntities() const;
// void setEntities(const TabEntities entities);
LrImage getImage() const;
void setImage(const LrImage &image);
LrImage *getImage() const;
void setImage(LrImage *image);
LrCamera getCamera() const;
void setCamera(const LrCamera &camera);
LrCamera *getCamera() const;
void setCamera(LrCamera *camera);
/**
* @brief Phase préparatoire à tout calcul.
* @param entities Liste de pointeurs vers des objets LrEntity.
* @param binder Pointeur vers la structure accéleratrice LrBinder.
*/
virtual void initialize(TabEntities &entities, LrBinder *binder)=0;
virtual void initialize(const LrEntityList &entities, LrBinder *binder)=0;
/**
* @brief Calcul indépendants de l'observateur, généralement
......@@ -112,10 +110,10 @@ class LrScene
protected :
TabEntities m_entities;
LrEntityList m_entities;
LrBinder *m_binder;
LrImage m_image;
LrCamera m_camera;
LrImage *m_image;
LrCamera *m_camera;
};
......
......@@ -19,6 +19,7 @@
#endif
#include "LrSceneRayTracing.h"
#include "LrOptic.h"
/*---------------------------------------------------------------------------*
* Constructeurs et destructeurs *
......@@ -27,7 +28,7 @@
LrSceneRayTracing::LrSceneRayTracing()
:
LrScene(),
m_nbRayPerPixel(),
m_nbRayPerPixel()
{
}
......@@ -39,15 +40,15 @@ LrSceneRayTracing::LrSceneRayTracing(const LrSceneRayTracing &source)
{
}
LrSceneRayTracing* LrSceneRayTracing::clone() const
LrScene * LrSceneRayTracing::clone()
{
return new LrSceneRayTracing(*this);
}
LrSceneRayTracing::LrSceneRayTracing(TabEntities entities,
LrSceneRayTracing::LrSceneRayTracing(const LrEntityList &entities,
LrBinder *binder,
LrImage &image,
LrCamera &camera,
LrImage *image,
LrCamera *camera,
int nbRayPerPixel)
:
LrScene(entities, binder, image, camera),
......@@ -80,7 +81,7 @@ LrSceneRayTracing&
* Accesseurs *
*---------------------------------------------------------------------------*/
LrImage LrSceneRayTracing::getNbRayPerPixel() const
int LrSceneRayTracing::getNbRayPerPixel() const
{
return m_nbRayPerPixel;
}
......@@ -89,7 +90,7 @@ LrImage LrSceneRayTracing::getNbRayPerPixel() const
* Méthodes *
*---------------------------------------------------------------------------*/
void LrSceneRayTracing::initialize(TabEntities &entities,
void LrSceneRayTracing::initialize(const LrEntityList &entities,
LrBinder *binder)
{
// stocker les entités et le binder
......@@ -112,26 +113,26 @@ void LrSceneRayTracing::computeScene()
void LrSceneRayTracing::generateImage(LrImage &image, const LrCamera &camera)
{
for (l = 0; l < image.getResolutionY; l++)
for (int l = 0; l < image.getWidth(); l++)
{
for (c = 0; c < image.getResolutionX; c++)
for (int c = 0; c < image.getHeight(); c++)
{
LrColor pixel = LrColor::BLUE;
for (i = 0; i < m_nbRayPerPixel; i++)
for (int i = 0; i < m_nbRayPerPixel; i++)
{
float u, v;
LrRay ray;
LrColor color;
// tirer u et v dans le pixel (l, c) aléatoirement
//dans un premier temps on prend le centre du pixel
u = ((c + 0.5) / image.getResolutionX) * 2 -1;
v = ((l + 0.5) / image.getResolutionY) * 2 -1;
u = ((c + 0.5) / image.getWidth()) * 2 -1;
v = ((l + 0.5) / image.getHeight()) * 2 -1;
ray = camera.getRay(u, v);
color = computeImageRay(ray);
pixel += color;
}
pixel /= m_nbRayPerPixel;
image.setPixel(l, c, pixel);
// pixel /= m_nbRayPerPixel; // >>>>>>>> À RÉSOUDRE !!!!!! <<<<<<<<<<<<
image.setPixel(pixel, l, c);
}
}
}
......@@ -142,20 +143,20 @@ LrColor LrSceneRayTracing::computeImageRay(const LrRay &ray)
LrColor colorResult = LrColor::BLUE;
LrRay newRay;
if (m_binder->getIntersection(ray, hit))
if (m_binder->getIntersection((LrRay &)ray, hit)) // >>>>>>>> À RÉSOUDRE !!!!!! <<<<<<<<<<<<
{
LrColor colorReflected;
LrColor colorRefracted;
LrColor colorSource = computeFromSource(ray, hit);
// rayon réfléchi
if (hit->optic.getReflectance()>0)
if (hit.optic->getReflectance()>0)
{
//calcul du rayon miroir du rayon lancé au niveau du point d'impact
//d' = d - 2(d.N).N
Real k = ray.getDirection()*hit.normal;
LrVector v_reflect = ray.getDirection()-(2*(k)*hit.normal);
newRay(v_reflect,hit.point);
// newRay(v_reflect,hit.point); // >>>>>>>> À RÉSOUDRE !!!!!! <<<<<<<<<<<<
colorReflected = computeImageRay(newRay);
}
......
......@@ -46,7 +46,7 @@ class LrSceneRayTracing : public LrScene
* @brief Méthode de clonage de LrSceneRayTracing.
* @return LrScene object.
*/
LrSceneRayTracing * clone() const;
virtual LrScene * clone();
/**
* @brief Constructeur personnel de LrSceneRayTracing.
......@@ -54,10 +54,10 @@ class LrSceneRayTracing : public LrScene
* @param camera Reference sur un objet LrCamera.
* @param nbRayPerPixel nombre de rayons lancés par pixel.
*/
LrSceneRayTracing(TabEntities &entities,
LrSceneRayTracing(const LrEntityList &entities,
LrBinder *binder,
LrImage &image,
LrCamera &camera,
LrImage *image,
LrCamera *camera,
int nbRayPerPixel);
/**
......@@ -80,7 +80,7 @@ class LrSceneRayTracing : public LrScene
* @param entities Liste de pointeurs vers des objets LrEntity.
* @param binder Pointeur vers la structure accéleratrice LrBinder.
*/
virtual void initialize(TabEntities &entities, LrBinder *binder);
virtual void initialize(const LrEntityList &entities, LrBinder *binder);
/**
* @brief Calcul indépendants de l'observateur, généralement
......@@ -120,7 +120,7 @@ class LrSceneRayTracing : public LrScene
// nombre de rayons a lancer par pixel
int m_nbRayPerPixel;
// pour un acces direct aux sources de lumiere
TabEntites m_lights;
LrEntityList m_lights;
};
......
......@@ -22,6 +22,14 @@ typedef double Real;
#define REAL_FORMAT "%lf"
#endif
#include <vector>
#include <list>
class LrEntity;
class LrOctree;
// typedef std::vector<LrEntity *> LrEntityVector;
typedef std::list<LrEntity *> LrEntityList;
typedef std::list<LrOctree *> LrOctreeList;
#ifndef X
#define X 0
#else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment