Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
iMSTK
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ruiliang Gao
iMSTK
Commits
0fe2a123
Commit
0fe2a123
authored
9 years ago
by
Tansel Halic
Committed by
Alexis Girault
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
The vertex buffer is added for tangents.
The tangents transfer to the shaders need to be checked.
parent
181316fc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Mesh/SurfaceMesh.cpp
+1
-0
1 addition, 0 deletions
Mesh/SurfaceMesh.cpp
VTKRendering/VTKMeshRenderDelegate.cpp
+45
-1
45 additions, 1 deletion
VTKRendering/VTKMeshRenderDelegate.cpp
VTKRendering/VTKRenderDelegate.h
+4
-1
4 additions, 1 deletion
VTKRendering/VTKRenderDelegate.h
with
50 additions
and
2 deletions
Mesh/SurfaceMesh.cpp
+
1
−
0
View file @
0fe2a123
...
...
@@ -151,6 +151,7 @@ void SurfaceMesh::computeTriangleTangents()
// Calculate the vertex tangents
if
(
this
->
useThreeDSTexureCoordinates
||
this
->
useOBJDSTexureCoordinates
)
{
this
->
vertexTangents
.
resize
(
this
->
vertices
.
size
(),
core
::
Vec3d
::
Zero
());
for
(
size_t
v
=
0
,
end
=
this
->
vertices
.
size
();
v
<
end
;
++
v
)
{
this
->
vertexTangents
[
v
][
0
]
=
this
->
vertexTangents
[
v
][
1
]
=
this
->
vertexTangents
[
v
][
2
]
=
0
;
...
...
This diff is collapsed.
Click to expand it.
VTKRendering/VTKMeshRenderDelegate.cpp
+
45
−
1
View file @
0fe2a123
...
...
@@ -50,9 +50,13 @@
#include
<vtkTexture.h>
#include
<vtkOpenGLPolyDataMapper.h>
#include
<vtkProperty.h>
#include
"vtkShaderProgram.h"
#include
"vtkOpenGLVertexArrayObject.h"
#include
"vtkOpenGLVertexBufferObject.h"
vtkStandardNewMacro
(
CustomGLPolyDataMapper
)
class
MeshRenderDelegate
:
public
VTKRenderDelegate
{
public:
...
...
@@ -201,6 +205,12 @@ void MeshRenderDelegate::initDraw()
mapper
=
CustomGLPolyDataMapper
::
New
();
mapper
->
SetInputConnection
(
normals
->
GetOutputPort
());
auto
mapperCustom
=
CustomGLPolyDataMapper
::
SafeDownCast
(
mapper
);
mesh
->
computeVertexNeighbors
();
mesh
->
setUseOBJTexture
(
true
);
mesh
->
computeTriangleTangents
();
mapperCustom
->
tangents
=
mesh
->
getVertexTangents
();
if
(
renderDetail
->
hasShaders
())
{
...
...
@@ -249,12 +259,46 @@ void MeshRenderDelegate::modified()
dataSet
->
Modified
();
}
void
CustomGLPolyDataMapper
::
initDraw
(){
cout
<<
"init"
<<
endl
;
}
void
CustomGLPolyDataMapper
::
BuildBufferObjects
(
vtkRenderer
*
ren
,
vtkActor
*
act
){
tangentsBuffer
=
vtkOpenGLBufferObject
::
New
();
tangentsBuffer
->
Bind
();
if
(
tangentsBuffer
->
Upload
(
this
->
tangents
,
vtkOpenGLBufferObject
::
ArrayBuffer
)){
cout
<<
"Completed Tangents Binding"
<<
endl
;
}
tangentsBuffer
->
Release
();
vtkOpenGLPolyDataMapper
::
BuildBufferObjects
(
ren
,
act
);
}
void
CustomGLPolyDataMapper
::
SetMapperShaderParameters
(
vtkOpenGLHelper
&
cellBO
,
vtkRenderer
*
ren
,
vtkActor
*
act
)
{
double
testColor1
=
0.01
;
double
testColor2
=
0.01
;
static
double
testColor3
=
0.01
;
vtkShaderProgram
*
program
=
cellBO
.
Program
;
testColor3
+=
0.01
;
program
->
SetUniformf
(
"TestColor1"
,
testColor1
);
program
->
SetUniformf
(
"TestColor2"
,
testColor2
);
program
->
SetUniformf
(
"TestColor3"
,
testColor3
);
cellBO
.
VAO
->
Bind
();
if
(
!
cellBO
.
VAO
->
AddAttributeArray
(
cellBO
.
Program
,
this
->
tangentsBuffer
,
"vertTangents"
,
0
,
0
,
VTK_DOUBLE
,
3
,
false
))
{
vtkErrorMacro
(
<<
"Error setting 'vertTangents' in shader VAO."
);
}
vtkOpenGLPolyDataMapper
::
SetMapperShaderParameters
(
cellBO
,
ren
,
act
);
}
RegisterFactoryClass
(
RenderDelegate
,
...
...
This diff is collapsed.
Click to expand it.
VTKRendering/VTKRenderDelegate.h
+
4
−
1
View file @
0fe2a123
...
...
@@ -8,11 +8,14 @@ class vtkActor;
class
CustomGLPolyDataMapper
:
public
vtkOpenGLPolyDataMapper
{
public:
static
CustomGLPolyDataMapper
*
New
();
vtkOpenGLBufferObject
*
tangentsBuffer
;
std
::
vector
<
core
::
Vec3d
>
tangents
;
vtkTypeMacro
(
CustomGLPolyDataMapper
,
vtkOpenGLPolyDataMapper
)
virtual
void
initDraw
()
{}
virtual
void
initDraw
()
;
virtual
void
modified
()
{}
virtual
void
draw
()
const
{
}
virtual
void
SetMapperShaderParameters
(
vtkOpenGLHelper
&
cellBO
,
vtkRenderer
*
ren
,
vtkActor
*
act
)
override
;
void
BuildBufferObjects
(
vtkRenderer
*
ren
,
vtkActor
*
act
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment