summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/drawsurface.cc
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-06-14 23:14:16 +0000
committerKarl Berry <karl@freefriends.org>2010-06-14 23:14:16 +0000
commitc2175edc7aa44ca0b526f008d473d6f8a8ac4933 (patch)
treed6c491676b413ad1922481f8c3fc7b64c3afc0a5 /Build/source/utils/asymptote/drawsurface.cc
parent5d08e9ff4fe5fc836d237ea08e82c82b27d558a2 (diff)
asy 1.98
git-svn-id: svn://tug.org/texlive/trunk@18982 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/drawsurface.cc')
-rw-r--r--Build/source/utils/asymptote/drawsurface.cc119
1 files changed, 35 insertions, 84 deletions
diff --git a/Build/source/utils/asymptote/drawsurface.cc b/Build/source/utils/asymptote/drawsurface.cc
index e5c8194700f..9a52e0c1919 100644
--- a/Build/source/utils/asymptote/drawsurface.cc
+++ b/Build/source/utils/asymptote/drawsurface.cc
@@ -10,7 +10,7 @@
namespace camp {
const double pixel=1.0; // Adaptive rendering constant.
-const triple drawSurface::zero;
+const triple drawElement::zero;
using vm::array;
@@ -26,27 +26,6 @@ void storecolor(GLfloat *colors, int i, const vm::array &pens, int j)
}
#endif
-inline void initMatrix(GLfloat *v, double x, double ymin, double zmin,
- double ymax, double zmax)
-{
- v[0]=x;
- v[1]=ymin;
- v[2]=zmin;
- v[3]=1.0;
- v[4]=x;
- v[5]=ymin;
- v[6]=zmax;
- v[7]=1.0;
- v[8]=x;
- v[9]=ymax;
- v[10]=zmin;
- v[11]=1.0;
- v[12]=x;
- v[13]=ymax;
- v[14]=zmax;
- v[15]=1.0;
-}
-
void drawSurface::bounds(bbox3& b)
{
double x,y,z;
@@ -142,7 +121,7 @@ void drawSurface::ratio(pair &b, double (*m)(double, double), double fuzz,
}
bool drawSurface::write(prcfile *out, unsigned int *, array *, array *, double,
- groupsmap&)
+ groupsmap&)
{
if(invisible || !prc)
return true;
@@ -217,35 +196,6 @@ inline double fraction(const triple& d, const triple& size)
fraction(d.getz(),size.getz()));
}
-#ifdef HAVE_GL
-struct billboard
-{
- triple u,v,w;
-
- void init() {
- gl::projection P=gl::camera(false);
- w=unit(P.camera-P.target);
- v=unit(perp(P.up,w));
- u=cross(v,w);
- }
-
- void store(GLfloat* C, const triple& V,
- const triple &center=drawSurface::zero) {
- double cx=center.getx();
- double cy=center.gety();
- double cz=center.getz();
- double x=V.getx()-cx;
- double y=V.gety()-cy;
- double z=V.getz()-cz;
- C[0]=cx+u.getx()*x+v.getx()*y+w.getx()*z;
- C[1]=cy+u.gety()*x+v.gety()*y+w.gety()*z;
- C[2]=cz+u.getz()*x+v.getz()*y+w.getz()*z;
- }
-};
-
-billboard BB;
-#endif
-
void drawSurface::render(GLUnurbs *nurb, double size2,
const triple& Min, const triple& Max,
double perspective, bool transparent)
@@ -260,34 +210,36 @@ void drawSurface::render(GLUnurbs *nurb, double size2,
static GLfloat v1[16];
static GLfloat v2[16];
- initMatrix(v1,Min.getx(),Min.gety(),Min.getz(),Max.gety(),Max.getz());
- initMatrix(v2,Max.getx(),Min.gety(),Min.getz(),Max.gety(),Max.getz());
-
- glPushMatrix();
- glMultMatrixf(v1);
- glGetFloatv(GL_MODELVIEW_MATRIX,v);
- glPopMatrix();
-
- bbox3 B(v[0],v[1],v[2]);
- B.addnonempty(v[4],v[5],v[6]);
- B.addnonempty(v[8],v[9],v[10]);
- B.addnonempty(v[12],v[13],v[14]);
-
- glPushMatrix();
- glMultMatrixf(v2);
- glGetFloatv(GL_MODELVIEW_MATRIX,v);
- glPopMatrix();
-
- B.addnonempty(v[0],v[1],v[2]);
- B.addnonempty(v[4],v[5],v[6]);
- B.addnonempty(v[8],v[9],v[10]);
- B.addnonempty(v[12],v[13],v[14]);
-
- triple M=B.Max();
- triple m=B.Min();
-
bool havebillboard=interaction == BILLBOARD;
+ triple m,M;
+ if(perspective || !havebillboard) {
+ initMatrix(v1,v2);
+
+ glPushMatrix();
+ glMultMatrixf(v1);
+ glGetFloatv(GL_MODELVIEW_MATRIX,v);
+ glPopMatrix();
+
+ bbox3 B(v[0],v[1],v[2]);
+ B.addnonempty(v[4],v[5],v[6]);
+ B.addnonempty(v[8],v[9],v[10]);
+ B.addnonempty(v[12],v[13],v[14]);
+
+ glPushMatrix();
+ glMultMatrixf(v2);
+ glGetFloatv(GL_MODELVIEW_MATRIX,v);
+ glPopMatrix();
+
+ B.addnonempty(v[0],v[1],v[2]);
+ B.addnonempty(v[4],v[5],v[6]);
+ B.addnonempty(v[8],v[9],v[10]);
+ B.addnonempty(v[12],v[13],v[14]);
+
+ m=B.Min();
+ M=B.Max();
+ }
+
if(perspective) {
double f=m.getz()*perspective;
double F=M.getz()*perspective;
@@ -349,7 +301,7 @@ void drawSurface::render(GLUnurbs *nurb, double size2,
if(lighton) {
if(havenormal && fraction(dperp,size3)*size2 <= 0.1) {
if(havebillboard)
- BB.store(Normal,normal);
+ BB.store(Normal,normal,zero);
else
store(Normal,normal);
glNormal3fv(Normal);
@@ -388,7 +340,7 @@ void drawSurface::render(GLUnurbs *nurb, double size2,
}
if(havebillboard)
- BB.store(Normal,normal);
+ BB.store(Normal,normal,zero);
else
store(Normal,normal);
@@ -527,8 +479,7 @@ void drawNurbs::render(GLUnurbs *nurb, double size2,
static GLfloat v1[16];
static GLfloat v2[16];
- initMatrix(v1,Min.getx(),Min.gety(),Min.getz(),Max.gety(),Max.getz());
- initMatrix(v2,Max.getx(),Min.gety(),Min.getz(),Max.gety(),Max.getz());
+ initMatrix(v1,v2);
glPushMatrix();
glMultMatrixf(v1);
@@ -549,9 +500,9 @@ void drawNurbs::render(GLUnurbs *nurb, double size2,
B.addnonempty(v[4],v[5],v[6]);
B.addnonempty(v[8],v[9],v[10]);
B.addnonempty(v[12],v[13],v[14]);
-
- triple M=B.Max();
+
triple m=B.Min();
+ triple M=B.Max();
double s;
if(perspective) {