6.5.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 7027a861 authored by mostajab's avatar mostajab

+ Fixing the MeshGeomteryRenderer shaders to support the user selected color

+ update the get function of abstractproperty.h and abstractproperty.cpp to support the const objects.

- Still sufring from invalid enumerator in meshgeomtery rendering.
parent 107a5055
......@@ -52,7 +52,7 @@ namespace campvis {
DataContainerInspectorCanvas::DataContainerInspectorCanvas(QWidget* parent /*= 0*/)
: tgt::QtThreadedCanvas("DataContainer Inspector", tgt::ivec2(640, 480), tgt::GLCanvas::RGBA_BUFFER, parent, true)
, p_currentSlice("CurrentSlice", "Slice", -1, -1, -1)
, p_meshSolidColor("MeshSolidColor", "Mesh Solid Color", tgt::vec4(1.f), tgt::vec4(0.f), tgt::vec4(255.f))
, p_meshSolidColor("MeshSolidColor", "Mesh Solid Color", tgt::vec4(50.f, 70.0f, 50.0f, 255.f), tgt::vec4(0.0f), tgt::vec4(255.0f))
, p_transferFunction("TransferFunction", "Transfer Function", new Geometry1DTransferFunction(256, tgt::vec2(0.f, 1.f)))
, _dataContainer(0)
, _paintShader(0)
......@@ -258,7 +258,7 @@ namespace campvis {
glPushAttrib(GL_ALL_ATTRIB_BITS);
_geomteryRenderingShader->activate();
LGL_ERROR;
// _geomteryRenderingShader->setIgnoreUniformLocationError(true);
_geomteryRenderingShader->setIgnoreUniformLocationError(true);
LGL_ERROR;
//decorateRenderProlog(data, _shader);
......@@ -270,13 +270,20 @@ namespace campvis {
campvis::IVec4Property* p_color = new campvis::IVec4Property("myColor", "MyRenderingColor", tgt::vec4(1.f), tgt::vec4(0.f), tgt::vec4(1.f));
tgt::mat4 myMat = _trackballEHs[meshIndex]->_trackball->getCamera()->getProjectionMatrix();
myMat = _trackballEHs[meshIndex]->_trackball->getCamera()->getViewMatrix();
_geomteryRenderingShader->setUniform("_projectionMatrix", _trackballEHs[meshIndex]->_trackball->getCamera()->getProjectionMatrix()/*_trackballCameraProperty->getValue().getProjectionMatrix()*/);
LGL_ERROR;
_geomteryRenderingShader->setUniform("_viewMatrix", _trackballEHs[meshIndex]->_trackball->getCamera()->getViewMatrix());
//_geomteryRenderingShader->setUniform("_colormory", p_color->getValue());
//_geomteryRenderingShader->setUniform("_cameraPosition", _trackballEHs[meshIndex]->_trackball->getCamera()->getPosition());
LGL_ERROR;
tgt::Vector4<float> meshColor = static_cast<tgt::Vector4<float>>(p_meshSolidColor.getValue());
meshColor.r /= 255.0f;
meshColor.g /= 255.0f;
meshColor.b /= 255.0f;
meshColor.a /= 255.0f;
_geomteryRenderingShader->setUniform("_Color", meshColor);
LGL_ERROR;
_geomteryRenderingShader->setUniform("_cameraPosition", _trackballEHs[meshIndex]->_trackball->getCamera()->getPosition());
_geomteryRenderingShader->setIgnoreUniformLocationError(false);
LGL_ERROR;
tgt::FramebufferObject* frameBuffer = new tgt::FramebufferObject();
......@@ -313,8 +320,10 @@ namespace campvis {
// if (const campvis::MeshGeometry* mg = dynamic_cast<const campvis::MeshGeometry*>(it->second.getData())) {
glPolygonMode(GL_FRONT, GL_POLYGON);
//mg->render(GL_POLYGON);
mg->render(GL_POLYGON);
_geomteryRenderingShader->setUniform("_Color", 1.0f, 1.0f, 1.0f, 1.0f);
// Render wireframe around the object
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
mg->render(GL_POLYGON);
......@@ -391,7 +400,7 @@ namespace campvis {
void DataContainerInspectorCanvas::mouseMoveEvent(tgt::MouseEvent* e)
{
LGL_ERROR;
//LGL_ERROR;
/*if (_renderFullscreen) {
_renderFullscreen = false;
}
......@@ -472,7 +481,7 @@ namespace campvis {
}
void DataContainerInspectorCanvas::mousePressEvent(tgt::MouseEvent* e) {
LGL_ERROR;
//LGL_ERROR;
//if (_renderFullscreen) {
tgt::ivec2 selectedIndex(e->x() / _quadSize.x, e->y() / _quadSize.y);
......@@ -632,6 +641,7 @@ namespace campvis {
float dist = 3 * fabs(mg->getWorldBounds().getLLF().z - mg->getWorldBounds().getURB().z);
trackballEH->reinitializeCamera(mg->getWorldBounds());
trackballEH->_trackball->moveCameraBackward(dist);
LGL_ERROR;
flag = true;
//}
_trackballEHs.push_back(trackballEH);
......@@ -639,7 +649,9 @@ namespace campvis {
tgt::Texture* colorBuffer = new tgt::Texture(0, tgt::ivec3(_renderingWndSize.x, _renderingWndSize.y, 1), GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, tgt::Texture::LINEAR);
tgt::Texture* depthBuffer = new tgt::Texture(0, tgt::ivec3(_renderingWndSize.x, _renderingWndSize.y, 1), GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT24, GL_FLOAT, tgt::Texture::LINEAR);
glewExperimental = true;
drawMeshGeomtery(mg, colorBuffer, depthBuffer, nMeshGeometry++);
LGL_ERROR;
_geomteryRendering_ColorBuffers.push_back(colorBuffer);
_geomteryRendering_DepthBuffers.push_back(depthBuffer);
......@@ -700,6 +712,7 @@ namespace campvis {
_trackballCameraProperties[nMeshGeometry]->getValue();
//drawMeshGeomtery(mg, _geomteryRendering_ColorBuffers[nMeshGeometry], _geomteryRendering_DepthBuffers[nMeshGeometry], nMeshGeometry);
glewExperimental = true;
drawMeshGeomtery(mg, colorBuffer, depthBuffer, nMeshGeometry);
nMeshGeometry++;
_textures.insert(_textures.begin() + nElement, colorBuffer);
......@@ -721,6 +734,14 @@ namespace campvis {
void DataContainerInspectorCanvas::onPropertyChanged(const AbstractProperty* prop) {
HasPropertyCollection::onPropertyChanged(prop);
invalidate();
/// if the Mesh Solid Color property is changed, update the mesh's color
const std::string propertyName = (prop)->getName();
if(propertyName == "MeshSolidColor")
{
_meshGeomTexturesDirty = true;
invalidateMeshGeomTextures();
}
}
}
......@@ -46,11 +46,11 @@ namespace campvis {
}
const std::string& AbstractProperty::getName() {
const std::string& AbstractProperty::getName() const {
return _name;
}
const std::string& AbstractProperty::getTitle() {
const std::string& AbstractProperty::getTitle() const {
return _title;
}
......
......@@ -78,13 +78,13 @@ namespace campvis {
* Returns the property name.
* \return _name
*/
const std::string& getName();
const std::string& getName() const;
/**
* Returns the property title (e.g. used for GUI).
* \return _title
*/
const std::string& getTitle();
const std::string& getTitle() const;
/**
* Returns the invalidation level that this property triggers.
......
......@@ -32,13 +32,14 @@
in vec3 ex_TexCoord; ///< incoming texture coordinate
in vec4 ex_Position; ///< incoming texture coordinate
in vec4 ex_Color; ///< outgoing colorin
in vec3 ex_Local_Position; ///< incoming local coordinate
uniform vec4 _Color = vec4(0, 1, 0, 1); ///< outgoing colorin
out vec4 out_Color; ///< outgoing fragment color
void main() {
out_Color = ex_Color;
out_Color = _Color;
//out_Color = vec4(normalize(ex_Local_Position), 1);
//out_Color = vec4(0, 1, 0, 1);
//out_Color = _color;
......
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