00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Jonathan McGee 00008 * Side Effects 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * NAME: GEO library (C++) 00015 * 00016 * COMMENTS: GEO_Delta is an abstract class for recording changes to 00017 * point positions, as well as point, primitive, or vertex 00018 * attributes. 00019 * 00020 * This class is a simple interface to the GDT library classes, 00021 * specifically GDT_Detail, which inherits from GEO_Delta. 00022 * 00023 * Existing geometry-modifying functions which are called 00024 * from the Edit SOP must be modified to take a GEO_Delta 00025 * pointer as a parameter, and must record all changes 00026 * to the geometry through this interface. 00027 * 00028 * Example of a point position change: 00029 * void geo_foo(... , GEO_Delta *geodelta, ...) 00030 * { 00031 * . 00032 * . 00033 * . 00034 * GEO_Point *pt = points()(i); 00035 * 00036 * geodelta->beginPointPositionChange(pt); 00037 * pt->getPos().multiply3(xform); 00038 * geodelta->endChange(); 00039 * . 00040 * . 00041 * . 00042 * } 00043 * 00044 * IMPORTANT IMPLEMENTATION NOTES: 00045 * The functions in this class are designed to 00046 * be as fast as possible, while maintaining some 00047 * degree of flexibility. The following rules are 00048 * in place to ensure very fast operation: 00049 * 00050 * 1. Every begin*Change() call must be accompanied by 00051 * a following endChange() call. 00052 * 00053 * 2. If a call to beginPointPositionChange() (for example) 00054 * is made, then ONLY the position of the given point 00055 * must change before the call to endChange. Any other 00056 * changes will NOT be recorded. This applies to any 00057 * begin*Change() call. 00058 * 00059 * 3. The attribute dictionary MUST be specifed with a 00060 * call to set*AttribDict. Deltas will only be computed 00061 * for the attributes found in this dictionary. 00062 * A call to set*AttribDict should be found in the 00063 * Edit SOP, and in any place where the dictionary is 00064 * modified (which is why the set*AttribDict functions 00065 * are included in this interface, just in case. 00066 * Caution - this introduces a lot of additional cases 00067 * to consider). 00068 * 00069 * 4. It is important that the given attribute dictionary 00070 * stays constant for future begin/end calls, since the 00071 * computation of deltas depends on its structure. 00072 */ 00073 00074 #ifndef __GEO_Delta_h__ 00075 #define __GEO_Delta_h__ 00076 00077 #include "GEO_API.h" 00078 class GEO_Detail; 00079 class GEO_Point; 00080 class GEO_PointList; 00081 class GEO_Primitive; 00082 class GEO_PointAttribDict; 00083 class GEO_PrimAttribDict; 00084 class GEO_VertexAttribDict; 00085 00086 00087 class GEO_API GEO_Delta 00088 { 00089 public: 00090 GEO_Delta() {} 00091 virtual ~GEO_Delta() {} 00092 00093 // Applies the delta to a point. 00094 // For orthoganality, additional methods should be created as needed. 00095 virtual void applyScaledPointDelta(GEO_Detail &gdp, GEO_Point &pt, 00096 float scale) const = 0; 00097 virtual void applyScaledVertexDelta(GEO_Detail &gdp, 00098 GEO_Primitive &prim, int vtxidx, 00099 float scale) const = 0; 00100 00101 // Begin changes to a point's position 00102 virtual void beginPointPositionChange( 00103 const GEO_Point &pt) = 0; 00104 00105 // Begin changes to a point's attributes 00106 virtual void beginPointAttributeChange( 00107 const GEO_Point &pt) = 0; 00108 00109 // Begin changes to a point list's attributes 00110 // NOTES: 00111 // - This function will use MUCH more memory than 00112 // beginPointAttributeChange. 00113 // - It should only be used when you KNOW that ALL the point 00114 // attributes on the gdp will change. beginPointAttributeChange is 00115 // much faster when only some point attributes will change, since 00116 // you can ignore the point attributes that don't matter. 00117 virtual void beginPointListAttributeChange( 00118 const GEO_PointList &ptlist) = 0; 00119 00120 // Begin changes to a primitive's transform 00121 virtual void beginPrimitiveTransformChange( 00122 const GEO_Primitive &prim) = 0; 00123 00124 // Begin changes to a primitive's attributes 00125 virtual void beginPrimitiveAttributeChange( 00126 const GEO_Primitive &prim) = 0; 00127 00128 // Begin changes to a vertex attribute; 00129 // linear_index is the index which would be passed 00130 // to GEO_Primitive::getVertex(unsigned idx) to retrieve 00131 // the desired vertex. 00132 virtual void beginVertexAttributeChange( 00133 const GEO_Primitive &prim, 00134 unsigned int linear_index_in_prim) = 0; 00135 00136 // interface for changing point capture weights 00137 virtual void initCaptureWeightChange( const GEO_Detail &gdp ) = 0; 00138 virtual void beginCaptureWeightChange( const GEO_Point &pt ) = 0; 00139 00140 // End any of the above changes 00141 virtual void endChange() = 0; 00142 00143 // Specify the attribute dictionary of the points to be modified 00144 // in between subsequent calls to beginPointAttributeChange 00145 // and endChange. 00146 virtual void setPointAttribDict( 00147 const GEO_PointAttribDict &dict) = 0; 00148 00149 // Specify the attribute dictionary of the primitives to be modified 00150 // in between subsequent calls to beginPointAttributeChange 00151 // and endChange. 00152 virtual void setPrimAttribDict( 00153 const GEO_PrimAttribDict &dict) = 0; 00154 00155 // Specify the attribute dictionary of the vertices to be modified 00156 // in between subsequent calls to beginPointAttributeChange 00157 // and endChange. 00158 virtual void setVertexAttribDict( 00159 const GEO_VertexAttribDict &dict) = 0; 00160 00161 // Refresh attributes added from GDT_Detail::set.*AttribDict() functions. 00162 // These functions assume that your geometry has not changed but your 00163 // attribute offsets might have changed because of re-cooking. 00164 // If a geometry function changes the attribute dictionary, then it should 00165 // call these. 00166 virtual void refreshPointAttribDict( 00167 const GEO_PointAttribDict &dict) = 0; 00168 virtual void refreshPrimAttribDict( 00169 const GEO_PrimAttribDict &dict) = 0; 00170 virtual void refreshVertexAttribDict( 00171 const GEO_VertexAttribDict &dict) = 0; 00172 00173 }; 00174 00175 #endif
1.5.9