TuttleOFX  1
camera.h
Go to the documentation of this file.
00001 #ifndef nukeOfxCamera_h
00002 #define nukeOfxCamera_h
00003 
00004 #include "ofxImageEffect.h"
00005 
00006 /*
00007 Software License :
00008 
00009 Copyright (c) 2010, The Foundry Visionmongers Ltd. All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without
00012 modification, are permitted provided that the following conditions are met:
00013 
00014     * Redistributions of source code must retain the above copyright notice,
00015       this list of conditions and the following disclaimer.
00016     * Redistributions in binary form must reproduce the above copyright notice,
00017       this list of conditions and the following disclaimer in the documentation
00018       and/or other materials provided with the distribution.
00019     * Neither the name The Foundry Visionmongers Ltd, nor the names of its 
00020       contributors may be used to endorse or promote products derived from this
00021       software without specific prior written permission.
00022 
00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00024 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00025 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00026 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
00027 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00028 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00030 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00031 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00032 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 */
00034 
00035 /** @file nukeOfxCamera.h
00036 
00037 This file defines a custom OFX extension to NUKE that allows cameras to
00038 be defined as nodal inputs to an image processing effect. It uses a 
00039 custom suite that allows you to define camera inputs to an effect in a similar
00040 manner as image clips are defined in the standard image processing API.
00041 
00042 It uses the standard descriptor/instance split that is common to other OFX
00043 objects. So during effect description you define a camera input by name
00044 and set some properties on it.
00045 
00046 You can define more than one camera input to the effect, they will need
00047 different names however.
00048 
00049 After instance creation you can fetch data from a 'live' camera. This is
00050 done by via functions in the suite. As this is Nuke, you need to specify 
00051 a frame and a view to fetch the value at. The view is available as a custom
00052 nuke property passed into all actions from nuke.
00053 */
00054 
00055 /** @brief string to identify the Camera suite, pass to OfxHost::fetchSuite */
00056 #define kNukeOfxCameraSuite "NukeOfxCameraSuite"
00057 
00058 typedef struct NukeOfxCameraStruct *NukeOfxCameraHandle;
00059 
00060 #define kNukeOfxCameraProjectionModePerspective 0.0
00061 #define kNukeOfxCameraProjectionModeOrthographic 1.0
00062 #define kNukeOfxCameraProjectionModeUV 2.0
00063 #define kNukeOfxCameraProjectionModeSpherical 3.0
00064 
00065 /** @brief Name of the projection mode nuke camera parameter.
00066 
00067 This has only one dimension and can be one of four values...
00068   - \ref kNukeOfxCameraProjectionPerspective
00069   - \ref kNukeOfxCameraProjectionOrthographic
00070   - \ref kNukeOfxCameraProjectionUV
00071   - \ref kNukeOfxCameraProjectionSpherical
00072 */
00073 #define kNukeOfxCameraParamProjectionMode "projection_mode"
00074 
00075 /** @brief Name of the focal length nuke camera parameter.
00076 
00077 This has only one dimension.
00078 */
00079 #define kNukeOfxCameraParamFocalLength "focal"
00080 
00081 /** @brief Name of the horizontal aperture nuke camera parameter.
00082 
00083 This has only one dimension.
00084 */
00085 #define kNukeOfxCameraParamHorizontalAperture "haperture"
00086 
00087 /** @brief Name of the vertical aperture nuke camera parameter.
00088 
00089 This has only one dimension.
00090 */
00091 #define kNukeOfxCameraParamVerticalAperture "vaperture"
00092 
00093 /** @brief Name of the near clipping plane nuke camera parameter 
00094 
00095 This has only one dimension.
00096 */
00097 #define kNukeOfxCameraParamNear "near"
00098 
00099 /** @brief Name of the far clipping plane nuke camera parameter 
00100 
00101 This has only one dimension.
00102 */
00103 #define kNukeOfxCameraParamFar "far"
00104 
00105 /** @brief Name of the window translate nuke camera parameter 
00106 
00107 This has two dimensions.
00108 */
00109 #define kNukeOfxCameraParamWindowTranslate "win_translate"
00110 
00111 /** @brief Name of the window scale nuke camera parameter 
00112 
00113 This has two dimensions.
00114 */
00115 #define kNukeOfxCameraParamWindowScale "win_scale"
00116 
00117 /** @brief Name of the window roll scale nuke camera parameter 
00118 
00119 This has one dimension.
00120 */
00121 #define kNukeOfxCameraParamWindowRoll "winroll"
00122 
00123 /** @brief Name of the focal point nuke camera parameter 
00124 
00125 This has only one dimension.
00126 */
00127 #define kNukeOfxCameraParamFocalPoint "focal_point"
00128 
00129 /** @brief Name of the camera position parameter 
00130 
00131 This represents a homogenous 4x4 transform matrix
00132 that places the camera in 3D space. As such it has 16 values.
00133 */
00134 #define kNukeOfxCameraParamPositionMatrix "position_matrix"
00135 
00136 /** @brief A suite to use Nuke cameras.
00137 
00138 This suite provides the functions needed by a plugin to define and use camera inputs for a Nuke image effect plugin.
00139 
00140 Cameras are named and more than one camera can be attached as an input to an effect.
00141 
00142 Camera descriptor property sets are defined to have the following properties
00143         - \ref kOfxPropType - (read only) set to "NukeCamera"
00144         - \ref kOfxPropName - (read only) the name the camera was created with
00145         - \ref kOfxPropLabel - (read/write) the user visible label for the camera
00146         - \ref kOfxPropShortLabel - (read/write)
00147         - \ref kOfxPropLongLabel - (read/write)
00148         - \ref kOfxImageClipPropOptional - (read/write)
00149 
00150 Instance property sets have all the descriptor properties (as read only) and the following properties...
00151         - \ref kOfxImageClipPropConnected - (read only)
00152 */
00153 typedef struct NukeOfxCameraSuiteV1 {
00154   /** @brief Define a camera input to an effect.
00155 
00156    \arg pluginHandle - the decriptor handle passed into the 'describeInContext' action
00157    \arg name - unique name of the camera to define
00158    \arg propertySet - a property handle for the camera descriptor will be returned here
00159 
00160    Called by the plugin when the 'describeInContext' action has been called.  Sets up a camera
00161    input with the given name.  If not NULL, then a pointer to a PropertySetHandle for the Camera
00162    may be put in *propertySet.
00163 
00164    More than one camera can be defined, they will need different names.
00165   */
00166   OfxStatus (*cameraDefine)        (OfxImageEffectHandle pluginHandle, const char *name, OfxPropertySetHandle *propertySet);
00167 
00168   /** @brief Get the handle of the named camera input to an effect.
00169 
00170   \arg pluginHandle - an instance handle to the plugin
00171   \arg name         - name of camera, previously used in a camera define call
00172   \arg camera       - where to return the camera handle
00173   \arg propertySet  - if not null, the descriptor handle for the camera's property set will be placed here.
00174   */
00175   OfxStatus (*cameraGetHandle)     (OfxImageEffectHandle pluginHandle, const char *name, NukeOfxCameraHandle *camera, OfxPropertySetHandle *propertySet);
00176 
00177   /** @brief Get the property set for the given camera
00178   
00179   \arg camera       - the handle of the camera, as obtained from cameraGetHandle
00180   \arg propertySet  - will be set with a pointer to the property set
00181   */
00182   OfxStatus (*cameraGetPropertySet)(NukeOfxCameraHandle camera, OfxPropertySetHandle *propHandle);
00183 
00184   /** @brief Get an arbitrary camera parameter for a given time and view
00185   
00186   \arg camera       - the handle of the camera, as obtained from cameraGetHandle
00187   \arg time         - the time to evaluate the parameter for
00188   \arg view         - the view to evaluate the parameter for
00189   \arg paramName    - parameter name to look up (matches name of knob in Nuke, see defines at top of \ref ofxCamera.h)
00190   \arg baseReturnAddress - base address to store the evaluated result
00191   \arg returnSize   - the number of doubles at the baseReturnAddress
00192 
00193   @returns
00194   - ::kOfxStatOK         - if the parameter was fetched succesfully
00195   - ::kOfxStatFailed     - if the camera was not connected
00196   - ::kOfxStatErrUnknown - if the named parameter could not be found
00197   */
00198   OfxStatus (*cameraGetParameter)  (NukeOfxCameraHandle camera, const char* paramName, double time, int view, double* baseReturnAddress, int returnSize);
00199 } NukeOfxCameraSuiteV1;
00200 
00201 #endif