tyVolumeObjectExt Interface

The tyVolumeObjectExt interface can be used to query tyFlow volume data.

/*Copyright (c) 2025, Tyson Ibele Productions Inc.
All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of 
this file ("tyVolumeObjectExt.h") and associated documentation files (the "Software"), 
to deal in the Software without restriction, including without limitation the rights 
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 
the Software, and to permit persons to whom the Software is furnished to do so, 
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all 
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 
OR OTHER DEALINGS IN THE SOFTWARE.
*/

#pragma once

//headers from Max SDK
#include "object.h"
#include "ipoint3.h"
#include "point3.h"
#include "matrix3.h"

#define TYVOLUME_INTERFACE_V1 Interface_ID(0x1213b15, 0x1e23512)

/*

tyVolumeObjectExt (v1) CHANGELOG:

05/20/2024:

* initial creation of basic volume interface

*/
	
namespace tyFlow
{		
	struct tyVolumeContainer
	{
		/*
		The world-space transform of the volume,
		relative to its zero-th coordinate.
		*/
		Matrix3 transform;
		
		/*
		The number of voxels the volume contains 
		along its X/Y/Z axes. 
		*/
		IPoint3 dimensions;

		/*
		Accessor functions which allow you to query per-voxel
		grid values, given a volume-local XYZ coordinate. 
		*/
		virtual float GetDensity(const IPoint3 xyz) = 0;
		virtual float GetTemperature(const IPoint3 xyz) = 0;
		virtual float GetFuel(const IPoint3 xyz) = 0;
		virtual Point3 GetVelocity(const IPoint3 xyz) = 0;
	};

	class tyVolumeObjectExt
	{
	public:
			
		/*		
		The plugin argument of this function takes the name of the plugin
		querying this interface, in lowercase letters.
		Ex: _T("arnold"), _T("octane"), _T("redshift"), _T("vray"), etc.
		This is a somewhat arbitrary value, but by having plugins identify
		themselves during a query, tyFlow can internally determine if any
		plugin-specific edge-cases need to be processed.	
		*/
		virtual void UpdateVolumes(INode* node, TimeValue t, TSTR plugin) = 0;

		/*
		Returns the total number of volumes available. 
		*/
		virtual int NumVolumes() = 0;

		/*
		Returns the tyVolumeContainer for a specific volume. 
		*/
		virtual tyVolumeContainer GetVolume(int idx) = 0;
	};
	
	typedef tyVolumeObjectExt tyVolumeInterface;
		
	inline tyVolumeInterface* GetTyVolumeInterface(BaseObject* obj)
	{
		return (tyVolumeInterface*)obj->GetInterface(TYVOLUME_INTERFACE_V1);
	}
};