Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
CGoGN
CGoGN
Commits
32c430ec
Commit
32c430ec
authored
Oct 04, 2013
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor bugs & optim
parent
895926cd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
38 deletions
+93
-38
Apps/Examples/viewerOBJ.cpp
Apps/Examples/viewerOBJ.cpp
+78
-30
Apps/Examples/viewerOBJ.h
Apps/Examples/viewerOBJ.h
+5
-0
src/Container/attributeContainer.cpp
src/Container/attributeContainer.cpp
+6
-4
src/Utils/drawer.cpp
src/Utils/drawer.cpp
+4
-4
No files found.
Apps/Examples/viewerOBJ.cpp
View file @
32c430ec
...
...
@@ -27,13 +27,15 @@
#include "Algo/Modelisation/polyhedron.h"
#include "Utils/vbo.h"
ObjView
::
ObjView
()
:
m_obj
(
myMap
),
m_positionVBO
(
NULL
),
m_normalVBO
(
NULL
),
m_texcoordVBO
(
NULL
),
m_shader
(
NULL
),
m_shader2
(
NULL
)
m_shader2
(
NULL
),
m_RenderStyle
(
2
)
{}
ObjView
::~
ObjView
()
...
...
@@ -53,6 +55,27 @@ ObjView::~ObjView()
delete
m_texcoordVBO
;
}
void
ObjView
::
cb_keyPress
(
int
k
)
{
switch
(
k
)
{
case
'm'
:
m_RenderStyle
=
0
;
break
;
case
'c'
:
m_RenderStyle
=
1
;
break
;
case
't'
:
m_RenderStyle
=
2
;
break
;
default:
break
;
}
updateGL
();
}
void
ObjView
::
cb_initGL
()
{
// choose to use GL version 2
...
...
@@ -63,12 +86,6 @@ void ObjView::cb_initGL()
m_texcoordVBO
=
new
Utils
::
VBO
;
m_normalVBO
=
new
Utils
::
VBO
;
// m_shader = new Utils::ShaderSimpleTexture();
// m_shader->setAttributePosition(m_positionVBO);
// m_shader->setAttributeTexCoord(m_texcoordVBO);
// m_shader->setTextureUnit(GL_TEXTURE0);
// registerShader(m_shader);
m_shader2
=
new
Utils
::
ShaderPhongTexture
();
m_shader2
->
setAttributePosition
(
m_positionVBO
);
m_shader2
->
setAttributeTexCoord
(
m_texcoordVBO
);
...
...
@@ -100,30 +117,61 @@ void ObjView::cb_redraw()
for
(
unsigned
int
i
=
0
;
i
<
nb
;
++
i
)
{
if
(
mats
[
i
]
->
textureDiffuse
!=
NULL
)
{
m_shader2
->
setTexture
(
mats
[
i
]
->
textureDiffuse
);
m_shader2
->
setShininess
(
mats
[
i
]
->
shininess
);
m_shader2
->
setAmbient
(
0.8
f
);
m_shader2
->
activeTexture
();
m_shader2
->
enableVertexAttribs
();
glDrawArrays
(
GL_TRIANGLES
,
m_obj
.
beginIndex
(
i
),
m_obj
.
nbIndices
(
i
));
m_shader2
->
disableVertexAttribs
();
}
else
switch
(
m_RenderStyle
)
{
Geom
::
Vec4f
v
;
// v[0] = mats[i]->ambiantColor[0]; v[1] = mats[i]->ambiantColor[1]; v[2] = mats[i]->ambiantColor[2]; v[3] = 0.0f;
v
[
0
]
=
0.5
f
;
v
[
1
]
=
0.5
f
;
v
[
2
]
=
0.5
f
;
v
[
3
]
=
0.0
f
;
m_phongShader
->
setAmbiant
(
v
)
;
v
[
0
]
=
mats
[
i
]
->
diffuseColor
[
0
];
v
[
1
]
=
mats
[
i
]
->
diffuseColor
[
1
];
v
[
2
]
=
mats
[
i
]
->
diffuseColor
[
2
];
v
[
3
]
=
0.0
f
;
m_phongShader
->
setDiffuse
(
v
)
;
v
[
0
]
=
mats
[
i
]
->
specularColor
[
0
];
v
[
1
]
=
mats
[
i
]
->
specularColor
[
1
];
v
[
2
]
=
mats
[
i
]
->
specularColor
[
2
];
v
[
3
]
=
0.0
f
;
m_phongShader
->
setSpecular
(
v
)
;
m_phongShader
->
setShininess
(
mats
[
i
]
->
shininess
)
;
m_phongShader
->
enableVertexAttribs
();
glDrawArrays
(
GL_TRIANGLES
,
m_obj
.
beginIndex
(
i
),
m_obj
.
nbIndices
(
i
));
m_phongShader
->
disableVertexAttribs
();
case
0
:
// MONO
{
Geom
::
Vec4f
v
(
0.2
f
,
1.0
f
,
0.4
f
,
0.0
f
);
// color here green
m_phongShader
->
setAmbiant
(
0.2
f
*
v
)
;
m_phongShader
->
setDiffuse
(
v
)
;
// v[0] = 1.0f; v[1] = 1.0f; v[2] = 1.0f; v[3] = 0.0f; // use this for specular effected
m_phongShader
->
setSpecular
(
v
)
;
m_phongShader
->
setShininess
(
10000.0
)
;
m_phongShader
->
enableVertexAttribs
();
glDrawArrays
(
GL_TRIANGLES
,
m_obj
.
beginIndex
(
i
),
m_obj
.
nbIndices
(
i
));
m_phongShader
->
disableVertexAttribs
();
}
break
;
case
1
:
// COLOR
{
Geom
::
Vec4f
v
(
mats
[
i
]
->
diffuseColor
[
0
],
mats
[
i
]
->
diffuseColor
[
1
],
mats
[
i
]
->
diffuseColor
[
2
],
0.0
f
);
m_phongShader
->
setAmbiant
(
0.2
f
*
v
)
;
m_phongShader
->
setDiffuse
(
v
)
;
// v[0] = 1.0f; v[1] = 1.0f; v[2] = 1.0f; v[3] = 0.0f; // use this for specular effected
m_phongShader
->
setSpecular
(
v
)
;
m_phongShader
->
setShininess
(
10000.0
)
;
m_phongShader
->
enableVertexAttribs
();
glDrawArrays
(
GL_TRIANGLES
,
m_obj
.
beginIndex
(
i
),
m_obj
.
nbIndices
(
i
));
m_phongShader
->
disableVertexAttribs
();
}
default:
{
if
(
mats
[
i
]
->
textureDiffuse
!=
NULL
)
{
m_shader2
->
setTexture
(
mats
[
i
]
->
textureDiffuse
);
m_shader2
->
setShininess
(
mats
[
i
]
->
shininess
);
m_shader2
->
setAmbient
(
0.8
f
);
m_shader2
->
activeTexture
();
m_shader2
->
enableVertexAttribs
();
glDrawArrays
(
GL_TRIANGLES
,
m_obj
.
beginIndex
(
i
),
m_obj
.
nbIndices
(
i
));
m_shader2
->
disableVertexAttribs
();
}
else
{
Geom
::
Vec4f
v
;
v
[
0
]
=
0.5
f
;
v
[
1
]
=
0.5
f
;
v
[
2
]
=
0.5
f
;
v
[
3
]
=
0.0
f
;
m_phongShader
->
setAmbiant
(
v
)
;
v
[
0
]
=
mats
[
i
]
->
diffuseColor
[
0
];
v
[
1
]
=
mats
[
i
]
->
diffuseColor
[
1
];
v
[
2
]
=
mats
[
i
]
->
diffuseColor
[
2
];
v
[
3
]
=
0.0
f
;
m_phongShader
->
setDiffuse
(
v
)
;
v
[
0
]
=
mats
[
i
]
->
specularColor
[
0
];
v
[
1
]
=
mats
[
i
]
->
specularColor
[
1
];
v
[
2
]
=
mats
[
i
]
->
specularColor
[
2
];
v
[
3
]
=
0.0
f
;
m_phongShader
->
setSpecular
(
v
)
;
m_phongShader
->
setShininess
(
mats
[
i
]
->
shininess
)
;
m_phongShader
->
enableVertexAttribs
();
glDrawArrays
(
GL_TRIANGLES
,
m_obj
.
beginIndex
(
i
),
m_obj
.
nbIndices
(
i
));
m_phongShader
->
disableVertexAttribs
();
}
}
}
}
}
...
...
Apps/Examples/viewerOBJ.h
View file @
32c430ec
...
...
@@ -77,6 +77,8 @@ public:
Utils
::
ShaderPhongTexture
*
m_shader2
;
Utils
::
ShaderPhong
*
m_phongShader
;
int
m_RenderStyle
;
ObjView
();
~
ObjView
();
...
...
@@ -88,6 +90,9 @@ public:
void
cb_initGL
();
void
cb_keyPress
(
int
k
);
};
#endif
src/Container/attributeContainer.cpp
View file @
32c430ec
...
...
@@ -174,11 +174,13 @@ void AttributeContainer::clear(bool removeAttrib)
for
(
std
::
vector
<
HoleBlockRef
*>::
iterator
it
=
m_holesBlocks
.
begin
();
it
!=
m_holesBlocks
.
end
();
++
it
)
delete
(
*
it
);
std
::
vector
<
HoleBlockRef
*>
bf
;
m_holesBlocks
.
swap
(
bf
);
{
// add bracket just for scope of temporary vectors
std
::
vector
<
HoleBlockRef
*>
bf
;
m_holesBlocks
.
swap
(
bf
);
std
::
vector
<
unsigned
int
>
bwf
;
m_tableBlocksWithFree
.
swap
(
bwf
);
std
::
vector
<
unsigned
int
>
bwf
;
m_tableBlocksWithFree
.
swap
(
bwf
);
}
// detruit les données
for
(
std
::
vector
<
AttributeMultiVectorGen
*>::
iterator
it
=
m_tableAttribs
.
begin
();
it
!=
m_tableAttribs
.
end
();
++
it
)
...
...
src/Utils/drawer.cpp
View file @
32c430ec
...
...
@@ -185,7 +185,7 @@ void Drawer::callList(float opacity)
{
if
(
pp
->
mode
==
GL_POINTS
)
glPointSize
(
pp
->
width
);
if
((
pp
->
mode
==
GL_LINES
)
||
(
pp
->
mode
==
GL_LINE_LOOP
))
if
((
pp
->
mode
==
GL_LINES
)
||
(
pp
->
mode
==
GL_LINE_LOOP
)
||
(
pp
->
mode
==
GL_LINE_STRIP
)
)
glLineWidth
(
pp
->
width
);
glDrawArrays
(
pp
->
mode
,
pp
->
begin
,
pp
->
nb
);
}
...
...
@@ -206,7 +206,7 @@ void Drawer::callSubList(int index, float opacity)
if
(
pp
->
mode
==
GL_POINTS
)
glPointSize
(
pp
->
width
);
if
((
pp
->
mode
==
GL_LINES
)
||
(
pp
->
mode
==
GL_LINE_LOOP
))
if
((
pp
->
mode
==
GL_LINES
)
||
(
pp
->
mode
==
GL_LINE_LOOP
)
||
(
pp
->
mode
==
GL_LINE_STRIP
)
)
glLineWidth
(
pp
->
width
);
glDrawArrays
(
pp
->
mode
,
pp
->
begin
,
pp
->
nb
);
...
...
@@ -226,7 +226,7 @@ void Drawer::callSubLists(int first, int nb, float opacity)
if
(
pp
->
mode
==
GL_POINTS
)
glPointSize
(
pp
->
width
);
if
((
pp
->
mode
==
GL_LINES
)
||
(
pp
->
mode
==
GL_LINE_LOOP
))
if
((
pp
->
mode
==
GL_LINES
)
||
(
pp
->
mode
==
GL_LINE_LOOP
)
||
(
pp
->
mode
==
GL_LINE_STRIP
)
)
glLineWidth
(
pp
->
width
);
glDrawArrays
(
pp
->
mode
,
pp
->
begin
,
pp
->
nb
);
}
...
...
@@ -247,7 +247,7 @@ void Drawer::callSubLists(std::vector<int> indices, float opacity)
if
(
pp
->
mode
==
GL_POINTS
)
glPointSize
(
pp
->
width
);
if
((
pp
->
mode
==
GL_LINES
)
||
(
pp
->
mode
==
GL_LINE_LOOP
))
if
((
pp
->
mode
==
GL_LINES
)
||
(
pp
->
mode
==
GL_LINE_LOOP
)
||
(
pp
->
mode
==
GL_LINE_STRIP
)
)
glLineWidth
(
pp
->
width
);
glDrawArrays
(
pp
->
mode
,
pp
->
begin
,
pp
->
nb
);
}
...
...
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