38 it->AppendTouchingModels(v);
56 double minx, miny, maxx, maxy, minz, maxz;
73 if (it->local_z.min < minz)
74 minz = it->local_z.min;
75 if (it->local_z.max > maxz)
76 maxz = it->local_z.max;
88 #define ENSURE_NOT_ZERO(x) \ 89 ((std::fabs(x) >= std::numeric_limits<double>::epsilon()) \ 91 : std::numeric_limits<double>::epsilon()) 95 const Size offset(b.
x.
min + size.
x / 2.0, b.
y.
min + size.
y / 2.0, 0);
104 pit->x = (pit->x - offset.
x) * (modsize.
x / size.
x);
105 pit->y = (pit->y - offset.
y) * (modsize.
y / size.
y);
109 it->local_z.min = (it->local_z.min - offset.
z) * (modsize.
z / size.
z);
110 it->local_z.max = (it->local_z.max - offset.
z) * (modsize.
z / size.
z);
141 it->DrawSolid(
false);
156 const GLubyte *estring;
158 estring = gluErrorString(errorCode);
159 fprintf(stderr,
"Tessellation Error: %s\n", estring);
166 GLdouble **new_vertex)
168 *new_vertex =
new GLdouble[3];
169 memcpy(*new_vertex, coords, 3 *
sizeof(GLdouble));
178 static GLUtesselator *tobj = NULL;
193 assert(tobj != NULL);
196 gluTessCallback(tobj, GLU_TESS_VERTEX, (GLvoid(*)()) & glVertex3dv);
197 gluTessCallback(tobj, GLU_TESS_EDGE_FLAG, (GLvoid(*)()) & glEdgeFlag);
198 gluTessCallback(tobj, GLU_TESS_BEGIN, (GLvoid(*)()) & glBegin);
199 gluTessCallback(tobj, GLU_TESS_END, (GLvoid(*)()) & glEnd);
202 gluTessCallback(tobj, GLU_TESS_ERROR, (GLvoid(*)()) &
errorCallback);
203 gluTessCallback(tobj, GLU_TESS_COMBINE, (GLvoid(*)()) &
combineCallback);
206 std::vector<std::vector<GLdouble> > contours;
209 std::vector<GLdouble> verts;
211 verts.push_back(it->x);
212 verts.push_back(it->y);
213 verts.push_back(blk->local_z.max);
215 contours.push_back(verts);
223 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
224 glEnable(GL_POLYGON_OFFSET_FILL);
225 glPolygonOffset(0.5, 0.5);
229 gluTessBeginPolygon(tobj, NULL);
232 gluTessBeginContour(tobj);
233 for (
size_t v = 0; v < contour->size(); v += 3)
234 gluTessVertex(tobj, &(*contour)[v], &(*contour)[v]);
235 gluTessEndContour(tobj);
238 gluTessEndPolygon(tobj);
246 glDisable(GL_POLYGON_OFFSET_FILL);
247 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
248 glDepthMask(GL_FALSE);
256 gluTessBeginPolygon(tobj, NULL);
259 gluTessBeginContour(tobj);
260 for (
size_t v = 0; v < contour->size(); v += 3)
261 gluTessVertex(tobj, &(*contour)[v], &(*contour)[v]);
262 gluTessEndContour(tobj);
265 gluTessEndPolygon(tobj);
270 glDepthMask(GL_TRUE);
271 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
296 PRINT_DEBUG1(
"attempting to load bitmap \"%s\n", bitmapfile.c_str());
300 if (bitmapfile[0] ==
'/')
303 char *workaround_const = strdup(wf->
filename.c_str());
304 full = std::string(
dirname(workaround_const)) +
"/" + bitmapfile;
305 free(workaround_const);
309 snprintf(buf, 512,
"[Image \"%s\"", bitmapfile.c_str());
313 PRINT_DEBUG1(
"attempting to load image %s", full.c_str());
315 Color col(1.0, 0.0, 1.0, 1.0);
317 std::vector<std::vector<point_t> > polys;
320 PRINT_ERR1(
"failed to load polys from image file \"%s\"", full.c_str());
336 it->Rasterize(data, width, height, cellwidth, cellheight);
virtual void PushColor(Color col)
Bounds y
volume extent along y axis, initially zero
double max
largest value in range, initially zero
void AppendTouchingModels(std::set< Model *> &touchers)
The Stage library uses its own namespace.
bounds3d_t BoundingBox() const
double min
smallest value in range, initially zero
int displaylist
OpenGL displaylist that renders this blockgroup.
void DrawFootPrint(const Geom &geom)
static void errorCallback(GLenum errorCode)
char * dirname(char *path)
static void combineCallback(GLdouble coords[3], GLdouble **, GLfloat *, GLdouble **new_vertex)
std::vector< Block > blocks
Contains the blocks in this group.
void LoadBitmap(const std::string &bitmapfile, Worldfile *wf)
void pose_shift(const Pose &pose)
int polys_from_image_file(const std::string &filename, std::vector< std::vector< point_t > > &polys)
rotated rectangle
virtual bool IsGUI() const
void Map(unsigned int layer)
Bounds x
volume extent along x axis, intially zero
void LoadBlock(Worldfile *wf, int entity)
void Rasterize(uint8_t *data, unsigned int width, unsigned int height, meters_t cellwidth, meters_t cellheight)
#define ENSURE_NOT_ZERO(x)
#define PRINT_DEBUG1(m, a)
Bounds z
volume extent along z axis, initially zero
World * world
Pointer to the world in which this model exists.
bool rebuild_displaylist
iff true, regenerate block display list before redraw
void UnMap(unsigned int layer)
void DrawSolid(const Geom &geom)
void AppendBlock(const Block &block)