#ifndef _blindDataShader #define _blindDataShader //- // ========================================================================== // Copyright (C) 1995 - 2005 Alias Systems Corp. and/or its licensors. All // rights reserved. // // The coded instructions, statements, computer programs, and/or related // material (collectively the "Data") in these files are provided by Alias // Systems Corp. ("Alias") and/or its licensors for the exclusive use of the // Customer (as defined in the Alias Software License Agreement that // accompanies this Alias software). Such Customer has the right to use, // modify, and incorporate the Data into other products and to distribute such // products for use by end-users. // // THE DATA IS PROVIDED "AS IS". ALIAS HEREBY DISCLAIMS ALL WARRANTIES // RELATING TO THE DATA, INCLUDING, WITHOUT LIMITATION, ANY AND ALL EXPRESS OR // IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND/OR FITNESS FOR A // PARTICULAR PURPOSE. IN NO EVENT SHALL ALIAS BE LIABLE FOR ANY DAMAGES // WHATSOEVER, WHETHER DIRECT, INDIRECT, SPECIAL, OR PUNITIVE, WHETHER IN AN // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, OR IN EQUITY, // ARISING OUT OF ACCESS TO, USE OF, OR RELIANCE UPON THE DATA. // ========================================================================== //+ // // *************************************************************************** // // How to use: // This plugin is an example plug-in. Its purpose is to show how to use // custom blind data in the hardware shader node. To try out the plugin, // you can run the provided mel script: "blindDataShader.mel" after manually // loading the plugin into memory. // // The mel script creates a polygonal grid-plane with random heights. // Each vertex has an associated color value that is stored as three // independant double blind data values: "red", "green" and "blue". // The height of the vertices is used to calculate the color. All this // work is done in the blindDataMesh class (blindDataMesh.h/.cpp). // // The mel script then associates the mesh with a new blindDataShader node // (blindDataShader.h/.cpp) This node gets from the blind data of the mesh // the vertex color values and renders the mesh. // // To get the blind data associated with the vertex IDs, you must do the // following: // 1. In your MPxHwShaderNode-extended class, you must overwrite the virtual // function: "provideVertexIDs" and return true. The "geometry" function // will receive the component IDs of the vertices in the "vertexIDs" formal // parameter. If you do not overwrite this function or it returns false, // that parameter will be NULL. // 2. You can create a MFnMesh object from the MDrawRequest object and use it // to get the raw blind data. // #include class blindDataShader : public MPxHwShaderNode { public: virtual MStatus bind(const MDrawRequest& request, M3dView& view); virtual MStatus unbind(const MDrawRequest& request, M3dView& view); virtual MStatus geometry( const MDrawRequest& request, M3dView& view, int prim, unsigned int writable, int indexCount, const unsigned int * indexArray, int vertexCount, const int * vertexIDs, const float * vertexArray, int normalCount, const float ** normalArrays, int colorCount, const float ** colorArrays, int texCoordCount, const float ** texCoordArrays); virtual bool provideVertexIDs() { return true; } public: // Standard Node functions // virtual MStatus compute( const MPlug&, MDataBlock& ); static void * creator(); static MStatus initialize(); static MTypeId id; }; #endif /* _blindDataShader */