Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions install/scripts/commands/shift_textures_randomly.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ def visitFace(self, face):
visitor = FaceVisitor()
GlobalSelectionSystem.foreachSelectedFace(visitor)

class PatchVisitor(dr.SelectionVisitor) :
def visit(self, node):
patch = node.getPatch()
if not patch.isNull():
s = random.randint(0, 100)
t = random.randint(0, 100)
patch.translateTexture(s, t)

patchVisitor = PatchVisitor()
GlobalSelectionSystem.foreachSelected(patchVisitor)

GlobalCameraManager.getActiveView().refresh()

# The variable __executeCommand__ evaluates to true
Expand Down
10 changes: 10 additions & 0 deletions install/scripts/commands/shift_textures_upwards_randomly.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ def visitFace(self, face):
visitor = FaceVisitor()
GlobalSelectionSystem.foreachSelectedFace(visitor)

class PatchVisitor(dr.SelectionVisitor) :
def visit(self, node):
patch = node.getPatch()
if not patch.isNull():
t = random.randint(0, 100)
patch.translateTexture(0, t)

patchVisitor = PatchVisitor()
GlobalSelectionSystem.foreachSelected(patchVisitor)

GlobalCameraManager.getActiveView().refresh()

# The variable __executeCommand__ evaluates to true
Expand Down
9 changes: 9 additions & 0 deletions plugins/script/interfaces/PatchInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ void ScriptPatchNode::controlPointsChanged()
patchNode->getPatch().controlPointsChanged();
}

void ScriptPatchNode::translateTexture(float s, float t)
{
IPatchNodePtr patchNode = std::dynamic_pointer_cast<IPatchNode>(_node.lock());
if (patchNode == NULL) return;

patchNode->getPatch().translateTexture(s, t);
}

const std::string& ScriptPatchNode::getShader() const
{
IPatchNodePtr patchNode = std::dynamic_pointer_cast<IPatchNode>(_node.lock());
Expand Down Expand Up @@ -265,6 +273,7 @@ void PatchInterface::registerInterface(py::module& scope, py::dict& globals)
patchNode.def("getSubdivisions", &ScriptPatchNode::getSubdivisions);
patchNode.def("setFixedSubdivisions", &ScriptPatchNode::setFixedSubdivisions);
patchNode.def("controlPointsChanged", &ScriptPatchNode::controlPointsChanged);
patchNode.def("translateTexture", &ScriptPatchNode::translateTexture);
patchNode.def("getTesselatedPatchMesh", &ScriptPatchNode::getTesselatedPatchMesh);

// Define the GlobalPatchCreator interface
Expand Down
3 changes: 3 additions & 0 deletions plugins/script/interfaces/PatchInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class ScriptPatchNode :

void controlPointsChanged();

// Texture manipulation
void translateTexture(float s, float t);

// Shader handling
const std::string& getShader() const;
void setShader(const std::string& name);
Expand Down