Commit ecd9c89e authored by Christopher Tenter's avatar Christopher Tenter

add ability to set reflection texture for bspline surface

parent 589e05bf
Pipeline #2100 failed with stage
in 1513 minutes and 46 seconds
...@@ -555,7 +555,10 @@ void TextureNode::leavePick(GLState& /*_state*/, PickTarget /*_target*/, const D ...@@ -555,7 +555,10 @@ void TextureNode::leavePick(GLState& /*_state*/, PickTarget /*_target*/, const D
GLuint TextureNode::activeTexture() GLuint TextureNode::activeTexture()
{ {
return textures_[activeTexture_].tex->id(); if (0 <= activeTexture_ && activeTexture_ < textures_.size())
return textures_[activeTexture_].tex->id();
return 0;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
......
...@@ -144,6 +144,9 @@ getRenderObjects(IRenderer* _renderer, GLState& _state, const DrawModes::DrawMod ...@@ -144,6 +144,9 @@ getRenderObjects(IRenderer* _renderer, GLState& _state, const DrawModes::DrawMod
// because normals aren't available in the vertex shader // because normals aren't available in the vertex shader
ro.shaderDesc.texGenPerFragment = true; ro.shaderDesc.texGenPerFragment = true;
if ( props->textured() && arb_texture_idx_)
ro.addTexture(ACG::RenderObject::Texture(arb_texture_idx_), 0);
if (props->primitive() == DrawModes::PRIMITIVE_POLYGON || props->primitive() == DrawModes::PRIMITIVE_WIREFRAME) if (props->primitive() == DrawModes::PRIMITIVE_POLYGON || props->primitive() == DrawModes::PRIMITIVE_WIREFRAME)
{ {
updateSurfaceMesh(); updateSurfaceMesh();
......
...@@ -212,10 +212,12 @@ class BSplineSurfaceNodeT : public BaseNode ...@@ -212,10 +212,12 @@ class BSplineSurfaceNodeT : public BaseNode
/// use arbitrary texture (in SOLID_TEXTURED mode) /// use arbitrary texture (in SOLID_TEXTURED mode)
void set_arb_texture( const QImage& _texture, bool _repeat = false, float _u_repeat = 1.0f, float _v_repeat = 1.0f); void set_arb_texture( const QImage& _texture, bool _repeat = false, float _u_repeat = 1.0f, float _v_repeat = 1.0f);
void set_repeat_arb_texture( bool _repeat = true, float _urep = 5.0f, float _vrep = 5.0f) { arb_texture_repeat_ = _repeat; arb_texture_repeat_u_ = _urep; arb_texture_repeat_v_ = _vrep; } void set_arb_texture(const GLuint _texture) { arb_texture_idx_ = _texture; }
void set_repeat_arb_texture(bool _repeat = true, float _urep = 5.0f, float _vrep = 5.0f) { arb_texture_repeat_ = _repeat; arb_texture_repeat_u_ = _urep; arb_texture_repeat_v_ = _vrep; }
bool get_repeat_arb_texture( ) { return arb_texture_repeat_; } bool get_repeat_arb_texture( ) { return arb_texture_repeat_; }
private: private:
void pick_vertices( GLState& _state ); void pick_vertices( GLState& _state );
......
...@@ -246,6 +246,9 @@ update(UpdateType _type) ...@@ -246,6 +246,9 @@ update(UpdateType _type)
splineSurfaceNode()->knotSelectionTextureValid(false); splineSurfaceNode()->knotSelectionTextureValid(false);
splineSurfaceNode()->updateGeometry(); splineSurfaceNode()->updateGeometry();
if (textureNode())
splineSurfaceNode()->set_arb_texture(textureNode()->activeTexture());
} }
else else
{ {
...@@ -262,6 +265,9 @@ update(UpdateType _type) ...@@ -262,6 +265,9 @@ update(UpdateType _type)
splineSurfaceNode()->cpSelectionTextureValid(false); splineSurfaceNode()->cpSelectionTextureValid(false);
else if (_type.contains(UPDATE_SELECTION_KNOTS)) else if (_type.contains(UPDATE_SELECTION_KNOTS))
splineSurfaceNode()->knotSelectionTextureValid(false); splineSurfaceNode()->knotSelectionTextureValid(false);
if (_type.contains(UPDATE_TEXTURE) && textureNode())
splineSurfaceNode()->set_arb_texture(textureNode()->activeTexture());
} }
} }
......
...@@ -16,6 +16,10 @@ if (EXISTS ${CMAKE_SOURCE_DIR}/ObjectTypes/HexahedralMesh) ...@@ -16,6 +16,10 @@ if (EXISTS ${CMAKE_SOURCE_DIR}/ObjectTypes/HexahedralMesh)
list( APPEND CURRENT_PLUGIN_DEPS OpenVolumeMesh ) list( APPEND CURRENT_PLUGIN_DEPS OpenVolumeMesh )
endif() endif()
if (EXISTS ${CMAKE_SOURCE_DIR}/ObjectTypes/BSplineSurface)
add_definitions (-DENABLE_BSPLINESURFACE_SUPPORT)
endif()
list(REMOVE_DUPLICATES CURRENT_PLUGIN_DEPS ) list(REMOVE_DUPLICATES CURRENT_PLUGIN_DEPS )
# use Qwt6 for QT5 # use Qwt6 for QT5
......
...@@ -127,6 +127,11 @@ void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _fil ...@@ -127,6 +127,11 @@ void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _fil
glName = PluginFunctions::polyhedralMeshObject(obj)->textureNode()->add_texture(imageStore().getImage(newId,0)); glName = PluginFunctions::polyhedralMeshObject(obj)->textureNode()->add_texture(imageStore().getImage(newId,0));
#endif #endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
if (obj->dataType(DATA_BSPLINE_SURFACE))
glName = PluginFunctions::bsplineSurfaceObject(obj)->textureNode()->add_texture(imageStore().getImage(newId, 0));
#endif
// ================================================================================ // ================================================================================
// Store texture information in objects metadata // Store texture information in objects metadata
// ================================================================================ // ================================================================================
...@@ -244,6 +249,9 @@ void TextureControlPlugin::addedEmptyObject( int _id ) { ...@@ -244,6 +249,9 @@ void TextureControlPlugin::addedEmptyObject( int _id ) {
#endif #endif
#ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
&& !obj->dataType(DATA_POLYHEDRAL_MESH) && !obj->dataType(DATA_POLYHEDRAL_MESH)
#endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
&& !obj->dataType(DATA_BSPLINE_SURFACE)
#endif #endif
) )
{ {
...@@ -288,6 +296,11 @@ void TextureControlPlugin::addedEmptyObject( int _id ) { ...@@ -288,6 +296,11 @@ void TextureControlPlugin::addedEmptyObject( int _id ) {
if ( obj->dataType( DATA_POLYHEDRAL_MESH ) ) if ( obj->dataType( DATA_POLYHEDRAL_MESH ) )
glName = PluginFunctions::polyhedralMeshObject(obj)->textureNode()->add_texture(imageStore().getImage(newImageId,0)); glName = PluginFunctions::polyhedralMeshObject(obj)->textureNode()->add_texture(imageStore().getImage(newImageId,0));
#endif #endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
if (obj->dataType(DATA_BSPLINE_SURFACE))
glName = PluginFunctions::bsplineSurfaceObject(obj)->textureNode()->add_texture(imageStore().getImage(newImageId, 0));
#endif
// ================================================================================ // ================================================================================
// Store texture information in objects metadata // Store texture information in objects metadata
...@@ -458,6 +471,12 @@ void TextureControlPlugin::slotTextureChangeImage( QString _textureName , QImage ...@@ -458,6 +471,12 @@ void TextureControlPlugin::slotTextureChangeImage( QString _textureName , QImage
} }
#endif #endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
else if (obj->dataType(DATA_BSPLINE_SURFACE)) {
PluginFunctions::bsplineSurfaceObject(obj)->textureNode()->set_texture(_image, texData->texture(_textureName).glName());
}
#endif
emit updateView(); emit updateView();
} }
...@@ -508,6 +527,11 @@ void TextureControlPlugin::slotTextureChangeImage( QString _textureName , QImage ...@@ -508,6 +527,11 @@ void TextureControlPlugin::slotTextureChangeImage( QString _textureName , QImage
else if ( o_it->dataType( DATA_POLYHEDRAL_MESH ) ) { else if ( o_it->dataType( DATA_POLYHEDRAL_MESH ) ) {
PluginFunctions::polyhedralMeshObject(o_it)->textureNode()->set_texture( _image , texData->texture(_textureName).glName()); PluginFunctions::polyhedralMeshObject(o_it)->textureNode()->set_texture( _image , texData->texture(_textureName).glName());
} }
#endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
else if (o_it->dataType(DATA_BSPLINE_SURFACE)) {
PluginFunctions::bsplineSurfaceObject(o_it)->textureNode()->set_texture(_image, texData->texture(_textureName).glName());
}
#endif #endif
} }
} }
...@@ -765,6 +789,9 @@ void TextureControlPlugin::slotTextureUpdated( QString _textureName , int _ident ...@@ -765,6 +789,9 @@ void TextureControlPlugin::slotTextureUpdated( QString _textureName , int _ident
#endif #endif
#ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
&& !obj->dataType( DATA_POLYHEDRAL_MESH ) && !obj->dataType( DATA_POLYHEDRAL_MESH )
#endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
&& !obj->dataType(DATA_BSPLINE_SURFACE)
#endif #endif
) )
return; return;
...@@ -834,6 +861,15 @@ void TextureControlPlugin::slotTextureUpdated( QString _textureName , int _ident ...@@ -834,6 +861,15 @@ void TextureControlPlugin::slotTextureUpdated( QString _textureName , int _ident
PluginFunctions::polyhedralMeshObject(obj)->textureNode()->set_repeat(texData->texture(_textureName).parameters.repeat); PluginFunctions::polyhedralMeshObject(obj)->textureNode()->set_repeat(texData->texture(_textureName).parameters.repeat);
} }
#endif #endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
else if (obj->dataType(DATA_BSPLINE_SURFACE)) {
// texcoords are parametric so nothing to update in the bspline surface mesh
// Texture has been bound to that object by slotAddTexture.. directly or by fileOpened from global texture
// Just activate it
PluginFunctions::bsplineSurfaceObject(obj)->textureNode()->activateTexture(texData->texture(_textureName).glName());
PluginFunctions::bsplineSurfaceObject(obj)->textureNode()->set_repeat(texData->texture(_textureName).parameters.repeat);
}
#endif
// ================================================================================ // ================================================================================
// Mark texture as not dirty // Mark texture as not dirty
...@@ -1030,6 +1066,9 @@ void TextureControlPlugin::slotObjectUpdated(int _identifier, const UpdateType& ...@@ -1030,6 +1066,9 @@ void TextureControlPlugin::slotObjectUpdated(int _identifier, const UpdateType&
#endif #endif
#ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
&& !obj->dataType( DATA_POLYHEDRAL_MESH ) && !obj->dataType( DATA_POLYHEDRAL_MESH )
#endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
&& !obj->dataType(DATA_BSPLINE_SURFACE)
#endif #endif
) )
return; return;
...@@ -1366,6 +1405,10 @@ void TextureControlPlugin::pluginsInitialized() { ...@@ -1366,6 +1405,10 @@ void TextureControlPlugin::pluginsInitialized() {
emit addContextMenuItem(contextMenu_->menuAction() ,DATA_POLYHEDRAL_MESH , CONTEXTOBJECTMENU ); emit addContextMenuItem(contextMenu_->menuAction() ,DATA_POLYHEDRAL_MESH , CONTEXTOBJECTMENU );
#endif #endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
emit addContextMenuItem(contextMenu_->menuAction(), DATA_BSPLINE_SURFACE, CONTEXTOBJECTMENU);
#endif
slotTextureAdded("Reflection Lines","reflection_map.png",2); slotTextureAdded("Reflection Lines","reflection_map.png",2);
slotSetTextureMode("Reflection Lines","type=environmentmap"); slotSetTextureMode("Reflection Lines","type=environmentmap");
} }
...@@ -1409,6 +1452,12 @@ void TextureControlPlugin::applyDialogSettings(TextureData* _texData, QString _t ...@@ -1409,6 +1452,12 @@ void TextureControlPlugin::applyDialogSettings(TextureData* _texData, QString _t
} }
#endif #endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
else if (obj->dataType(DATA_BSPLINE_SURFACE)) {
PluginFunctions::bsplineSurfaceObject(obj)->textureNode()->set_texture(imageStore().getImage(texture.textureImageId(), 0), texture.glName());
}
#endif
// Always mark texture as dirty // Always mark texture as dirty
_texData->texture( _textureName ).setDirty(); _texData->texture( _textureName ).setDirty();
...@@ -1678,6 +1727,12 @@ void TextureControlPlugin::doSwitchTexture( QString _textureName , int _id ) { ...@@ -1678,6 +1727,12 @@ void TextureControlPlugin::doSwitchTexture( QString _textureName , int _id ) {
// Activate the requested texture in texture node // Activate the requested texture in texture node
PluginFunctions::polyhedralMeshObject(obj)->textureNode()->activateTexture( texData->texture( _textureName ).glName() ); PluginFunctions::polyhedralMeshObject(obj)->textureNode()->activateTexture( texData->texture( _textureName ).glName() );
} }
#endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
else if (obj->dataType(DATA_BSPLINE_SURFACE)){
// Activate the requested texture in texture node
PluginFunctions::bsplineSurfaceObject(obj)->textureNode()->activateTexture(texData->texture(_textureName).glName());
}
#endif #endif
else { else {
emit log(LOGERR, "doSwitchTexture: Texture Error ( mesh required) for Texture: " + _textureName ); emit log(LOGERR, "doSwitchTexture: Texture Error ( mesh required) for Texture: " + _textureName );
...@@ -1752,6 +1807,9 @@ void TextureControlPlugin::slotUpdateContextMenu( int _objectId ) { ...@@ -1752,6 +1807,9 @@ void TextureControlPlugin::slotUpdateContextMenu( int _objectId ) {
#endif #endif
#ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
&& !obj->dataType( DATA_POLYHEDRAL_MESH ) && !obj->dataType( DATA_POLYHEDRAL_MESH )
#endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
&& !obj->dataType(DATA_BSPLINE_SURFACE)
#endif #endif
) )
{ {
......
...@@ -75,6 +75,10 @@ ...@@ -75,6 +75,10 @@
#include <ObjectTypes/HexahedralMesh/HexahedralMesh.hh> #include <ObjectTypes/HexahedralMesh/HexahedralMesh.hh>
#endif #endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
#include <ObjectTypes/BSplineSurface/BSplineSurface.hh>
#endif
#include <OpenFlipper/common/Types.hh> #include <OpenFlipper/common/Types.hh>
#include "textureProperties.hh" #include "textureProperties.hh"
......
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