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
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sauvage
CGoGN
Commits
877cc473
Commit
877cc473
authored
Feb 28, 2011
by
untereiner
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of cgogn:~thery/CGoGN
parents
f348eec9
53c1e31e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
31 deletions
+67
-31
Apps/Tuto/tuto5.cpp
Apps/Tuto/tuto5.cpp
+25
-4
include/Algo/Render/topo3_vboRender.h
include/Algo/Render/topo3_vboRender.h
+5
-0
include/Algo/Render/topo3_vboRender.hpp
include/Algo/Render/topo3_vboRender.hpp
+9
-15
src/Algo/Render/topo3_vboRender.cpp
src/Algo/Render/topo3_vboRender.cpp
+28
-12
No files found.
Apps/Tuto/tuto5.cpp
View file @
877cc473
...
...
@@ -108,9 +108,26 @@ void myGlutWin::myRedraw(void)
glTranslatef
(
-
gPosObj
[
0
],
-
gPosObj
[
1
],
-
gPosObj
[
2
]);
glPolygonMode
(
GL_FRONT_AND_BACK
,
GL_FILL
);
glDisable
(
GL_LIGHTING
);
glLineWidth
(
3.0
);
glBegin
(
GL_LINES
);
glColor3f
(
1.
,
0.
,
0.
);
glVertex3f
(
0.0
,
0.0
,
0.0
);
glVertex3f
(
1.0
,
0.0
,
0.0
);
glColor3f
(
0.
,
1.
,
0.
);
glVertex3f
(
0.0
,
0.0
,
0.0
);
glVertex3f
(
0.0
,
1.0
,
0.0
);
glColor3f
(
0.
,
0.
,
1.
);
glVertex3f
(
0.0
,
0.0
,
0.0
);
glVertex3f
(
0.0
,
0.0
,
1.0
);
glEnd
();
glColor3f
(
0.0
f
,
1.0
f
,
.0
f
);
m_render
->
draw
(
Algo
::
Render
::
VBO
::
POINTS
);
...
...
@@ -187,6 +204,7 @@ void myGlutWin::myKeyboard(unsigned char keycode, int x, int y)
}
break
;
case
'x'
:
{
// push/pop color is only needed for dart coloring conservation
...
...
@@ -203,22 +221,23 @@ void myGlutWin::myKeyboard(unsigned char keycode, int x, int y)
glTranslatef
(
-
gPosObj
[
0
],
-
gPosObj
[
1
],
-
gPosObj
[
2
]);
//pick
Dart
d
=
m_render_topo
->
picking
(
x
,
H
-
y
);
glPopMatrix
();
m_render_topo
->
popColors
();
if
(
d
!=
Dart
::
nil
())
if
(
d
!=
Dart
::
nil
())
{
m_render_topo
->
setDartColor
(
d
,
1.0
,
0.0
,
0.0
);
redraw
();
std
::
stringstream
ss
;
ss
<<
"Pick dart:"
<<
d
<<
std
::
endl
<<
"pos="
<<
position
[
d
];
glColor3f
(
1.
,
1.
,
0.
);
printString2D
(
x
+
12
,
y
+
22
,
ss
.
str
());
glutSwapBuffers
();
// std::cout << "Pick dart:" << d << " position= "<< position[d] << std::endl;
std
::
cout
<<
"Pick dart:"
<<
d
<<
std
::
endl
;
std
::
cout
<<
"Pick dart:"
<<
d
<<
" pos= "
<<
position
[
d
]
<<
std
::
endl
;
}
// in console:
break
;
}
...
...
@@ -427,6 +446,8 @@ int main(int argc, char **argv)
nb
=
atoi
(
argv
[
1
]);
dglobal
=
prim
.
hexaGrid_topo
(
nb
,
nb
,
nb
);
prim
.
embedHexaGrid
(
1.0
f
,
1.0
f
,
1.0
f
);
// Geom::Matrix44f mat;
// mat.identity();
// Geom::scale(2.0f, 2.0f,2.0f,mat);
...
...
include/Algo/Render/topo3_vboRender.h
View file @
877cc473
...
...
@@ -118,6 +118,11 @@ protected:
public:
Dart
colToDart
(
float
*
color
);
void
dartToCol
(
Dart
d
,
float
&
r
,
float
&
g
,
float
&
b
);
/**
* Constructor
* @param map the map to draw
...
...
include/Algo/Render/topo3_vboRender.hpp
View file @
877cc473
...
...
@@ -905,21 +905,15 @@ void topo3_VBORender::setDartsIdColor(typename PFP::MAP& map, const FunctorSelec
{
if
(
good
(
d
))
{
unsigned
int
lab
=
d
.
index
+
1
;
// add one to avoid picking the black of screen
float
r
=
float
(
lab
%
256
)
/
256.0
f
;
lab
=
lab
/
256
;
float
g
=
float
(
lab
%
256
)
/
256.0
f
;
lab
=
lab
/
256
;
float
b
=
float
(
lab
%
256
)
/
256.0
f
;
lab
=
lab
/
256
;
if
(
lab
!=
0
)
std
::
cerr
<<
"Error picking color, too many darts"
<<
std
::
endl
;
*
colorBuffer
++
=
r
;
*
colorBuffer
++
=
g
;
*
colorBuffer
++
=
b
;
*
colorBuffer
++
=
r
;
*
colorBuffer
++
=
g
;
*
colorBuffer
++
=
b
;
float
r
,
g
,
b
;
dartToCol
(
d
,
r
,
g
,
b
);
float
*
local
=
colorBuffer
+
3
*
m_attIndex
[
d
];
// get the right position in VBO
*
local
++
=
r
;
*
local
++
=
g
;
*
local
++
=
b
;
*
local
++
=
r
;
*
local
++
=
g
;
*
local
++
=
b
;
nb
++
;
}
...
...
src/Algo/Render/topo3_vboRender.cpp
View file @
877cc473
...
...
@@ -98,7 +98,7 @@ void topo3_VBORender::setAllDartsColor(float r, float g, float b)
void
topo3_VBORender
::
drawDarts
()
{
glColor3f
(
1.0
f
,
1.0
f
,
1.0
f
);
//
glColor3f(1.0f,1.0f,1.0f);
glLineWidth
(
m_topo_dart_width
);
glPointSize
(
2.0
f
*
m_topo_dart_width
);
...
...
@@ -214,6 +214,32 @@ void topo3_VBORender::popColors()
}
Dart
topo3_VBORender
::
colToDart
(
float
*
color
)
{
unsigned
int
r
=
(
unsigned
int
)(
color
[
0
]
*
255.0
f
);
unsigned
int
g
=
(
unsigned
int
)(
color
[
1
]
*
255.0
f
);
unsigned
int
b
=
(
unsigned
int
)(
color
[
2
]
*
255.0
f
);
unsigned
int
id
=
r
+
255
*
g
+
255
*
255
*
b
;
if
(
id
==
0
)
return
Dart
::
nil
();
return
Dart
(
id
-
1
);
}
void
topo3_VBORender
::
dartToCol
(
Dart
d
,
float
&
r
,
float
&
g
,
float
&
b
)
{
unsigned
int
lab
=
d
.
index
+
1
;
// add one to avoid picking the black of screen
r
=
float
(
lab
%
255
)
/
255.0
f
;
lab
=
lab
/
255
;
g
=
float
(
lab
%
255
)
/
255.0
f
;
lab
=
lab
/
255
;
b
=
float
(
lab
%
255
)
/
255.0
f
;
lab
=
lab
/
255
;
if
(
lab
!=
0
)
std
::
cerr
<<
"Error picking color, too many darts"
<<
std
::
endl
;
}
Dart
topo3_VBORender
::
picking
(
unsigned
int
x
,
unsigned
int
y
)
{
//more easy picking for
...
...
@@ -241,17 +267,7 @@ Dart topo3_VBORender::picking(unsigned int x, unsigned int y)
glClearColor
(
cc
[
0
],
cc
[
1
],
cc
[
2
],
cc
[
3
]);
// compute dart index:
unsigned
int
r
=
(
unsigned
int
)(
color
[
0
]
*
255.0
f
);
unsigned
int
g
=
(
unsigned
int
)(
color
[
1
]
*
255.0
f
);
unsigned
int
b
=
(
unsigned
int
)(
color
[
2
]
*
255.0
f
);
unsigned
int
id
=
r
+
256
*
g
+
256
*
256
*
b
;
if
(
id
==
0
)
return
Dart
::
nil
();
return
Dart
(
id
-
1
);
// -1 because we draw +1
return
colToDart
(
color
);
}
...
...
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