Commit d90a7c09 authored by Sylvain Thery's avatar Sylvain Thery

update on renderin for VR

parent 7aea3ea5
...@@ -27,8 +27,10 @@ ...@@ -27,8 +27,10 @@
#include "Geometry/basic.h" #include "Geometry/basic.h"
#include "Geometry/bounding_box.h" #include "Geometry/bounding_box.h"
#include "Topology/generic/attributeHandler.h"
#include "Topology/generic/traversorCell.h" #include "Topology/generic/traversorCell.h"
namespace CGoGN namespace CGoGN
{ {
......
...@@ -106,13 +106,15 @@ public: ...@@ -106,13 +106,15 @@ public:
/** /**
* use as glVertex * use as glVertex
* @return index of position for update
*/ */
void vertex(const Geom::Vec3f& v); unsigned int vertex(const Geom::Vec3f& v);
/** /**
* use as glVertex * use as glVertex
* @return index of position for update
*/ */
void vertex3f(float x, float y, float z); unsigned int vertex3f(float x, float y, float z);
/** /**
* use as glColor * use as glColor
...@@ -139,6 +141,22 @@ public: ...@@ -139,6 +141,22 @@ public:
*/ */
void pointSize(float ps); void pointSize(float ps);
/**
* update position of VBO of drawer
* @param first index of vertex to update
* @param nb number of vertex tp update
* @param P ptr to table of vertices
*/
void updatePositions(unsigned int first, unsigned int nb, const Geom::Vec3f* P);
/**
* update position of VBO of drawer
* @param first index of vertex to update
* @param nb number of vertex tp update
* @param P ptr to table of vertices
*/
void updatePositions(unsigned int first, unsigned int nb, const float* P);
/** /**
* rendering in svg struct * rendering in svg struct
*/ */
......
...@@ -52,12 +52,18 @@ public: ...@@ -52,12 +52,18 @@ public:
void popTransfo() void popTransfo()
{ {
if (m_stack.empty()) return; if (m_stack.empty())
return;
m_matrices[2] = m_stack.top(); m_matrices[2] = m_stack.top();
m_stack.pop(); m_stack.pop();
} }
glm::mat4 getTransfo() const const glm::mat4& getTransfo() const
{
return m_matrices[2];
}
glm::mat4& getTransfo()
{ {
return m_matrices[2]; return m_matrices[2];
} }
...@@ -82,6 +88,12 @@ public: ...@@ -82,6 +88,12 @@ public:
m_matrices[2] = glm::scale(m_matrices[2], glm::vec3(s,s,s)); m_matrices[2] = glm::scale(m_matrices[2], glm::vec3(s,s,s));
} }
void apply (const glm::mat4& m)
{
m_matrices[2] = m * m_matrices[2];
}
}; };
......
...@@ -103,7 +103,7 @@ void Drawer::color3f(float r, float g, float b) ...@@ -103,7 +103,7 @@ void Drawer::color3f(float r, float g, float b)
color(Geom::Vec3f(r,g,b)); color(Geom::Vec3f(r,g,b));
} }
void Drawer::vertex(const Geom::Vec3f& v) unsigned int Drawer::vertex(const Geom::Vec3f& v)
{ {
if (m_dataPos.size() == m_dataCol.size()) if (m_dataPos.size() == m_dataCol.size())
{ {
...@@ -112,13 +112,13 @@ void Drawer::vertex(const Geom::Vec3f& v) ...@@ -112,13 +112,13 @@ void Drawer::vertex(const Geom::Vec3f& v)
else else
m_dataCol.push_back( m_dataCol.back()); m_dataCol.push_back( m_dataCol.back());
} }
m_dataPos.push_back(v); m_dataPos.push_back(v);
return m_dataPos.size()-1;
} }
void Drawer::vertex3f(float r, float g, float b) unsigned int Drawer::vertex3f(float r, float g, float b)
{ {
vertex(Geom::Vec3f(r,g,b)); return vertex(Geom::Vec3f(r,g,b));
} }
void Drawer::newList(GLenum comp) void Drawer::newList(GLenum comp)
...@@ -152,6 +152,20 @@ void Drawer::endList() ...@@ -152,6 +152,20 @@ void Drawer::endList()
callList(); callList();
} }
void Drawer::updatePositions(unsigned int first, unsigned int nb, const Geom::Vec3f* P)
{
m_vboPos->bind();
glBufferSubData(GL_ARRAY_BUFFER, first * sizeof(Geom::Vec3f), nb * sizeof(Geom::Vec3f), P);
}
void Drawer::updatePositions(unsigned int first, unsigned int nb, const float* P)
{
m_vboPos->bind();
glBufferSubData(GL_ARRAY_BUFFER, first * 3 * sizeof(float), nb * 3 * sizeof(float), P);
}
void Drawer::callList() void Drawer::callList()
{ {
if (m_begins.empty()) if (m_begins.empty())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment