Commit 10f27bec authored by Emeric Verschuur's avatar Emeric Verschuur

--no commit message

--no commit message
parent 6f84c929
......@@ -49,7 +49,8 @@ LrScene::LrScene(const LrScene &source)
m_entities(source.m_entities),
m_binder(source.m_binder),
m_image(source.m_image),
m_camera(source.m_camera)
m_camera(source.m_camera),
m_antialiasing(source.m_antialiasing)
{
sem_init(&sem,0,0);
}
......@@ -57,12 +58,14 @@ LrScene::LrScene(const LrScene &source)
LrScene::LrScene(const LrEntityList &entities,
LrBinder *binder,
LrImage *image,
LrCamera *camera)
LrCamera *camera,
LrAntiAliasing *antialiasing)
:
m_entities(entities),
m_binder(binder),
m_image(image),
m_camera(camera)
m_camera(camera),
m_antialiasing(antialiasing)
{
sem_init(&sem,0,0);
}
......@@ -85,6 +88,7 @@ LrScene& LrScene::operator = (const LrScene &source)
m_binder = m_binder,
m_image = source.m_image;
m_camera = source.m_camera;
m_antialiasing = source.m_antialiasing;
return *this;
}
......@@ -139,7 +143,7 @@ struct __lr_generateimage_t{
pthread_mutex_t mut;
};
static void *__lr_generateimage(void *ptr){
void *LrScene::generateTask(void *ptr){
__lr_generateimage_t *p=(__lr_generateimage_t*)ptr;
int it;
while(true){
......@@ -200,7 +204,7 @@ void LrScene::generateImage(int nbThreads)
gettimeofday(&tvCalculBeg, NULL);
for( int i=0 ; i < nbThreads ; i++ ){
pthread_create(&thLst[i],NULL,__lr_generateimage,(void*)&ptr);
pthread_create(&thLst[i],NULL,LrScene::generateTask,(void*)&ptr);
}
const char *curs="-\\|/";
......
......@@ -23,6 +23,7 @@
#include "LrBinder.h"
#include "LrCamera.h"
#include "LrImage.h"
#include "LrAntiAliasing.h"
/**
* @brief SCENE : Generation de la scene.
......@@ -61,7 +62,8 @@ class LrScene
LrScene(const LrEntityList &entities,
LrBinder *binder,
LrImage *image,
LrCamera *camera);
LrCamera *camera,
LrAntiAliasing *antialiasing);
/**
* @brief Destructeur de LrScene.
......@@ -121,6 +123,8 @@ class LrScene
* @param nbThreads le nombre de threads a lancer pour le calcul
*/
void generateImage(int nbThreads=1);
protected :
/**
* @brief Methode abstraite pour la génération des images.
......@@ -129,13 +133,16 @@ class LrScene
* @param lNb entier correspondant au nombre de lignes a calculer
*/
virtual void generateImagePart(int lOffset, int lNb)=0;
protected :
//L'AntiAliasing a appliquer a la scene
LrEntityList m_entities;
LrBinder *m_binder;
LrImage *m_image;
LrCamera *m_camera;
LrAntiAliasing *m_antialiasing;
sem_t sem;
static void *generateTask(void *ptr);
};
#endif
......@@ -30,7 +30,6 @@ LrSceneRayTracing::LrSceneRayTracing()
:
LrScene(),
m_lights(),
m_antialiasing(),
m_nbRebonds()
{
}
......@@ -41,7 +40,6 @@ LrSceneRayTracing::LrSceneRayTracing(const LrSceneRayTracing &source)
:
LrScene(source),
m_lights(source.m_lights),
m_antialiasing(source.m_antialiasing),
m_nbRebonds(source.m_nbRebonds)
{
......@@ -57,9 +55,8 @@ LrSceneRayTracing::LrSceneRayTracing(const LrEntityList &entities,
LrAntiAliasing *antialiasing,
int nbRebonds)
:
LrScene(entities, binder, image, camera),
LrScene(entities, binder, image, camera, antialiasing),
m_lights(lights),
m_antialiasing(antialiasing),
m_nbRebonds(nbRebonds)
{
......@@ -82,7 +79,6 @@ LrSceneRayTracing&
LrScene::operator = (source);
m_lights = source.m_lights;
m_antialiasing = source.m_antialiasing;
m_nbRebonds = source.m_nbRebonds;
return *this;
......
......@@ -22,7 +22,6 @@
#include "LrHit.h"
#include "LrEntityLight.h"
#include "LrVector.h"
#include "LrAntiAliasing.h"
/**
* @brief SCENE : Generation de la scene par la methode de lancer de rayons.
......@@ -77,16 +76,6 @@ public :
*/
LrSceneRayTracing & operator = (const LrSceneRayTracing &source);
/**
* @brief Methode abstraite pour la génération des images.
* @brief Genere une partie de l'image
* @param lOffset entier correspondant a ligne de depart
* @param lNb entier correspondant au nombre de lignes a calculer
*/
virtual void generateImagePart(int lOffset, int lNb);
/**
* @brief Phase préparatoire à tout calcul.
*/
......@@ -106,13 +95,21 @@ public :
* @param hit Reference sur un objet LrHit.
* @return La couleur LrColor de l'influence des sources lumineuses
*/
LrColor computeFromSource(const LrRay &ray, LrHit &hit);
LrColor computeFromSource(const LrRay &ray, LrHit &hit);
protected:
/**
* @brief Methode abstraite pour la génération des images.
* @brief Genere une partie de l'image
* @param lOffset entier correspondant a ligne de depart
* @param lNb entier correspondant au nombre de lignes a calculer
*/
virtual void generateImagePart(int lOffset, int lNb);
private :
// pour un acces direct aux sources de lumiere
LrEntityList m_lights;
//L'AntiAliasing a appliquer a la scene
LrAntiAliasing *m_antialiasing;
//nombre de rebonds
int m_nbRebonds;
/**
......
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