set the color for the picking
Change-Id: If7b902b16626384440241d88937161cf327e14d5
This commit is contained in:
@@ -79,6 +79,7 @@ struct Polygon3DInfo
|
||||
bool twoSidesLighting;
|
||||
long fillStyle;
|
||||
glm::vec4 polygonColor;
|
||||
glm::vec4 id;
|
||||
Vertices3D *vertices;
|
||||
UVs3D *uvs;
|
||||
Normals3D *normals;
|
||||
@@ -93,6 +94,7 @@ struct Extrude3DInfo
|
||||
bool rounded;
|
||||
bool twoSidesLighting;
|
||||
glm::vec4 extrudeColor;
|
||||
glm::vec4 id;
|
||||
float xScale;
|
||||
float yScale;
|
||||
float zScale;
|
||||
@@ -136,6 +138,7 @@ struct PackedVertex{
|
||||
|
||||
struct TextInfo
|
||||
{
|
||||
glm::vec4 id;
|
||||
GLuint texture;
|
||||
float vertex[12];
|
||||
};
|
||||
@@ -159,20 +162,20 @@ public:
|
||||
void Set3DSenceInfo(sal_uInt32 color = 255, bool twoSidesLighting = true);
|
||||
void SetLightInfo(bool lightOn, sal_uInt32 color, const glm::vec4& direction);
|
||||
void AddShapePolygon3DObject(sal_uInt32 color, bool lineOnly, sal_uInt32 lineColor,
|
||||
long fillStyle, sal_uInt32 specular);
|
||||
long fillStyle, sal_uInt32 specular, sal_uInt32 nUniqueId);
|
||||
void EndAddShapePolygon3DObject();
|
||||
void AddPolygon3DObjectNormalPoint(float x, float y, float z);
|
||||
void EndAddPolygon3DObjectNormalPoint();
|
||||
void AddPolygon3DObjectPoint(float x, float y, float z);
|
||||
void EndAddPolygon3DObjectPoint();
|
||||
void AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 color, sal_uInt32 specular, glm::mat4 modelMatrix);
|
||||
void AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 color, sal_uInt32 specular, const glm::mat4& modelMatrix, sal_uInt32 nUniqueId);
|
||||
void EndAddShape3DExtrudeObject();
|
||||
double GetTime();
|
||||
void SetFPS(float fps);
|
||||
void RenderClickPos(Point aMPos);
|
||||
void SetSize(const Size& rSize);
|
||||
void SetCameraInfo(glm::vec3 pos, glm::vec3 direction, glm::vec3 up);
|
||||
void CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft);
|
||||
void CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft, sal_uInt32 nUniqueId);
|
||||
void ProcessUnrenderedShape();
|
||||
|
||||
void SetPickingMode(bool bPickingMode);
|
||||
|
@@ -39,7 +39,7 @@ Bar::Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, sal_uInt32 aCo
|
||||
|
||||
void Bar::render()
|
||||
{
|
||||
mpRenderer->AddShape3DExtrudeObject(mbRoundedCorners, maColor.GetColor(), 0xFFFFFF, maPos);
|
||||
mpRenderer->AddShape3DExtrudeObject(mbRoundedCorners, maColor.GetColor(), 0xFFFFFF, maPos, mnUniqueId);
|
||||
mpRenderer->EndAddShape3DExtrudeObject();
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ Line::Line(OpenGL3DRenderer* pRenderer, sal_uInt32 nId):
|
||||
|
||||
void Line::render()
|
||||
{
|
||||
mpRenderer->AddShapePolygon3DObject(0, true, maLineColor.GetColor(), 0, 0);
|
||||
mpRenderer->AddShapePolygon3DObject(0, true, maLineColor.GetColor(), 0, 0, mnUniqueId);
|
||||
mpRenderer->AddPolygon3DObjectPoint(maPosBegin.x, maPosBegin.y, maPosBegin.z);
|
||||
mpRenderer->AddPolygon3DObjectPoint(maPosEnd.x, maPosEnd.y, maPosEnd.z);
|
||||
mpRenderer->EndAddShapePolygon3DObject();
|
||||
@@ -87,7 +87,7 @@ void Text::render()
|
||||
{
|
||||
glm::vec3 dir2 = maTopRight - maTopLeft;
|
||||
glm::vec3 bottomLeft = maBottomRight - dir2;
|
||||
mpRenderer->CreateTextTexture(maText, maTopLeft, maTopRight, maBottomRight, bottomLeft);
|
||||
mpRenderer->CreateTextTexture(maText, maTopLeft, maTopRight, maBottomRight, bottomLeft, mnUniqueId);
|
||||
}
|
||||
|
||||
Size Text::getSize() const
|
||||
@@ -112,7 +112,7 @@ void Rectangle::render()
|
||||
glm::vec3 dir1 = maBottomRight - maTopLeft;
|
||||
glm::vec3 dir2 = maTopRight - maTopLeft;
|
||||
glm::vec3 normal = glm::normalize(glm::cross(dir1, dir2));
|
||||
mpRenderer->AddShapePolygon3DObject(maColor.GetColor(), false, 0, 1, 0xFFFFFF);
|
||||
mpRenderer->AddShapePolygon3DObject(maColor.GetColor(), false, 0, 1, 0xFFFFFF, mnUniqueId);
|
||||
glm::vec3 bottomLeft = maBottomRight - dir2;
|
||||
//set polygon points and normals
|
||||
mpRenderer->AddPolygon3DObjectPoint(maBottomRight.x, maBottomRight.y, maBottomRight.z);
|
||||
@@ -128,7 +128,7 @@ void Rectangle::render()
|
||||
//we should render the edge if the edge color is different from the fill color
|
||||
if (maColor.GetColor() != maLineColor.GetColor())
|
||||
{
|
||||
mpRenderer->AddShapePolygon3DObject(0, true, maLineColor.GetColor(), 0, 0xFFFFFF);
|
||||
mpRenderer->AddShapePolygon3DObject(0, true, maLineColor.GetColor(), 0, 0xFFFFFF, mnUniqueId);
|
||||
mpRenderer->AddPolygon3DObjectPoint(maBottomRight.x, maBottomRight.y, maBottomRight.z);
|
||||
mpRenderer->AddPolygon3DObjectPoint(maTopRight.x, maTopRight.y, maTopRight.z);
|
||||
mpRenderer->AddPolygon3DObjectPoint(maTopLeft.x, maTopLeft.y, maTopLeft.z);
|
||||
|
@@ -706,7 +706,10 @@ void OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
|
||||
//fill vertex buffer
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, pointList->size() * sizeof(glm::vec3), &pointList[0][0], GL_STATIC_DRAW);
|
||||
glUniform4fv(maResources.m_2DColorID, 1, &polygon.polygonColor[0]);
|
||||
if(mbPickingMode)
|
||||
glUniform4fv(maResources.m_2DColorID, 1, &polygon.id[0]);
|
||||
else
|
||||
glUniform4fv(maResources.m_2DColorID, 1, &polygon.polygonColor[0]);
|
||||
glUniformMatrix4fv(maResources.m_MatrixID, 1, GL_FALSE, &m_3DMVP[0][0]);
|
||||
|
||||
// 1rst attribute buffer : vertices
|
||||
@@ -786,6 +789,7 @@ void OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
|
||||
{
|
||||
glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model;
|
||||
glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
|
||||
glUniform4fv(maResources.m_2DColorID, 1, &polygon.id[0]);
|
||||
}
|
||||
|
||||
GLint maVertexID = mbPickingMode ? maPickingResources.m_2DVertexID : maResources.m_3DVertexID;
|
||||
@@ -878,9 +882,10 @@ void OpenGL3DRenderer::SetLightInfo(bool lightOn, sal_uInt32 nColor, const glm::
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGL3DRenderer::AddShapePolygon3DObject(sal_uInt32 nColor, bool lineOnly, sal_uInt32 nLineColor,long fillStyle, sal_uInt32 specular)
|
||||
void OpenGL3DRenderer::AddShapePolygon3DObject(sal_uInt32 nColor, bool lineOnly, sal_uInt32 nLineColor,long fillStyle, sal_uInt32 specular, sal_uInt32 nUniqueId)
|
||||
{
|
||||
m_Polygon3DInfo.polygonColor = getColorAsVector(nColor);
|
||||
m_Polygon3DInfo.id = getColorAsVector(nUniqueId);
|
||||
m_Polygon3DInfo.material.materialColor = m_Polygon3DInfo.polygonColor;//material color seems to be the same for all parts, so we use the polygon color
|
||||
//line or Polygon
|
||||
m_Polygon3DInfo.lineOnly = lineOnly;
|
||||
@@ -960,8 +965,9 @@ void OpenGL3DRenderer::EndAddPolygon3DObjectPoint()
|
||||
m_Polygon3DInfo.vertices = NULL;
|
||||
}
|
||||
|
||||
void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 nColor, sal_uInt32 specular, glm::mat4 modelMatrix)
|
||||
void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 nColor, sal_uInt32 specular, const glm::mat4& modelMatrix, sal_uInt32 nUniqueId)
|
||||
{
|
||||
m_Extrude3DInfo.id = getColorAsVector(nUniqueId);
|
||||
glm::vec4 tranform = modelMatrix * glm::vec4(0.0, 0.0, 0.0, 1.0);
|
||||
glm::vec4 DirX = modelMatrix * glm::vec4(1.0, 0.0, 0.0, 0.0);
|
||||
glm::vec4 DirY = modelMatrix * glm::vec4(0.0, 1.0, 0.0, 0.0);
|
||||
@@ -1091,6 +1097,7 @@ void OpenGL3DRenderer::RenderExtrudeFlatSurface(const Extrude3DInfo& extrude3D,
|
||||
{
|
||||
glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model;
|
||||
glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
|
||||
glUniform4fv(maResources.m_2DColorID, 1, &extrude3D.id[0]);
|
||||
}
|
||||
|
||||
glDrawElements(GL_TRIANGLES, extrude3D.size[surIndex], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[surIndex]));
|
||||
@@ -1134,6 +1141,7 @@ void OpenGL3DRenderer::RenderExtrudeBottomSurface(const Extrude3DInfo& extrude3D
|
||||
{
|
||||
glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model;
|
||||
glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
|
||||
glUniform4fv(maResources.m_2DColorID, 1, &extrude3D.id[0]);
|
||||
}
|
||||
glDrawElements(GL_TRIANGLES, extrude3D.size[BOTTOM_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[BOTTOM_SURFACE]));
|
||||
}
|
||||
@@ -1178,6 +1186,7 @@ void OpenGL3DRenderer::RenderExtrudeMiddleSurface(const Extrude3DInfo& extrude3D
|
||||
{
|
||||
glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model;
|
||||
glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
|
||||
glUniform4fv(maResources.m_2DColorID, 1, &extrude3D.id[0]);
|
||||
}
|
||||
glDrawElements(GL_TRIANGLES, extrude3D.size[MIDDLE_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[MIDDLE_SURFACE]));
|
||||
}
|
||||
@@ -1223,6 +1232,7 @@ void OpenGL3DRenderer::RenderExtrudeTopSurface(const Extrude3DInfo& extrude3D)
|
||||
{
|
||||
glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model;
|
||||
glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
|
||||
glUniform4fv(maResources.m_2DColorID, 1, &extrude3D.id[0]);
|
||||
}
|
||||
glDrawElements(GL_TRIANGLES, extrude3D.size[TOP_SURFACE], GL_UNSIGNED_SHORT, reinterpret_cast<GLvoid*>(extrude3D.startIndex[TOP_SURFACE]));
|
||||
RenderExtrudeFlatSurface(extrude3D, FLAT_BOTTOM_SURFACE);
|
||||
@@ -1253,6 +1263,7 @@ void OpenGL3DRenderer::RenderNonRoundedBar(const Extrude3DInfo& extrude3D)
|
||||
{
|
||||
glm::mat4 aMVP = m_3DProjection * m_3DView * m_Model;
|
||||
glUniformMatrix4fv(maPickingResources.m_MatrixID, 1, GL_FALSE, &aMVP[0][0]);
|
||||
glUniform4fv(maResources.m_2DColorID, 1, &extrude3D.id[0]);
|
||||
}
|
||||
glDrawArrays(GL_TRIANGLES, 0, 36);
|
||||
}
|
||||
@@ -1279,7 +1290,9 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
if(mbPickingMode)
|
||||
{
|
||||
glUseProgram(maPickingResources.m_CommonProID);
|
||||
}
|
||||
else
|
||||
{
|
||||
Update3DUniformBlock();
|
||||
@@ -1294,6 +1307,9 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
|
||||
Extrude3DInfo extrude3DInfo = m_Extrude3DList[i];
|
||||
GLuint vertexBuf = extrude3DInfo.rounded ? m_CubeVertexBuf : m_BoundBox;
|
||||
GLuint normalBuf = extrude3DInfo.rounded ? m_CubeNormalBuf : m_BoundBoxNormal;
|
||||
|
||||
if(mbPickingMode)
|
||||
glUniform4fv(maResources.m_2DColorID, 1, &extrude3DInfo.id[0]);
|
||||
// 1st attribute buffer : vertices
|
||||
|
||||
GLint aVertexID = mbPickingMode ? maPickingResources.m_2DVertexID : maResources.m_3DVertexID;
|
||||
@@ -1348,13 +1364,14 @@ void OpenGL3DRenderer::RenderExtrude3DObject()
|
||||
glDisable(GL_CULL_FACE);
|
||||
}
|
||||
|
||||
void OpenGL3DRenderer::CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft)
|
||||
void OpenGL3DRenderer::CreateTextTexture(const BitmapEx& rBitmapEx, glm::vec3 vTopLeft,glm::vec3 vTopRight, glm::vec3 vBottomRight, glm::vec3 vBottomLeft, sal_uInt32 nUniqueId)
|
||||
{
|
||||
long bmpWidth = rBitmapEx.GetSizePixel().Width();
|
||||
long bmpHeight = rBitmapEx.GetSizePixel().Height();
|
||||
boost::scoped_array<sal_uInt8> bitmapBuf(OpenGLHelper::ConvertBitmapExToRGBABuffer(rBitmapEx));
|
||||
|
||||
TextInfo aTextInfo;
|
||||
aTextInfo.id = getColorAsVector(nUniqueId);
|
||||
aTextInfo.vertex[0] = vBottomRight.x;
|
||||
aTextInfo.vertex[1] = vBottomRight.y;
|
||||
aTextInfo.vertex[2] = vBottomRight.z * m_fHeightWeight;
|
||||
|
Reference in New Issue
Block a user