// RiExamplesPlugin.h : Declaration of the CRiExamplesPlugin

#pragma once

/**
@interface IRiExamplesPlugin

This interface declares script commands that are added into Rosetta after plugin is initialized. Use this script commands 
*/

[
	object,
	uuid("1EC91013-40C8-4cae-AB13-48A756DA46F2"),
	dual, helpstring("IRiExamplesPlugin Interface"),
	pointer_default(unique)
]
__interface IRiExamplesPlugin : IDispatch
{
	/**
		This example demonstrates how to create simple script command which prepares RcHelloWorldCmd and executes it.
		
		Execute command by typing ExamplesPlugin.HelloWorld() in a command prompt.
    */
    [id(1), helpstring("method HelloWorld")] HRESULT HelloWorld();


	/**
		This example demonstrates how to pass parameters from script to command using connectors.
		
		Execute command by typing ExamplesPlugin.ParameterPassing(10.5,'some text') in a command prompt.
    */
    [id(2), helpstring("method ParameterPassing")] HRESULT ParameterPassing(float fFlt, BSTR szStr);

	
	/**
		Topology example demonstrates how to use event recorder to handle undo/redo for changes on dependency graph. It also
		demonstrates how to create various rosetta nodes like encapsulator, shape or matrix and how to work with connectors.

		Execute command by typing ExamplesPlugin.TopologyExample() in a command prompt, then click on Undo and Redo icon.
	
		Example creates cube object in scene center.
     */
    [id(3), helpstring("method TopologyExample")] HRESULT TopologyExample();
	

	/**
		Material modify example demonstrates how to use space3d material function set to work with materials. Example also demonstrates
		passing simple parameters (BSTR string) to command using connectors. 

		Again, event recorder is used for undo/redo. 

		Execute example by selecting mesh object and typing ExamplesPlugin.MaterialModifyExample('') in a command prompt. You can 
		write node path directly as a parameter.
	
		Example takes first selected object and changes it's first material texture shader to red color
     */
    [id(4), helpstring("method MaterialModifyExample")] HRESULT MaterialModifyExample(BSTR szSelection);


	/**
	Shot example demonstrates how to use a functionality of physics to create own active behavior of objects. Example also demonstrates
	passing object's interface (VARIANT) to command using connectors in scripts. 

	Shot command creates ten small spheres with phys properties around the given point (vPosition) and gives to each sphere a speed (fPower) direct from the given point
	When physics is not running, command starts it. When physics is running, spheres are added directly to simulation.
	Command could be used for achieving an effects of bomb, speedy spheres added to simulation interact with other objects and push them, for example.

	Execute example typing ExamplesPlugin.Shot(20.0, 0) in a command prompt - 10 spheres will be added around the point (0,0,3) with speed of 20.0

	In jscript, you could used example in this way:
	
		var point = System.CreateDO('Math Package/Point Data'); ... create point data object
		point.x = 1.0; 
		point.y = 1.0;
		point.z = 3.4;											... init point object						

		ExamplesPlugin.Shot(15.0, point);						... execute command
		
	*/
	[id(5), helpstring("method Shot")] HRESULT Shot(float fPower, VARIANT vPosition);
	
	/**
	Camera transform example shows how to find active view and how to access its active camera. Command reads displays some
	camera information into debug window and sets random rotation and position.
	*/

	[id(6), helpstring("method CameraTransformExample")] HRESULT CameraTransformExample();

};


// CRiExamplesPlugin
[
	ATTRIBUTE_COCLASS,
	threading(both),
	vi_progid("ExamplesPlugin.RiExamplesPlugin"),
	progid("ExamplesPlugin.RiExamplesPlugin.1"),
	version(1.0),
	uuid("D1ACE24F-1B01-45e7-9E82-46AE6FE104C9"),
	helpstring("RiExamplesPlugin Class")
]

class ATL_NO_VTABLE CRiExamplesPlugin : 
    IMPLEMENT_DISPATCH(IRiExamplesPlugin),
    public IRsNamedItem,
	public IRsObject
{
public:
	CRiExamplesPlugin()
	{
	}


	//DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		return S_OK;
	}
	
	void FinalRelease() 
	{
	}

     // IRsObject
    RS_DECLARE_IRS_OBJECT(IRiExamplesPlugin, L"Examples plugin")

	// IRsNamedItem
	STDMETHOD(get_Name)(BSTR* pVal);

public:

    STDMETHOD(HelloWorld)();
	STDMETHOD(ParameterPassing)(float fFlt, BSTR szStr);
	STDMETHOD(TopologyExample)();
	STDMETHOD(MaterialModifyExample)(BSTR szSelection);
	STDMETHOD(CameraTransformExample)();
	STDMETHOD(Shot)(float fPower, VARIANT vPosition);
};

