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
GLuint TextureNode::activeTexture()
{
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
// because normals aren't available in the vertex shader
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)
{
updateSurfaceMesh();
......
......@@ -212,10 +212,12 @@ class BSplineSurfaceNodeT : public BaseNode
/// 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_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_; }
private:
void pick_vertices( GLState& _state );
......
......@@ -246,6 +246,9 @@ update(UpdateType _type)
splineSurfaceNode()->knotSelectionTextureValid(false);
splineSurfaceNode()->updateGeometry();
if (textureNode())
splineSurfaceNode()->set_arb_texture(textureNode()->activeTexture());
}
else
{
......@@ -262,6 +265,9 @@ update(UpdateType _type)
splineSurfaceNode()->cpSelectionTextureValid(false);
else if (_type.contains(UPDATE_SELECTION_KNOTS))
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)
list( APPEND CURRENT_PLUGIN_DEPS OpenVolumeMesh )
endif()
if (EXISTS ${CMAKE_SOURCE_DIR}/ObjectTypes/BSplineSurface)
add_definitions (-DENABLE_BSPLINESURFACE_SUPPORT)
endif()
list(REMOVE_DUPLICATES CURRENT_PLUGIN_DEPS )
# use Qwt6 for QT5
......
......@@ -127,6 +127,11 @@ void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _fil
glName = PluginFunctions::polyhedralMeshObject(obj)->textureNode()->add_texture(imageStore().getImage(newId,0));
#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
// ================================================================================
......@@ -244,6 +249,9 @@ void TextureControlPlugin::addedEmptyObject( int _id ) {
#endif
#ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
&& !obj->dataType(DATA_POLYHEDRAL_MESH)
#endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
&& !obj->dataType(DATA_BSPLINE_SURFACE)
#endif
)
{
......@@ -289,6 +297,11 @@ void TextureControlPlugin::addedEmptyObject( int _id ) {
glName = PluginFunctions::polyhedralMeshObject(obj)->textureNode()->add_texture(imageStore().getImage(newImageId,0));
#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
// ================================================================================
......@@ -458,6 +471,12 @@ void TextureControlPlugin::slotTextureChangeImage( QString _textureName , QImage
}
#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();
}
......@@ -508,6 +527,11 @@ void TextureControlPlugin::slotTextureChangeImage( QString _textureName , QImage
else if ( o_it->dataType( DATA_POLYHEDRAL_MESH ) ) {
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
}
}
......@@ -765,6 +789,9 @@ void TextureControlPlugin::slotTextureUpdated( QString _textureName , int _ident
#endif
#ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
&& !obj->dataType( DATA_POLYHEDRAL_MESH )
#endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
&& !obj->dataType(DATA_BSPLINE_SURFACE)
#endif
)
return;
......@@ -834,6 +861,15 @@ void TextureControlPlugin::slotTextureUpdated( QString _textureName , int _ident
PluginFunctions::polyhedralMeshObject(obj)->textureNode()->set_repeat(texData->texture(_textureName).parameters.repeat);
}
#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
......@@ -1030,6 +1066,9 @@ void TextureControlPlugin::slotObjectUpdated(int _identifier, const UpdateType&
#endif
#ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
&& !obj->dataType( DATA_POLYHEDRAL_MESH )
#endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
&& !obj->dataType(DATA_BSPLINE_SURFACE)
#endif
)
return;
......@@ -1366,6 +1405,10 @@ void TextureControlPlugin::pluginsInitialized() {
emit addContextMenuItem(contextMenu_->menuAction() ,DATA_POLYHEDRAL_MESH , CONTEXTOBJECTMENU );
#endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
emit addContextMenuItem(contextMenu_->menuAction(), DATA_BSPLINE_SURFACE, CONTEXTOBJECTMENU);
#endif
slotTextureAdded("Reflection Lines","reflection_map.png",2);
slotSetTextureMode("Reflection Lines","type=environmentmap");
}
......@@ -1409,6 +1452,12 @@ void TextureControlPlugin::applyDialogSettings(TextureData* _texData, QString _t
}
#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
_texData->texture( _textureName ).setDirty();
......@@ -1678,6 +1727,12 @@ void TextureControlPlugin::doSwitchTexture( QString _textureName , int _id ) {
// Activate the requested texture in texture node
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
else {
emit log(LOGERR, "doSwitchTexture: Texture Error ( mesh required) for Texture: " + _textureName );
......@@ -1752,6 +1807,9 @@ void TextureControlPlugin::slotUpdateContextMenu( int _objectId ) {
#endif
#ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
&& !obj->dataType( DATA_POLYHEDRAL_MESH )
#endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
&& !obj->dataType(DATA_BSPLINE_SURFACE)
#endif
)
{
......
......@@ -75,6 +75,10 @@
#include <ObjectTypes/HexahedralMesh/HexahedralMesh.hh>
#endif
#ifdef ENABLE_BSPLINESURFACE_SUPPORT
#include <ObjectTypes/BSplineSurface/BSplineSurface.hh>
#endif
#include <OpenFlipper/common/Types.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