#ifndef massedobject_h #define massedobject_h #include "sobject.h" #include "object.h" #include "voxel.h" class rtl_groupobj; class rtl_groupmem : public rtl_subobject { public: jInt materialindex() const { return m_idx; } void materialindex( jInt mi ) { m_idx = mi; } virtual inline rtl_material* material(); inline const rtl_object* group() const; protected: rtl_groupmem(); jInt m_idx; rtl_groupobj* mobj; friend class rtl_groupobj; }; class rtl_groupobj : public rtl_object { public: rtl_groupobj(); rtl_groupobj( rtl_groupobj* ); ~rtl_groupobj(); void add( rtl_groupmem* ); void add( rtl_material* ); rtl_material* getMaterial( jInt i ) { return i>=0 ? mat.table[i] : rtl_object::mat; } const rtl_subobject* subobject() const { return last_hit; } protected: static const jULng Reference; jFlt intersect( const rtl_ray& ray, bool rehit ) { voxel->groupObject(this); return rtl_object::intersect(ray,rehit); } jFlt lclintersect( const rtl_ray& ); jNorm3 lclnormal( const jVec3& ) { voxel->groupObject(this); return last_hit->normal(); } struct mat_link { mat_link( rtl_material*, mat_link* ); ~mat_link(); rtl_material* m; mat_link* n; }; union { mat_link* linked; rtl_material** table; rtl_groupobj* ref; } mat; jInt mcnt; rtl_lclvoxel* voxel; rtl_groupmem* last_hit; private: static const jULng Tabled; friend class rtl_groupmem; void buildMatTable(); }; #include "groupobject.inl" #endif