VolumeTexture/VolumeTexture.cpp

VolumeTexture/VolumeTexture.cpp
//**************************************************************************/
// Copyright (c) 2012 Autodesk, Inc.
// All rights reserved.
//
// Use of this software is subject to the terms of the Autodesk license
// agreement provided at the time of installation or download, or which
// otherwise accompanies this software in either electronic or hard copy form.
//
//**************************************************************************/
// DESCRIPTION: Volume Texture Sampler for map extraction
// CREATED: March 2012
//**************************************************************************/
#include "VolumeTexture.h"
#include <math.h>
// This macro is needed to make the class ready for RTTI
IMPLEMENT_SCLASS( VolumeTexture, Sampler, "Volume Texture", 0 );
// This macro shares some info about the plugin.
MB_PLUGIN( "VolumeTexture", "Volumetric Texture Generator for Map Extraction", "Autodesk", "http://www.mudbox3d.com", NULL );
// This function is only called once, and has to return some basic info about the Sampler.
struct Sampler::DataInfo VolumeTexture::DataInfo( void ) const
{
struct DataInfo i;
// Name of the paint channel which will be used to preview the result of the extraction.
i.m_sMaterialChannelName = "Diffuse";
// Internal name of the Sampler. Other plugins might use this name to identify the Sampler.
i.m_sDataName = "volume";
return i;
};
// Main function of the Sampler. This will be called once for each point on the target surface, and must
// calculate the data (in this case a color) for the given surface point.
Data VolumeTexture::ProcessSurfacePoint( const TargetLocation &cTarget, const SurfacePoint &cSource )
{
// In this case the color will be simply calculated from the 3D position of the surface point
// of the source surface.
float d = cSource.WorldPosition().DistanceFromLine( Vector(), Vector( -2, 10, 4 ) );
float w = sinf(d)+1/2;
w = w*w;
w = w*w;
w = w*w;
w = w*w;
return Color( w, w, w );
};