00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#ifndef CYLINDER_H
00022
#define CYLINDER_H
00023
00024
#include "object3d.h"
00025
#include "intersection.h"
00026
00031 class Cylinder :
public Object3D {
00032
00033
public:
00036
Cylinder();
00037
00040
Cylinder(
const Vector3& base,
const Vector3& cap, DBL r);
00041
00042
public:
00043
00044
00045 Object3D*
duplicate()
const {
return new Cylinder(*
this);}
00046
00047
Intersection* intersectLocalLimitedTime(
const Ray &r, DBL maxtime)
const;
00048
bool isInsideAt(
const Vector3 &locallocation)
const;
00049
00050
private:
00051
enum hittype {SIDE,BASE,CAP,NONE};
00052
00053
private:
00054
static HitStatistics stat;
00055
00056
private:
00057
00060
class CylinderIntersection:
public Intersection {
00061
00062
private:
00063 DBL currenttime, secondtime;
00064 hittype hit1, hit2;
00065
00066
public:
00067 CylinderIntersection(
const Object3D* o,
const Ray &r, DBL t1, DBL t2, hittype h1, hittype h2):
00068
Intersection(o,r), currenttime(t1), secondtime(t2), hit1(h1), hit2(h2) {}
00069
00070
public:
00071
00072
00073 DBL currentTime() {
return currenttime;}
00074
void next();
00075
Vector3 normal();
00076
00077 };
00078
00079
private:
00080
static DBL absVec2(
const Vector3&);
00081
static DBL dotVec2(
const Vector3&,
const Vector3&);
00082
00083 };
00084
00085
#endif