1 ////////////////////////////////////////////////////////////////////// 2 // 3 // Pixie 4 // 5 // Copyright � 1999 - 2003, Okan Arikan 6 // 7 // Contact: okan@cs.utexas.edu 8 // 9 // This library is free software; you can redistribute it and/or 10 // modify it under the terms of the GNU Lesser General Public 11 // License as published by the Free Software Foundation; either 12 // version 2.1 of the License, or (at your option) any later version. 13 // 14 // This library is distributed in the hope that it will be useful, 15 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 // Lesser General Public License for more details. 18 // 19 // You should have received a copy of the GNU Lesser General Public 20 // License along with this library; if not, write to the Free Software 21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 // 23 /////////////////////////////////////////////////////////////////////// 24 /////////////////////////////////////////////////////////////////////// 25 // 26 // File : points.h 27 // Classes : CPoints 28 // Description : Points primitive 29 // 30 //////////////////////////////////////////////////////////////////////// 31 #ifndef POINTS_H 32 #define POINTS_H 33 34 #include "common/global.h" 35 #include "ray.h" 36 #include "shading.h" 37 #include "surface.h" 38 #include "pl.h" 39 #include "refCounter.h" 40 41 /////////////////////////////////////////////////////////////////////// 42 // Class : CPoints 43 // Description : Implements a points primitive 44 // Comments : 45 class CPoints : public CSurface { 46 47 /////////////////////////////////////////////////////////////////////// 48 // Class : CPointBase 49 // Description : This class holds the memory for the points 50 // Comments : 51 class CPointBase : public CRefCounter { 52 public: CPointBase()53 CPointBase() { osCreateMutex(mutex); } ~CPointBase()54 ~CPointBase() { variables->detach(); if (parameters != NULL) delete parameters; if (vertex != NULL) delete vertex; osDeleteMutex(mutex); } 55 56 float *vertex; // The vertex data for the points 57 CParameter *parameters; // The parameters for the points 58 CVertexData *variables; // The vertex data 59 float maxSize; // The maximum size of the point in camera space 60 TMutex mutex; // Holds the synchronization object 61 }; 62 public: 63 CPoints(CAttributes *,CXform *,CPl *,int); 64 CPoints(CAttributes *,CXform *,CPointBase *,int,const float **); 65 ~CPoints(); 66 67 // Object interface intersect(CShadingContext *,CRay *)68 void intersect(CShadingContext *,CRay *) { } 69 void dice(CShadingContext *); 70 void instantiate(CAttributes *,CXform *,CRendererContext *) const; 71 72 // Surface interface 73 void sample(int,int,float **,float ***,unsigned int &) const; moving()74 int moving() const { return (pl != NULL ? (pl->data1 !=NULL) : base->variables->moving); } 75 void interpolate(int,float **,float ***) const; 76 77 78 private: 79 void prep(); 80 81 int numPoints; // The number of points 82 CPl *pl; // The parameter list 83 84 // The variables below will only be ready after prep() is called 85 86 const float **points; // Entry points to points 87 88 CPointBase *base; // The point base 89 }; 90 91 #endif 92 93