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
ca42b69e
Commit
ca42b69e
authored
Jul 19, 2013
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor modifs for viewerOBJ
parent
5d78847f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
9 deletions
+27
-9
Apps/Examples/viewerOBJ.cpp
Apps/Examples/viewerOBJ.cpp
+3
-4
include/Algo/Import/importObjTex.h
include/Algo/Import/importObjTex.h
+9
-1
include/Algo/Import/importObjTex.hpp
include/Algo/Import/importObjTex.hpp
+15
-3
include/Utils/textures.hpp
include/Utils/textures.hpp
+0
-1
No files found.
Apps/Examples/viewerOBJ.cpp
View file @
ca42b69e
...
...
@@ -104,18 +104,17 @@ void ObjView::cb_redraw()
{
m_shader2
->
setTexture
(
mats
[
i
]
->
textureDiffuse
);
m_shader2
->
setShininess
(
mats
[
i
]
->
shininess
);
m_shader2
->
setAmbient
(
0.
3
f
);
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
]
=
mats
[
i
]
->
ambiantColor
[
0
];
v
[
1
]
=
mats
[
i
]
->
ambiantColor
[
1
];
v
[
2
]
=
mats
[
i
]
->
ambiantColor
[
2
];
v
[
3
]
=
0.0
f
;
// 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
)
;
...
...
include/Algo/Import/importObjTex.h
View file @
ca42b69e
...
...
@@ -93,6 +93,8 @@ protected:
std
::
vector
<
unsigned
int
>
m_beginIndices
;
std
::
vector
<
unsigned
int
>
m_nbIndices
;
unsigned
int
m_maxTextureSize
;
/// vector of group name
// std::vector<std::string> m_groupNames;
// std::vector<std::string> m_groupMaterialNames;
...
...
@@ -149,6 +151,12 @@ public:
~
OBJModel
();
/**
* @brief resize texture (at import) to max size
* @param mts max texture size in x & y
*/
void
setMaxTextureSize
(
unsigned
int
mts
);
/**
* @brief set position attribute
* @param position attribute
...
...
@@ -231,7 +239,7 @@ public:
* @brief read materials from files. Call after creating VBOs !!
* @param filename name of file
*/
void
readMaterials
(
unsigned
int
maxTextureSize
=
2048
,
const
std
::
string
&
filename
=
""
);
void
readMaterials
(
const
std
::
string
&
filename
=
""
);
/**
* @brief getMaterials
...
...
include/Algo/Import/importObjTex.hpp
View file @
ca42b69e
...
...
@@ -41,7 +41,7 @@ namespace Import
template
<
typename
PFP
>
OBJModel
<
PFP
>::
OBJModel
(
typename
PFP
::
MAP
&
map
)
:
m_map
(
map
),
m_map
(
map
),
m_maxTextureSize
(
2048
),
m_tagV
(
0
),
m_tagVT
(
0
),
m_tagVN
(
0
),
m_tagG
(
0
),
m_tagF
(
0
),
m_specialVertices
(
map
),
m_dirtyEdges
(
map
)
{
...
...
@@ -55,6 +55,16 @@ OBJModel<PFP>::~OBJModel()
delete
*
it
;
}
template
<
typename
PFP
>
inline
void
OBJModel
<
PFP
>::
setMaxTextureSize
(
unsigned
int
mts
)
{
m_maxTextureSize
=
mts
;
}
template
<
typename
PFP
>
inline
typename
PFP
::
VEC3
OBJModel
<
PFP
>::
getPosition
(
Dart
d
)
{
...
...
@@ -62,6 +72,7 @@ inline typename PFP::VEC3 OBJModel<PFP>::getPosition(Dart d)
}
template
<
typename
PFP
>
inline
typename
PFP
::
VEC3
OBJModel
<
PFP
>::
getNormal
(
Dart
d
)
{
...
...
@@ -105,7 +116,7 @@ void OBJModel<PFP>::setTexCoordAttribute(VertexAttribute<Geom::Vec2f>texcoord)
template
<
typename
PFP
>
void
OBJModel
<
PFP
>::
readMaterials
(
unsigned
int
/*maxTextureSize*/
,
const
std
::
string
&
filename
)
void
OBJModel
<
PFP
>::
readMaterials
(
const
std
::
string
&
filename
)
{
m_materials
.
reserve
(
m_materialNames
.
size
());
...
...
@@ -211,7 +222,7 @@ void OBJModel<PFP>::readMaterials(unsigned int /*maxTextureSize*/, const std::st
currentMat
->
textureDiffuse
->
load
(
m_matPath
+
tname
);
CGoGNout
<<
"Loading texture "
<<
m_matPath
+
tname
<<
" -> "
<<
std
::
hex
<<
currentMat
->
textureDiffuse
<<
std
::
dec
<<
CGoGNendl
;
// currentMat->textureDiffuse->scaleNearest( currentMat->textureDiffuse->newMaxSize(
maxTextureSize));
currentMat
->
textureDiffuse
->
scaleNearest
(
currentMat
->
textureDiffuse
->
newMaxSize
(
m_
maxTextureSize
));
currentMat
->
textureDiffuse
->
setFiltering
(
GL_LINEAR
);
currentMat
->
textureDiffuse
->
setWrapping
(
GL_REPEAT
);
currentMat
->
textureDiffuse
->
update
();
...
...
@@ -231,6 +242,7 @@ void OBJModel<PFP>::readMaterials(unsigned int /*maxTextureSize*/, const std::st
tname
=
tname
.
substr
(
0
,
tname
.
length
()
-
1
);
currentMat
->
textureDiffuse
->
load
(
m_matPath
+
tname
);
CGoGNout
<<
"Loading texture "
<<
m_matPath
+
tname
<<
" -> "
<<
std
::
hex
<<
currentMat
->
textureDiffuse
<<
std
::
dec
<<
CGoGNendl
;
currentMat
->
textureDiffuse
->
scaleNearest
(
currentMat
->
textureDiffuse
->
newMaxSize
(
m_maxTextureSize
));
currentMat
->
textureDiffuse
->
setFiltering
(
GL_LINEAR
);
currentMat
->
textureDiffuse
->
setWrapping
(
GL_REPEAT
);
currentMat
->
textureDiffuse
->
update
();
...
...
include/Utils/textures.hpp
View file @
ca42b69e
...
...
@@ -1095,7 +1095,6 @@ void Texture<DIM,TYPE>::update()
glTexImage1D
(
m_target
,
0
,
internalFormat
(),
this
->
m_size
[
0
],
0
,
format
(),
m_type
,
this
->
m_data_ptr
);
break
;
case
2
:
std
::
cout
<<
"updateSize: "
<<
this
->
m_size
[
0
]
<<
" / "
<<
this
->
m_size
[
1
]
<<
std
::
endl
;
glTexImage2D
(
m_target
,
0
,
internalFormat
(),
this
->
m_size
[
0
],
this
->
m_size
[
1
],
0
,
format
(),
m_type
,
this
->
m_data_ptr
);
break
;
case
3
:
...
...
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