static void post_scene_init()
{
+ int num_mir = mscn->calc_mirror_planes();
+ info_log("found %d mirror planes\n", num_mir);
+
exman->load(mscn, "data/exhibits");
}
show_message("VR recenter\n");
break;
- case 'x':
- exman->load(mscn, "data/exhibits");
- break;
-
case KEY_UP:
exui_scroll(-1);
break;
~DataSet();
void clear();
- void update();
+ void update(long timeslice = 20);
T get(const char *name) const;
}
template <typename T>
-void DataSet<T>::update()
+void DataSet<T>::update(long timeslice)
{
+ resman_setopt(rman, RESMAN_OPT_TIMESLICE, timeslice);
resman_poll(rman);
}
virtual void invalidate();
virtual Vec3 get_corner(int idx) const;
+ virtual Plane get_plane(int pidx) const;
virtual bool intersect(const Ray &ray, HitPoint *hit = 0) const;
virtual bool contains(const Vec3 &pt) const;
MTL_TEX_UNKNOWN
};
+enum {
+ MTL_MIRROR_NONE,
+ MTL_MIRROR_AUTO, // determine mirror plane automatically
+ MTL_MIRROR_AABB_PX, // plane = AABB +X side
+ MTL_MIRROR_AABB_NX, // plane = AABB -X side
+ MTL_MIRROR_AABB_PY, // plane = AABB +Y side
+ MTL_MIRROR_AABB_NY, // plane = AABB -Y side
+ MTL_MIRROR_AABB_PZ, // plane = AABB +Z side
+ MTL_MIRROR_AABB_NZ // plane = AABB -Z side
+};
+
#define NUM_MTL_TEXTURES MTL_TEX_UNKNOWN
class Material {
float alpha;
float reflect;
- bool flat_mirror;
+ int flat_mirror; // see MTL_MIRROR_* enumerations above
Texture *stdtex[NUM_MTL_TEXTURES];
std::vector<Texture*> textures;
const Mesh *mesh = ((ObjMesh*)obj)->mesh;
if(!mesh) continue;
- // assume the object is actually flat, so grab the first triangle and make a plane
- Triangle face = Triangle(0, (const Vec3*)mesh->get_attrib_data(MESH_ATTR_VERTEX),
- mesh->get_index_data());
- face.calc_normal();
-
FlatMirror *mir = new FlatMirror;
- mir->plane.pt = face.v[0];
- mir->plane.normal = face.normal;
mir->reflect = obj->mtl.reflect;
+ if(obj->mtl.flat_mirror == MTL_MIRROR_AUTO) {
+ // assume the object is actually flat, so grab the first triangle and make a plane
+ Triangle face = Triangle(0, (const Vec3*)mesh->get_attrib_data(MESH_ATTR_VERTEX),
+ mesh->get_index_data());
+ face.calc_normal();
+
+ mir->plane.pt = face.v[0];
+ mir->plane.normal = face.normal;
+ } else {
+ }
+
// check to see if we have found this mirror plane already
bool found = false;
FlatMirror *node = mirrors;
while(node) {
- if(fabs(dot(mir->plane.normal, node->plane.normal)) < 1e-4 &&
+ if(1.0f - dot(mir->plane.normal, node->plane.normal) < 1e-4f &&
fabs(dot(mir->plane.normal, normalize(mir->plane.pt - node->plane.pt))) < 1e-4) {
found = true;
break;
}
+ node = node->next;
}
if(!found) {