Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
CGoGN
CGoGN
Commits
e314968a
Commit
e314968a
authored
Jul 19, 2013
by
Thomas Jund
Browse files
Options
Browse Files
Download
Plain Diff
Merge cgogn.u-strasbg.fr:~thery/CGoGN
parents
d1a9cd6e
ca42b69e
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 @
e314968a
...
@@ -104,18 +104,17 @@ void ObjView::cb_redraw()
...
@@ -104,18 +104,17 @@ void ObjView::cb_redraw()
{
{
m_shader2
->
setTexture
(
mats
[
i
]
->
textureDiffuse
);
m_shader2
->
setTexture
(
mats
[
i
]
->
textureDiffuse
);
m_shader2
->
setShininess
(
mats
[
i
]
->
shininess
);
m_shader2
->
setShininess
(
mats
[
i
]
->
shininess
);
m_shader2
->
setAmbient
(
0.
3
f
);
m_shader2
->
setAmbient
(
0.
8
f
);
m_shader2
->
activeTexture
();
m_shader2
->
activeTexture
();
m_shader2
->
enableVertexAttribs
();
m_shader2
->
enableVertexAttribs
();
glDrawArrays
(
GL_TRIANGLES
,
m_obj
.
beginIndex
(
i
),
m_obj
.
nbIndices
(
i
));
glDrawArrays
(
GL_TRIANGLES
,
m_obj
.
beginIndex
(
i
),
m_obj
.
nbIndices
(
i
));
m_shader2
->
disableVertexAttribs
();
m_shader2
->
disableVertexAttribs
();
}
}
else
else
{
{
Geom
::
Vec4f
v
;
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
)
;
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
;
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
)
;
m_phongShader
->
setDiffuse
(
v
)
;
...
...
include/Algo/Import/importObjTex.h
View file @
e314968a
...
@@ -93,6 +93,8 @@ protected:
...
@@ -93,6 +93,8 @@ protected:
std
::
vector
<
unsigned
int
>
m_beginIndices
;
std
::
vector
<
unsigned
int
>
m_beginIndices
;
std
::
vector
<
unsigned
int
>
m_nbIndices
;
std
::
vector
<
unsigned
int
>
m_nbIndices
;
unsigned
int
m_maxTextureSize
;
/// vector of group name
/// vector of group name
// std::vector<std::string> m_groupNames;
// std::vector<std::string> m_groupNames;
// std::vector<std::string> m_groupMaterialNames;
// std::vector<std::string> m_groupMaterialNames;
...
@@ -149,6 +151,12 @@ public:
...
@@ -149,6 +151,12 @@ public:
~
OBJModel
();
~
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
* @brief set position attribute
* @param position attribute
* @param position attribute
...
@@ -231,7 +239,7 @@ public:
...
@@ -231,7 +239,7 @@ public:
* @brief read materials from files. Call after creating VBOs !!
* @brief read materials from files. Call after creating VBOs !!
* @param filename name of file
* @param filename name of file
*/
*/
void
readMaterials
(
unsigned
int
maxTextureSize
=
2048
,
const
std
::
string
&
filename
=
""
);
void
readMaterials
(
const
std
::
string
&
filename
=
""
);
/**
/**
* @brief getMaterials
* @brief getMaterials
...
...
include/Algo/Import/importObjTex.hpp
View file @
e314968a
...
@@ -41,7 +41,7 @@ namespace Import
...
@@ -41,7 +41,7 @@ namespace Import
template
<
typename
PFP
>
template
<
typename
PFP
>
OBJModel
<
PFP
>::
OBJModel
(
typename
PFP
::
MAP
&
map
)
:
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_tagV
(
0
),
m_tagVT
(
0
),
m_tagVN
(
0
),
m_tagG
(
0
),
m_tagF
(
0
),
m_specialVertices
(
map
),
m_dirtyEdges
(
map
)
m_specialVertices
(
map
),
m_dirtyEdges
(
map
)
{
{
...
@@ -55,6 +55,16 @@ OBJModel<PFP>::~OBJModel()
...
@@ -55,6 +55,16 @@ OBJModel<PFP>::~OBJModel()
delete
*
it
;
delete
*
it
;
}
}
template
<
typename
PFP
>
inline
void
OBJModel
<
PFP
>::
setMaxTextureSize
(
unsigned
int
mts
)
{
m_maxTextureSize
=
mts
;
}
template
<
typename
PFP
>
template
<
typename
PFP
>
inline
typename
PFP
::
VEC3
OBJModel
<
PFP
>::
getPosition
(
Dart
d
)
inline
typename
PFP
::
VEC3
OBJModel
<
PFP
>::
getPosition
(
Dart
d
)
{
{
...
@@ -62,6 +72,7 @@ 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
>
template
<
typename
PFP
>
inline
typename
PFP
::
VEC3
OBJModel
<
PFP
>::
getNormal
(
Dart
d
)
inline
typename
PFP
::
VEC3
OBJModel
<
PFP
>::
getNormal
(
Dart
d
)
{
{
...
@@ -105,7 +116,7 @@ void OBJModel<PFP>::setTexCoordAttribute(VertexAttribute<Geom::Vec2f>texcoord)
...
@@ -105,7 +116,7 @@ void OBJModel<PFP>::setTexCoordAttribute(VertexAttribute<Geom::Vec2f>texcoord)
template
<
typename
PFP
>
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
());
m_materials
.
reserve
(
m_materialNames
.
size
());
...
@@ -211,7 +222,7 @@ void OBJModel<PFP>::readMaterials(unsigned int /*maxTextureSize*/, const std::st
...
@@ -211,7 +222,7 @@ void OBJModel<PFP>::readMaterials(unsigned int /*maxTextureSize*/, const std::st
currentMat
->
textureDiffuse
->
load
(
m_matPath
+
tname
);
currentMat
->
textureDiffuse
->
load
(
m_matPath
+
tname
);
CGoGNout
<<
"Loading texture "
<<
m_matPath
+
tname
<<
" -> "
<<
std
::
hex
<<
currentMat
->
textureDiffuse
<<
std
::
dec
<<
CGoGNendl
;
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
->
setFiltering
(
GL_LINEAR
);
currentMat
->
textureDiffuse
->
setWrapping
(
GL_REPEAT
);
currentMat
->
textureDiffuse
->
setWrapping
(
GL_REPEAT
);
currentMat
->
textureDiffuse
->
update
();
currentMat
->
textureDiffuse
->
update
();
...
@@ -231,6 +242,7 @@ void OBJModel<PFP>::readMaterials(unsigned int /*maxTextureSize*/, const std::st
...
@@ -231,6 +242,7 @@ void OBJModel<PFP>::readMaterials(unsigned int /*maxTextureSize*/, const std::st
tname
=
tname
.
substr
(
0
,
tname
.
length
()
-
1
);
tname
=
tname
.
substr
(
0
,
tname
.
length
()
-
1
);
currentMat
->
textureDiffuse
->
load
(
m_matPath
+
tname
);
currentMat
->
textureDiffuse
->
load
(
m_matPath
+
tname
);
CGoGNout
<<
"Loading texture "
<<
m_matPath
+
tname
<<
" -> "
<<
std
::
hex
<<
currentMat
->
textureDiffuse
<<
std
::
dec
<<
CGoGNendl
;
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
->
setFiltering
(
GL_LINEAR
);
currentMat
->
textureDiffuse
->
setWrapping
(
GL_REPEAT
);
currentMat
->
textureDiffuse
->
setWrapping
(
GL_REPEAT
);
currentMat
->
textureDiffuse
->
update
();
currentMat
->
textureDiffuse
->
update
();
...
...
include/Utils/textures.hpp
View file @
e314968a
...
@@ -1095,7 +1095,6 @@ void Texture<DIM,TYPE>::update()
...
@@ -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
);
glTexImage1D
(
m_target
,
0
,
internalFormat
(),
this
->
m_size
[
0
],
0
,
format
(),
m_type
,
this
->
m_data_ptr
);
break
;
break
;
case
2
:
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
);
glTexImage2D
(
m_target
,
0
,
internalFormat
(),
this
->
m_size
[
0
],
this
->
m_size
[
1
],
0
,
format
(),
m_type
,
this
->
m_data_ptr
);
break
;
break
;
case
3
:
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