00001 /* 00002 * Copyright (c) 2012 00003 * Side Effects Software Inc. All rights reserved. 00004 * 00005 * Redistribution and use of Houdini Development Kit samples in source and 00006 * binary forms, with or without modification, are permitted provided that the 00007 * following conditions are met: 00008 * 1. Redistributions of source code must retain the above copyright notice, 00009 * this list of conditions and the following disclaimer. 00010 * 2. The name of Side Effects Software may not be used to endorse or 00011 * promote products derived from this software without specific prior 00012 * written permission. 00013 * 00014 * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS 00015 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00016 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 00017 * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 00018 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00019 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00020 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00021 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00022 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00023 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00024 * 00025 *---------------------------------------------------------------------------- 00026 * This is a simple particle system... Not too much to it, but this can be 00027 * used as a template for your own... 00028 */ 00029 00030 00031 #ifndef __SOP_SParticle_h__ 00032 #define __SOP_SParticle_h__ 00033 00034 #include <SOP/SOP_Node.h> 00035 00036 #define INT_PARM(name, idx, vidx, t) \ 00037 return evalInt(name, &myOffsets[idx], vidx, t); 00038 00039 #define FLT_PARM(name, idx, vidx, t) \ 00040 return evalFloat(name, &myOffsets[idx], vidx, t); 00041 00042 class GEO_ParticleVertex; 00043 class GEO_PrimParticle; 00044 class GU_RayIntersect; 00045 00046 namespace HDK_Sample { 00047 class SOP_SParticle : public SOP_Node 00048 { 00049 public: 00050 SOP_SParticle(OP_Network *net, const char *name, OP_Operator *op); 00051 virtual ~SOP_SParticle(); 00052 00053 static PRM_Template myTemplateList[]; 00054 static OP_Node *myConstructor(OP_Network*, const char *, 00055 OP_Operator *); 00056 00057 protected: 00058 virtual unsigned disableParms(); 00059 virtual const char *inputLabel(unsigned idx) const; 00060 00061 void birthParticle(); 00062 int moveParticle(GEO_ParticleVertex *vtx, 00063 const UT_Vector3 &force); 00064 00065 void initSystem(); 00066 void timeStep(float now); 00067 00068 // Method to cook geometry for the SOP 00069 virtual OP_ERROR cookMySop(OP_Context &context); 00070 00071 private: 00072 // These use defines to make it easy to add parms and remove them. 00073 // The evaluation routines use the indexed name lookup which is quite 00074 // fast, yet easy to change indices (since the order of the indices 00075 // doesn't have to be in sequential order... 00076 int RESET() { INT_PARM("reset", 0, 0, 0) } 00077 int BIRTH(float t) { INT_PARM("birth", 2, 0, t) } 00078 float FX(float t) { FLT_PARM("force", 1, 0, t) } 00079 float FY(float t) { FLT_PARM("force", 1, 1, t) } 00080 float FZ(float t) { FLT_PARM("force", 1, 2, t) } 00081 00082 const GU_Detail *mySource; 00083 int mySourceNum; // Source point to birth from 00084 int mySourceVel; // Velocity attrib in source 00085 00086 GU_RayIntersect *myCollision; 00087 00088 GEO_PrimParticle *mySystem; 00089 float myLastCookTime; // Last cooked time 00090 int myVelocity; // My velocity attribute 00091 int myLife; // My life attribute 00092 00093 static int *myOffsets; 00094 00095 // This variable is used together with the call to the "checkInputChanged" 00096 // routine to notify the handles (if any) if the input has changed. 00097 GU_DetailGroupPair myDetailGroupPair; 00098 }; 00099 } // End HDK_Sample namespace 00100 00101 #endif
1.5.9