-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #554 from johnhaddon/mapOffset
Added a MapOffset node for offsetting texture coordinates.
- Loading branch information
Showing
9 changed files
with
409 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright (c) 2013, Image Engine Design Inc. All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are | ||
// met: | ||
// | ||
// * Redistributions of source code must retain the above | ||
// copyright notice, this list of conditions and the following | ||
// disclaimer. | ||
// | ||
// * Redistributions in binary form must reproduce the above | ||
// copyright notice, this list of conditions and the following | ||
// disclaimer in the documentation and/or other materials provided with | ||
// the distribution. | ||
// | ||
// * Neither the name of John Haddon nor the names of | ||
// any other contributors to this software may be used to endorse or | ||
// promote products derived from this software without specific prior | ||
// written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
// | ||
////////////////////////////////////////////////////////////////////////// | ||
|
||
#ifndef GAFFERSCENE_MAPOFFSET_H | ||
#define GAFFERSCENE_MAPOFFSET_H | ||
|
||
#include "GafferScene/SceneElementProcessor.h" | ||
|
||
namespace GafferScene | ||
{ | ||
|
||
/// Applies offsets to texture coordinates. | ||
class MapOffset : public SceneElementProcessor | ||
{ | ||
|
||
public : | ||
|
||
MapOffset( const std::string &name=defaultName<MapOffset>() ); | ||
virtual ~MapOffset(); | ||
|
||
IE_CORE_DECLARERUNTIMETYPEDEXTENSION( GafferScene::MapOffset, MapOffsetTypeId, SceneElementProcessor ); | ||
|
||
Gaffer::V2fPlug *offsetPlug(); | ||
const Gaffer::V2fPlug *offsetPlug() const; | ||
|
||
Gaffer::IntPlug *udimPlug(); | ||
const Gaffer::IntPlug *udimPlug() const; | ||
|
||
Gaffer::StringPlug *sNamePlug(); | ||
const Gaffer::StringPlug *sNamePlug() const; | ||
|
||
Gaffer::StringPlug *tNamePlug(); | ||
const Gaffer::StringPlug *tNamePlug() const; | ||
|
||
virtual void affects( const Gaffer::Plug *input, AffectedPlugsContainer &outputs ) const; | ||
|
||
protected : | ||
|
||
virtual bool processesObject() const; | ||
virtual void hashProcessedObject( const ScenePath &path, const Gaffer::Context *context, IECore::MurmurHash &h ) const; | ||
virtual IECore::ConstObjectPtr computeProcessedObject( const ScenePath &path, const Gaffer::Context *context, IECore::ConstObjectPtr inputObject ) const; | ||
|
||
private : | ||
|
||
static size_t g_firstPlugIndex; | ||
|
||
}; | ||
|
||
} // namespace GafferScene | ||
|
||
#endif // GAFFERSCENE_MAPOFFSET_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
########################################################################## | ||
# | ||
# Copyright (c) 2013, Image Engine Design Inc. All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are | ||
# met: | ||
# | ||
# * Redistributions of source code must retain the above | ||
# copyright notice, this list of conditions and the following | ||
# disclaimer. | ||
# | ||
# * Redistributions in binary form must reproduce the above | ||
# copyright notice, this list of conditions and the following | ||
# disclaimer in the documentation and/or other materials provided with | ||
# the distribution. | ||
# | ||
# * Neither the name of John Haddon nor the names of | ||
# any other contributors to this software may be used to endorse or | ||
# promote products derived from this software without specific prior | ||
# written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
########################################################################## | ||
|
||
import os | ||
import unittest | ||
|
||
import IECore | ||
|
||
import Gaffer | ||
import GafferTest | ||
import GafferScene | ||
import GafferSceneTest | ||
|
||
class MapOffsetTest( GafferSceneTest.SceneTestCase ) : | ||
|
||
def test( self ) : | ||
|
||
plane = GafferScene.Plane() | ||
offset = GafferScene.MapOffset() | ||
offset["in"].setInput( plane["out"] ) | ||
|
||
self.assertSceneValid( offset["out"] ) | ||
self.assertScenesEqual( offset["out"], plane["out"] ) | ||
|
||
inputObject = plane["out"].object( "/plane" ) | ||
|
||
self.assertEqual( offset["out"].object( "/plane" ), inputObject ) | ||
|
||
offset["udim"].setValue( 1022 ) | ||
self.assertSceneValid( offset["out"] ) | ||
|
||
for i, s in enumerate( offset["out"].object( "/plane" )["s"].data ) : | ||
self.assertEqual( s, inputObject["s"].data[i] + 1 ) | ||
|
||
for i, t in enumerate( offset["out"].object( "/plane" )["t"].data ) : | ||
self.assertEqual( t, inputObject["t"].data[i] + 2 ) | ||
|
||
offset["offset"].setValue( IECore.V2f( 0.5, 1.5 ) ) | ||
self.assertSceneValid( offset["out"] ) | ||
|
||
for i, s in enumerate( offset["out"].object( "/plane" )["s"].data ) : | ||
self.assertEqual( s, inputObject["s"].data[i] + 1.5 ) | ||
|
||
for i, t in enumerate( offset["out"].object( "/plane" )["t"].data ) : | ||
self.assertEqual( t, inputObject["t"].data[i] + 3.5 ) | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
########################################################################## | ||
# | ||
# Copyright (c) 2013, Image Engine Design Inc. All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are | ||
# met: | ||
# | ||
# * Redistributions of source code must retain the above | ||
# copyright notice, this list of conditions and the following | ||
# disclaimer. | ||
# | ||
# * Redistributions in binary form must reproduce the above | ||
# copyright notice, this list of conditions and the following | ||
# disclaimer in the documentation and/or other materials provided with | ||
# the distribution. | ||
# | ||
# * Neither the name of John Haddon nor the names of | ||
# any other contributors to this software may be used to endorse or | ||
# promote products derived from this software without specific prior | ||
# written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
########################################################################## | ||
|
||
import Gaffer | ||
import GafferUI | ||
import GafferScene | ||
|
||
GafferUI.Metadata.registerNodeDescription( | ||
|
||
GafferScene.MapOffset, | ||
|
||
"""Adds an offset to object texture coordinates. Provides a convenient way of looking at specific texture UDIMs.""", | ||
|
||
"offset", | ||
"An offset added to the texture coordinates. Note that moving the texture coordinates in the positive direction will move the texture in the negative direction.", | ||
|
||
"udim", | ||
"A specific UDIM to offset the texture coordinates to. The UDIM is converted to an offset which is added to the offset above.", | ||
|
||
"sName", | ||
"The name of the primitive variable holding the s coordinate.", | ||
|
||
"tName", | ||
"The name of the primitive variable holding the t coordinate.", | ||
|
||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.