Skip to content

Commit

Permalink
#5746: Introduce a texture tool scene graph module which is going to …
Browse files Browse the repository at this point in the history
…be hosted in the core module. It will collect and represent the editable faces, patches and their vertices, and expose them to both the UI module for rendering as well as to the Manipulator algorithms which are in the same binary.
  • Loading branch information
codereader committed Sep 13, 2021
1 parent 1520dbb commit 050efe5
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 9 deletions.
51 changes: 51 additions & 0 deletions include/itexturetoolmodel.h
@@ -0,0 +1,51 @@
#pragma once

#include "imodule.h"
#include "inode.h"

namespace textool
{

// The base element of every node in the ITextureToolSceneGraph
class INode
{
public:
virtual ~INode() {}

using Ptr = std::shared_ptr<INode>;

// The scene node this texture tool node is relating to
virtual scene::INodePtr getSceneNode() = 0;
};

/**
* The scene graph of all texture tool items. From all the selected
* items in the regular SceneGraph the texture-editable elements
* are extracted and put into this graph.
*
* It can have multiple top-level elements (faces, patches) each of which
* can have an arbitrary number of child elements (vertices).
*
* Like in the regular scene graph, some of the elements have special
* properties like being renderable or transformable, which manifests
* in them implementing the corresponding interface.
*/
class ITextureToolSceneGraph :
public RegisterableModule
{
public:
virtual ~ITextureToolSceneGraph() {}

// Iterate over every node in this graph calling the given functor
virtual void foreachNode(const std::function<bool(const INode::Ptr&)>& functor) = 0;
};

}

constexpr const char* const MODULE_TEXTOOL_SCENEGRAPH("TextureToolSceneGraph");

inline textool::ITextureToolSceneGraph& GlobalTextureToolSceneGraph()
{
static module::InstanceReference<textool::ITextureToolSceneGraph> _reference(MODULE_TEXTOOL_SCENEGRAPH);
return _reference;
}
Expand Up @@ -44,7 +44,7 @@ void TextureRotator::transform(const Matrix4& pivot2world, const VolumeTest& vie
auto sign = _start.crossProduct(current) < 0 ? +1 : -1;
_curAngle *= sign;

//rMessage() << "Angle " << radians_to_degrees(angle) << std::endl;
_rotateFunctor(_curAngle);
}

void TextureRotator::resetCurAngle()
Expand All @@ -58,6 +58,7 @@ Vector3::ElementType TextureRotator::getCurAngle() const
}

TextureToolRotateManipulator::TextureToolRotateManipulator() :
_rotator(std::bind(&TextureToolRotateManipulator::rotateSelected, this, std::placeholders::_1)),
_renderableCircle(8 << 3)
{
draw_circle(8, 1.0f, &_renderableCircle.front(), RemapXYZ());
Expand Down Expand Up @@ -110,14 +111,8 @@ void TextureToolRotateManipulator::testSelect(SelectionTest& test, const Matrix4

if (!selector.empty())
{
//rMessage() << "Got the circle!" << std::endl;

selector.begin()->second->setSelected(true);
}
else
{
//rMessage() << "MISSED" << std::endl;
}
}

void TextureToolRotateManipulator::renderComponents(const Matrix4& pivot2World)
Expand Down Expand Up @@ -148,4 +143,9 @@ void TextureToolRotateManipulator::renderComponents(const Matrix4& pivot2World)
glPopMatrix();
}

void TextureToolRotateManipulator::rotateSelected(double angle)
{
// TODO
}

}
Expand Up @@ -16,9 +16,13 @@ class TextureRotator :

// The most recently calculated angle for rendering purposes
Vector2::ElementType _curAngle;

std::function<void(Vector2::ElementType)> _rotateFunctor;

public:
TextureRotator() :
_curAngle(0)
TextureRotator(const std::function<void(Vector2::ElementType)>& rotateFunctor) :
_curAngle(0),
_rotateFunctor(rotateFunctor)
{}

void beginTransformation(const Matrix4& pivot2world, const VolumeTest& view, const Vector2& devicePoint) override;
Expand Down Expand Up @@ -55,6 +59,9 @@ class TextureToolRotateManipulator :
virtual bool isSelected() const override;
virtual void testSelect(SelectionTest& test, const Matrix4& pivot2world) override;
virtual void renderComponents(const Matrix4& pivot2World) override;

private:
void rotateSelected(double angle);
};

}
1 change: 1 addition & 0 deletions tools/msvc/include.vcxproj
Expand Up @@ -198,6 +198,7 @@
<ClInclude Include="..\..\include\ispeakernode.h" />
<ClInclude Include="..\..\include\istatusbarmanager.h" />
<ClInclude Include="..\..\include\itextstream.h" />
<ClInclude Include="..\..\include\itexturetoolmodel.h" />
<ClInclude Include="..\..\include\itexturetoolview.h" />
<ClInclude Include="..\..\include\itoolbarmanager.h" />
<ClInclude Include="..\..\include\itraceable.h" />
Expand Down

0 comments on commit 050efe5

Please sign in to comment.