Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
lray
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Emeric Verschuur
lray
Commits
59b49075
Commit
59b49075
authored
Mar 15, 2008
by
Emeric Verschuur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Beaucoup de correction d'erreur. Ajout de LrEntityList, LrOctreeList dans config.h
parent
5dc3f272
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
69 additions
and
72 deletions
+69
-72
LrBinder.h
LrBinder.h
+3
-5
LrCamera.cpp
LrCamera.cpp
+3
-3
LrImage.h
LrImage.h
+1
-1
LrOctree.cpp
LrOctree.cpp
+6
-6
LrOctree.h
LrOctree.h
+2
-5
LrPoint.cpp
LrPoint.cpp
+1
-1
LrScene.cpp
LrScene.cpp
+8
-13
LrScene.h
LrScene.h
+13
-15
LrSceneRayTracing.cpp
LrSceneRayTracing.cpp
+18
-17
LrSceneRayTracing.h
LrSceneRayTracing.h
+6
-6
global.h
global.h
+8
-0
No files found.
LrBinder.h
View file @
59b49075
...
...
@@ -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
:
L
istObjec
t
m_liste_objets
;
//la liste d'objet
L
rEntityLis
t
m_liste_objets
;
//la liste d'objet
public
:
typedef
list
<
LrEntity
*>
ListObject
;
LrBinder
();
LrBinder
(
const
LrBinder
&
source
);
LrBinder
(
L
istObjec
t
l
);
LrBinder
(
L
rEntityLis
t
l
);
virtual
~
LrBinder
()
=
0
;
...
...
@@ -41,4 +40,3 @@ class LrBinder
virtual
bool
getIntersection
(
LrRay
&
ray
,
LrHit
&
hit
);
};
#endif
\ No newline at end of file
LrCamera.cpp
View file @
59b49075
...
...
@@ -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
.
normali
ser
();
m_horizontal
.
normali
ser
();
m_direction
.
normali
ser
();
m_vertical
.
normali
ze
();
m_horizontal
.
normali
ze
();
m_direction
.
normali
ze
();
}
LrCamera
::~
LrCamera
()
{
...
...
LrImage.h
View file @
59b49075
...
...
@@ -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
...
...
LrOctree.cpp
View file @
59b49075
...
...
@@ -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
++
)
Lr
EntityList
::
iterator
itObj_rhs
=
rhstemp
.
m_listeObj
.
begin
();
for
(
Lr
EntityList
::
iterator
itObj_lhs
=
lhstemp
.
m_listeObj
.
begin
();
itObj_lhs
!=
lhstemp
.
m_listeObj
.
end
();
itObj_lhs
++
)
{
res
=
res
&&
(
*
itObj_lhs
==
*
itObj_rhs
);
itObj_rhs
++
;
}
OctreeSon
List
::
iterator
itOct_rhs
=
rhstemp
.
m_listeOct
.
begin
();
OctreeSon
List
::
iterator
itOct_lhs
;
LrOctree
List
::
iterator
itOct_rhs
=
rhstemp
.
m_listeOct
.
begin
();
LrOctree
List
::
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
)
{
OctreeSon
List
::
iterator
it
=
((
LrOctree
*
)
this
)
->
m_listeOct
.
begin
();
LrOctree
List
::
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
();
Lr
EntityList
::
iterator
it
=
((
LrOctree
*
)
this
)
->
m_listeObj
.
begin
();
int
i
=
0
;
while
(
i
!=
index
)
it
++
;
return
*
it
;
...
...
LrOctree.h
View file @
59b49075
...
...
@@ -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
// ***************************
...
...
LrPoint.cpp
View file @
59b49075
...
...
@@ -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
)
{
}
...
...
LrScene.cpp
View file @
59b49075
...
...
@@ -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
::
set
Direction
(
const
LrImage
&
image
)
void
LrScene
::
set
Image
(
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
;
}
...
...
LrScene.h
View file @
59b49075
...
...
@@ -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
;
};
...
...
LrSceneRayTracing.cpp
View file @
59b49075
...
...
@@ -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)
{
}
LrScene
RayTracing
*
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
(
i
nt
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
.
get
ResolutionX
)
*
2
-
1
;
v
=
((
l
+
0.5
)
/
image
.
get
ResolutionY
)
*
2
-
1
;
u
=
((
c
+
0.5
)
/
image
.
get
Width
()
)
*
2
-
1
;
v
=
((
l
+
0.5
)
/
image
.
get
Height
()
)
*
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
);
}
...
...
LrSceneRayTracing.h
View file @
59b49075
...
...
@@ -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
;
};
...
...
global.h
View file @
59b49075
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment