-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de1f63f
commit 5b78c7a
Showing
7 changed files
with
691 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
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,116 @@ | ||
////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright (c) 2020, Don Boogert. 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 Don Boogert 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 GAFFERVDB_SCATTERPOINTS_H | ||
#define GAFFERVDB_SCATTERPOINTS_H | ||
|
||
#include "GafferVDB/Export.h" | ||
#include "GafferVDB/TypeIds.h" | ||
|
||
#include "GafferScene/BranchCreator.h" | ||
|
||
#include "Gaffer/NumericPlug.h" | ||
#include "Gaffer/StringPlug.h" | ||
|
||
namespace GafferVDB | ||
{ | ||
|
||
class GAFFERVDB_API VolumeScatter : public GafferScene::BranchCreator | ||
{ | ||
|
||
public : | ||
|
||
VolumeScatter(const std::string &name = defaultName<VolumeScatter>() ); | ||
~VolumeScatter(); | ||
|
||
IE_CORE_DECLARERUNTIMETYPEDEXTENSION( GafferVDB::VolumeScatter, VolumeScatterTypeId, GafferScene::BranchCreator ); | ||
|
||
Gaffer::StringPlug *namePlug(); | ||
const Gaffer::StringPlug *namePlug() const; | ||
|
||
Gaffer::StringPlug *gridPlug(); | ||
const Gaffer::StringPlug *gridPlug() const; | ||
|
||
enum class Mode | ||
{ | ||
Density, | ||
PointCount | ||
}; | ||
|
||
Gaffer::IntPlug *modePlug(); | ||
const Gaffer::IntPlug *modePlug() const; | ||
|
||
Gaffer::IntPlug *pointCountPlug(); | ||
const Gaffer::IntPlug *pointCountPlug() const; | ||
|
||
Gaffer::FloatPlug *densityPlug(); | ||
const Gaffer::FloatPlug *densityPlug() const; | ||
|
||
Gaffer::StringPlug *pointTypePlug(); | ||
const Gaffer::StringPlug *pointTypePlug() const; | ||
|
||
protected : | ||
|
||
bool affectsBranchBound( const Gaffer::Plug *input ) const override; | ||
void hashBranchBound( const ScenePath &sourcePath, const ScenePath &branchPath, const Gaffer::Context *context, IECore::MurmurHash &h ) const override; | ||
Imath::Box3f computeBranchBound( const ScenePath &sourcePath, const ScenePath &branchPath, const Gaffer::Context *context ) const override; | ||
|
||
bool affectsBranchTransform( const Gaffer::Plug *input ) const override; | ||
void hashBranchTransform( const ScenePath &sourcePath, const ScenePath &branchPath, const Gaffer::Context *context, IECore::MurmurHash &h ) const override; | ||
Imath::M44f computeBranchTransform( const ScenePath &sourcePath, const ScenePath &branchPath, const Gaffer::Context *context ) const override; | ||
|
||
bool affectsBranchAttributes( const Gaffer::Plug *input ) const override; | ||
void hashBranchAttributes( const ScenePath &sourcePath, const ScenePath &branchPath, const Gaffer::Context *context, IECore::MurmurHash &h ) const override; | ||
IECore::ConstCompoundObjectPtr computeBranchAttributes( const ScenePath &sourcePath, const ScenePath &branchPath, const Gaffer::Context *context ) const override; | ||
|
||
bool affectsBranchObject( const Gaffer::Plug *input ) const override; | ||
void hashBranchObject( const ScenePath &sourcePath, const ScenePath &branchPath, const Gaffer::Context *context, IECore::MurmurHash &h ) const override; | ||
IECore::ConstObjectPtr computeBranchObject( const ScenePath &sourcePath, const ScenePath &branchPath, const Gaffer::Context *context ) const override; | ||
|
||
bool affectsBranchChildNames( const Gaffer::Plug *input ) const override; | ||
void hashBranchChildNames( const ScenePath &sourcePath, const ScenePath &branchPath, const Gaffer::Context *context, IECore::MurmurHash &h ) const override; | ||
IECore::ConstInternedStringVectorDataPtr computeBranchChildNames( const ScenePath &sourcePath, const ScenePath &branchPath, const Gaffer::Context *context ) const override; | ||
|
||
private: | ||
|
||
static size_t g_firstPlugIndex; | ||
}; | ||
|
||
IE_CORE_DECLAREPTR( VolumeScatter ) | ||
|
||
} // namespace GafferVDB | ||
|
||
#endif // GAFFERVDB_SCATTERPOINTS_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
########################################################################## | ||
# | ||
# Copyright (c) 2020, Don Boogert. 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 Don Boogert 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 GafferUI | ||
import GafferVDB | ||
|
||
GafferUI.Metadata.registerNode( | ||
|
||
GafferVDB.VolumeScatter, | ||
|
||
'description', | ||
""" | ||
Scatter points into active voxels of VDB grid | ||
""", | ||
|
||
"layout:activator:density", lambda node : node["mode"].getValue() == GafferVDB.VolumeScatter.Mode.Density, | ||
"layout:activator:pointCount", lambda node : node["mode"].getValue() == GafferVDB.VolumeScatter.Mode.PointCount, | ||
|
||
plugs = { | ||
|
||
"name" : [ | ||
|
||
"description", | ||
""" | ||
The name given to the object generated - | ||
this will be placed under the parent in | ||
the scene hierarchy. | ||
""", | ||
|
||
], | ||
|
||
'grid' : [ | ||
|
||
'description', | ||
""" | ||
Name of grid in VDBObject in which points will be scattered | ||
""", | ||
|
||
], | ||
|
||
'mode' : [ | ||
|
||
'description', | ||
""" | ||
Select whether to generate a fixed number of points distributed over any active | ||
voxels, or a density of points based on the value of the selected grid and a density | ||
multiplier. | ||
""", | ||
|
||
"preset:Density", GafferVDB.VolumeScatter.Mode.Density, | ||
"preset:Point Count", GafferVDB.VolumeScatter.Mode.PointCount, | ||
|
||
"plugValueWidget:type", "GafferUI.PresetsPlugValueWidget", | ||
|
||
], | ||
|
||
'pointCount' : [ | ||
|
||
'description', | ||
""" | ||
If the total number of points to generate. | ||
""", | ||
"layout:visibilityActivator", "pointCount", | ||
|
||
], | ||
|
||
'density' : [ | ||
|
||
'description', | ||
""" | ||
This density is multiplied with the value of the grid to produce a number of points per unit volume. | ||
""", | ||
"layout:visibilityActivator", "density", | ||
|
||
], | ||
|
||
"pointType" : [ | ||
|
||
"description", | ||
""" | ||
The render type of the points. This defaults to | ||
"gl:point" so that the points are rendered in a | ||
lightweight manner in the viewport. | ||
""", | ||
|
||
"preset:GL Point", "gl:point", | ||
"preset:Particle", "particle", | ||
"preset:Sphere", "sphere", | ||
"preset:Disk", "disk", | ||
"preset:Patch", "patch", | ||
"preset:Blobby", "blobby", | ||
|
||
"plugValueWidget:type", "GafferUI.PresetsPlugValueWidget", | ||
|
||
], | ||
|
||
"destination" : [ | ||
|
||
"description", | ||
""" | ||
The location where the points primitives will be placed in the output scene. | ||
When the destination is evaluated, the `${scene:path}` variable holds | ||
the location of the source mesh, so the default value parents the points | ||
under the mesh. | ||
> Tip : `${scene:path}/..` may be used to place the points alongside the | ||
> source mesh. | ||
""", | ||
|
||
], | ||
|
||
} | ||
) |
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.