43 #define WIN32_LEAN_AND_MEAN 47 # define DLLEXPORT __declspec( dllexport ) 49 # define DLLEXPORT __declspec( dllimport ) 51 #define PLATFORM_ID "Windows" 52 #pragma warning(disable:4244) // disable double->float conversion complaint 53 #pragma warning(disable:4250) // disable inheritance via dominance complaint 54 #pragma warning(disable:4996) // disable strerror warning 55 #pragma warning(disable:4100) // disable unreferenced formal parameter warning 56 #elif defined(__APPLE__) 62 #include <sys/posix_shm.h> 64 #define MAXSHMNAMLEN PSHMNAMLEN 66 #define PLATFORM_ID "OSX" 75 #define MAXSHMNAMLEN NAME_MAX 77 #define PLATFORM_ID "Linux" 78 typedef unsigned long _WId;
81 #define dPI 3.141592653589793238462 83 #define fEPSILON 1.0e-10f 84 #define dEPSILON 1.0e-10 86 #define _HASH(h,v,s) (((h)<<(s)|((h)>>((sizeof(h)<<3)-(s))))^(v)) 88 #define DBGOUT(c) do { std::cout << c << std::endl; std::cout.flush(); } while(0) 90 #define SAFE_DELETE(p) do { if((p)!=NULL){ delete (p); (p)=NULL; } } while(0) 102 typedef unsigned char u8;
104 typedef unsigned long long u64;
112 static const real
realInf=std::numeric_limits<real>::infinity();
114 template<
typename T> T
_min(
const T& a,
const T& b) {
return a<b ? a : b; }
115 template<
typename T> T
_max(
const T& a,
const T& b) {
return a>b ? a : b; }
117 template<
typename T> T
clamp(
const T& val,
const T& minval,
const T& maxval)
127 template<
typename T> T
lerpXi(
const T& val,
const T& minv,
const T& maxv)
129 return minv==maxv ? val : (val-minv)/(maxv-minv);
132 template<
typename V,
typename T> T
lerp(
const V& val,
const T& v1,
const T& v2)
134 return v1+(v2-v1)*val;
137 template<
typename T>
int compT(
const T& t1,
const T& t2)
147 template<
typename T>
int compV(
const void* t1,
const void* t2)
149 return compT<T>(*((T*)t1),*((T*)t2));
159 return compT(((T*)v1)->second,((T*)v2)->second);
164 return compT(((T*)v1)->third,((T*)v2)->third);
169 return compT(((T*)v1)->fourth,((T*)v2)->fourth);
198 DWORD
self=GetCurrentProcessId();
203 std::ostringstream out;
213 pid_t
self=getppid();
215 std::ostringstream out;
222 const char* parentpid=getenv(parentPIDVar);
223 return parentpid==NULL || std::string(parentpid)==
getPIDStr();
228 union {T v; u8 b[
sizeof(T)]; } src,dst;
230 for(
size_t x=0;x<
sizeof(T);x++)
231 dst.b[x]=src.b[
sizeof(T)-x-1];
237 union {T v; u8 b[4]; } src,dst;
248 union {T v; u8 b[8]; } src,dst;
261 template<
typename F,
typename S,
typename T>
270 triple(
const F& first,
const S& second,
const T& third) : first(first),second(second), third(third) {}
274 template<
typename F,
typename S,
typename T,
typename U>
284 quadruple(
const F& first,
const S& second,
const T& third,
const U& fourth) : first(first),second(second), third(third),fourth(fourth) {}
297 u8 tmp,*aa=(u8*)&a,*bb=(u8*)&b;
298 for(
size_t i=0;i<
sizeof(T);i++){
315 TimingObject(
const std::string& label,
bool doPrint=
true) : delta(0),doPrint(doPrint), entered(false), label(label)
318 this->label=label.substr(label.find_last_of(
"::")+1);
323 std::cout << this->label << std::endl;
333 delta=double(stop-start)/CLOCKS_PER_SEC;
335 std::cout << label <<
" dT (s) = " << delta << std::endl;
350 #define TIMING TimingObject __functimer(__FUNCTION__) 351 #define TIMINGBLOCK(label) for(TimingObject __blockobj(label);__blockobj.loopOnce();) 354 #define MutexType CRITICAL_SECTION 355 #define trylock_mutex(m) (TryEnterCriticalSection(m)!=0) 356 #define lock_mutex EnterCriticalSection 357 #define unlock_mutex LeaveCriticalSection 358 #define destroy_mutex DeleteCriticalSection 360 #define MutexType pthread_mutex_t 361 #define trylock_mutex(m) (pthread_mutex_trylock(m)==0) 362 #define lock_mutex pthread_mutex_lock 363 #define unlock_mutex pthread_mutex_unlock 364 #define destroy_mutex pthread_mutex_destroy 397 InitializeCriticalSection(&_mutex);
399 pthread_mutexattr_t attrs;
400 pthread_mutexattr_init(&attrs);
401 pthread_mutexattr_settype(&attrs,PTHREAD_MUTEX_RECURSIVE);
402 pthread_mutex_init(&_mutex,&attrs);
415 clock_t start=clock();
419 while(!result && delta<timeout){
421 delta=
real(clock()-start)/CLOCKS_PER_SEC;
436 #define critical(m) for(Mutex::Locker __locker__=Mutex::Locker(m);__locker__.loopOnce();) 437 #define trylock(m,timeout) for(Mutex::Locker __locker__=Mutex::Locker(m,timeout);__locker__.loopOnce();) 509 std::string formatLastErrorMsg();
537 u32 bf =
u32(val*255);
540 u32 al = (left & 0x00ff00ff);
541 u32 ah = (left & 0xff00ff00) >> 8;
542 u32 bl = (right & 0x00ff00ff);
543 u32 bh = (right & 0xff00ff00) >> 8;
545 u32 ml = (al * af + bl * bf);
546 u32 mh = (ah * af + bh * bf);
548 return (mh & 0xff00ff00) | ((ml & 0xff00ff00) >> 8);
551 color(
float r=1.0f,
float g=1.0f,
float b=1.0f,
float a=1.0f) : _r(r),_g(g),_b(b),_a(a)
554 color(
const color & c) : _r(c.r()),_g(c.g()),_b(c.b()),_a(c.a())
557 color(
const rgba& c) : _r(u8(c>>24)/255.0f), _g(u8(c>>16)/255.0f), _b(u8(c>>8)/255.0f), _a(u8(c)/255.0f)
560 float r()
const {
return _r; }
561 float g()
const {
return _g; }
562 float b()
const {
return _b; }
563 float a()
const {
return _a; }
565 float r(
float val) { _r=val;
return _r; }
566 float g(
float val) { _g=val;
return _g; }
567 float b(
float val) { _b=val;
return _b; }
568 float a(
float val) { _a=val;
return _a; }
570 void setBuff(
float *v)
const { v[0]=_r; v[1]=_g; v[2]=_b; v[3]=_a; }
575 rgba result=
u8(_r*255);
576 result=(result<<8)|
u8(_g*255);
577 result=(result<<8)|
u8(_b*255);
578 result=(result<<8)|
u8(_a*255);
592 return color(_r*val1+col.
r()*val,_g*val1+col.
g()*val,_b*val1+col.
b()*val,_a*val1+col.
a()*val);
597 return color(
clamp(_r,0.0f,1.0f),
clamp(_g,0.0f,1.0f),
clamp(_b,0.0f,1.0f),
clamp(_a,0.0f,1.0f));
601 bool operator != (
const color & c)
const {
return !((*this)==c); }
604 color operator * (real r)
const {
return color(_r*r,_g*r,_b*r,_a*r); }
607 color operator + (real r)
const {
return color(_r+r,_g+r,_b+r,_a+r); }
610 color operator - (real r)
const {
return color(_r-r,_g-r,_b-r,_a-r); }
615 friend std::ostream& operator << (std::ostream &out,
const color &c)
617 return out <<
"color(" << c.
r() <<
", " << c.
g() <<
", " << c.
b() <<
", " << c.
a() <<
")";
628 vec3(real val=0) : _x(val),_y(val),_z(val) {}
630 vec3(real x, real y, real z=0) : _x(x),_y(y),_z(z) {}
632 vec3(
const vec3 & v) : _x(v.x()),_y(v.y()),_z(v.z()) {}
634 real
x()
const {
return _x; }
635 real
y()
const {
return _y; }
636 real
z()
const {
return _z; }
638 real
x(real v) { _x=v;
return _x; }
639 real
y(real v) { _y=v;
return _y; }
640 real
z(real v) { _z=v;
return _z; }
642 void setBuff(
float *v)
const { v[0]=_x; v[1]=_y; v[2]=_z; }
648 vec3 operator + (real v)
const {
return vec3(_x+v,_y+v,_z+v); }
649 vec3 operator - (real v)
const {
return vec3(_x-v,_y-v,_z-v); }
650 vec3 operator * (real v)
const {
return vec3(_x*v,_y*v,_z*v); }
651 vec3 operator / (real v)
const {
return vec3(_x/v,_y/v,_z/v); }
652 vec3 operator - ()
const {
return vec3(-_x,-_y,-_z); }
657 vec3 inv()
const {
return vec3(_x!=0 ? 1/_x : 0,_y!=0 ? 1/_y : 0,_z!=0 ? 1/_z : 0); }
659 vec3 sign()
const {
return vec3(_x>=0 ? 1 : -1,_y>=0 ? 1 : -1,_z>=0 ? 1 : -1); }
663 real
dot(
const vec3& v)
const {
return _x*v.
x()+_y*v.
y()+_z*v.
z(); }
665 real
len()
const {
return sqrt(_x*_x+_y*_y+_z*_z); }
667 real
lenSq()
const {
return _x*_x+_y*_y+_z*_z; }
669 vec3 norm()
const { real l=len();
return l==0.0 ?
vec3() : (*this)*(1.0/l); }
671 real
distTo(
const vec3 & v)
const {
return ((*
this)-v).len(); }
683 void normThis() { real l=len();
if(l>0){ _x/=l;_y/=l;_y/=l;} }
705 return *
this>minv && *
this<maxv;
711 vec3 diff=(*this)-center;
724 bool isInUnitCube(real margin=0.0)
const {
return _x>=-margin && _x<=(1.0+margin) && _y>=-margin && _y<=(1.0+margin) && _z>=-margin && _z<=(1.0+margin); }
729 return cross(other).isZero();
744 if(_z<v.
z())
return -1;
745 if(_z>v.
z())
return 1;
746 if(_y<v.
y())
return -1;
747 if(_y>v.
y())
return 1;
748 if(_x<v.
x())
return -1;
749 if(_x>v.
x())
return 1;
756 real l=sqrt(lenSq() * v.
lenSq());
778 vec3 norm=planeNorm(v2,v3);
779 return norm.
angleTo(farv-*
this)>=(
dPI*0.5) ? norm : -norm;
791 real order=(v1-*
this).cross(v2-*
this).dot(planenorm);
816 if(planeDist(p1,p)<0 || planeDist(p2,-p)<0)
825 return vec3(_x+(v.
x()-_x)*val,_y+(v.
y()-_y)*val,_z+(v.
z()-_z)*val);
830 union { real f; i64 i;} x,y,z;
836 return i32(hash>>32)^
i32(hash);
839 friend std::ostream& operator << (std::ostream &out,
const vec3 &v)
841 return out <<
"vec3(" << v.
x() <<
", " << v.
y() <<
", " << v.
z() <<
")";
844 static int compX(
const void* v1,
const void* v2)
846 return compT<real>(((
const vec3*)v1)->x(),((
const vec3*)v2)->x());
849 static int compY(
const void* v1,
const void* v2)
851 return compT<real>(((
const vec3*)v1)->y(),((
const vec3*)v2)->y());
854 static int compZ(
const void* v1,
const void* v2)
856 return compT<real>(((
const vec3*)v1)->z(),((
const vec3*)v2)->z());
887 mat4(
const real* mat) { memcpy(m,mat,
sizeof(real)*16); }
888 mat4(real m00,real m01,real m02,real m03, real m10,real m11,real m12,real m13, real m20,real m21,real m22,real m23, real m30,real m31,real m32,real m33) :
889 m00(m00),m01(m01),m02(m02),m03(m03), m10(m10),m11(m11),m12(m12),m13(m13), m20(m20),m21(m21),m22(m22),m23(m23), m30(m30),m31(m31),m32(m32),m33(m33) {}
891 void clear() { memset(m,0,
sizeof(real)*16); }
892 void ident() { clear(); m00=m11=m22=m33=1.0; }
898 vec3 vv=
vec3(m00*v.
x() + m01*v.
y() + m02*v.
z() + m03,m10*v.
x() + m11*v.
y() + m12*v.
z() + m13,m20*v.
x() + m21*v.
y() + m22*v.
z() + m23);
899 real d=m30*v.
x() + m31*v.
y() + m32*v.
z() + m33;
900 return d==0 ?
vec3() : (vv/d);
939 real x0 = m00*m11, x1 = m22*m33, x2 = m00*m12, x3 = m23*m31, x4 = m00*m13, x5 = m21*m32, x6 = m01*m10,
940 x7 = m23*m32, x8 = m01*m12, x9 = m20*m33, x10 = m01*m13, x11 = m22*m30, x12 = m02*m10, x13 = m21*m33,
941 x14 = m02*m11, x15 = m23*m30, x16 = m02*m13, x17 = m20*m31, x18 = m03*m10, x19 = m22*m31,
942 x20 = m03*m11, x21 = m20*m32, x22 = m03*m12, x23 = m21*m30;
944 return x0*x1 - x0*x7 - x1*x6 + x10*x11 - x10*x21 - x11*x20 + x12*x13 - x12*x3 - x13*x2 + x14*x15 - x14*x9 - x15*x8 +
945 x16*x17 - x16*x23 - x17*x22 + x18*x19 - x18*x5 - x19*x4 + x2*x3 + x20*x21 + x22*x23 + x4*x5 + x6*x7 + x8*x9;
950 real s0 = m00*m11 - m01*m10;
951 real s1 = m00*m12 - m02*m10;
952 real s2 = m00*m13 - m03*m10;
953 real s3 = m01*m12 - m02*m11;
954 real s4 = m01*m13 - m03*m11;
955 real s5 = m02*m13 - m03*m12;
956 real c5 = m22*m33 - m23*m32;
957 real c4 = m21*m33 - m23*m31;
958 real c3 = m21*m32 - m22*m31;
959 real c2 = m20*m33 - m23*m30;
960 real c1 = m20*m32 - m22*m30;
961 real c0 = m20*m31 - m21*m30;
963 real invdet = 1.0 / (s0 * c5 - s1 * c4 + s2 * c3 + s3 * c2 - s4 * c1 + s5 * c0);
965 real b00 = ( c3*m13 - c4*m12 + c5*m11 ) * invdet;
966 real b01 = ( -c3*m03 + c4*m02 - c5*m01 ) * invdet;
967 real b02 = ( m31*s5 - m32*s4 + m33*s3 ) * invdet;
968 real b03 = ( -m21*s5 + m22*s4 - m23*s3 ) * invdet;
969 real b10 = ( -c1*m13 + c2*m12 - c5*m10 ) * invdet;
970 real b11 = ( c1*m03 - c2*m02 + c5*m00 ) * invdet;
971 real b12 = ( -m30*s5 + m32*s2 - m33*s1 ) * invdet;
972 real b13 = ( m20*s5 - m22*s2 + m23*s1 ) * invdet;
973 real b20 = ( c0*m13 - c2*m11 + c4*m10 ) * invdet;
974 real b21 = ( -c0*m03 + c2*m01 - c4*m00 ) * invdet;
975 real b22 = ( m30*s4 - m31*s2 + m33*s0 ) * invdet;
976 real b23 = ( -m20*s4 + m21*s2 - m23*s0 ) * invdet;
977 real b30 = ( -c0*m12 + c1*m11 - c3*m10 ) * invdet;
978 real b31 = ( c0*m02 - c1*m01 + c3*m00 ) * invdet;
979 real b32 = ( -m30*s3 + m31*s1 - m32*s0 ) * invdet;
980 real b33 = ( m20*s3 - m21*s1 + m22*s0 ) * invdet;
982 return mat4(b00,b01,b02,b03,b10,b11,b12,b13,b20,b21,b22,b23,b30,b31,b32,b33);
1038 real c1 = cos(0.5*roll);
1039 real s1 = sin(0.5*roll);
1040 real c2 = cos(0.5*yaw);
1041 real s2 = sin(0.5*yaw);
1042 real c3 = cos(0.5*pitch);
1043 real s3 = sin(0.5*pitch);
1049 _w =c1c2*c3 - s1s2*s3;
1050 _x =c1c2*s3 + s1s2*c3;
1051 _y =s1c2*c3 + c1s2*s3;
1052 _z =c1s2*c3 - s1c2*s3;
1059 rotator(real m00,real m01,real m02,real m10,real m11,real m12,real m20,real m21,real m22)
1061 real tr = m00 + m11 + m22;
1064 real S = sqrt(tr+1.0) * 2;
1066 _x = (m21 - m12) / S;
1067 _y = (m02 - m20) / S;
1068 _z = (m10 - m01) / S;
1069 }
else if(m00 > m11 && m00 > m22) {
1070 real S = sqrt(1.0 + m00 - m11 - m22) * 2;
1071 _w = (m21 - m12) / S;
1073 _y = (m01 + m10) / S;
1074 _z = (m02 + m20) / S;
1075 }
else if (m11 > m22) {
1076 real S = sqrt(1.0 + m11 - m00 - m22) * 2;
1077 _w = (m02 - m20) / S;
1078 _x = (m01 + m10) / S;
1080 _z = (m12 + m21) / S;
1082 real S = sqrt(1.0 + m22 - m00 - m11) * 2;
1083 _w = (m10 - m01) / S;
1084 _x = (m02 + m20) / S;
1085 _y = (m12 + m21) / S;
1110 set(
rotator(rot*row2,row1)*rot);
1118 real srads = (
real)sin(rads / 2.0);
1119 set(na.
x()*srads,na.
y()*srads,na.
z()*srads,(
real)cos(rads / 2.0));
1128 set(r._x,r._y,r._z,r._w);
1132 void set(real ry,real rz, real rw)
1134 set(sqrt(1.0-(ry*ry+rz*rz+rw*rw)),ry,rz,rw);
1138 void set(real rx,real ry, real rz,real rw)
1146 real
w()
const {
return _w; }
1147 real
x()
const {
return _x; }
1148 real
y()
const {
return _y; }
1149 real
z()
const {
return _z; }
1154 real test=_x*_y+_z*_w;
1161 return atan2(2*_x*_w-2*_y*_z , 1 - 2*_x*_x - 2*_z*_z);
1167 real test=_x*_y+_z*_w;
1174 return asin(2*test);
1180 real test=_x*_y+_z*_w;
1182 return 2*atan2(_x,_w);
1185 return -2*atan2(_x,_w);
1187 return atan2(2*_y*_w-2*_x*_z , 1 - 2*_y*_y - 2*_z*_z);
1193 vec3 axis(_x,_y,_z);
1196 return (vc*(2.0*_w))+(vcc*2.0)+v;
1220 rr.
set( _w * r.
_x + _x * r.
_w + _y * r.
_z - _z * r.
_y,
1221 _w * r.
_y + _y * r.
_w + _z * r.
_x - _x * r.
_z,
1222 _w * r.
_z + _z * r.
_w + _x * r.
_y - _y * r.
_x,
1223 _w * r.
_w - _x * r.
_x - _y * r.
_y - _z * r.
_z);
1230 rr.
set(_x*r,_y*r,_z*r,_w*r);
1251 rr.
set(-_x,-_y,-_z,-_w);
1266 bool operator != (
const rotator &v)
const {
return !((*this)==v); }
1271 rr.
set(-_x,-_y,-_z,_w);
1277 return sqrt(_x*_x+_y*_y+_z*_z+_w*_w);
1282 return _x*r.
_x + _y*r.
_y + _z*r.
_z + _w*r.
_w;
1321 rr.
set(*
this + ((dot(r)<0.0 ? -r : r) - *
this)*val);
1330 real x2=r.
x()*r.
x(),y2=r.
y()*r.
y(),z2=r.
z()*r.
z(),
1331 xy=r.
x()*r.
y(),xz=r.
x()*r.
z(),yz=r.
y()*r.
z(),
1332 wz=r.
w()*r.
z(),wx=r.
w()*r.
x(),wy=r.
w()*r.
y();
1334 mat[ 0] = 1.0f - 2.0f * ( y2 + z2 );
1335 mat[ 1] = 2.0f * (xy - wz);
1336 mat[ 2] = 2.0f * (xz + wy);
1338 mat[ 4] = 2.0f * (xy + wz);
1339 mat[ 5] = 1.0f - 2.0f * (x2 + z2);
1340 mat[ 6] = 2.0f * (yz - wx );
1342 mat[ 8] = 2.0f * (xz - wy);
1343 mat[ 9] = 2.0f * (yz + wx);
1344 mat[10] = 1.0f - 2.0f * (x2 + y2);
1361 union { real f; i64 i;} x,y,z,w;
1368 return i32(hash>>32)^
i32(hash);
1371 friend std::ostream& operator << (std::ostream &out,
const rotator &r)
1373 return out <<
"rotator(" << r.
x() <<
", " << r.
y() <<
", " << r.
z() <<
", " << r.
w() <<
")";
1390 std::ostringstream out;
1391 out <<
"Bad value " << val <<
" for index '" << name.c_str() <<
"' (0 <= " << name.c_str() <<
" < " << maxval <<
")";
1396 IndexException(std::string name,
size_t val,
size_t maxval) : name(name),val(val),maxval(maxval)
1408 virtual const char*
what()
const throw() {
return msg.c_str(); }
1420 std::ostringstream out;
1421 out << m <<
": errno: " << strerror(errno);
1429 virtual const char*
what()
const throw() {
return msg.c_str(); }
1440 std::ostringstream out;
1441 out << file <<
":" << line <<
":" << msg;
1442 this->msg=out.str();
1449 virtual const char*
what()
const throw() {
return msg.c_str(); }
1457 ValueException(
const std::string valuename,
const std::string msg,
const char* file=NULL,
int line=-1)
1459 std::ostringstream out;
1461 out << file <<
":" << line <<
": ";
1462 out <<
"Bad value for " << valuename <<
": " << msg;
1463 this->msg=out.str();
1471 virtual const char*
what()
const throw() {
return msg.c_str(); }
1477 throw ValueException(valuename,
"Must not be null",file,line);
1480 #define CHECK_NULL(val) checkNull("val",(const void*)val,__FILE__,__LINE__) 1487 void readBinaryFileToBuff(
const char* filename,
size_t offset,
void* dest,
size_t len)
throw(MemException);
1490 void storeBufftoBinaryFile(
const char* filename,
void* src,
size_t len,
int* header,
size_t headerlen)
throw(MemException);
1497 typedef std::map<std::string,std::string>
metamap;
1505 bool hasMetaKey(
const char* key)
const {
return _meta.find(key)!=_meta.end(); }
1509 std::vector<std::string> result;
1510 for(citer i=_meta.begin();i!=_meta.end();i++)
1511 result.push_back((*i).first);
1518 std::ostringstream out;
1519 for(citer c=_meta.begin();c!=_meta.end();c++)
1520 out << (*c).first <<
" = " << (*c).second << std::endl;
1526 const char*
meta(
const char* key)
const 1528 return hasMetaKey(key) ? _meta.find(key)->second.c_str() :
"";
1532 void meta(
const char* key,
const char* val)
1537 std::string fkey=key,fval=val;
1540 fkey.erase (std::remove(fkey.begin(), fkey.end(),
'|'), fkey.end());
1541 fval.erase (std::remove(fval.begin(), fval.end(),
'|'), fval.end());
1549 for(citer i=m->
_meta.begin();i!=m->
_meta.end();i++)
1550 meta((*i).first.c_str(),(*i).second.c_str());
1556 std::ostringstream out;
1557 for(citer i=_meta.begin();i!=_meta.end();i++)
1558 out << (*i).first <<
"||" << (*i).second <<
"||";
1566 char *buf=
new char[s.length()+1];
1567 strcpy(buf,s.c_str());
1569 char* p=strtok(buf,
"|");
1584 template<
typename R,
typename LH,
typename RH>
struct AddOp {
static inline R
op(
const LH& lh,
const RH& rh) {
return lh+rh; } };
1585 template<
typename R,
typename LH,
typename RH>
struct SubOp {
static inline R
op(
const LH& lh,
const RH& rh) {
return lh-rh; } };
1586 template<
typename R,
typename LH,
typename RH>
struct DivOp {
static inline R
op(
const LH& lh,
const RH& rh) {
return lh/rh; } };
1587 template<
typename R,
typename LH,
typename RH>
struct MulOp {
static inline R
op(
const LH& lh,
const RH& rh) {
return lh*rh; } };
1627 _name(name), _type(""),_sharedname(""),data(0),_n_actual(0),_n(n),_m(m),_isShared(false)
1629 checkDimension(
"m",m);
1630 setShared(isShared);
1635 _name(name), _type(type),_sharedname(""),data(0),_n_actual(0),_n(n),_m(m),_isShared(false)
1637 checkDimension(
"m",m);
1638 setShared(isShared);
1642 Matrix(
const char* name,
const char* type,
const char* sharedname,
const char* serialmeta,sval n, sval m)
throw(
MemException) :
1643 _name(name), _type(type),_sharedname(sharedname),data(0),_n_actual(n),_n(n),_m(m),_isShared(
true)
1645 checkDimension(
"n",n);
1646 checkDimension(
"m",m);
1647 deserializeMeta(serialmeta);
1648 data=createShared();
1652 Matrix(
const char* name,
const char* type,
const T* array,sval n, sval m,
bool isShared=
false) throw(
MemException) :
1653 _name(name), _type(type),_sharedname(""),data(0),_n_actual(0),_n(n),_m(m),_isShared(false)
1655 checkDimension(
"n",n);
1656 checkDimension(
"m",m);
1657 setShared(isShared);
1658 memcpy(data,array,memSize());
1671 Matrix<T>* m=
new Matrix<T>(newname ? newname : _name.c_str(),_type.c_str(),_n,_m,isShared);
1672 memcpy(m->
data,data,memSize());
1677 const char*
getName()
const {
return _name.c_str(); }
1679 const char*
getType()
const {
return _type.c_str(); }
1697 if(data && val==_isShared)
1702 sval size=memSize();
1707 T* shared=createShared();
1710 memcpy(shared,data,size);
1714 memset(shared,0,size);
1721 closeShared(olddata);
1745 sval
n()
const {
return _n; }
1748 sval
m()
const {
return _m; }
1757 for(sval n=0;n<_n*_m;n++)
1766 memcpy(data,r->
dataPtr(),minsize);
1772 checkDimension(
"n",n);
1773 checkDimension(
"m",m);
1776 throw MemException(
"Submatrix dimensions may not exceed matrix dimensions");
1778 if((n+noff)>_n || (m+moff)>_m)
1779 throw MemException(
"Submatrix dimensions plus offsets may not exceed matrix dimensions");
1783 for(sval nn=0;nn<n;nn++)
1784 for(sval mm=0;mm<m;mm++)
1785 mat->
at(nn,mm)=at(nn+noff,mm+moff);
1797 checkDimension(
"n",n);
1798 checkDimension(
"m",m);
1808 template<
typename Ctx>
1809 void applyFunc(T (*op)(Ctx,
const T&,sval,sval),Ctx ctx,sval minrow=0,sval mincol=0,sval maxrow=-1,sval maxcol=-1)
1811 maxcol=
_min(_m,maxcol);
1812 maxrow=
_min(_n,maxrow);
1814 for(sval n=minrow;n<maxrow;n++)
1815 for(sval m=mincol;m<maxcol;m++)
1816 at(n,m)=op(ctx,at(n,m),n,m);
1820 template<
typename R,
typename OpType>
1821 void scalarop(
const R& r,sval minrow=0,sval mincol=0,sval maxrow=-1,sval maxcol=-1)
1823 maxcol=
_min(_m,maxcol);
1824 maxrow=
_min(_n,maxrow);
1826 for(sval n=minrow;n<maxrow;n++)
1827 for(sval m=mincol;m<maxcol;m++)
1828 at(n,m)=OpType::op(at(n,m),r);
1832 template<
typename R,
typename OpType>
1833 void matop(
const Matrix<R>& mat,sval minrow=0,sval mincol=0,sval maxrow=-1,sval maxcol=-1)
1838 for(sval n=minrow;n<maxrow;n++)
1839 for(sval m=mincol;m<maxcol;m++)
1840 at(n,m)=OpType::op(at(n,m),mat(n,m));
1844 template<
typename R>
void add(
const R& r,sval minrow=0,sval mincol=0,sval maxrow=-1,sval maxcol=-1)
1846 return scalarop<R,AddOp<T,T,R> >(r,minrow,mincol,maxrow,maxcol);
1850 template<
typename R>
void sub(
const R& r,sval minrow=0,sval mincol=0,sval maxrow=-1,sval maxcol=-1)
1852 return scalarop<R,SubOp<T,T,R> >(r,minrow,mincol,maxrow,maxcol);
1856 template<
typename R>
void mul(
const R& r,sval minrow=0,sval mincol=0,sval maxrow=-1,sval maxcol=-1)
1858 return scalarop<R,MulOp<T,T,R> >(r,minrow,mincol,maxrow,maxcol);
1862 template<
typename R>
void div(
const R& r,sval minrow=0,sval mincol=0,sval maxrow=-1,sval maxcol=-1)
1864 return scalarop<R,DivOp<T,T,R> >(r,minrow,mincol,maxrow,maxcol);
1868 template<
typename R>
void addm(
const Matrix<R>& mat,sval minrow=0,sval mincol=0,sval maxrow=-1,sval maxcol=-1)
1870 return matop<R,AddOp<T,T,R> >(mat,minrow,mincol,maxrow,maxcol);
1874 template<
typename R>
void subm(
const Matrix<R>& mat,sval minrow=0,sval mincol=0,sval maxrow=-1,sval maxcol=-1)
1876 return matop<R,SubOp<T,T,R> >(mat,minrow,mincol,maxrow,maxcol);
1880 template<
typename R>
void mulm(
const Matrix<R>& mat,sval minrow=0,sval mincol=0,sval maxrow=-1,sval maxcol=-1)
1882 return matop<R,MulOp<T,T,R> >(mat,minrow,mincol,maxrow,maxcol);
1886 template<
typename R>
void divm(
const Matrix<R>& mat,sval minrow=0,sval mincol=0,sval maxrow=-1,sval maxcol=-1)
1888 return matop<R,DivOp<T,T,R> >(mat,minrow,mincol,maxrow,maxcol);
1895 for(sval j=0;j<_m;j++)
1896 checkIndex(
"sortinds",orderinds[j],_m);
1898 for(sval i=0;i<_n;i++){
1899 for(sval j=0;j<_m;j++)
1902 for(sval j=0;j<_m;j++)
1903 at(i,j)=buff[orderinds[j]];
1912 for(sval i=0;i<len;i++)
1917 T&
at(sval n, sval m=0)
const {
return data[m+(_m*n)]; }
1918 const T&
atc(sval n, sval m=0)
const {
return data[m+(_m*n)]; }
1919 void ats(sval n, sval m,
const T& t) { data[m+(_m*n)]=t; }
1922 T& operator () (sval n, sval m=0)
const {
return data[m+(_m*n)]; }
1924 T& operator [] (sval n)
const {
return data[n]; }
1943 checkDimension(
"_newm",_newm);
1945 _newm=_max<sval>(1,_newm);
1947 throw MemException(
"New m value larger than matrix size");
1949 _n=
sval((_n*_m)/_newm);
1963 throw MemException(
"Column dimensions of `this' and `t' do not match");
1967 memcpy(data+(_m*oldn),t.data,t.memSize());
1980 checkIndex(
"n",n,_n);
1983 std::memmove(&data[n*_m],&data[(n+1)*_m],(_n-n-1)*_m*
sizeof(T));
2008 indexpair
indexOf(
const T& t,sval aftern=0,sval afterm=0)
const 2010 sval numelems=_n*_m;
2011 sval nm=afterm+aftern*_m;
2013 while(nm<numelems && data[nm]!=t)
2024 checkIndex(
"n",n,_n);
2025 checkIndex(
"m",m,_m);
2039 throw MemException(
"Operation may only be performed on non-shared matrices");
2045 std::ostringstream out;
2046 out <<
"Matrix dimension " << name <<
" must be non-zero";
2060 if((_n+reserveNum)<=_n_actual && !_isShared)
2064 sval new_n_actual=data==NULL ? _n : _max<sval>(1000ul,((_n*3)/2)+reserveNum);
2066 if(new_n_actual<_n_actual && !_isShared)
2070 data=
new T[new_n_actual*_m];
2072 memset(data,0,new_n_actual*_m*
sizeof(T));
2075 memcpy(data,olddata,_n_actual*_m*
sizeof(T));
2080 _n_actual=new_n_actual;
2086 std::ostringstream out;
2091 out << std::hex << counter << std::dec;
2093 out << GetCurrentProcessId() << _name;
2094 _sharedname=out.str();
2100 out << std::hex << counter << std::dec;
2102 out << getpid() << _name;
2104 out <<
"__viz__" << getppid() <<
"_" << getpid();
2106 out <<
"_" << std::hex << counter << std::dec;
2108 out <<
"_" << _name;
2111 _sharedname=out.str();
2113 for(sval i=0;i<_sharedname.size();i++)
2114 if(_sharedname[i]==
'/')
2125 sval size=memSize();
2127 bool isCreator=_sharedname==
"";
2133 std::ostringstream out;
2135 createFileMapping();
2138 for(
int c=1;c<100000 && isCreator && mapFile && GetLastError()==ERROR_ALREADY_EXISTS;c++){
2139 CloseHandle(mapFile);
2140 chooseSharedName(c);
2141 createFileMapping();
2145 out <<
"Unable to open shared memory handle to " << _sharedname <<
": " << formatLastErrorMsg();
2146 throw MemException(out.str());
2149 ptr=(T*)MapViewOfFile(mapFile,FILE_MAP_ALL_ACCESS,0,0,size);
2151 if(!ptr && isCreator && GetLastError()==ERROR_ACCESS_DENIED){
2152 for(
int c=1;c<100000 && mapFile && !ptr && (GetLastError()==ERROR_ACCESS_DENIED || GetLastError()==ERROR_ALREADY_EXISTS);c++){
2153 CloseHandle(mapFile);
2154 chooseSharedName(c);
2155 createFileMapping();
2158 ptr=(T*)MapViewOfFile(mapFile,FILE_MAP_ALL_ACCESS,0,0,size);
2163 CloseHandle(mapFile);
2164 out <<
"Unable to map view of memory file " << _sharedname <<
": " << formatLastErrorMsg();
2165 throw MemException(out.str());
2170 int shm_fd=shm_open(_sharedname.c_str(), O_CREAT | O_RDWR | (isCreator ? O_EXCL : 0), S_IRUSR | S_IWUSR);
2173 for(
int c=1;c<100000 && isCreator && shm_fd==-1 && errno==EEXIST;c++){
2174 chooseSharedName(c);
2175 shm_fd=shm_open(_sharedname.c_str(), O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR);
2179 throw MemException(std::string(
"Unable to open shared memory descriptor, filename:")+_sharedname,errno);
2181 if(isCreator && ftruncate(shm_fd, size) == -1)
2182 throw MemException(std::string(
"Unable to extend shared memory section, filename:")+_sharedname,errno);
2184 ptr = (T*)mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0);
2186 if(!ptr || ptr==MAP_FAILED){
2188 shm_unlink(_sharedname.c_str());
2190 throw MemException(
"Unable to mmap shared memory",errno);
2208 if(!UnmapViewOfFile(ptr))
2211 if(!CloseHandle(mapFile))
2214 int mures=munmap(ptr,memSize());
2222 void createFileMapping()
2225 const char* name=_sharedname.c_str();
2226 wchar_t namebuff[1024];
2228 ::MultiByteToWideChar(CP_ACP, NULL,name, -1, namebuff,
int(_sharedname.size()+1));
2230 const char* namebuff=_sharedname.c_str();
2233 mapFile = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, DWORD(memSize()), namebuff);
2262 const char*
getName()
const {
return name.c_str(); }
2264 virtual DataSet*
clone(
const char* name,
bool cloneNodes=
false){
return NULL;}
2273 virtual void setIndexNames(std::vector<std::string> names) { indexnames=names; }
2276 virtual IndexMatrix*
getIndexSet(
const char* name)
const {
return NULL; }
2279 virtual bool hasIndexSet(
const char* name)
const {
return getIndexSet(name)!=NULL; }
2282 virtual void setIndexSet(IndexMatrix *indices,
const char *alias=NULL) {}
2288 virtual void setFieldNames(std::vector<std::string> names) { fieldnames=names; }
2294 virtual bool hasDataField(
const char* name)
const {
return getDataField(name)!=NULL; }
2322 virtual void fillColor(
const ColorMatrix *mat,indexval depth) {}
2323 virtual void fillColor(
const RealMatrix *mat,indexval depth,real minval=0.0,real maxval=1.0,
const Material* colormat=NULL,
const RealMatrix *alphamat=NULL,
bool mulAlpha=
true) {}
2349 virtual bool setParameter(
const std::string& param,
const std::string& val) {
return false; }
2350 virtual std::string
getParameter(
const std::string& param)
const {
return ""; }
2351 virtual std::string
getEntryPoint()
const {
return getParameter(
"entry_point"); }
2352 virtual std::string
getProfiles()
const {
return getParameter(
"profiles"); }
2355 virtual void setProfiles(
const std::string profiles) { setParameter(
"profiles",profiles); }
2358 template<
typename T>
2377 vals.
append(ListValue(pos,val));
2383 vals.
setN(pos->
n());
2384 for(indexval i=0;i<pos->
n();i++)
2385 vals[i]=ListValue(pos->
at(i),ctrls->
at(i));
2394 return vals.
getAt(index).second;
2399 vals.
setAt(ListValue(pos,value),index);
2405 return vals.
getAt(index).first;
2414 indexval
find(real pos,
const T& value)
const 2417 sval numVals=vals.
n();
2428 qsort(vals.
dataPtr(),vals.
n(),
sizeof(ListValue),sortTupleFirstCB<ListValue>);
2437 template<
typename T>
2470 for(sval i=0;i<pts->
n();i++)
2482 derivs(0,0)=ctrls[0];
2483 derivs(0,1)=ctrls[0];
2486 derivs(0,0)=ctrls[0];
2487 derivs(0,1)=ctrls[1];
2488 derivs(1,0)=ctrls[1];
2489 derivs(1,1)=ctrls[0];
2492 RealMatrix mat(
"",n,3);
2494 Matrix<T> localderivs(
"localderivs",n,1);
2496 localderivs[0]=ctrls[0];
2497 localderivs[n-1]=ctrls[n-1];
2500 localderivs[1]=ctrls[1]*6-ctrls[0]-ctrls[n-1];
2502 localderivs[1]=ctrls[1]*6-ctrls[0];
2503 localderivs[n-2]=ctrls[n-2]*6-ctrls[n-1];
2505 for(indexval i=2;i<n-2;i++)
2506 localderivs[i]=ctrls[i]*6;
2509 for(indexval i=0;i<n;i++){
2516 for(indexval i=2;i<n-1;i++){
2517 mat(i,1)=mat(i,1)/mat(i-1,0);
2518 mat(i,0)=mat(i,0)-(mat(i,1)*mat(i-1,2));
2519 localderivs[i]=localderivs[i]-(localderivs[i-1]*mat(i,1));
2522 localderivs[n-2]=localderivs[n-2]/mat(n-2,0);
2524 for(indexval i=n-3;i>0;i--)
2525 localderivs[i]=(localderivs[i]-(localderivs[i+1]*mat(i,2)))/mat(i,0);
2527 for(indexval s=0;s<n;s++){
2528 indexval e=clamp<indexval>(s+1,0,n-1);
2529 derivs(s,0)=(localderivs[s] * (2.0 / 3.0)) + (localderivs[e] / 3.0);
2530 derivs(s,1)=(localderivs[s] / 3.0) + (localderivs[e] * (2.0 / 3.0));
2536 virtual T
at(real tt)
const 2538 indexval n=ctrls.
n();
2541 indexval s=clamp<indexval>(
indexval(tn),0,n-1);
2542 indexval e=clamp<indexval>(
indexval(tn)+1,0,n-1);
2550 return (ctrls[s]*(t1*t1*t1))+(ctrls[e]*(t*t*t))+(d1*(3*t1*t1*t))+(d2*(3*t1*t*t));
2624 real minx=ctrls.
n()==0 ? 0.0 : ctrls[ctrls.
n()-1].x();
2625 tt=
vec3(clamp<real>(t.
x(),minx,1.0),clamp<real>(t.
y(),0.0,1.0),0);
2634 real minx=index==0 ? 0.0 : ctrls[index-1].x();
2635 tt=
vec3(clamp<real>(t.x(),minx,1.0),clamp<real>(t.y(),0.0,1.0),0);
2638 ctrls.
setAt(tt,index);
2641 for(sval i=index+1;i<ctrls.
n();i++)
2642 ctrls[i].x(clamp<real>(ctrls[i].x(),ctrls[i-1].x(),1.0));
2655 real
atX(real x, real threshold=0.0001)
const 2658 return ctrls[0].y();
2660 if(x>=ctrls[ctrls.
n()-1].x())
2661 return ctrls[ctrls.
n()-1].y();
2665 while(ctrls[i].x()<x)
2668 real xi=lerpXi<real>(x,ctrls[i-1].x(),ctrls[i].x());
2669 return lerp<real>(xi,ctrls[i-1].y(),ctrls[i].y());
2672 real start=0.0, end=1.0, mid=0.5;
2675 real diff=val.
x()-x;
2678 while(fabs(diff)>threshold && (end-start)>threshold){
2684 mid=start+(end-start)*0.5;
2705 Spectrum(
const std::string& name=
"") : alphacurve(true), name(name) {}
2707 virtual const char*
getName()
const {
return name.c_str(); }
2732 spec.
add(pos,value);
2739 return spec.
pos(index);
2745 return spec.
get(index);
2751 return spec.
find(pos,value);
2757 spec.
set(index,pos,value);
2829 float alpha=getAlpha();
2830 indexval specsize=spec.
size();
2833 result=getDefaultColor();
2834 else if(pos<=spec.
pos(0))
2835 result= spec.
get(0);
2836 else if(pos>=spec.
pos(specsize-1))
2837 result=spec.
get(specsize-1);
2840 while(index<specsize-1 && spec.
pos(index+1)<pos)
2846 real interp=
lerpXi(pos,spec.
pos(index),spec.
pos(index+1));
2852 real a=clamp<real>(alphacurve.
atX(pos),0.0,1.0);
2853 if(alpha>=0.0 && specsize>0)
2870 bool hasMatAlpha=mat->
m()>=col->
m()*2;
2871 sval len=
_min(col->
n(),mat->
n());
2872 sval width=
_min(col->
m(),mat->
m());
2874 for(sval i=0;i<len;i++){
2875 for(sval j=0;j<width;j++){
2876 float val=mat->
getAt(i,j);
2877 color c=interpolateColor(val);
2880 c.
a(mat->
getAt(i,col->
m()+j)*c.
a());
2881 else if(useValAsAlpha)
2911 virtual void copyTo(
Material* mat,
bool copyTex=
false,
bool copySpec=
false,
bool copyProgs=
false)
const {}
2914 virtual real
getAlpha()
const {
return useAlpha ? alpha : -1.0; }
2921 this->alpha=(float)alpha;
2922 setDiffuse(getDiffuse());
2923 setSpecular(getSpecular());
2933 setDiffuse(getDiffuse());
2934 setSpecular(getSpecular());
2967 virtual bool isTransparentColor()
const {
return useAlpha && alpha<1.0 && !usesVertexColor() && !strcmp(getTexture(),
""); }
3040 virtual void setSpotlight(real radsInner, real radsOuter, real falloff=1.0f) {}
3043 virtual void setAttenuation(real range, real constant=0.0f,real linear=1.0f, real quad=0.0f) {}
3100 template<
typename Ctx>
3114 CallbackVertexBuffer(Ctx context, sval numvertices, vecfunc vertfunc, vecfunc normalfunc=NULL, colfunc colorfunc=NULL, vecfunc uvwfunc=NULL):
3115 vertfunc(vertfunc),normalfunc(normalfunc),colorfunc(colorfunc),uvwfunc(uvwfunc),numvertices(numvertices),context(context)
3125 virtual bool hasColor()
const {
return colorfunc!=NULL; }
3130 template<
typename Ctx>
3135 typedef sval (*ifunc)(Ctx,int,int);
3144 widthfunc(widthfunc), indexfunc(indexfunc), numindices(numindices), context(context)
3148 virtual sval
indexWidth(
int i)
const {
return widthfunc(context,i); }
3149 virtual sval
getIndex(
int i,
int w)
const {
return indexfunc(context,i,w); }
3171 : vecs(vecs), cols(cols),extinds(extinds), deleteMatrices(
false)
3176 numverts=
sval(extinds!=NULL ? extinds->
n() : vecs->
n());
3186 if(buf->hasUVWCoord())
3188 else if(buf->hasNormal())
3191 vecs=
new Vec3Matrix(
"copyvecs",buf->numVertices(),columns);
3194 cols=
new ColorMatrix(
"copycols",buf->numVertices());
3196 for(sval i=0;i<numverts;i++){
3197 vecs->
at(i,0)=buf->getVertex(i);
3198 if(buf->hasNormal())
3199 vecs->
at(i,1)=buf->getNormal(i);
3200 if(buf->hasUVWCoord())
3201 vecs->
at(i,3)=buf->getUVWCoord(i);
3204 cols->
at(i)=buf->getColor(i);
3217 sval
getIndex(sval i)
const {
return extinds!=NULL ? extinds->
at(i) : i; }
3239 MatrixIndexBuffer(IndexMatrix* indices,IndexMatrix* extinds=NULL) : indices(indices), extinds(extinds), deleteMatrices(false)
3248 indices=
new IndexMatrix(
"copyinds",buf->numIndices(),buf->indexWidth(0));
3250 for(sval i=0;i<buf->numIndices();i++)
3251 for(sval j=0;j<
_min(indices->
m(),buf->indexWidth(i));j++)
3252 indices->
at(i,j)=buf->getIndex(i,j);
3267 else if(extinds!=NULL)
3268 return sval(extinds->
n());
3270 return sval(indices->
n());
3293 setDirection(r.
dir);
3309 throw std::invalid_argument(
"Direction vector is zero length.");
3328 return pos.
onPlane(planept,planenorm) && (pos+dir).onPlane(planept,planenorm);
3338 return planenorm.
dot(planepos-pos)/planenorm.
dot(dir);
3348 real tmin, tmax, tymin, tymax, tzmin, tzmax;
3350 tmin = ((signx ? maxv : minv).x() - pos.
x()) * invdir.
x();
3351 tmax = ((signx ? minv : maxv).x() - pos.
x()) * invdir.
x();
3352 tymin = ((signy ? maxv : minv).y() - pos.
y()) * invdir.
y();
3353 tymax = ((signy ? minv : maxv).y() - pos.
y()) * invdir.
y();
3355 if ( (tmin > tymax) || (tymin > tmax) )
3363 tzmin = ((signz ? maxv : minv).z() - pos.
z()) * invdir.
z();
3364 tzmax = ((signz ? minv : maxv).z() - pos.
z()) * invdir.
z();
3366 if ( (tmin > tzmax) || (tzmin > tmax) )
3385 real tca = distTo(center);
3390 vec3 L = center - pos;
3391 real d2 = L.
dot(L) - tca * tca;
3394 thc = sqrt(r2 - d2);
3397 return realpair(tca - thc, tca + thc);
3412 vec3 pt1=getPosition(t1);
3415 if(p2==pt1 || p1==pt2){
3428 t=intersectsPlane(p2,rd.
cross(norm));
3429 s=ray.
distTo(getPosition(t));
3442 if(dist<0 || dist==realInf)
3445 vec3 lpos=getPosition(dist);
3473 real invdet=1.0/det;
3476 real u=p.
dot(t)*invdet;
3482 real v=dir.
dot(q)*invdet;
3484 if(v < 0 || u + v > 1)
3487 real len=e2.
dot(q)*invdet;
3506 std::vector<indextriple>
intersectsTriMesh(
const Vec3Matrix*
const nodes,
const IndexMatrix*
const inds,
3507 const Vec3Matrix*
const centers,
const RealMatrix*
const radii2, sval numResults=0,sval excludeInd=-1)
const throw(
IndexException)
3509 std::vector<indextriple> results;
3512 if(centers && radii2)
3513 len=
_min(len,
_min(centers->
n(),radii2->
n()));
3515 for(sval n=0;n<len && (numResults==0 || results.size()<numResults);n++){
3519 vec3 ncenter,npos,v0,v1,v2;
3522 if(centers && radii2){
3523 ncenter=centers->
at(n);
3530 cdist=distTo(ncenter);
3531 if((cdist*cdist)>nrad)
3534 v0=nodes->
getAt(inds->
at(n,0));
3535 v1=nodes->
getAt(inds->
at(n,1));
3536 v2=nodes->
getAt(inds->
at(n,2));
3539 v0=nodes->
getAt(inds->
at(n,0));
3540 v1=nodes->
getAt(inds->
at(n,1));
3541 v2=nodes->
getAt(inds->
at(n,2));
3543 ncenter=(v0+v1+v2)/3.0;
3545 npos=getPosition(ncenter.
distTo(pos));
3551 realtriple inter=intersectsTri(v0,v1,v2);
3579 trans(trans),scale(scale),rot(rot),_isInverse(isInv)
3586 transform(real x, real y, real z, real sx, real sy, real sz, real yaw, real pitch, real roll,
bool isInv=
false) :
3587 trans(x,y,z), scale(sx,sy,sz),rot(yaw,pitch,roll), _isInverse(isInv)
3604 return scale*(rot*(v+trans));
3606 return trans+(rot*(v*scale));
3669 rotator rot((xcorner-mincorner).norm(),(ycorner-mincorner).norm(),
vec3(1,0,0),
vec3(0,1,0));
3670 vec3 scale=rot/(maxcorner-mincorner);
3705 mat[ 3]=trans.
dot(
vec3(mat[0],mat[1],mat[2]));
3706 mat[ 7]=trans.
dot(
vec3(mat[4],mat[5],mat[6]));
3707 mat[11]=trans.
dot(
vec3(mat[8],mat[9],mat[10]));
3732 friend std::ostream& operator << (std::ostream &out,
const transform &t)
3757 virtual std::string
encode(
const std::string& format) {
return ""; }
3778 virtual const char*
getName()
const {
return ""; }
3803 Ray *r=getProjectedRay(x,y,isAbsolute);
3821 virtual void setViewport(real left=0.0f,real top=0.0f,real width=1.0f,real height=1.0f) {}
3890 virtual std::pair<vec3,vec3>
getAABB()
const {
return std::pair<vec3,vec3>(
vec3(),
vec3()); }
3991 virtual void addGlyphMesh(
const std::string& name,
const Vec3Matrix* nodes,
const Vec3Matrix* norms,
const IndexMatrix* inds) {}
4022 virtual void setFont(
const std::string& fontname) {}
4054 typedef std::pair<std::string,std::string>
strpair;
4062 void set(
const char*
group,
const char* name,
const char* value) { map[getPair(group,name)]=value; }
4063 void set(
const char* name,
const char* value) { map[getPair(
"",name)]=value; }
4064 bool hasValue(
const char* group,
const char* name)
const {
return map.find(getPair(group,name))!=map.end(); }
4066 const char*
get(
const char*
group,
const char* name) {
return hasValue(group,name) ? map[getPair(group,name)].c_str() :
""; }
4067 const char*
get(
const char* name) {
return get(
"",name); }
4071 std::ostringstream out;
4072 for(configmap::const_iterator i=map.begin();i!=map.end();i++)
4073 out <<
"(" <<(*i).first.first <<
", " << (*i).first.second <<
") = " << (*i).second << std::endl;
4078 friend std::ostream& operator << (std::ostream &out,
const Config *c)
4080 for(configmap::const_iterator i=c->
map.begin();i!=c->
map.end();i++)
4081 out <<
"(" <<(*i).first.first <<
", " << (*i).first.second <<
") = " << (*i).second << std::endl;
4087 strpair
getPair(
const char* group,
const char* name)
const 4089 std::string sgroup=
group,sname=name;
4090 std::transform(sgroup.begin(), sgroup.end(), sgroup.begin(), ::tolower);
4091 std::transform(sname.begin(), sname.end(), sname.begin(), ::tolower);
4092 return strpair(sgroup,sname);
4206 virtual void resize(
int x,
int y,
int width,
int height){}
4222 std::ostringstream os;
4224 mat->
meta(
"min",os.str().c_str());
4227 mat->
meta(
"max",os.str().c_str());
4231 template<
typename T>
struct StrConvert {
static T
conv(
const char* str) {
return T(); } };
4232 template<>
struct StrConvert<real> {
static real
conv(
const char* str) {
return atof(str); } };
4233 template<>
struct StrConvert<indexval> {
static indexval
conv(
const char* str) {
return atol(str); } };
4238 static void parse(
const char* line,sval numvals,T* list)
4240 char *buf=
new char[strlen(line)+1];
4243 char* p=strtok(buf,
" \t\r\n");
4245 for(sval x=0;x<numvals && p;x++){
4247 p=strtok(NULL,
" \t\r\n");
4259 char *buf=
new char[strlen(line)+1];
4262 char* p=strtok(buf,
" \t\r\n");
4264 for(sval i=0;i<numvals && p;i++){
4266 p=strtok(NULL,
" \t\r\n");
4268 p=strtok(NULL,
" \t\r\n");
4270 p=strtok(NULL,
" \t\r\n");
4271 list[i]=
vec3(x,y,z);
4279 template<
typename T>
4282 std::ifstream in(filename.c_str());
4288 sval numvals=
sval(mat->
m());
4289 T* entry=
new T[numvals];
4292 sval* header=
new sval[numHeaders];
4293 std::getline(in,line);
4298 while(std::getline(in,line)){
4299 if(line.find_first_not_of(
" \n\t\r")==std::string::npos)
4305 sval pos=mat->
n()-1;
4306 for(sval x=1;x<numvals;x++)
4307 mat->
at(pos,x)=entry[x];
4316 template<
typename T>
4321 sval mn=mat->
n(),mm=mat->
m();
4323 for(sval n=0;n<mn;n++)
4324 for(sval m=0;m<mm;m++){
4325 T val=stream[n*mm+m];
4326 minval=
_min(val,minval);
4327 maxval=
_max(val,maxval);
4332 setMatrixMinMax<real,real>(mat,minval,maxval);
4364 void basis_Tet1NL(real xi0, real xi1, real xi2, real* coeffs);
4367 void basis_Hex1NL(real xi0, real xi1, real xi2, real* coeffs);
4369 real
basis_n_NURBS(sval ctrlpt,sval degree, real xi,
const RealMatrix *knots);
4371 void basis_NURBS_default(real u, real v, real w,sval ul, sval vl, sval wl, sval udegree, sval vdegree, sval wdegree,real* coeffs);
4387 real
mat4Det(real a, real b, real c, real d, real e, real f, real g, real h, real i, real j, real k, real l, real m, real n, real o, real p);
4398 return -
mat4Det(a.
x(),b.
x(),c.
x(),d.
x(),a.
y(),b.
y(),c.
y(),d.
y(),a.
z(),b.
z(),c.
z(),d.
z(),1,1,1,1)/6.0;
4431 template<
typename T>
4439 for(sval i=0;i<rows;i++)
4440 for(sval j=0;j<cols;j++){
4441 T a=coeffs[0]*v1->
at(i,j);
4442 T b=coeffs[1]*v2->
at(i,j);
4443 T c=coeffs[2]*m1->
at(i,j);
4444 T d=coeffs[3]*m2->
at(i,j);
4445 result->
at(i,j)=a+b+c+d;
4450 template<
typename T>
4453 int minx=-1,maxx=-1,miny=-1,maxy=-1;
4458 for(sval i=0;i<rows && miny<0;i++)
4459 for(sval j=0;j<cols;j++)
4460 if(mat->
at(i,j)>threshold){
4465 for(sval i=rows;i>0 && maxy<0;i--)
4466 for(sval j=0;j<cols;j++)
4467 if(mat->
at(i-1,j)>threshold){
4472 for(sval j=0;j<cols && minx<0;j++)
4473 for(sval i=0;i<rows;i++)
4474 if(mat->
at(i,j)>threshold){
4479 for(sval j=cols;j>0 && maxx<0;j--)
4480 for(sval i=0;i<rows;i++)
4481 if(mat->
at(i,j-1)>threshold){
4489 template<
typename T>
4492 sval count=0, rows=mat->
n(), cols=mat->
m();
4494 for(sval i=0;i<rows;i++)
4495 for(sval j=0;j<cols;j++){
4496 sval val=mat->
at(i,j);
4497 if(val>=minv && val<=maxv)
4504 template<
typename T>
4507 std::vector<vec3> result;
4512 for(sval i=0;i<rows;i++)
4513 for(sval j=0;j<cols;j++){
4514 T val=mat->
atc(i,j);
4518 bool allInternal=
true;
4519 for(sval n=_max<sval>(0,i-1);allInternal && n<
_min(rows,i+1);n++)
4520 for(sval m=_max<sval>(0,j-1);allInternal && m<
_min(cols,j+1);m++)
4522 allInternal=allInternal && mat->
getAt(n,m)>=threshold;
4525 result.push_back(
vec3(i,j,0));
4531 template<
typename T>
4538 for(sval i=0;i<rows;i++)
4539 for(sval j=0;j<cols;j++)
4540 result+=mat->
atc(i,j);
4545 template<
typename T>
4554 std::pair<T,T> result(mat->
atc(0,0),mat->
atc(0,0));
4556 for(sval i=0;i<rows;i++)
4557 for(sval j=0;j<cols;j++){
4558 T val=mat->
atc(i,j);
4559 if(val<result.first)
4561 else if(val>result.second)
4568 template<
typename T>
4574 if(x<0.0 || x>1.0 || y<0.0 || y>1.0)
4580 sval sx=(
sval)floor(x);
4581 sval sy=(
sval)floor(y);
4588 return dx*(dy*mat->
atc(sy+1,sx+1)+dy1*mat->
atc(sy,sx+1)) + dx1*(dy*mat->
atc(sy+1,sx)+dy1*mat->
atc(sy,sx));
4598 template<
typename T>
4601 T val1=bilerpMatrix<T>(mat1,v1.x(),v1.y());
4602 T val2=bilerpMatrix<T>(mat2,v2.x(),v2.y());
4604 real absz=fabs(v1.z());
4605 real lerpval=lerpXi<real>(absz,0,absz+fabs(v2.z()));
4607 return lerp(lerpval,val1,val2);
4617 return (orientinv*(pos-planepos))/
vec3(dimvec.
x(),dimvec.
y(),1);
4641 #endif // RENDERTYPES_H static void parse(const char *line, sval numvals, T *list)
Definition: RenderTypes.h:4238
See CallbackVertexBuffer, the same concept applies here with a buffer accepting functions defined in ...
Definition: RenderTypes.h:3131
sval calculateHexValueIntersects(real val, const real *vals, intersect *results)
Definition: RenderTypes.cpp:586
virtual bool usesDepthWrite() const
Definition: RenderTypes.h:2953
std::string _type
Definition: RenderTypes.h:1610
void stopTiming()
Definition: RenderTypes.h:330
MatrixIndexBuffer(IndexMatrix *indices, IndexMatrix *extinds=NULL)
Create the buffer from these matrices. The caller is responsible for deleting these when appropriate...
Definition: RenderTypes.h:3239
void readBinaryFile(const char *filename, size_t offset)
Read a binary file of data into this matrix starting from byte `offset'.
Definition: RenderTypes.h:1989
virtual sval getWidth() const
Definition: RenderTypes.h:3831
virtual vec3 getNormal(int i) const
Returns the i'th normal, i<numVertices()
Definition: RenderTypes.h:3064
Matrix(const char *name, const char *type, sval n, sval m=1, bool isShared=false)
Constructs a matrix named `name' with type `type' of `n' rows and `m' columns, local if `isShared' is...
Definition: RenderTypes.h:1634
virtual void setLookAt(const vec3 &v)
Definition: RenderTypes.h:3810
void add(const R &r, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1)
Add `r' to every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in the matrix.
Definition: RenderTypes.h:1844
void clear()
Definition: RenderTypes.h:891
bool lock(real timeout=0.0)
Definition: RenderTypes.h:412
real x() const
Definition: RenderTypes.h:634
virtual void setEmissive(const color &c)
Definition: RenderTypes.h:2974
virtual u8 * getData()
Get a pointer to the internal data buffer.
Definition: RenderTypes.h:3755
static vec3 negInfinity()
Definition: RenderTypes.h:860
DataSet(const char *name)
Definition: RenderTypes.h:2260
virtual bool hasNormal() const
Returns true if the buffer contains normal data.
Definition: RenderTypes.h:3124
Definition: RenderTypes.h:476
real z(real v)
Definition: RenderTypes.h:640
std::vector< std::string > fieldnames
Definition: RenderTypes.h:2257
Definition: RenderTypes.h:1584
virtual void setAlphaCurve(const Vec3Matrix *pts)
Definition: RenderTypes.h:2802
rotator conjugate() const
Definition: RenderTypes.h:1268
color(float r=1.0f, float g=1.0f, float b=1.0f, float a=1.0f)
Definition: RenderTypes.h:551
bool isLinear
Definition: RenderTypes.h:2613
T _max(const T &a, const T &b)
Definition: RenderTypes.h:115
vec3 pos
Definition: RenderTypes.h:3279
virtual std::vector< std::string > getIndexNames() const
Lists the names of index matrices stored.
Definition: RenderTypes.h:2270
virtual sval numIndices() const
Returns the number of index sets.
Definition: RenderTypes.h:3263
std::vector< std::string > indexnames
Definition: RenderTypes.h:2256
virtual void setDiffuse(const color &c)
Sets the diffuse color, if usesInternalAlpha() returns true the alpha value will be set the internal ...
Definition: RenderTypes.h:2971
virtual void setSpecular(const color &c)
Set the specular color to reflect.
Definition: RenderTypes.h:3031
virtual void setLanguage(const std::string &lang)
Set the language for the source of the program, eg. cg.
Definition: RenderTypes.h:2338
real m10
Definition: RenderTypes.h:878
MemException(const MemException &op)
Definition: RenderTypes.h:1425
virtual std::string encode(const std::string &format)
Encode the image data as the byte stream for a file, the format of which is given by `format' (eg...
Definition: RenderTypes.h:3757
vec3 pointSearchLinHex(vec3 pt, vec3 n1, vec3 n2, vec3 n3, vec3 n4, vec3 n5, vec3 n6, vec3 n7, vec3 n8)
Definition: RenderTypes.cpp:481
virtual bool usesLighting() const
Definition: RenderTypes.h:2950
virtual ~IndexException()
Definition: RenderTypes.h:1406
Definition: RenderTypes.h:475
sval m() const
Get the number of columns.
Definition: RenderTypes.h:1748
Partial templates for converting a line of text into a list of primitives/vec3.
Definition: RenderTypes.h:4236
int sortTupleThirdCB(const void *v1, const void *v2)
Definition: RenderTypes.h:162
virtual void setCameraAlign(bool align)
Definition: RenderTypes.h:4030
vec3 planeNorm(const vec3 &v2, const vec3 &v3) const
Returns the normal of a plane defined by `this', `v2', and `v3' winding clockwise.
Definition: RenderTypes.h:773
ifunc indexfunc
Definition: RenderTypes.h:3138
real m23
Definition: RenderTypes.h:878
virtual void useDepthCheck(bool use)
Definition: RenderTypes.h:2989
Definition: RenderTypes.h:4017
virtual BlendMode getBlendMode() const
Definition: RenderTypes.h:2947
Mutex * parent
Definition: RenderTypes.h:376
Simple mutex type allowing locking and attempted locking with timeout.
Definition: RenderTypes.h:368
virtual bool hasError() const
Returns true if the source code given for the program has failed to parse.
Definition: RenderTypes.h:2344
virtual void setVertFOV(real rads)
Definition: RenderTypes.h:3818
virtual void setFarClip(real dist)
Definition: RenderTypes.h:3817
static const char * platformID
Definition: RenderTypes.h:95
std::string msg
Definition: RenderTypes.h:1435
Texture()
Definition: RenderTypes.h:2310
PositionQueue()
Definition: RenderTypes.h:2366
float g(float val)
Definition: RenderTypes.h:566
IndexMatrix * extinds
Definition: RenderTypes.h:3234
bool deleteMatrices
Definition: RenderTypes.h:3166
realpair intersectsSphere(const vec3 ¢er, real rad) const
Definition: RenderTypes.h:3383
static R op(const LH &lh, const RH &rh)
Definition: RenderTypes.h:1587
virtual void addAlphaCtrl(vec3 v)
Definition: RenderTypes.h:2784
vec3 inv() const
Return a vector with each component of `this' inverted or 0 if already 0.
Definition: RenderTypes.h:657
Definition: RenderTypes.h:444
virtual void setCtrlPoint(const T &t, indexval index)
Definition: RenderTypes.h:2462
virtual void setGPUProgram(const std::string &name, ProgramType pt)
Definition: RenderTypes.h:3000
T get(indexval index) const
Definition: RenderTypes.h:2392
static const char * RenderParamGroup
Definition: RenderTypes.h:97
Definition: RenderTypes.h:4101
virtual void setTexture(const char *name)
Definition: RenderTypes.h:2995
virtual sval getIndex(int i, int w) const
Returns the w'th value of index set i.
Definition: RenderTypes.h:3149
color(const color &c)
Definition: RenderTypes.h:554
bool pointInTet(vec3 pt, vec3 n1, vec3 n2, vec3 n3, vec3 n4)
Returns true if `pt' is in the tet (n1,n2,n3,n4).
Definition: RenderTypes.cpp:435
virtual real getVertFOV() const
Definition: RenderTypes.h:3826
Definition: RenderTypes.h:494
real determinant() const
Definition: RenderTypes.h:930
virtual vec3 getUVWCoord(int i) const
Returns the i'th UVW texture coord, i<numVertices()
Definition: RenderTypes.h:3068
static T swap(T t)
Definition: RenderTypes.h:1591
virtual void fillColor(const RealMatrix *mat, indexval depth, real minval=0.0, real maxval=1.0, const Material *colormat=NULL, const RealMatrix *alphamat=NULL, bool mulAlpha=true)
Definition: RenderTypes.h:2323
virtual void fillColorMatrix(ColorMatrix *mat)
Transfer the image data into the given matrix.
Definition: RenderTypes.h:3761
rotator(const vec3 &from, const vec3 &to)
Defines the rotation which transforms normalized vectors `from' to `to' rotating about their cross pr...
Definition: RenderTypes.h:1023
Represents a texture loaded into memory and available to the graphis hardware.
Definition: RenderTypes.h:2307
real _x
Definition: RenderTypes.h:996
virtual void setDirectional()
Make this a directional light, illuminating all scene objects in the set direction.
Definition: RenderTypes.h:3034
#define destroy_mutex
Definition: RenderTypes.h:364
#define _HASH(h, v, s)
Definition: RenderTypes.h:86
void basis_Hex1NL(real xi0, real xi1, real xi2, real *coeffs)
Linear Nodal Lagrange hexahedron basis function, fills in `coeffs' for the given xi value...
Definition: RenderTypes.cpp:308
virtual void setPointAttenuation(bool enabled, real constant=0.0f, real linear=1.0f, real quad=0.0f)
Sets point attenuation, the given real values are constants the attenuation equation.
Definition: RenderTypes.h:2983
static vec3 swap(vec3 t)
Definition: RenderTypes.h:1594
void bswap(T &a, T &b)
Definition: RenderTypes.h:295
virtual bool isVisible() const
Returns true if this light is actively illuminating the scene.
Definition: RenderTypes.h:3049
static const real realInf
Definition: RenderTypes.h:112
virtual void fillBlack()
Definition: RenderTypes.h:2320
virtual void updateSpectrum()
Definition: RenderTypes.h:2727
virtual real getAlpha() const
Definition: RenderTypes.h:3965
~Locker()
Definition: RenderTypes.h:382
Definition: RenderTypes.h:480
virtual DataSet * clone(const char *name, bool cloneNodes=false)
Definition: RenderTypes.h:2264
virtual Config * getConfig() const
Returns the Config object used to define properties for the scene.
Definition: RenderTypes.h:4152
virtual ~PositionQueue()
Definition: RenderTypes.h:2367
virtual ~RenderException()
Definition: RenderTypes.h:1447
Definition: RenderTypes.h:1381
real planeDist(const vec3 &planept, const vec3 &planenorm) const
Returns the distance from `this' to a plane defined by a point on the plane and the plane normal (pos...
Definition: RenderTypes.h:783
Definition: RenderTypes.h:1432
std::string msg
Definition: RenderTypes.h:1414
Matrix(const char *name, sval n, sval m=1, bool isShared=false)
Constructs a matrix named `name' of `n' rows and `m' columns, local if `isShared' is false and shared...
Definition: RenderTypes.h:1626
static real conv(const char *str)
Definition: RenderTypes.h:4232
Config()
Definition: RenderTypes.h:4060
T trilerpMatrices(const Matrix< T > *mat1, const Matrix< T > *mat2, vec3 v1, vec3 v2)
Definition: RenderTypes.h:4599
void clear()
Definition: RenderTypes.h:2390
bool equalsEpsilon(real v1, real v2)
Returns true if `v1' and `v2' are within 'dEPSILON' of one another.
Definition: RenderTypes.h:173
def first(iterable, default=None)
Definition: Utils.py:2081
void copyFrom(const PositionQueue< T > *queue)
Definition: RenderTypes.h:2369
virtual bool hasIndexSet(const char *name) const
Returns true if an index matrix of the given name is stored.
Definition: RenderTypes.h:2279
virtual ~GPUProgram()
Definition: RenderTypes.h:2330
rotator(real x, real y, real z, real w)
Defines a rotator by the given quaternion values.
Definition: RenderTypes.h:1017
u32 sval
Definition: RenderTypes.h:107
mat4()
Definition: RenderTypes.h:886
sval size() const
Definition: RenderTypes.h:2388
virtual void rotate(const rotator &r)
Definition: RenderTypes.h:3813
virtual real getSpaceWidth() const
Definition: RenderTypes.h:4039
virtual vec3 getUVWCoord(int i) const
Returns the i'th UVW texture coord, i<numVertices()
Definition: RenderTypes.h:3121
static const char * parentPIDVar
Definition: RenderTypes.h:96
virtual std::string getName() const
Definition: RenderTypes.h:2332
virtual ~TextureVolumeFigure()
Definition: RenderTypes.h:3959
virtual bool usesPointSprites() const
Definition: RenderTypes.h:2957
Definition: RenderTypes.h:275
sval numverts
Definition: RenderTypes.h:3165
const char * getSharedName() const
Definition: RenderTypes.h:1678
void reserveRows(sval num)
Ensure that at least `num' rows are reserved in memory, throws exception if shared.
Definition: RenderTypes.h:1957
color unitClamp()
Definition: RenderTypes.h:595
const char * getName() const
Definition: RenderTypes.h:2262
void initSharedDir(const std::string &path)
Definition: RenderTypes.cpp:27
real _w
Definition: RenderTypes.h:996
float b() const
Definition: RenderTypes.h:562
FigureType
Defines the figure types which the Figure class and subclasses are capable of representing.
Definition: RenderTypes.h:441
virtual color getDiffuse() const
Definition: RenderTypes.h:2938
#define MAXSHMNAMLEN
Definition: RenderTypes.h:75
virtual color getSpectrumValue(indexval index) const
Get the color of the spectrum value at the given index in the list.
Definition: RenderTypes.h:2743
Definition: RenderTypes.h:447
T sumMatrix(const Matrix< T > *mat)
Definition: RenderTypes.h:4532
std::string msg
Definition: RenderTypes.h:1385
MemException(const std::string m, int err)
Definition: RenderTypes.h:1418
virtual void setPointSize(real min, real max)
Set the minimum and maximum point size for attenuated points.
Definition: RenderTypes.h:2979
bool onPlane(const vec3 &planept, const vec3 &planenorm) const
Returns true if the ray is on the plane defined by the position `planept' and normal `planenorm'...
Definition: RenderTypes.h:3326
wfunc widthfunc
Definition: RenderTypes.h:3137
virtual void setPointSizeAbs(real size)
Set the absolute point size.
Definition: RenderTypes.h:2981
virtual void setText(const std::string &text)
Definition: RenderTypes.h:4021
void append(const T &t, sval m=0)
Append `t' to a new row, placing it in column `m'.
Definition: RenderTypes.h:1971
virtual const char * getName() const
Definition: RenderTypes.h:2707
virtual color getDefaultColor() const
Definition: RenderTypes.h:2916
real m03
Definition: RenderTypes.h:878
colfunc colorfunc
Definition: RenderTypes.h:3109
virtual real getAlpha() const
Get the alpha (transparency) value, 1.0 is opaque and 0.0 is invisible, -1.0 if alpha shouldn't be us...
Definition: RenderTypes.h:2914
#define dEPSILON
Definition: RenderTypes.h:84
static vec3 X()
Returns the X-axis unit vector.
Definition: RenderTypes.h:863
Definition: RenderTypes.h:503
Matrix< vec3 > Vec3Matrix
Definition: RenderTypes.h:2239
virtual void setHAlign(HAlignType align)
Definition: RenderTypes.h:4026
std::string toString()
Definition: RenderTypes.h:4069
virtual real getSpectrumPos(indexval index) const
Get the position of the spectrum value at the given index in the list.
Definition: RenderTypes.h:2737
void clear()
Definition: RenderTypes.h:2455
virtual void setBGColor(const color &c)
Definition: RenderTypes.h:3819
int sortTupleFourthCB(const void *v1, const void *v2)
Definition: RenderTypes.h:167
vec3 cross(const vec3 &v) const
Return the cross product of `this' and `v'.
Definition: RenderTypes.h:661
Implementation of a IndexBuffer which uses matrices for storage, like MatrixVertexBuffer.
Definition: RenderTypes.h:3231
virtual sval getHeight() const
Get the image height.
Definition: RenderTypes.h:3749
bool loopOnce()
Definition: RenderTypes.h:340
i32 hash() const
Definition: RenderTypes.h:828
virtual void initializeResources()
Onces all resource directories are added, initialize the internal resource system.
Definition: RenderTypes.h:4125
S second
Definition: RenderTypes.h:266
Matrix< real > RealMatrix
Definition: RenderTypes.h:2238
float r(float val)
Definition: RenderTypes.h:565
rotator(real yaw, real pitch, real roll)
Defines a rotation from Euler angles: yaw = Z-axis rotation, pitch = X-axis rotation, roll = Y-axis rotation.
Definition: RenderTypes.h:1036
vec3(real val=0)
Construct a vector by setting all components to `val'.
Definition: RenderTypes.h:628
Definition: RenderTypes.h:464
bool loopOnce()
Definition: RenderTypes.h:384
virtual void setTexture(const Texture *tex)
Definition: RenderTypes.h:2996
virtual void fillColor(color col)
Definition: RenderTypes.h:2321
Definition: RenderTypes.h:3772
void setType(const char *type)
Definition: RenderTypes.h:1682
bool alwaysHighQuality
Definition: RenderTypes.h:4104
Definition: RenderTypes.h:501
virtual void setPoint()
Make this a point light, illuminating all objects within range as defined by the attenuation settings...
Definition: RenderTypes.h:3037
Locker(Mutex *p, real timeout=0.0)
Definition: RenderTypes.h:380
CallbackIndexBuffer(Ctx context, sval numindices, wfunc widthfunc, ifunc indexfunc)
Definition: RenderTypes.h:3143
virtual vec3 getVertex(int i) const
Returns the i'th vertex, i<numVertices()
Definition: RenderTypes.h:3118
virtual color getDefaultColor() const
Definition: RenderTypes.h:2723
real y() const
Definition: RenderTypes.h:635
float alpha
Definition: RenderTypes.h:2901
virtual std::string getLanguage() const
Definition: RenderTypes.h:2335
virtual bool usesInternalAlpha() const
Returns true if the internal alpha value is to be applied to colors, otherwise the alpha components o...
Definition: RenderTypes.h:2927
void set(indexval index, real pos, T value)
Definition: RenderTypes.h:2397
void divm(const Matrix< R > &mat, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1)
Divide every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in the matrix by the same in `mat'...
Definition: RenderTypes.h:1886
virtual real getTextHeight() const
Definition: RenderTypes.h:4038
rotator()
Default no-op.
Definition: RenderTypes.h:1000
virtual void setCtrlPoints(const Matrix< T > *pts)
Definition: RenderTypes.h:2467
Ray()
Definition: RenderTypes.h:3283
void readTextFile(const char *filename, sval numHeaders)
Read a text file of data into this matrix which has with `numHeaders' values in the header line...
Definition: RenderTypes.h:1995
const T & atc(sval n, sval m=0) const
Definition: RenderTypes.h:1918
virtual void setOrtho(bool isOrtho)
Definition: RenderTypes.h:3822
virtual vec3 getPosition() const
Definition: RenderTypes.h:3790
real m01
Definition: RenderTypes.h:878
quadruple(const F &first, const S &second, const T &third, const U &fourth)
Definition: RenderTypes.h:284
mat4 inverse() const
Definition: RenderTypes.h:948
bool isZero() const
Returns true if the length of the vector is within dEPSILON of 0.
Definition: RenderTypes.h:698
vec3 toPolar() const
Returns an equivalent vector in polar coordinates, assuming `this' was in cartesian coordinates...
Definition: RenderTypes.h:686
Represents a Red-Green-Blue-Alpha color with float channels. Note the lack of virtual members implies...
Definition: RenderTypes.h:529
virtual void setWireframe(bool isWireframe)
Definition: RenderTypes.h:3823
std::pair< real, T > ListValue
Definition: RenderTypes.h:2362
const char * getName() const
Definition: RenderTypes.h:1677
#define trylock_mutex(m)
Definition: RenderTypes.h:361
TextureFormat
Definition: RenderTypes.h:473
virtual void copyTo(Material *mat, bool copyTex=false, bool copySpec=false, bool copyProgs=false) const
Copy this material's settings to `mat'.
Definition: RenderTypes.h:2911
real m12
Definition: RenderTypes.h:878
virtual vec3 getVertex(int i) const
Returns the i'th vertex, i<numVertices()
Definition: RenderTypes.h:3219
int compV(const void *t1, const void *t2)
Definition: RenderTypes.h:147
virtual void setIndexNames(std::vector< std::string > names)
Sets the internal list of index names, should be used to update name list whenever setIndexSet is cal...
Definition: RenderTypes.h:2273
triple()
Definition: RenderTypes.h:269
bool renderHighQuality
Definition: RenderTypes.h:4103
vec3 * calculateTriNorms(vec3 *nodes, sval numnodes, indexval *inds, sval numinds)
Definition: RenderTypes.cpp:664
static indexval swap(indexval t)
Definition: RenderTypes.h:1593
virtual real getAlpha() const
Definition: RenderTypes.h:2725
Vec3Matrix * vecs
Definition: RenderTypes.h:3162
static rgba interpolate(real val, rgba left, rgba right)
Fast linear interpolation between rgba values.
Definition: RenderTypes.h:535
void setBuff(float *v) const
Definition: RenderTypes.h:570
virtual void setColor(const color &col)
Definition: RenderTypes.h:4023
virtual bool hasNormal() const
Returns true if the buffer contains normal data.
Definition: RenderTypes.h:3225
virtual bool hasColor() const
Returns true if the buffer contains color data.
Definition: RenderTypes.h:3226
virtual sval numIndices() const
Returns the number of index sets.
Definition: RenderTypes.h:3087
std::string msg
Definition: RenderTypes.h:1455
ControlCurve()
Definition: RenderTypes.h:2445
virtual ~ValueException()
Definition: RenderTypes.h:1469
real m22
Definition: RenderTypes.h:878
IndexException(const IndexException &ind)
Definition: RenderTypes.h:1401
static R op(const LH &lh, const RH &rh)
Definition: RenderTypes.h:1584
virtual void setZUp()
Definition: RenderTypes.h:3812
size_t val
Definition: RenderTypes.h:1386
void calculateImageHistogram(const RealMatrix *img, RealMatrix *hist, i32 minv)
Definition: RenderTypes.cpp:652
vec3 pointSearchLinTet(vec3 pt, vec3 n1, vec3 n2, vec3 n3, vec3 n4)
Definition: RenderTypes.cpp:446
virtual indexval getSpectrumIndex(real pos, color value) const
Get the index of the spectrum value with the given position and color, returns numSpectrumValues() if...
Definition: RenderTypes.h:2749
MemException(const std::string msg)
Definition: RenderTypes.h:1416
virtual void setNumPlanes(sval num)
Definition: RenderTypes.h:3961
int compT(const T &t1, const T &t2)
Definition: RenderTypes.h:137
real angleTo(const vec3 &v) const
Returns the angle between `this' and `v'.
Definition: RenderTypes.h:754
real lineDist(vec3 p1, vec3 p2) const
Returns the cylindrical distance from `this' to the line segment `p1'->`p2', or -1 if p1==p2 or `this...
Definition: RenderTypes.h:809
void convertRealStreamToRealMatrix(const char *stream, RealMatrix *mat)
Definition: RenderTypes.cpp:275
Matrix< ListValue > vals
Definition: RenderTypes.h:2363
std::vector< vec3 > findBoundaryPoints(const Matrix< T > *mat, const T &threshold)
Definition: RenderTypes.h:4505
Definition: RenderTypes.h:496
real m13
Definition: RenderTypes.h:878
virtual std::string getParameter(const std::string ¶m) const
Definition: RenderTypes.h:2350
real atX(real x, real threshold=0.0001) const
Definition: RenderTypes.h:2655
Definition: RenderTypes.cpp:23
void removeRow(sval n)
Definition: RenderTypes.h:1977
virtual Vec3Matrix * getNodes() const
Definition: RenderTypes.h:2266
triple(const triple< F, S, T > &t)
Definition: RenderTypes.h:271
virtual real getNearClip() const
Definition: RenderTypes.h:3828
void convertFloatStreamToRealMatrix(const char *stream, RealMatrix *mat)
Definition: RenderTypes.cpp:270
std::string getPPIDStr()
Definition: RenderTypes.h:208
virtual void setDataField(RealMatrix *field, const char *alias=NULL)
Add a new field matrix to the data set using its internal name or the supplied name, replaces an existing stored matrix.
Definition: RenderTypes.h:2297
void unlinkShared(const std::string &name)
Definition: RenderTypes.cpp:62
vec3 planeProject(const vec3 &planept, const vec3 &planenorm) const
Returns the projection of `this' on a plane defined by a point on the plane and the plane normal...
Definition: RenderTypes.h:786
Definition: RenderTypes.h:465
real _y
Definition: RenderTypes.h:996
rgba toRGBA() const
Convert this color to a 32-bit red-green-blue-alpha value suitable for certain renderer input values...
Definition: RenderTypes.h:573
void addm(const Matrix< R > &mat, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1)
Add every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in `mat' to the same cell in the matrix...
Definition: RenderTypes.h:1868
virtual bool hasUVWCoord() const
Returns true if the buffer contains texture coord data.
Definition: RenderTypes.h:3227
This type is used with the TIMING and TIMINGBLOCK macros to time routine calls and code blocks...
Definition: RenderTypes.h:306
void toMatrix(real *mat) const
Definition: RenderTypes.h:1327
real intersectsLineSeg(const vec3 &v1, const vec3 &v2) const
Returns 0 if `v1' or `v2' are the origin of this ray, a value t >= 0 if the ray intersects the line a...
Definition: RenderTypes.h:3438
float a() const
Definition: RenderTypes.h:563
virtual sval getHeight() const
Definition: RenderTypes.h:2316
virtual void setEntryPoint(const std::string main)
Definition: RenderTypes.h:2354
void chooseSharedName(int counter=0)
Determine a shared name based on the name stored in this matrix and the counter value, used to determine a system-wide unique name.
Definition: RenderTypes.h:2084
sval getIndex(sval i) const
Definition: RenderTypes.h:3217
void scalarop(const R &r, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1)
Apply the operation OpType::op to every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in the matri...
Definition: RenderTypes.h:1821
virtual void setViewport(real left=0.0f, real top=0.0f, real width=1.0f, real height=1.0f)
Definition: RenderTypes.h:3821
Definition: RenderTypes.h:449
Definition: RenderTypes.h:477
real m21
Definition: RenderTypes.h:878
Definition: RenderTypes.h:3160
void copyFrom(const Matrix< R > *r)
Copy the data bitwise from `r', the number of bytes copied is the minimum or either matrices' size...
Definition: RenderTypes.h:1762
std::pair< real, real > realpair
Definition: RenderTypes.h:289
virtual TextureFormat getFormat() const
Definition: RenderTypes.h:2319
MatrixVertexBuffer(const VertexBuffer *buf)
Copy the data from `buf' into internal matrices which this object is responsible for and will delete ...
Definition: RenderTypes.h:3180
virtual bool isTransparentColor() const
Returns true if the intenal alpha value is used, if it's <1.0, if vertex colors are not used...
Definition: RenderTypes.h:2967
Definition: RenderTypes.h:448
vec3(const vec3 &v)
Copy constructor.
Definition: RenderTypes.h:632
bool deleteMatrices
Definition: RenderTypes.h:3235
Definition: RenderTypes.h:872
virtual bool setGPUParamColor(ProgramType pt, const std::string &name, color val)
Definition: RenderTypes.h:3006
virtual color interpolateColor(real pos) const
Definition: RenderTypes.h:2826
virtual std::string getProfiles() const
Definition: RenderTypes.h:2352
Definition: RenderTypes.h:487
float g() const
Definition: RenderTypes.h:561
real len() const
Definition: RenderTypes.h:1275
void storeBufftoBinaryFile(const char *filename, void *src, size_t srcsize, int *header, size_t headerlen)
Using mmap, copy the contents of `header' and then `src' into file `filename'.
Definition: RenderTypes.cpp:150
realpair intersectsRay(const Ray &ray) const
Definition: RenderTypes.h:3405
virtual T getCtrlPoint(indexval index) const
Definition: RenderTypes.h:2465
F first
Definition: RenderTypes.h:265
real getYaw() const
Get the yaw angle (z-axis rotation in radians)
Definition: RenderTypes.h:1165
Represents a GPU program (vertex/fragment/geometry shader)
Definition: RenderTypes.h:2327
real m31
Definition: RenderTypes.h:878
bool inSphere(const vec3 ¢er, real radius) const
Returns true if the vector's distance to `center' is less than or equal to `radius'+`dEPSILON'.
Definition: RenderTypes.h:718
void checkDimension(const char *name, sval dim) const
Definition: RenderTypes.h:2042
virtual RenderScene * getRenderScene()
Definition: RenderTypes.h:4207
VAlignType
Definition: RenderTypes.h:499
void setMsg()
Definition: RenderTypes.h:1388
void interpolateImageStack(const std::vector< RealMatrix *> &stack, const transform &stacktransinv, RealMatrix *out, const transform &outtrans)
Definition: RenderTypes.cpp:611
vec3 toCylindrical() const
Returns an equivalent vector in cylindrical coordinates, assuming `this' was in cartesian coordinates...
Definition: RenderTypes.h:689
virtual bool usesFlatShading() const
Definition: RenderTypes.h:2951
virtual color getAmbient() const
Definition: RenderTypes.h:2937
T swapEndianN(T t)
Definition: RenderTypes.h:226
virtual std::string getEntryPoint() const
Definition: RenderTypes.h:2351
sval _n_actual
Definition: RenderTypes.h:1614
unsigned int u32
Definition: RenderTypes.h:103
bool getRenderHighQuality() const
Returns whether the next render operation will be in high quality mode.
Definition: RenderTypes.h:4167
void mul(const R &r, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1)
Multiple every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in the matrix by `r'.
Definition: RenderTypes.h:1856
Definition: RenderTypes.h:2438
rotator inverse() const
Returns a rotator representing the opposite rotation.
Definition: RenderTypes.h:1304
Definition: RenderTypes.h:478
rotator(const vec3 &axis, real rads)
Defines a rotation about the given axis.
Definition: RenderTypes.h:1010
int planeOrder(const vec3 &planenorm, const vec3 &v1, const vec3 &v2) const
Given a plane defined by this and `planenorm', returns the circular ordering of `v1' and `v2'...
Definition: RenderTypes.h:789
virtual ~Matrix()
Definition: RenderTypes.h:1661
virtual void useFlatShading(bool use)
Definition: RenderTypes.h:2988
vec3 fromCylindrical() const
Returns an equivalent vector in cartesian coordinates, assuming `this' was in cylindrical coordinates...
Definition: RenderTypes.h:695
void setMatrixMinMax(Matrix< T > *mat, const V &minv, const V &maxv)
Definition: RenderTypes.h:4220
virtual bool hasUVWCoord() const
Returns true if the buffer contains texture coord data.
Definition: RenderTypes.h:3126
virtual void setFont(const std::string &fontname)
Definition: RenderTypes.h:4022
virtual const char * what() const
Definition: RenderTypes.h:1429
Partial templates for converting strings to primitives/vec3.
Definition: RenderTypes.h:4231
virtual bool hasColor() const
Returns true if the buffer contains color data.
Definition: RenderTypes.h:3125
rotator(vec3 row1, vec3 col1, vec3 row2, vec3 col2)
Definition: RenderTypes.h:1096
void setLinear(bool b)
Definition: RenderTypes.h:2617
virtual bool hasAlpha() const
Definition: RenderTypes.h:2318
int cmp(const vec3 &v) const
Definition: RenderTypes.h:741
virtual vec3 getVertex(int i) const
Returns the i'th vertex, i<numVertices()
Definition: RenderTypes.h:3062
rotator(const rotator &r)
Copy constructor.
Definition: RenderTypes.h:1004
void subm(const Matrix< R > &mat, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1)
Subtract every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in `mat' from the same cell in the ma...
Definition: RenderTypes.h:1874
Definition: RenderTypes.h:1606
rotator interpolate(real val, const rotator &r) const
Semi-linearly interpolates between `this' and `r', this varies from a circular interpolation but is f...
Definition: RenderTypes.h:1312
virtual Texture * loadTextureFile(const char *name, const char *absFilename)
Load a texture of the given name from the image absolute path filename.
Definition: RenderTypes.h:4143
virtual ~Light()
Definition: RenderTypes.h:3019
Vec3Curve(bool isXFunc)
Definition: RenderTypes.h:2615
indexval find(real pos, const T &value) const
Definition: RenderTypes.h:2414
virtual void addResourceDir(const char *dir)
Add a directory to search for resources in.
Definition: RenderTypes.h:4122
bool signz
Definition: RenderTypes.h:3280
virtual void useVertexColor(bool use)
Definition: RenderTypes.h:2986
virtual color getSpecular() const
Definition: RenderTypes.h:2939
virtual void logMessage(const char *msg)
Log a message to the renderer log file.
Definition: RenderTypes.h:4155
void checkIndex(const char *name, sval val, sval maxval) const
Definition: RenderTypes.h:2030
void convertIntStreamToRealMatrix(const char *stream, RealMatrix *mat)
Definition: RenderTypes.cpp:265
std::string _name
Definition: RenderTypes.h:1609
Definition: RenderTypes.h:993
virtual vec3 getTexXiDir(vec3 pos) const
Definition: RenderTypes.h:3974
virtual void setIndexSet(IndexMatrix *indices, const char *alias=NULL)
Add a new index matrix to the data set using its internal name or the supplied name, replaces an existing stored matrix.
Definition: RenderTypes.h:2282
real fround(real r)
Definition: RenderTypes.h:190
void storeBinaryFile(const char *filename, int *header, sval headerlen)
Store the header values `header' and then this matrix's contents to the file.
Definition: RenderTypes.h:2002
virtual void setAlpha(real alpha)
Set the internal alpha value, resetting the diffuse and specular values expected a subtype to set the...
Definition: RenderTypes.h:2919
real distTo(const vec3 &v) const
Return the distance from `this' to `v'.
Definition: RenderTypes.h:671
virtual const char * getGPUProgram(ProgramType pt) const
Definition: RenderTypes.h:2959
void readBinaryFileToBuff(const char *filename, size_t offset, void *dest, size_t len)
Using mmap, copy the contents from file `filename' into `dest' starting `offset' bytes from the begin...
Definition: RenderTypes.cpp:90
vec3 getDirection() const
Get the direction the ray is pointing.
Definition: RenderTypes.h:3300
std::pair< std::string, std::string > strpair
Definition: RenderTypes.h:4054
Definition: RenderTypes.h:453
virtual void setCtrlPoint(const vec3 &t, indexval index)
Definition: RenderTypes.h:2630
virtual Figure * createFigure(const char *name, const char *mat, FigureType type)
Create a figure of the given name, with material named by `mat', and type `type'. ...
Definition: RenderTypes.h:4131
virtual void usePointSprites(bool useSprites)
Definition: RenderTypes.h:2994
virtual void setAlpha(real a)
Definition: RenderTypes.h:3964
CallbackVertexBuffer(Ctx context, sval numvertices, vecfunc vertfunc, vecfunc normalfunc=NULL, colfunc colorfunc=NULL, vecfunc uvwfunc=NULL)
Definition: RenderTypes.h:3114
virtual real getAspectRatio() const
Get the aspect ratio of the notional box this camera sees through and shall render to a target...
Definition: RenderTypes.h:3781
virtual void calculateDerivs()
Definition: RenderTypes.h:2476
virtual void setSourceCode(const std::string &code)
Set the source code for the program, this must be done in the main thread.
Definition: RenderTypes.h:2341
virtual real getPointSizeAbs() const
Definition: RenderTypes.h:2945
virtual bool isClampTexAddress() const
Definition: RenderTypes.h:2955
void basis_Tet1NL(real xi0, real xi1, real xi2, real *coeffs)
Linear Nodal Lagrange tetrahedron basis function, fills in `coeffs' for the given xi value...
Definition: RenderTypes.cpp:300
vecfunc normalfunc
Definition: RenderTypes.h:3108
virtual void useInternalAlpha(bool val)
Set whether to use the internal alpha value or use those specified in the diffuse and specular color ...
Definition: RenderTypes.h:2930
virtual void useTexFiltering(bool use)
Definition: RenderTypes.h:2991
virtual void setFieldNames(std::vector< std::string > names)
Sets the internal list of field names, should be used to update name list whenever setDataField is ca...
Definition: RenderTypes.h:2288
void calculateTetValueIntersects(real val, real a, real b, real c, real d, real *results)
Definition: RenderTypes.cpp:576
Definition: RenderTypes.h:4199
virtual Camera * createCamera(const char *name, real left=0.0f, real top=0.0f, real width=1.0f, real height=1.0f)
Definition: RenderTypes.h:4116
void convertUIntStreamToRealMatrix(const char *stream, RealMatrix *mat)
Definition: RenderTypes.cpp:260
virtual ~MatrixIndexBuffer()
Definition: RenderTypes.h:3255
sval memSize() const
Get the total memory usage in bytes.
Definition: RenderTypes.h:1751
Definition: RenderTypes.h:461
virtual sval getIndex(int i, int w) const
Returns the w'th value of index set i.
Definition: RenderTypes.h:3091
u32 indexval
Definition: RenderTypes.h:110
virtual u64 createWindow(int width, int height)
Definition: RenderTypes.h:4204
virtual void setSpectrumValue(sval index, real pos, color value)
Set the spectrum value at the given list index.
Definition: RenderTypes.h:2755
bool hasValue(const char *name) const
Definition: RenderTypes.h:4065
u32 rgba
Definition: RenderTypes.h:109
void normThis()
Definition: RenderTypes.h:1292
Definition: RenderTypes.h:489
T _min(const T &a, const T &b)
Definition: RenderTypes.h:114
virtual void fillColorMatrix(ColorMatrix *col, const RealMatrix *mat, bool useValAsAlpha=false)
Definition: RenderTypes.h:2868
quadruple()
Definition: RenderTypes.h:283
static vec3 Z()
Returns the Z-axis unit vector.
Definition: RenderTypes.h:869
Definition: RenderTypes.h:446
virtual real getPointSizeMin() const
Definition: RenderTypes.h:2943
virtual IndexMatrix * getIndexSet(const char *name) const
Get the index matrix of the given name, or NULL if not found.
Definition: RenderTypes.h:2276
virtual void setDirection(vec3 &v)
Set the direction to emit light at, only meaningful for directional and spot lights.
Definition: RenderTypes.h:3025
Definition: RenderTypes.h:445
bool doPrint
Definition: RenderTypes.h:311
virtual bool setGPUParamVec3(ProgramType pt, const std::string &name, vec3 val)
Definition: RenderTypes.h:3005
bool useAlpha
Definition: RenderTypes.h:2902
real w() const
Definition: RenderTypes.h:1146
T swapEndian64(T t)
Definition: RenderTypes.h:246
virtual ~RenderScene()
Definition: RenderTypes.h:4109
real getRoll() const
Get the roll angle (y-axis rotation in radians)
Definition: RenderTypes.h:1178
virtual void setDiffuse(const color &c)
Set the diffuse color to emit.
Definition: RenderTypes.h:3028
Definition: RenderTypes.h:3101
float a(float val)
Definition: RenderTypes.h:568
S second
Definition: RenderTypes.h:279
vec3 fromPolar() const
Returns an equivalent vector in cartesian coordinates, assuming `this' was in polar coordinates...
Definition: RenderTypes.h:692
void setRenderHighQuality(bool val)
Set whether rendering should be done using high quality passes or not.
Definition: RenderTypes.h:4161
std::pair< T, T > minmaxMatrix(const Matrix< T > *mat)
Definition: RenderTypes.h:4546
vec3 lerp(real val, const vec3 &v) const
Linearly interpolate between `this' and `v'.
Definition: RenderTypes.h:823
virtual sval numAlphaCtrls() const
Definition: RenderTypes.h:2774
Definition: RenderTypes.h:454
void setShared(bool val)
Definition: RenderTypes.h:1695
virtual void setGPUProgram(const GPUProgram *prog)
Definition: RenderTypes.h:3001
Ray(const Ray &r)
Definition: RenderTypes.h:3291
Definition: RenderTypes.h:3956
virtual std::string getText() const
Definition: RenderTypes.h:4032
virtual mat4 getProjMatrix() const
Definition: RenderTypes.h:3795
void ident()
Definition: RenderTypes.h:892
void setAxis(const vec3 &axis, real rads)
Set the rotator to represent a rotation of `rads' radians around `axis'.
Definition: RenderTypes.h:1114
virtual GPUProgram * createGPUProgram(const char *name, ProgramType ptype, const char *language)
Load a GPU program (shader) of the given name, type, and language (ie. Cg).
Definition: RenderTypes.h:4146
virtual void addCtrlPoint(const T &t)
Definition: RenderTypes.h:2461
T * dataPtr() const
Definition: RenderTypes.h:1666
Definition: RenderTypes.h:2898
sval countValuesInRange(const Matrix< T > *mat, const T &minv, const T &maxv)
Definition: RenderTypes.h:4490
real x(real v)
Definition: RenderTypes.h:638
virtual Light * createLight()
Create a light object.
Definition: RenderTypes.h:4134
int sortTupleSecondCB(const void *v1, const void *v2)
Definition: RenderTypes.h:157
virtual const char * what() const
Definition: RenderTypes.h:1449
Definition: RenderTypes.h:262
real distTo(const vec3 v) const
Returns the distance from `v' to the projection of `v' on the ray, which is at getPosition(distTo(v))...
Definition: RenderTypes.h:3323
virtual void setNodes(Vec3Matrix *nodes)
Definition: RenderTypes.h:2267
void matop(const Matrix< R > &mat, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1)
Apply the operation OpType::op to every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in the matri...
Definition: RenderTypes.h:1833
unsigned long long u64
Definition: RenderTypes.h:104
configmap map
Definition: RenderTypes.h:4057
Definition: RenderTypes.h:1452
void applyFunc(T(*op)(Ctx, const T &, sval, sval), Ctx ctx, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1)
Apply the function `op' to each cell from (minrow,mincol) to (maxrow-1,maxcol-1), passing in `ctx' as...
Definition: RenderTypes.h:1809
void setBuff(float *v) const
Definition: RenderTypes.h:642
virtual void setSpecular(const color &c)
Sets the specular color, if usesInternalAlpha() returns true the alpha value will be set the internal...
Definition: RenderTypes.h:2973
RenderAdapter * getRenderAdapter(Config *config)
std::string getSharedDir()
Definition: RenderTypes.cpp:40
virtual bool usesDepthCheck() const
Definition: RenderTypes.h:2952
double delta
Definition: RenderTypes.h:310
#define unlock_mutex
Definition: RenderTypes.h:363
Definition: RenderTypes.h:443
virtual ~ControlCurve()
Definition: RenderTypes.h:2446
virtual void updateSpectrum()
Definition: RenderTypes.h:3008
virtual void setVisible(bool isVisible)
Set whether this light is currently illuminating or not.
Definition: RenderTypes.h:3046
virtual void clampTexAddress(bool use)
Definition: RenderTypes.h:2992
Definition: RenderTypes.h:488
void remove(indexval index)
Definition: RenderTypes.h:2408
virtual void fillRealMatrix(RealMatrix *mat)
Transfer the image data into the given matrix.
Definition: RenderTypes.h:3759
real _z
Definition: RenderTypes.h:996
Definition: RenderTypes.h:1586
Definition: RenderTypes.h:481
realtriple calculateTriPlaneSlice(const vec3 &planept, const vec3 &planenorm, const vec3 &a, const vec3 &b, const vec3 &c)
Definition: RenderTypes.cpp:516
T lerpXi(const T &val, const T &minv, const T &maxv)
Definition: RenderTypes.h:127
virtual void fillColor(const ColorMatrix *mat, indexval depth)
Definition: RenderTypes.h:2322
std::vector< indextriple > intersectsTriMesh(const Vec3Matrix *const nodes, const IndexMatrix *const inds, const Vec3Matrix *const centers, const RealMatrix *const radii2, sval numResults=0, sval excludeInd=-1) const
Definition: RenderTypes.h:3506
virtual std::vector< std::string > getFieldNames() const
Lists the names of field matrices stored.
Definition: RenderTypes.h:2285
virtual void setAABB(const vec3 &minv, const vec3 &maxv)
Definition: RenderTypes.h:3969
bool isShared() const
Returns true if the matrix is allocated in shared memory.
Definition: RenderTypes.h:1685
void fill(const RealMatrix *pos, const Matrix< T > *ctrls)
Definition: RenderTypes.h:2381
Definition: RenderTypes.h:1585
Ray(const vec3 &pos, const vec3 &dir)
Definition: RenderTypes.h:3286
real _z
Definition: RenderTypes.h:624
std::map< strpair, std::string > configmap
Definition: RenderTypes.h:4055
mat4(const real *mat)
Definition: RenderTypes.h:887
T third
Definition: RenderTypes.h:267
bool isXFunc
Definition: RenderTypes.h:2612
vec3 getPlaneXi(const vec3 &pos, const vec3 &planepos, const rotator &orientinv, const vec3 &dimvec)
Definition: RenderTypes.h:4615
virtual void setAspectRatio(real rat)
Definition: RenderTypes.h:3820
void catmullRomSpline(real t, real *coeffs)
Produces the 4 coefficients for a Catmull-Rom spline in [value 1, value 2, derivative 1...
Definition: RenderTypes.cpp:409
void cubicInterpMatrices(real t, const Matrix< T > *v1, const Matrix< T > *v2, const Matrix< T > *m1, const Matrix< T > *m2, const Matrix< T > *result)
Definition: RenderTypes.h:4432
const char * getType() const
Definition: RenderTypes.h:1679
Matrix< T > * reshape(const char *name, sval n, sval m, bool isShared=false) const
Definition: RenderTypes.h:1795
virtual vec3 getScreenPosition(vec3 pos) const
Returns the (x,y) screen coordinate of the vector `pos' as drawn with the current camera configuratio...
Definition: RenderTypes.h:3798
real dot(const vec3 &v) const
Return the dot product of `this' and `v'.
Definition: RenderTypes.h:663
Definition: RenderTypes.h:479
virtual rotator getRotation() const
Definition: RenderTypes.h:3792
i32 hash() const
Definition: RenderTypes.h:1359
virtual const char * getTexture() const
Definition: RenderTypes.h:2958
virtual bool usesTexFiltering() const
Definition: RenderTypes.h:2954
real m00
Definition: RenderTypes.h:878
Definition: RenderTypes.h:3056
virtual sval getWidth() const
Get the image width.
Definition: RenderTypes.h:3747
mat4 toMatrix() const
Definition: RenderTypes.h:1352
virtual void setBlendMode(BlendMode bm)
Definition: RenderTypes.h:2985
~Mutex()
Definition: RenderTypes.h:406
virtual bool isCameraAligned() const
Definition: RenderTypes.h:4041
Definition: RenderTypes.h:1411
#define lock_mutex
Definition: RenderTypes.h:362
virtual color getColor() const
Definition: RenderTypes.h:4034
T * createShared()
Create a shared segment and return a mapped pointer to it.
Definition: RenderTypes.h:2123
virtual Material * createMaterial(const char *name)
Create a material object of the given name.
Definition: RenderTypes.h:4128
T swapEndian32(T t)
Definition: RenderTypes.h:235
virtual sval numVertices() const
Returns number of total vertices.
Definition: RenderTypes.h:3224
real pos(indexval index) const
Definition: RenderTypes.h:2403
virtual void setUp(const vec3 &v)
Definition: RenderTypes.h:3811
virtual vec3 getTexXiPos(vec3 pos) const
Definition: RenderTypes.h:3972
virtual real getGPUParamReal(ProgramType pt, const std::string &name)
Definition: RenderTypes.h:2962
virtual void setTexAABB(const vec3 &minv, const vec3 &maxv)
Definition: RenderTypes.h:3967
virtual bool isCullBackfaces() const
Definition: RenderTypes.h:2956
bool isParentProc()
Definition: RenderTypes.h:220
T * data
Definition: RenderTypes.h:1613
Spectrum(const std::string &name="")
Definition: RenderTypes.h:2705
vec3(real x, real y, real z=0)
Construct a vector with the given components.
Definition: RenderTypes.h:630
quadruple(const quadruple< F, S, T, U > &t)
Definition: RenderTypes.h:285
virtual void cullBackfaces(bool cull)
Definition: RenderTypes.h:2993
virtual void calculateDerivs()
Definition: RenderTypes.h:2647
Definition: RenderTypes.h:1591
rotator(real m00, real m01, real m02, real m10, real m11, real m12, real m20, real m21, real m22)
Defines a rotation from the significant 3x3 components of a 4x4 rotation matrix.
Definition: RenderTypes.h:1059
void setAlwaysHighQuality(bool val)
Set whether to force high quality rendering.
Definition: RenderTypes.h:4164
Represents a ray emanating from a point and moving in a direction. It provides methods for doing inte...
Definition: RenderTypes.h:3277
static R op(const LH &lh, const RH &rh)
Definition: RenderTypes.h:1585
virtual sval getHeight() const
Definition: RenderTypes.h:3832
Light()
Definition: RenderTypes.h:3018
RenderException(const std::string msg, const char *file, int line)
Definition: RenderTypes.h:1439
Definition: RenderTypes.h:2252
virtual ~RenderAdapter()
Definition: RenderTypes.h:4202
virtual bool usesVertexColor() const
Definition: RenderTypes.h:2949
sval _n
Definition: RenderTypes.h:1615
virtual void renderToFile(const std::string &filename, sval width, sval height, TextureFormat format=TF_RGB24, real stereoOffset=0.0)
Create an offscreen texture, render to it, then write the contents to the file `filename', assuming it's extension is for an understood format.
Definition: RenderTypes.h:3839
void normThis()
Normalizes `this', or do nothing if zero-length.
Definition: RenderTypes.h:683
quadruple< int, int, int, int > calculateBoundSquare(const Matrix< T > *const mat, const T &threshold)
Returns the bounding box (minx,miny,maxx,maxy) in matrix coordinates containing all values in `mat' g...
Definition: RenderTypes.h:4451
void checkNotShared() const
Definition: RenderTypes.h:2036
virtual Ray * getProjectedRay(real x, real y, bool isAbsolute=true) const
Definition: RenderTypes.h:3788
real z() const
Definition: RenderTypes.h:636
virtual ~Texture()
Definition: RenderTypes.h:2311
virtual void clearSpectrum()
Definition: RenderTypes.h:2709
real distToSq(const vec3 &v) const
Return the squared distance from `this' to `v'; this is faster than dist().
Definition: RenderTypes.h:673
ColorMatrix * cols
Definition: RenderTypes.h:3163
float b(float val)
Definition: RenderTypes.h:567
void reorderColumns(const sval *orderinds)
Definition: RenderTypes.h:1891
virtual sval numIndices() const
Returns the number of index sets.
Definition: RenderTypes.h:3147
real m33
Definition: RenderTypes.h:878
Definition: RenderTypes.h:3015
std::pair< indexval, realtriple > indextriple
Definition: RenderTypes.h:291
color(const rgba &c)
Definition: RenderTypes.h:557
void ats(sval n, sval m, const T &t)
Definition: RenderTypes.h:1919
color interpolate(real val, const color &col) const
Linearly interpolate between `this' and `col', val==0.0 yields `this', val==1.0 yields `col'...
Definition: RenderTypes.h:583
static real swap(real t)
Definition: RenderTypes.h:1592
virtual vec3 getNormal(int i) const
Returns the i'th normal, i<numVertices()
Definition: RenderTypes.h:3119
virtual vec3 getUVWCoord(int i) const
Returns the i'th UVW texture coord, i<numVertices()
Definition: RenderTypes.h:3222
void sub(const R &r, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1)
Subtract `r' from every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in the matrix.
Definition: RenderTypes.h:1850
virtual vec3 getWorldPosition(real x, real y, bool isAbsolute=true) const
Returns the world position of screen coordinate (x,y), which is either absolute pixel coordinates or ...
Definition: RenderTypes.h:3801
std::string name
Definition: RenderTypes.h:2255
void checkNull(const std::string valuename, const void *val, const char *file=NULL, int line=-1)
Definition: RenderTypes.h:1474
virtual void setAttenuation(real range, real constant=0.0f, real linear=1.0f, real quad=0.0f)
Set the attenuation values for spot and point lights.
Definition: RenderTypes.h:3043
Definition: RenderTypes.h:2610
virtual sval indexWidth(int i) const
Returns the width of index set i, i<numIndices(). All index sets for now are assumed to be the same w...
Definition: RenderTypes.h:3272
def toMatrix(mtype)
Definition: VTKPlugin.py:76
vec3 sign() const
Return a vector with each component of `this' replaced with 1 if positive otherwise -1...
Definition: RenderTypes.h:659
IndexException(std::string name, size_t val, size_t maxval)
Definition: RenderTypes.h:1396
T bilerpMatrix(const Matrix< T > *mat, real x, real y)
Definition: RenderTypes.h:4569
void resize(sval reserveNum=0)
Definition: RenderTypes.h:2058
virtual bool hasUVWCoord() const
Returns true if the buffer contains texture coord data.
Definition: RenderTypes.h:3077
virtual Texture * createTexture(const char *name, sval width, sval height, sval depth, TextureFormat format)
Create a 3D texture with the given name, dimensions, and format. Textures are always 3D but a `depth'...
Definition: RenderTypes.h:4140
bool isInUnitCube(real margin=0.0) const
Returns true if each component is on the interval [0,1]; this exact within a value of `margin' in the...
Definition: RenderTypes.h:724
vecfunc uvwfunc
Definition: RenderTypes.h:3110
virtual const char * getFilename() const
Definition: RenderTypes.h:2314
static R op(const LH &lh, const RH &rh)
Definition: RenderTypes.h:1586
unsigned char u8
Definition: RenderTypes.h:102
virtual color getColor(int i) const
Returns the i'th color, i<numVertices()
Definition: RenderTypes.h:3221
bool inAABB(const vec3 &minv, const vec3 &maxv) const
Returns true if the vector is within the axis-aligned bounding box defined by the given min and max c...
Definition: RenderTypes.h:701
int i32
Definition: RenderTypes.h:100
TimingObject(const std::string &label, bool doPrint=true)
Definition: RenderTypes.h:315
bool isNan(real v)
Returns true if `v' is NaN.
Definition: RenderTypes.h:179
void append(const Matrix< T > &t)
Append `t' to the bottom of `this', throws exception if shared or if columns of `t' and `this' don't ...
Definition: RenderTypes.h:1960
virtual void setLinearAlpha(bool b)
Definition: RenderTypes.h:2808
void setMinVals(const vec3 &v)
Set each component of `this' to minimum of its component and the equivalent in `v'.
Definition: RenderTypes.h:678
Image objects represented loaded image files. These are used to access image data in code rather than...
Definition: RenderTypes.h:3739
void addShared(const std::string &name)
Definition: RenderTypes.cpp:45
virtual void addSpectrumValue(real pos, color value)
Add a color value to the spectrum at the given position then resort the spectrum. ...
Definition: RenderTypes.h:2730
real m20
Definition: RenderTypes.h:878
static indexval conv(const char *str)
Definition: RenderTypes.h:4233
bool onPlane(const vec3 &planept, const vec3 &planenorm) const
Returns true if the vector lies on the plane defined by the point `planept' and normal `planenorm'...
Definition: RenderTypes.h:721
virtual ~Camera()
Definition: RenderTypes.h:3776
bool runblock
Definition: RenderTypes.h:377
The all-important 3-space vector type. Note the lack of virtual members implies no vtable pointer...
Definition: RenderTypes.h:622
Mutex()
Definition: RenderTypes.h:394
real m02
Definition: RenderTypes.h:878
#define SAFE_DELETE(p)
Definition: RenderTypes.h:90
virtual void setVAlign(VAlignType align)
Definition: RenderTypes.h:4025
virtual color getEmissive() const
Definition: RenderTypes.h:2940
An IndexBuffer is used by Figure objects to read in the topologies for the figures to render...
Definition: RenderTypes.h:3081
T clamp(const T &val, const T &minval, const T &maxval)
Definition: RenderTypes.h:117
float r() const
Definition: RenderTypes.h:560
static vec3 Y()
Returns the Y-axis unit vector.
Definition: RenderTypes.h:866
virtual const char * getName() const
Definition: RenderTypes.h:2313
Definition: RenderTypes.h:495
mat4(real m00, real m01, real m02, real m03, real m10, real m11, real m12, real m13, real m20, real m21, real m22, real m23, real m30, real m31, real m32, real m33)
Definition: RenderTypes.h:888
virtual void saveScreenshot(const char *filename, Camera *c=NULL, int width=0, int height=0, real stereoOffset=0.0, TextureFormat tf=TF_RGB24)
Save a screenshot to the given filename taken from the given camera, or of the whole 3D window if thi...
Definition: RenderTypes.h:4149
unsigned long _WId
Definition: RenderTypes.h:78
virtual sval getDepth() const
Get the image depth.
Definition: RenderTypes.h:3751
static int compZ(const void *v1, const void *v2)
Definition: RenderTypes.h:854
Definition: RenderTypes.h:452
virtual ~IndexBuffer()
Definition: RenderTypes.h:3084
Matrix(const char *name, const char *type, const T *array, sval n, sval m, bool isShared=false)
Constructor for converting a memory pointer into a Matrix, this will copy n*m values from `array'...
Definition: RenderTypes.h:1652
triple(const F &first, const S &second, const T &third)
Definition: RenderTypes.h:270
realpair intersectsAABB(const vec3 &minv, const vec3 &maxv) const
Definition: RenderTypes.h:3346
virtual sval getWidth() const
Definition: RenderTypes.h:2315
void clear()
Definition: RenderTypes.h:1727
virtual void removeAlphaCtrl(indexval index)
Definition: RenderTypes.h:2790
real getImageStackValue(const std::vector< RealMatrix *> &stack, const vec3 &pos)
Definition: RenderTypes.cpp:640
ProgramType
Definition: RenderTypes.h:485
virtual sval getNumPlanes() const
Definition: RenderTypes.h:3962
real m30
Definition: RenderTypes.h:878
virtual void setRotation(const rotator &r)
Definition: RenderTypes.h:3814
vec3 dir
Definition: RenderTypes.h:3279
virtual bool isPointInViewport(int x, int y) const
Definition: RenderTypes.h:3834
virtual const char * getName() const
Definition: RenderTypes.h:3778
std::string name
Definition: RenderTypes.h:2702
Matrix(const char *name, const char *type, const char *sharedname, const char *serialmeta, sval n, sval m)
Constructor for unpickling only, do not use.
Definition: RenderTypes.h:1642
real triArea(const vec3 &b, const vec3 &c) const
Returns the area of a triangle defined by `this', `b', and `c'.
Definition: RenderTypes.h:800
#define PLATFORM_ID
Definition: RenderTypes.h:77
Ctx context
Definition: RenderTypes.h:3112
IndexMatrix * indices
Definition: RenderTypes.h:3233
static int compX(const void *v1, const void *v2)
Definition: RenderTypes.h:844
~TimingObject()
Definition: RenderTypes.h:328
bool hasValue(const char *group, const char *name) const
Definition: RenderTypes.h:4064
real * getPointer() const
Definition: RenderTypes.h:894
static T conv(const char *str)
Definition: RenderTypes.h:4231
virtual void setAmbientLight(const color &c)
Set the scene ambient light to the given color value.
Definition: RenderTypes.h:4119
real calculateLinePlaneSlice(const vec3 &planept, const vec3 &planenorm, const vec3 &a, const vec3 &b)
Definition: RenderTypes.cpp:546
virtual real getPointSizeMax() const
Definition: RenderTypes.h:2944
bool isLinearFunc() const
Definition: RenderTypes.h:2618
std::pair< vec3, vec3 > calculateBoundBox(const Vec3Matrix *mat)
Definition: RenderTypes.cpp:280
T third
Definition: RenderTypes.h:280
void convertByteStreamToRealMatrix(const char *stream, RealMatrix *mat)
Definition: RenderTypes.cpp:250
virtual color getGPUParamColor(ProgramType pt, const std::string &name)
Definition: RenderTypes.h:2964
virtual sval numVertices() const
Returns number of total vertices.
Definition: RenderTypes.h:3123
virtual sval numVertices() const
Returns number of total vertices.
Definition: RenderTypes.h:3071
Definition: RenderTypes.h:462
MatrixVertexBuffer(Vec3Matrix *vecs, ColorMatrix *cols=NULL, IndexMatrix *extinds=NULL)
Create the buffer from these matrices, vecs.m() in (1,2,4). The caller is responsible for deleting th...
Definition: RenderTypes.h:3170
virtual sval getIndex(int i, int j) const
Returns the w'th value of index set i.
Definition: RenderTypes.h:3273
sval numvertices
Definition: RenderTypes.h:3111
real lenSq() const
Return the squared length of `this'; this is faster than len().
Definition: RenderTypes.h:667
void setMaxVals(const vec3 &v)
Set each component of `this' to maximum of its component and the equivalent in `v'.
Definition: RenderTypes.h:680
virtual void removeSpectrumValue(indexval index)
Remove the spectrum value at the given index.
Definition: RenderTypes.h:2768
virtual bool isLinearAlpha() const
Definition: RenderTypes.h:2814
virtual void setPosition(vec3 &v)
Set the position for this light, only meaningful for point and spot lights.
Definition: RenderTypes.h:3022
virtual void setAlphaCtrl(vec3 v, indexval index)
Definition: RenderTypes.h:2796
void addRows(sval num)
Add `num' rows, throws exception if shared.
Definition: RenderTypes.h:1954
sval numindices
Definition: RenderTypes.h:3140
virtual Image * loadImageFile(const std::string &filename)
Load an image from the given filename.
Definition: RenderTypes.h:4137
triple< real, real, real > realtriple
Definition: RenderTypes.h:290
virtual vec3 getAlphaCtrl(indexval index) const
Definition: RenderTypes.h:2779
real len() const
Return the length of `this'.
Definition: RenderTypes.h:665
virtual T at(real tt) const
Definition: RenderTypes.h:2536
Matrix< T > * clone(const char *newname=NULL, bool isShared=false) const
Copy the contents of this matrix into a newly allocated one (which can be shared if isShared is true)...
Definition: RenderTypes.h:1669
virtual vec3 getGPUParamVec3(ProgramType pt, const std::string &name)
Definition: RenderTypes.h:2963
virtual ~MatrixVertexBuffer()
Definition: RenderTypes.h:3208
vec3 getPosition(real t=0) const
Get a position on the line at distance t, ie. t=0 is the origin.
Definition: RenderTypes.h:3297
rotator norm() const
Definition: RenderTypes.h:1285
Definition: RenderTypes.h:373
static color swap(color t)
Definition: RenderTypes.h:1595
real m[4][4]
Definition: RenderTypes.h:883
virtual void copySpectrumFrom(const Spectrum *s)
Definition: RenderTypes.h:2716
virtual ~Material()
Definition: RenderTypes.h:2905
virtual HAlignType getHAlign() const
Definition: RenderTypes.h:4037
void fill(const T &t)
Set every cell of the matrix to the given value.
Definition: RenderTypes.h:1754
virtual void useSpectrumTexture(bool use)
Definition: RenderTypes.h:2998
vec3 norm() const
Return the normalized version of `this', or a zero vector if `this' is zero-length.
Definition: RenderTypes.h:669
PositionQueue< color > spec
Definition: RenderTypes.h:2698
void setPosition(const vec3 &v)
Set the origin of the ray, this is what getPosition(0) shall return.
Definition: RenderTypes.h:3303
static void parse(const char *line, sval numvals, vec3 *list)
Definition: RenderTypes.h:4257
virtual void setSpaceWidth(real width)
Definition: RenderTypes.h:4028
virtual sval numPoints() const
Definition: RenderTypes.h:2464
RenderScene()
Definition: RenderTypes.h:4107
void setM(sval _newm)
Reshape to fit this many columns, does not allocate new columns but re-arranges existing ones and tru...
Definition: RenderTypes.h:1941
virtual bool setParameter(const std::string ¶m, const std::string &val)
Definition: RenderTypes.h:2349
Vec3Curve alphacurve
Definition: RenderTypes.h:2700
void setDirection(const vec3 &v)
Set the direction the ray is pointing.
Definition: RenderTypes.h:3306
virtual const char * what() const
Definition: RenderTypes.h:1408
virtual void setNearClip(real dist)
Definition: RenderTypes.h:3816
virtual sval numSpectrumValues() const
Get the number of spectrum values.
Definition: RenderTypes.h:2762
Material()
Definition: RenderTypes.h:2904
virtual void setAmbient(const color &c)
Definition: RenderTypes.h:2969
Ctx context
Definition: RenderTypes.h:3141
bool getAlwaysHighQuality() const
Returns whether to always render in high quality mode.
Definition: RenderTypes.h:4170
virtual bool setGPUParamInt(ProgramType pt, const std::string &name, int val)
Definition: RenderTypes.h:3003
void div(const R &r, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1)
Divide every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in the matrix by `r'.
Definition: RenderTypes.h:1862
bool inOBB(const vec3 ¢er, const vec3 &hx, const vec3 &hy, const vec3 &hz) const
Returns true if the vector is within the oriented bounding box defined by the given center position a...
Definition: RenderTypes.h:709
Definition: RenderTypes.h:463
std::string label
Definition: RenderTypes.h:313
real frand()
Definition: RenderTypes.h:185
virtual ~VertexBuffer()
Definition: RenderTypes.h:3059
virtual size_t getDataSize() const
Get the image data size in bytes.
Definition: RenderTypes.h:3753
sval n() const
Get the number of rows.
Definition: RenderTypes.h:1745
Matrix< T > ctrls
Definition: RenderTypes.h:2441
real dot(const rotator &r) const
Definition: RenderTypes.h:1280
strpair getPair(const char *group, const char *name) const
Definition: RenderTypes.h:4087
bool _isShared
Definition: RenderTypes.h:1617
real m32
Definition: RenderTypes.h:878
real intersectsPlane(const vec3 &planepos, const vec3 &planenorm) const
Definition: RenderTypes.h:3336
virtual ~MemException()
Definition: RenderTypes.h:1427
virtual void removeCtrlPoint(indexval index)
Definition: RenderTypes.h:2463
virtual void setType(ProgramType pt)
Definition: RenderTypes.h:2333
void setName(const char *name)
Definition: RenderTypes.h:1681
real x() const
Definition: RenderTypes.h:1147
U fourth
Definition: RenderTypes.h:281
virtual void useLighting(bool use)
Definition: RenderTypes.h:2987
virtual int getGPUParamInt(ProgramType pt, const std::string &name)
Definition: RenderTypes.h:2961
real y(real v)
Definition: RenderTypes.h:639
virtual Image * renderToImage(sval width, sval height, TextureFormat format=TF_RGB24, real stereoOffset=0.0)
Create an offscreen texture, render to it, then blit the contents to the returned Image object...
Definition: RenderTypes.h:3843
void closeShared(T *ptr)
Unmap the given shared segment, and delete it if this object created it.
Definition: RenderTypes.h:2202
virtual sval getDepth() const
Definition: RenderTypes.h:2317
virtual std::string getSourceCode() const
Return the text of the source for this program.
Definition: RenderTypes.h:2347
Matrix< indexval > IndexMatrix
Definition: RenderTypes.h:2240
void mulm(const Matrix< R > &mat, sval minrow=0, sval mincol=0, sval maxrow=-1, sval maxcol=-1)
Multiply every cell from (minrow,mincol) to (maxrow-1,maxcol-1) in the matrix by the same in `mat'...
Definition: RenderTypes.h:1880
virtual ~Image()
Definition: RenderTypes.h:3742
int sortTupleFirstCB(const void *v1, const void *v2)
Definition: RenderTypes.h:152
static vec3 posInfinity()
Definition: RenderTypes.h:859
virtual real getShininess() const
Definition: RenderTypes.h:2942
RenderException(const RenderException &op)
Definition: RenderTypes.h:1445
void convertUByteStreamToRealMatrix(const char *stream, RealMatrix *mat)
Definition: RenderTypes.cpp:240
void swapEndian()
Definition: RenderTypes.h:1909
bool pointInHex(vec3 pt, vec3 n1, vec3 n2, vec3 n3, vec3 n4, vec3 n5, vec3 n6, vec3 n7, vec3 n8)
Returns true if `pt' is in the hex defined by (n1-n8)
Definition: RenderTypes.cpp:441
#define dPI
Definition: RenderTypes.h:81
virtual void setSpotlight(real radsInner, real radsOuter, real falloff=1.0f)
Make this a spot light with the given beam angles and falloff values.
Definition: RenderTypes.h:3040
Camera()
Definition: RenderTypes.h:3775
void setAt(const T &t, sval n, sval m=0)
Set the value at (n,m) to t.
Definition: RenderTypes.h:1930
Definition: RenderTypes.h:2695
Matrix< T > * subMatrix(const char *name, sval n, sval m=1, sval noff=0, sval moff=0, bool isShared=false) const
Create a submatrix from this one of dimensions (n,m), starting at row `noff' and column `moff'...
Definition: RenderTypes.h:1770
bool entered
Definition: RenderTypes.h:312
HAlignType
Definition: RenderTypes.h:492
std::string name
Definition: RenderTypes.h:1384
virtual bool isSecondaryCamera()
Definition: RenderTypes.h:3836
virtual color getColor(int i) const
Returns the i'th color, i<numVertices()
Definition: RenderTypes.h:3120
real y() const
Definition: RenderTypes.h:1148
MatrixIndexBuffer(const IndexBuffer *buf)
Copy the data from `buf' into internal matrices which this object is responsible for and will delete ...
Definition: RenderTypes.h:3243
sval getIndex(sval n, sval m) const
Get the index corresponding to cell (n,m)
Definition: RenderTypes.h:2022
BlendMode
Definition: RenderTypes.h:459
static int compY(const void *v1, const void *v2)
Definition: RenderTypes.h:849
std::string _sharedname
Definition: RenderTypes.h:1611
virtual VAlignType getVAlign() const
Definition: RenderTypes.h:4036
virtual void setShininess(real c)
Set the amount of specular hightlighting to apply.
Definition: RenderTypes.h:2976
MutexType _mutex
Definition: RenderTypes.h:370
vecfunc vertfunc
Definition: RenderTypes.h:3107
real getPitch() const
Get the pitch angle (x-axis rotation in radians)
Definition: RenderTypes.h:1152
Definition: RenderTypes.h:1587
Definition: RenderTypes.h:482
virtual sval getPlaneIntersects(vec3 planept, vec3 planenorm, vec3 buffer[6][2], bool transformPlane=false, bool isXiPoint=false)
Definition: RenderTypes.h:3976
Definition: RenderTypes.h:450
virtual void paint()
Definition: RenderTypes.h:4205
void convertStreamToRealMatrix(const T *stream, RealMatrix *mat)
Fill a given RealMatrix with data from the given byte stream which contains values of various types...
Definition: RenderTypes.h:4317
vec3 abs() const
Return a vector with the absolute value of each component of `this'.
Definition: RenderTypes.h:655
virtual real getFarClip() const
Definition: RenderTypes.h:3829
Definition: RenderTypes.h:2359
T & at(sval n, sval m=0) const
Same as getAt except returning a reference and no bounds check.
Definition: RenderTypes.h:1917
virtual void setBGObject(color col, bool enabled)
Set the background skybox to the given color if `enabled' is true, otherwise disable it...
Definition: RenderTypes.h:4158
bool isParallel(const vec3 &other) const
Returns true if `other' is parallel with this vector, ie. they represent the same or opposite directi...
Definition: RenderTypes.h:727
virtual ProgramType getType() const
Definition: RenderTypes.h:2334
virtual ~TextFigure()
Definition: RenderTypes.h:4020
void convertShortStreamToRealMatrix(const char *stream, RealMatrix *mat)
Definition: RenderTypes.cpp:255
void readTextFileMatrix(const std::string &filename, sval numHeaders, Matrix< T > *mat)
Reads the text file into the given matrix, ignoring the header of integers and using the dimensions o...
Definition: RenderTypes.h:4280
virtual bool setGPUParamReal(ProgramType pt, const std::string &name, real val)
Definition: RenderTypes.h:3004
virtual void setSecondaryCamera(bool selective)
Definition: RenderTypes.h:3824
virtual bool hasColor() const
Returns true if the buffer contains color data.
Definition: RenderTypes.h:3075
virtual bool usesPointAttenuation() const
Definition: RenderTypes.h:2946
virtual vec3 getLookAt() const
Definition: RenderTypes.h:3791
virtual void setTextHeight(real height)
Definition: RenderTypes.h:4027
void release()
Releases the mutex lock.
Definition: RenderTypes.h:433
realtriple intersectsTri(const vec3 &v0, const vec3 &v1, const vec3 &v2) const
Definition: RenderTypes.h:3463
T getAt(sval n, sval m=0) const
Get the element at (n,m) in the matrix, throws exception if `n' or `m' out of range.
Definition: RenderTypes.h:1927
void add(real pos, T val)
Definition: RenderTypes.h:2375
virtual TextureFormat getFormat() const
Get the loaded data's format.
Definition: RenderTypes.h:3745
virtual bool hasDataField(const char *name) const
Returns true if a field matrix of the given name is stored.
Definition: RenderTypes.h:2294
F first
Definition: RenderTypes.h:278
float _r
Definition: RenderTypes.h:531
IndexMatrix * extinds
Definition: RenderTypes.h:3164
indexpair indexOf(const T &t, sval aftern=0, sval afterm=0) const
Find the row-column pair in the matrix where `t' is found, or indexpair(n(),0) if not found (None in ...
Definition: RenderTypes.h:2008
ValueException(const std::string valuename, const std::string msg, const char *file=NULL, int line=-1)
Definition: RenderTypes.h:1457
double real
Definition: RenderTypes.h:108
Matrix< color > ColorMatrix
Definition: RenderTypes.h:2241
real z() const
Definition: RenderTypes.h:1149
clock_t stop
Definition: RenderTypes.h:309
virtual std::string getFont() const
Definition: RenderTypes.h:4033
vec3 clamp(const vec3 &v1, const vec3 &v2) const
Return a vector whose components are clamped within the AABB defined by the given vectors...
Definition: RenderTypes.h:675
virtual RealMatrix * getDataField(const char *name) const
Get the field matrix of the given name, or NULL if not found.
Definition: RenderTypes.h:2291
virtual void resize(int x, int y, int width, int height)
Definition: RenderTypes.h:4206
vec3 planeNorm(const vec3 &v2, const vec3 &v3, const vec3 &farv) const
Returns the normal of a plane defined by `this', `v2', and `v3' with `farv' defined as below the plan...
Definition: RenderTypes.h:776
virtual sval indexWidth(int i) const
Returns the width of index set i, i<numIndices(). All index sets for now are assumed to be the same w...
Definition: RenderTypes.h:3148
virtual sval indexWidth(int i) const
Returns the width of index set i, i<numIndices(). All index sets for now are assumed to be the same w...
Definition: RenderTypes.h:3089
real basis_n_NURBS(sval ctrlpt, sval degree, real xi, const RealMatrix *knots)
Definition: RenderTypes.cpp:325
virtual Material * clone(const char *name) const
Make a copy of this material with the given name.
Definition: RenderTypes.h:2908
long long i64
Definition: RenderTypes.h:101
void set(const rotator &r)
Copy the values of `r' into `this'.
Definition: RenderTypes.h:1126
Definition: RenderTypes.h:4051
#define MutexType
Definition: RenderTypes.h:360
virtual std::vector< std::string > getParameterNames() const
Definition: RenderTypes.h:2353
def group(iterable, width=2)
Definition: Utils.py:2148
triple< sval, sval, real > intersect
Definition: RenderTypes.h:292
RenderException(const std::string msg)
Definition: RenderTypes.h:1437
virtual vec3 getNormal(int i) const
Returns the i'th normal, i<numVertices()
Definition: RenderTypes.h:3220
real m11
Definition: RenderTypes.h:878
void sort()
Definition: RenderTypes.h:2425
virtual color getColor(int i) const
Returns the i'th color, i<numVertices()
Definition: RenderTypes.h:3066
void basis_NURBS_default(real u, real v, real w, sval ul, sval vl, sval wl, sval udegree, sval vdegree, sval wdegree, real *coeffs)
Definition: RenderTypes.cpp:370
virtual bool hasNormal() const
Returns true if the buffer contains normal data.
Definition: RenderTypes.h:3073
std::pair< indexval, indexval > indexpair
Definition: RenderTypes.h:288
virtual void setProfiles(const std::string profiles)
Definition: RenderTypes.h:2355
std::string getPIDStr()
Definition: RenderTypes.h:195
T lerp(const V &val, const T &v1, const T &v2)
Definition: RenderTypes.h:132
virtual void useDepthWrite(bool use)
Definition: RenderTypes.h:2990
Matrix< T > derivs
Definition: RenderTypes.h:2442
virtual void renderToStream(void *stream, sval width, sval height, TextureFormat format=TF_RGB24, real stereoOffset=0.0)
Create an offscreen texture, render to it, then blit the contents to `stream', which must be large en...
Definition: RenderTypes.h:3841
void copyFrom(const ControlCurve< T > *con)
Definition: RenderTypes.h:2448
float calculateTetVolume(vec3 a, vec3 b, vec3 c, vec3 d)
Returns the volume of the linear tetrahedron defined by (a,b,c,d), the volume will be negative for an...
Definition: RenderTypes.h:4396
ValueException(const ValueException &op)
Definition: RenderTypes.h:1467
virtual void addCtrlPoint(const vec3 &t)
Definition: RenderTypes.h:2620
real mat4Det(real a, real b, real c, real d, real e, real f, real g, real h, real i, real j, real k, real l, real m, real n, real o, real p)
Definition: RenderTypes.cpp:423
virtual mat4 getViewMatrix() const
Definition: RenderTypes.h:3794
Definition: RenderTypes.h:502
void setN(sval _newn)
Resize the matrix to have _newn rows, throws exception if shared.
Definition: RenderTypes.h:1933
virtual void setPosition(const vec3 &v)
Definition: RenderTypes.h:3809
virtual const char * what() const
Definition: RenderTypes.h:1471
void convertUShortStreamToRealMatrix(const char *stream, RealMatrix *mat)
Definition: RenderTypes.cpp:245