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
S
SocialAgents3D
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Pitiot
SocialAgents3D
Commits
bbc8a3a9
Commit
bbc8a3a9
authored
Mar 02, 2015
by
Thomas Pitiot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added surface representation
parent
aa471233
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
191 additions
and
0 deletions
+191
-0
include/surface.h
include/surface.h
+42
-0
src/surface.cpp
src/surface.cpp
+149
-0
No files found.
include/surface.h
0 → 100644
View file @
bbc8a3a9
#ifndef Surface_H
#define Surface_H
#include <iostream>
#include "glm/glm.hpp"
#include "env_map.h"
#include "ArticulatedObject.h"
#include "Algo/Tiling/Surface/triangular.h"
#include "Algo/Render/GL2/mapRender.h"
#include "Utils/vbo.h"
#include "Utils/Shaders/shaderSimpleColor.h"
//particules
using
namespace
CGoGN
;
class
Simulator
;
class
Surface
:
public
ArticulatedObject
{
public:
Surface
(
Simulator
*
sim
,
VEC3
offset
)
;
SURFACE
surfaceMap
;
// map
VertexAttribute
<
VEC3
,
SURFACE
>
positionSurface
;
//position
VertexAttribute
<
int
,
SURFACE
>
indexParticule
;
// index des particules de chaque sommet
void
initPlane
();
//initialisation d'une grille
// visualisation
void
initGL
();
void
draw
();
Algo
::
Render
::
GL2
::
MapRender
*
m_render
;
Utils
::
VBO
*
m_positionVBO
;
Utils
::
ShaderSimpleColor
*
m_simpleColorShader
;
};
#endif
src/surface.cpp
0 → 100644
View file @
bbc8a3a9
#include "simulator.h"
//initialisation Surface
Surface
::
Surface
(
Simulator
*
sim
,
VEC3
offset
)
{
surfaceMap
.
initImplicitProperties
();
positionSurface
=
surfaceMap
.
addAttribute
<
VEC3
,
VERTEX
,
SURFACE
>
(
"positionSurface"
);
indexParticule
=
surfaceMap
.
addAttribute
<
int
,
VERTEX
,
SURFACE
>
(
"indexParticule"
);
initPlane
();
index_articulated
=
sim
->
objects
.
size
();
r
=
0.1
f
;
g
=
0.4
f
;
b
=
0.5
f
;
sim_
=
sim
;
width
=
1.0
;
nbVertices
=
0
;
nbEdges
=
0
;
belonging_cells
=
new
std
::
vector
<
Dart
>
[
nbEdges
];
neighbor_cells
=
new
std
::
vector
<
Dart
>
[
nbEdges
];
TraversorV
<
SURFACE
>
tv
(
surfaceMap
);
for
(
Dart
d
=
tv
.
begin
()
;
d
!=
tv
.
end
()
;
d
=
tv
.
next
())
{
positionSurface
[
d
]
+=
offset
;
indexParticule
[
d
]
=
nbVertices
;
parts_
.
push_back
(
new
CGoGN
::
Algo
::
Volume
::
MovingObjects
::
ParticleCell3D
<
PFP
>
(
sim_
->
envMap_
.
map
,
sim_
->
envMap_
.
getBelongingCell
(
positionSurface
[
d
]),
positionSurface
[
d
]
,
sim_
->
envMap_
.
position
));
nbVertices
++
;
}
TraversorE
<
SURFACE
>
tE
(
surfaceMap
);
for
(
Dart
d
=
tE
.
begin
()
;
d
!=
tE
.
end
()
;
d
=
tE
.
next
())
{
#ifdef DEBUG_affichage
CGoGNout
<<
" init Segment :"
<<
nbEdges
;
CGoGNout
<<
" || nb_segments :"
<<
Segments_
.
size
()
<<
CGoGNendl
;
#endif
unsigned
int
ind1
=
indexParticule
[
d
];
unsigned
int
ind2
=
indexParticule
[
surfaceMap
.
phi1
(
d
)];
Segment
*
o
=
new
Segment
(
parts_
[
ind1
]
->
getPosition
(),
parts_
[
ind2
]
->
getPosition
(),
this
,
ind1
,
ind2
,
nbEdges
,
r
,
g
,
b
);
Segments_
.
push_back
(
o
);
sim_
->
envMap_
.
FirstRegistrationSegment
(
o
);
nbEdges
++
;
}
}
void
Surface
::
initGL
()
{
//rendering
m_render
=
new
Algo
::
Render
::
GL2
::
MapRender
();
m_positionVBO
=
new
Utils
::
VBO
();
m_simpleColorShader
=
new
Utils
::
ShaderSimpleColor
();
m_simpleColorShader
->
setAttributePosition
(
m_positionVBO
);
m_simpleColorShader
->
setColor
(
Geom
::
Vec4f
(
0.
,
1.
,
0.
,
0.
));
m_positionVBO
->
updateData
(
position
)
;
m_render
->
initPrimitives
<
PFP2
>
(
map
,
Algo
::
Render
::
GL2
::
TRIANGLES
)
;
m_render
->
initPrimitives
<
PFP2
>
(
map
,
Algo
::
Render
::
GL2
::
LINES
)
;
}
void
Surface
::
draw
()
{
m_positionVBO
->
updateData
(
position
)
;
m_simpleColorShader
->
setColor
(
Geom
::
Vec4f
(
1.0
,
0.627
,
0.0
,
0.
));
m_render
->
draw
(
m_simpleColorShader
,
Algo
::
Render
::
GL2
::
TRIANGLES
);
m_simpleColorShader
->
setColor
(
Geom
::
Vec4f
(
0.0
,
0.0
,
0.0
,
0.
));
m_render
->
draw
(
m_simpleColorShader
,
Algo
::
Render
::
GL2
::
LINES
);
}
void
Surface
::
initPlane
()
{
Algo
::
Surface
::
Tilings
::
Triangular
::
Grid
<
PFPSurface
>
prim
(
surfaceMap
,
1
,
1
)
;
prim
.
embedIntoGrid
(
positionSurface
,
1.0
f
,
1.0
f
,
0.0
f
)
;
Dart
dY
=
prim
.
getDart
()
;
//remind the first quad of the line
Dart
dX
=
prim
.
getDart
()
;
//goes through the line
bool
odd
=
true
;
//odd line or not
int
nx
=
1
,
ny
=
1
;
for
(
unsigned
int
i
=
0
;
i
<
nx
*
ny
;)
{
Dart
dNext
=
surfaceMap
.
phi1
(
surfaceMap
.
phi2
(
surfaceMap
.
phi1
(
dX
)))
;
Dart
toCut
=
dX
;
if
(
odd
)
{
toCut
=
surfaceMap
.
phi1
(
toCut
)
;
//change the side of the split face
positionSurface
[
toCut
][
0
]
-=
sim_
->
envMap_
.
maxCellSize
/
2.0
f
;
//move vertices for equilateral triangles
}
surfaceMap
.
splitFace
(
toCut
,
surfaceMap
.
phi1
(
surfaceMap
.
phi1
(
toCut
)))
;
++
i
;
if
(
i
%
nx
==
0
&&
i
>
0
)
//goes up and change side of split
{
Dart
endSquare
=
surfaceMap
.
newFace
(
3
)
;
//add triangle add end of lines to make a square
Dart
dN
;
if
(
odd
)
{
dN
=
surfaceMap
.
phi1
(
surfaceMap
.
phi2
(
surfaceMap
.
phi1
(
dX
)))
;
surfaceMap
.
sewFaces
(
dN
,
endSquare
)
;
positionSurface
[
surfaceMap
.
phi_1
(
endSquare
)]
=
positionSurface
[
surfaceMap
.
phi1
(
endSquare
)]
;
positionSurface
[
surfaceMap
.
phi_1
(
endSquare
)][
0
]
+=
sim_
->
envMap_
.
maxCellSize
/
2.0
f
;
}
else
{
dN
=
surfaceMap
.
phi1
(
dX
)
;
surfaceMap
.
sewFaces
(
dN
,
endSquare
)
;
positionSurface
[
surfaceMap
.
phi_1
(
endSquare
)]
=
positionSurface
[
endSquare
]
;
}
if
(
odd
)
dY
=
surfaceMap
.
phi2
(
surfaceMap
.
phi_1
(
surfaceMap
.
phi2
(
surfaceMap
.
phi1
(
dY
))))
;
else
dY
=
surfaceMap
.
phi2
(
surfaceMap
.
phi1
(
surfaceMap
.
phi2
(
surfaceMap
.
phi_1
(
dY
))))
;
dX
=
dY
;
odd
=
!
odd
;
}
else
dX
=
dNext
;
}
// //add hexagons
// for(Dart d = surfaceMap.begin(); d != surfaceMap.end(); surfaceMap.next(d))
// {
// if(surfaceMap.vertexDegree(d)==6)
// {
// surfaceMap.deleteVertex(d);
// }
// }
}
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