GLuint GeomGenList(GLuint geomlist, gdouble scaleBall, gdouble scaleStick) { if(!GeomOrb) return 0; if (glIsList(geomlist) == GL_TRUE) glDeleteLists(geomlist,1); geomlist = glGenLists(1); glNewList(geomlist, GL_COMPILE); GeomDraw(scaleBall, scaleStick); glEndList(); return geomlist; }
Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips"; #endif /* Authors: Charlie Gunn, Stuart Levy, Tamara Munzner, Mark Phillips */ #include "mg.h" #include "bezierP.h" #include "bsptreeP.h" Bezier * BezierDraw(Bezier *bezier) { const Appearance *ap = mggetappearance(); if (mgfeature(MGF_BEZIER)>0) { mgbezier (bezier->degree_u, bezier->degree_v , bezier->dimn, bezier->CtrlPnts, (bezier->geomflags & BEZ_ST) ? bezier->STCoords : NULL, (bezier->geomflags & BEZ_C) ? bezier->c : NULL); } else { GeomMakePath(bezier, 'B', path, pathlen); if (ap->valid & APF_DICE) { bezier->nu = ap->dice[0]; bezier->nv = ap->dice[1]; } if (bezier->mesh == NULL || bezier->mesh->nu != bezier->nu || bezier->mesh->nv != bezier->nv) bezier->geomflags |= BEZ_REMESH; if (bezier->geomflags & BEZ_REMESH) { BezierReDice(bezier); } bezier->mesh->ppath = path; bezier->mesh->ppathlen = pathlen; GeomDraw( (Geom *)bezier->mesh ); } return bezier; }
Inst *InstDraw(Inst *inst) { GeomIter *it, *txit = NULL; Transform T, tT, Tl2o, Ttx; mgNDctx *NDctx = NULL; void *saved_ctx; GeomMakePath(inst, 'I', path, pathlen); if (inst->geom == NULL) { return inst; } inst->geom->ppath = path; inst->geom->ppathlen = pathlen; inst->geomflags &= ~GEOM_ALPHA; mgctxget(MG_NDCTX, &NDctx); if (NDctx) { if (inst->location > L_LOCAL) { /* temporarily disable ND-drawing, makes sense only for * L_LOCAL, really. The universe is 3d in Geomview, in * some sense. */ mgctxset(MG_NDCTX, NULL, MG_END); } else if (inst->origin != L_NONE) { static int was_here; if (!was_here) OOGLError(1, "FIXME: don't know how to handle origin != L_LOCAL " "with ND-drawing.\n"); return NULL; } else { if (inst->NDaxis) { saved_ctx = NDctx->saveCTX(NDctx); NDctx->pushTN(NDctx, inst->NDaxis); GeomDraw(inst->geom); NDctx->restoreCTX(NDctx, saved_ctx); } else { it = GeomIterate((Geom *)inst, DEEP); txit = GeomIterate((Geom *)inst->txtlist, DEEP); while (NextTransform(it, T)) { if (!NextTransform(txit, Ttx)) { txit = NULL; } else { mgpushtxtransform(); mgtxtransform(Ttx); } saved_ctx = NDctx->saveCTX(NDctx); NDctx->pushT(NDctx, T); GeomDraw(inst->geom); NDctx->restoreCTX(NDctx, saved_ctx); if (txit != NULL) { mgpoptxtransform(); } } } if (inst->geom->geomflags & GEOM_ALPHA) { inst->geomflags |= GEOM_ALPHA; } return inst; } } it = GeomIterate((Geom *)inst, DEEP); txit = GeomIterate((Geom *)inst->txtlist, DEEP); while (NextTransform(it, T)) { mgpushtransform(); if (!NextTransform(txit, Ttx)) { txit = NULL; } else { mgpushtxtransform(); mgtxtransform(Ttx); } /* Compute origin *before* changing mg tfm */ if (inst->origin != L_NONE) { Point3 originwas, delta; TmCoord (*l2o)[4], (*o2W)[4]; static HPoint3 zero = { 0, 0, 0, 1 }; /* We have location2W, origin2W. We want to translate * in 'origin' coords such that (0,0,0) in location * coords maps to originpt in origin coords. */ o2W = coords2W(inst->origin, _mgc->xstk->T); l2o = coordsto(inst->location, inst->origin, _mgc->xstk->T, _mgc->xstk->Tinv); HPt3TransPt3(l2o, &zero, &originwas); Pt3Sub(&inst->originpt, &originwas, &delta); TmTranslate(tT, delta.x, delta.y, delta.z); TmConcat(l2o, tT, Tl2o); TmConcat(T, Tl2o, tT); TmConcat(tT, o2W, T); mgsettransform(T); } else if (inst->location > L_LOCAL) { TmConcat(T, coords2W(inst->location, _mgc->xstk->T), T); mgsettransform(T); } else { mgtransform(T); } GeomDraw(inst->geom); mgpoptransform(); if (txit != NULL) { mgpoptxtransform(); } } if(NDctx) { /* restore the ND-context, also: if we have a BSP-tree, then we * need to add our object to the tree, because GeomBSPTreeDraw() * does not do so for ND drawing. */ if (NDctx->bsptree != NULL && (inst->geom->geomflags & GEOM_ALPHA)) { GeomBSPTree((Geom *)inst, NDctx->bsptree, BSPTREE_ADDGEOM); } mgctxset(MG_NDCTX, NDctx, MG_END); } if (inst->geom->geomflags & GEOM_ALPHA) { inst->geomflags |= GEOM_ALPHA; } return inst; }