| 1 | /* $Id: backend.cpp,v 1.1 2000-02-09 08:50:21 jeroen Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | ** License Applicability. Except to the extent portions of this file are
|
|---|
| 4 | ** made subject to an alternative license as permitted in the SGI Free
|
|---|
| 5 | ** Software License B, Version 1.0 (the "License"), the contents of this
|
|---|
| 6 | ** file are subject only to the provisions of the License. You may not use
|
|---|
| 7 | ** this file except in compliance with the License. You may obtain a copy
|
|---|
| 8 | ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
|---|
| 9 | ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
|---|
| 10 | **
|
|---|
| 11 | ** http://oss.sgi.com/projects/FreeB
|
|---|
| 12 | **
|
|---|
| 13 | ** Note that, as provided in the License, the Software is distributed on an
|
|---|
| 14 | ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
|---|
| 15 | ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
|---|
| 16 | ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
|---|
| 17 | ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
|---|
| 18 | **
|
|---|
| 19 | ** Original Code. The Original Code is: OpenGL Sample Implementation,
|
|---|
| 20 | ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
|---|
| 21 | ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
|---|
| 22 | ** Copyright in any portions created by third parties is as indicated
|
|---|
| 23 | ** elsewhere herein. All Rights Reserved.
|
|---|
| 24 | **
|
|---|
| 25 | ** Additional Notice Provisions: The application programming interfaces
|
|---|
| 26 | ** established by SGI in conjunction with the Original Code are The
|
|---|
| 27 | ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
|---|
| 28 | ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
|---|
| 29 | ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
|---|
| 30 | ** Window System(R) (Version 1.3), released October 19, 1998. This software
|
|---|
| 31 | ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
|---|
| 32 | ** published by SGI, but has not been independently verified as being
|
|---|
| 33 | ** compliant with the OpenGL(R) version 1.2.1 Specification.
|
|---|
| 34 | */
|
|---|
| 35 |
|
|---|
| 36 | /*
|
|---|
| 37 | * backend.c++
|
|---|
| 38 | *
|
|---|
| 39 | * $Date: 2000-02-09 08:50:21 $ $Revision: 1.1 $
|
|---|
| 40 | * $Header: /home/ktk/tmp/odin/2007/netlabs.cvs/odin32/src/opengl/glu/nurbs/internals/backend.cpp,v 1.1 2000-02-09 08:50:21 jeroen Exp $
|
|---|
| 41 | */
|
|---|
| 42 |
|
|---|
| 43 | /* Bezier surface backend
|
|---|
| 44 | - interprets display mode (wireframe,shaded,...)
|
|---|
| 45 | */
|
|---|
| 46 | #include <stdio.h>
|
|---|
| 47 | #include "glimports.h"
|
|---|
| 48 | #include "mystdio.h"
|
|---|
| 49 | #include "backend.h"
|
|---|
| 50 | #include "basiccrveval.h"
|
|---|
| 51 | #include "basicsurfeval.h"
|
|---|
| 52 | #include "nurbsconsts.h"
|
|---|
| 53 |
|
|---|
| 54 | #define NOWIREFRAME
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 | /*-------------------------------------------------------------------------
|
|---|
| 58 | * bgnsurf - preamble to surface definition and evaluations
|
|---|
| 59 | *-------------------------------------------------------------------------
|
|---|
| 60 | */
|
|---|
| 61 | void
|
|---|
| 62 | Backend::bgnsurf( int wiretris, int wirequads, long nuid )
|
|---|
| 63 | {
|
|---|
| 64 | /*#ifndef NOWIREFRAME*/ //need this for old version
|
|---|
| 65 | wireframetris = wiretris;
|
|---|
| 66 | wireframequads = wirequads;
|
|---|
| 67 | /*#endif*/
|
|---|
| 68 |
|
|---|
| 69 | /*in the spec, GLU_DISPLAY_MODE is either
|
|---|
| 70 | * GLU_FILL
|
|---|
| 71 | * GLU_OUTLINE_POLY
|
|---|
| 72 | * GLU_OUTLINE_PATCH.
|
|---|
| 73 | *In fact, GLU_FLL is has the same effect as
|
|---|
| 74 | * set GL_FRONT_AND_BACK to be GL_FILL
|
|---|
| 75 | * and GLU_OUTLINE_POLY is the same as set
|
|---|
| 76 | * GL_FRONT_AND_BACK to be GL_LINE
|
|---|
| 77 | *It is more efficient to do this once at the beginning of
|
|---|
| 78 | *each surface than to do it for each primitive.
|
|---|
| 79 | * The internal has more options: outline_triangle and outline_quad
|
|---|
| 80 | *can be seperated. But since this is not in spec, and more importantly,
|
|---|
| 81 | *this is not so useful, so we don't need to keep this option.
|
|---|
| 82 | */
|
|---|
| 83 |
|
|---|
| 84 | surfaceEvaluator.bgnmap2f( nuid );
|
|---|
| 85 |
|
|---|
| 86 | if(wiretris)
|
|---|
| 87 | surfaceEvaluator.polymode(N_MESHLINE);
|
|---|
| 88 | else
|
|---|
| 89 | surfaceEvaluator.polymode(N_MESHFILL);
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | void
|
|---|
| 93 | Backend::patch( REAL ulo, REAL uhi, REAL vlo, REAL vhi )
|
|---|
| 94 | {
|
|---|
| 95 | surfaceEvaluator.domain2f( ulo, uhi, vlo, vhi );
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | void
|
|---|
| 99 | Backend::surfbbox( long type, REAL *from, REAL *to )
|
|---|
| 100 | {
|
|---|
| 101 | surfaceEvaluator.range2f( type, from, to );
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | /*-------------------------------------------------------------------------
|
|---|
| 105 | * surfpts - pass a desription of a surface map
|
|---|
| 106 | *-------------------------------------------------------------------------
|
|---|
| 107 | */
|
|---|
| 108 | void
|
|---|
| 109 | Backend::surfpts(
|
|---|
| 110 | long type, /* geometry, color, texture, normal */
|
|---|
| 111 | REAL *pts, /* control points */
|
|---|
| 112 | long ustride, /* distance to next point in u direction */
|
|---|
| 113 | long vstride, /* distance to next point in v direction */
|
|---|
| 114 | int uorder, /* u parametric order */
|
|---|
| 115 | int vorder, /* v parametric order */
|
|---|
| 116 | REAL ulo, /* u lower bound */
|
|---|
| 117 | REAL uhi, /* u upper bound */
|
|---|
| 118 | REAL vlo, /* v lower bound */
|
|---|
| 119 | REAL vhi ) /* v upper bound */
|
|---|
| 120 | {
|
|---|
| 121 | surfaceEvaluator.map2f( type,ulo,uhi,ustride,uorder,vlo,vhi,vstride,vorder,pts );
|
|---|
| 122 | surfaceEvaluator.enable( type );
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | /*-------------------------------------------------------------------------
|
|---|
| 126 | * surfgrid - define a lattice of points with origin and offset
|
|---|
| 127 | *-------------------------------------------------------------------------
|
|---|
| 128 | */
|
|---|
| 129 | void
|
|---|
| 130 | Backend::surfgrid( REAL u0, REAL u1, long nu, REAL v0, REAL v1, long nv )
|
|---|
| 131 | {
|
|---|
| 132 | surfaceEvaluator.mapgrid2f( nu, u0, u1, nv, v0, v1 );
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | /*-------------------------------------------------------------------------
|
|---|
| 136 | * surfmesh - evaluate a mesh of points on lattice
|
|---|
| 137 | *-------------------------------------------------------------------------
|
|---|
| 138 | */
|
|---|
| 139 | void
|
|---|
| 140 | Backend::surfmesh( long u, long v, long n, long m )
|
|---|
| 141 | {
|
|---|
| 142 | #ifndef NOWIREFRAME
|
|---|
| 143 | if( wireframequads ) {
|
|---|
| 144 | long v0, v1;
|
|---|
| 145 | long u0f = u, u1f = u+n;
|
|---|
| 146 | long v0f = v, v1f = v+m;
|
|---|
| 147 | long parity = (u & 1);
|
|---|
| 148 |
|
|---|
| 149 | for( v0 = v0f, v1 = v0f++ ; v0<v1f; v0 = v1, v1++ ) {
|
|---|
| 150 | surfaceEvaluator.bgnline();
|
|---|
| 151 | for( long u = u0f; u<=u1f; u++ ) {
|
|---|
| 152 | if( parity ) {
|
|---|
| 153 | surfaceEvaluator.evalpoint2i( u, v0 );
|
|---|
| 154 | surfaceEvaluator.evalpoint2i( u, v1 );
|
|---|
| 155 | } else {
|
|---|
| 156 | surfaceEvaluator.evalpoint2i( u, v1 );
|
|---|
| 157 | surfaceEvaluator.evalpoint2i( u, v0 );
|
|---|
| 158 | }
|
|---|
| 159 | parity = 1 - parity;
|
|---|
| 160 | }
|
|---|
| 161 | surfaceEvaluator.endline();
|
|---|
| 162 | }
|
|---|
| 163 | } else {
|
|---|
| 164 | surfaceEvaluator.mapmesh2f( N_MESHFILL, u, u+n, v, v+m );
|
|---|
| 165 | }
|
|---|
| 166 | #else
|
|---|
| 167 | if( wireframequads ) {
|
|---|
| 168 |
|
|---|
| 169 | surfaceEvaluator.mapmesh2f( N_MESHLINE, u, u+n, v, v+m );
|
|---|
| 170 | } else {
|
|---|
| 171 |
|
|---|
| 172 | surfaceEvaluator.mapmesh2f( N_MESHFILL, u, u+n, v, v+m );
|
|---|
| 173 | }
|
|---|
| 174 | #endif
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | /*-------------------------------------------------------------------------
|
|---|
| 178 | * endsurf - postamble to surface
|
|---|
| 179 | *-------------------------------------------------------------------------
|
|---|
| 180 | */
|
|---|
| 181 | void
|
|---|
| 182 | Backend::endsurf( void )
|
|---|
| 183 | {
|
|---|
| 184 | surfaceEvaluator.endmap2f();
|
|---|
| 185 | }
|
|---|
| 186 |
|
|---|
| 187 | /***************************************/
|
|---|
| 188 | void
|
|---|
| 189 | Backend::bgntfan( void )
|
|---|
| 190 | {
|
|---|
| 191 | surfaceEvaluator.bgntfan();
|
|---|
| 192 | /*
|
|---|
| 193 | if(wireframetris)
|
|---|
| 194 | surfaceEvaluator.polymode( N_MESHLINE );
|
|---|
| 195 | else
|
|---|
| 196 | surfaceEvaluator.polymode( N_MESHFILL );
|
|---|
| 197 | */
|
|---|
| 198 | }
|
|---|
| 199 |
|
|---|
| 200 | void
|
|---|
| 201 | Backend::endtfan( void )
|
|---|
| 202 | {
|
|---|
| 203 | surfaceEvaluator.endtfan();
|
|---|
| 204 | }
|
|---|
| 205 |
|
|---|
| 206 | void
|
|---|
| 207 | Backend::bgnqstrip( void )
|
|---|
| 208 | {
|
|---|
| 209 | surfaceEvaluator.bgnqstrip();
|
|---|
| 210 | /*
|
|---|
| 211 | if(wireframequads)
|
|---|
| 212 | surfaceEvaluator.polymode( N_MESHLINE );
|
|---|
| 213 | else
|
|---|
| 214 | surfaceEvaluator.polymode( N_MESHFILL );
|
|---|
| 215 | */
|
|---|
| 216 | }
|
|---|
| 217 |
|
|---|
| 218 | void
|
|---|
| 219 | Backend::endqstrip( void )
|
|---|
| 220 | {
|
|---|
| 221 | surfaceEvaluator.endqstrip();
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | void
|
|---|
| 225 | Backend::evalUStrip(int n_upper, REAL v_upper, REAL* upper_val,
|
|---|
| 226 | int n_lower, REAL v_lower, REAL* lower_val
|
|---|
| 227 | )
|
|---|
| 228 | {
|
|---|
| 229 | surfaceEvaluator.evalUStrip(n_upper, v_upper, upper_val,
|
|---|
| 230 | n_lower, v_lower, lower_val);
|
|---|
| 231 | }
|
|---|
| 232 |
|
|---|
| 233 | void
|
|---|
| 234 | Backend::evalVStrip(int n_left, REAL u_left, REAL* left_val,
|
|---|
| 235 | int n_right, REAL u_right, REAL* right_val
|
|---|
| 236 | )
|
|---|
| 237 | {
|
|---|
| 238 | surfaceEvaluator.evalVStrip(n_left, u_left, left_val,
|
|---|
| 239 | n_right, u_right, right_val);
|
|---|
| 240 | }
|
|---|
| 241 |
|
|---|
| 242 | /***************************************/
|
|---|
| 243 |
|
|---|
| 244 |
|
|---|
| 245 | /*-------------------------------------------------------------------------
|
|---|
| 246 | * bgntmesh - preamble to a triangle mesh
|
|---|
| 247 | *-------------------------------------------------------------------------
|
|---|
| 248 | */
|
|---|
| 249 | void
|
|---|
| 250 | Backend::bgntmesh( char * )
|
|---|
| 251 | {
|
|---|
| 252 | #ifndef NOWIREFRAME
|
|---|
| 253 |
|
|---|
| 254 | meshindex = 0; /* I think these need to be initialized to zero */
|
|---|
| 255 | npts = 0;
|
|---|
| 256 |
|
|---|
| 257 | if( !wireframetris ) {
|
|---|
| 258 | surfaceEvaluator.bgntmesh();
|
|---|
| 259 | }
|
|---|
| 260 | #else
|
|---|
| 261 |
|
|---|
| 262 | if( wireframetris ) {
|
|---|
| 263 | surfaceEvaluator.bgntmesh();
|
|---|
| 264 | surfaceEvaluator.polymode( N_MESHLINE );
|
|---|
| 265 | } else {
|
|---|
| 266 | surfaceEvaluator.bgntmesh();
|
|---|
| 267 | surfaceEvaluator.polymode( N_MESHFILL );
|
|---|
| 268 | }
|
|---|
| 269 | #endif
|
|---|
| 270 | }
|
|---|
| 271 |
|
|---|
| 272 | void
|
|---|
| 273 | Backend::tmeshvert( GridTrimVertex *v )
|
|---|
| 274 | {
|
|---|
| 275 | if( v->isGridVert() ) {
|
|---|
| 276 | tmeshvert( v->g );
|
|---|
| 277 | } else {
|
|---|
| 278 | tmeshvert( v->t );
|
|---|
| 279 | }
|
|---|
| 280 | }
|
|---|
| 281 |
|
|---|
| 282 | void
|
|---|
| 283 | Backend::tmeshvertNOGE(TrimVertex *t)
|
|---|
| 284 | {
|
|---|
| 285 | // surfaceEvaluator.inDoEvalCoord2NOGE( t->param[0], t->param[1], temp, ttt);
|
|---|
| 286 | #ifdef USE_OPTTT
|
|---|
| 287 | surfaceEvaluator.inDoEvalCoord2NOGE( t->param[0], t->param[1], t->cache_point, t->cache_normal);
|
|---|
| 288 | #endif
|
|---|
| 289 | }
|
|---|
| 290 |
|
|---|
| 291 | //opt for a line with the same u.
|
|---|
| 292 | void
|
|---|
| 293 | Backend::tmeshvertNOGE_BU(TrimVertex *t)
|
|---|
| 294 | {
|
|---|
| 295 | #ifdef USE_OPTTT
|
|---|
| 296 | surfaceEvaluator.inDoEvalCoord2NOGE_BU( t->param[0], t->param[1], t->cache_point, t->cache_normal);
|
|---|
| 297 | #endif
|
|---|
| 298 | }
|
|---|
| 299 |
|
|---|
| 300 | //opt for a line with the same v.
|
|---|
| 301 | void
|
|---|
| 302 | Backend::tmeshvertNOGE_BV(TrimVertex *t)
|
|---|
| 303 | {
|
|---|
| 304 | #ifdef USE_OPTTT
|
|---|
| 305 | surfaceEvaluator.inDoEvalCoord2NOGE_BV( t->param[0], t->param[1], t->cache_point, t->cache_normal);
|
|---|
| 306 | #endif
|
|---|
| 307 | }
|
|---|
| 308 |
|
|---|
| 309 | void
|
|---|
| 310 | Backend::preEvaluateBU(REAL u)
|
|---|
| 311 | {
|
|---|
| 312 | surfaceEvaluator.inPreEvaluateBU_intfac(u);
|
|---|
| 313 | }
|
|---|
| 314 |
|
|---|
| 315 | void
|
|---|
| 316 | Backend::preEvaluateBV(REAL v)
|
|---|
| 317 | {
|
|---|
| 318 | surfaceEvaluator.inPreEvaluateBV_intfac(v);
|
|---|
| 319 | }
|
|---|
| 320 |
|
|---|
| 321 |
|
|---|
| 322 | /*-------------------------------------------------------------------------
|
|---|
| 323 | * tmeshvert - evaluate a point on a triangle mesh
|
|---|
| 324 | *-------------------------------------------------------------------------
|
|---|
| 325 | */
|
|---|
| 326 | void
|
|---|
| 327 | Backend::tmeshvert( TrimVertex *t )
|
|---|
| 328 | {
|
|---|
| 329 |
|
|---|
| 330 | const long nuid = t->nuid;
|
|---|
| 331 | const REAL u = t->param[0];
|
|---|
| 332 | const REAL v = t->param[1];
|
|---|
| 333 |
|
|---|
| 334 | #ifndef NOWIREFRAME
|
|---|
| 335 | npts++;
|
|---|
| 336 | if( wireframetris ) {
|
|---|
| 337 | if( npts >= 3 ) {
|
|---|
| 338 | surfaceEvaluator.bgnclosedline();
|
|---|
| 339 | if( mesh[0][2] == 0 )
|
|---|
| 340 | surfaceEvaluator.evalcoord2f( mesh[0][3], mesh[0][0], mesh[0][1] );
|
|---|
| 341 | else
|
|---|
| 342 | surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] );
|
|---|
| 343 | if( mesh[1][2] == 0 )
|
|---|
| 344 | surfaceEvaluator.evalcoord2f( mesh[1][3], mesh[1][0], mesh[1][1] );
|
|---|
| 345 | else
|
|---|
| 346 | surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] );
|
|---|
| 347 | surfaceEvaluator.evalcoord2f( nuid, u, v );
|
|---|
| 348 | surfaceEvaluator.endclosedline();
|
|---|
| 349 | }
|
|---|
| 350 | mesh[meshindex][0] = u;
|
|---|
| 351 | mesh[meshindex][1] = v;
|
|---|
| 352 | mesh[meshindex][2] = 0;
|
|---|
| 353 | mesh[meshindex][3] = nuid;
|
|---|
| 354 | meshindex = (meshindex+1) % 2;
|
|---|
| 355 | } else {
|
|---|
| 356 | surfaceEvaluator.evalcoord2f( nuid, u, v );
|
|---|
| 357 | }
|
|---|
| 358 | #else
|
|---|
| 359 |
|
|---|
| 360 | surfaceEvaluator.evalcoord2f( 0, u, v );
|
|---|
| 361 | //for uninitial memory read surfaceEvaluator.evalcoord2f( nuid, u, v );
|
|---|
| 362 | #endif
|
|---|
| 363 | }
|
|---|
| 364 |
|
|---|
| 365 | //the same as tmeshvert(trimvertex), for efficiency purpose
|
|---|
| 366 | void
|
|---|
| 367 | Backend::tmeshvert( REAL u, REAL v )
|
|---|
| 368 | {
|
|---|
| 369 |
|
|---|
| 370 | const long nuid = 0;
|
|---|
| 371 |
|
|---|
| 372 |
|
|---|
| 373 | #ifndef NOWIREFRAME
|
|---|
| 374 | npts++;
|
|---|
| 375 | if( wireframetris ) {
|
|---|
| 376 | if( npts >= 3 ) {
|
|---|
| 377 | surfaceEvaluator.bgnclosedline();
|
|---|
| 378 | if( mesh[0][2] == 0 )
|
|---|
| 379 | surfaceEvaluator.evalcoord2f( mesh[0][3], mesh[0][0], mesh[0][1] );
|
|---|
| 380 | else
|
|---|
| 381 | surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] );
|
|---|
| 382 | if( mesh[1][2] == 0 )
|
|---|
| 383 | surfaceEvaluator.evalcoord2f( mesh[1][3], mesh[1][0], mesh[1][1] );
|
|---|
| 384 | else
|
|---|
| 385 | surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] );
|
|---|
| 386 | surfaceEvaluator.evalcoord2f( nuid, u, v );
|
|---|
| 387 | surfaceEvaluator.endclosedline();
|
|---|
| 388 | }
|
|---|
| 389 | mesh[meshindex][0] = u;
|
|---|
| 390 | mesh[meshindex][1] = v;
|
|---|
| 391 | mesh[meshindex][2] = 0;
|
|---|
| 392 | mesh[meshindex][3] = nuid;
|
|---|
| 393 | meshindex = (meshindex+1) % 2;
|
|---|
| 394 | } else {
|
|---|
| 395 | surfaceEvaluator.evalcoord2f( nuid, u, v );
|
|---|
| 396 | }
|
|---|
| 397 | #else
|
|---|
| 398 |
|
|---|
| 399 | surfaceEvaluator.evalcoord2f( 0, u, v );
|
|---|
| 400 | #endif
|
|---|
| 401 | }
|
|---|
| 402 |
|
|---|
| 403 | /*-------------------------------------------------------------------------
|
|---|
| 404 | * tmeshvert - evaluate a grid point of a triangle mesh
|
|---|
| 405 | *-------------------------------------------------------------------------
|
|---|
| 406 | */
|
|---|
| 407 | void
|
|---|
| 408 | Backend::tmeshvert( GridVertex *g )
|
|---|
| 409 | {
|
|---|
| 410 | const long u = g->gparam[0];
|
|---|
| 411 | const long v = g->gparam[1];
|
|---|
| 412 |
|
|---|
| 413 | #ifndef NOWIREFRAME
|
|---|
| 414 | npts++;
|
|---|
| 415 | if( wireframetris ) {
|
|---|
| 416 | if( npts >= 3 ) {
|
|---|
| 417 | surfaceEvaluator.bgnclosedline();
|
|---|
| 418 | if( mesh[0][2] == 0 )
|
|---|
| 419 | surfaceEvaluator.evalcoord2f( (long) mesh[0][3], mesh[0][0], mesh[0][1] );
|
|---|
| 420 | else
|
|---|
| 421 | surfaceEvaluator.evalpoint2i( (long) mesh[0][0], (long) mesh[0][1] );
|
|---|
| 422 | if( mesh[1][2] == 0 )
|
|---|
| 423 | surfaceEvaluator.evalcoord2f( (long) mesh[1][3], mesh[1][0], mesh[1][1] );
|
|---|
| 424 | else
|
|---|
| 425 | surfaceEvaluator.evalpoint2i( (long) mesh[1][0], (long) mesh[1][1] );
|
|---|
| 426 | surfaceEvaluator.evalpoint2i( u, v );
|
|---|
| 427 | surfaceEvaluator.endclosedline();
|
|---|
| 428 | }
|
|---|
| 429 | mesh[meshindex][0] = u;
|
|---|
| 430 | mesh[meshindex][1] = v;
|
|---|
| 431 | mesh[meshindex][2] = 1;
|
|---|
| 432 | meshindex = (meshindex+1) % 2;
|
|---|
| 433 | } else {
|
|---|
| 434 | surfaceEvaluator.evalpoint2i( u, v );
|
|---|
| 435 | }
|
|---|
| 436 | #else
|
|---|
| 437 | surfaceEvaluator.evalpoint2i( u, v );
|
|---|
| 438 | #endif
|
|---|
| 439 | }
|
|---|
| 440 |
|
|---|
| 441 | /*-------------------------------------------------------------------------
|
|---|
| 442 | * swaptmesh - perform a swap of the triangle mesh pointers
|
|---|
| 443 | *-------------------------------------------------------------------------
|
|---|
| 444 | */
|
|---|
| 445 | void
|
|---|
| 446 | Backend::swaptmesh( void )
|
|---|
| 447 | {
|
|---|
| 448 | #ifndef NOWIREFRAME
|
|---|
| 449 | if( wireframetris ) {
|
|---|
| 450 | meshindex = 1 - meshindex;
|
|---|
| 451 | } else {
|
|---|
| 452 | surfaceEvaluator.swaptmesh();
|
|---|
| 453 | }
|
|---|
| 454 | #else
|
|---|
| 455 | surfaceEvaluator.swaptmesh();
|
|---|
| 456 | #endif
|
|---|
| 457 | }
|
|---|
| 458 |
|
|---|
| 459 | /*-------------------------------------------------------------------------
|
|---|
| 460 | * endtmesh - postamble to triangle mesh
|
|---|
| 461 | *-------------------------------------------------------------------------
|
|---|
| 462 | */
|
|---|
| 463 | void
|
|---|
| 464 | Backend::endtmesh( void )
|
|---|
| 465 | {
|
|---|
| 466 | #ifndef NOWIREFRAME
|
|---|
| 467 | if( ! wireframetris )
|
|---|
| 468 | surfaceEvaluator.endtmesh();
|
|---|
| 469 | #else
|
|---|
| 470 | surfaceEvaluator.endtmesh();
|
|---|
| 471 | /* surfaceEvaluator.polymode( N_MESHFILL );*/
|
|---|
| 472 | #endif
|
|---|
| 473 | }
|
|---|
| 474 |
|
|---|
| 475 |
|
|---|
| 476 | /*-------------------------------------------------------------------------
|
|---|
| 477 | * bgnoutline - preamble to outlined rendering
|
|---|
| 478 | *-------------------------------------------------------------------------
|
|---|
| 479 | */
|
|---|
| 480 | void
|
|---|
| 481 | Backend::bgnoutline( void )
|
|---|
| 482 | {
|
|---|
| 483 | surfaceEvaluator.bgnline();
|
|---|
| 484 | }
|
|---|
| 485 |
|
|---|
| 486 | /*-------------------------------------------------------------------------
|
|---|
| 487 | * linevert - evaluate a point on an outlined contour
|
|---|
| 488 | *-------------------------------------------------------------------------
|
|---|
| 489 | */
|
|---|
| 490 | void
|
|---|
| 491 | Backend::linevert( TrimVertex *t )
|
|---|
| 492 | {
|
|---|
| 493 | surfaceEvaluator.evalcoord2f( t->nuid, t->param[0], t->param[1] );
|
|---|
| 494 | }
|
|---|
| 495 |
|
|---|
| 496 | /*-------------------------------------------------------------------------
|
|---|
| 497 | * linevert - evaluate a grid point of an outlined contour
|
|---|
| 498 | *-------------------------------------------------------------------------
|
|---|
| 499 | */
|
|---|
| 500 | void
|
|---|
| 501 | Backend::linevert( GridVertex *g )
|
|---|
| 502 | {
|
|---|
| 503 | surfaceEvaluator.evalpoint2i( g->gparam[0], g->gparam[1] );
|
|---|
| 504 | }
|
|---|
| 505 |
|
|---|
| 506 | /*-------------------------------------------------------------------------
|
|---|
| 507 | * endoutline - postamble to outlined rendering
|
|---|
| 508 | *-------------------------------------------------------------------------
|
|---|
| 509 | */
|
|---|
| 510 | void
|
|---|
| 511 | Backend::endoutline( void )
|
|---|
| 512 | {
|
|---|
| 513 | surfaceEvaluator.endline();
|
|---|
| 514 | }
|
|---|
| 515 |
|
|---|
| 516 | /*-------------------------------------------------------------------------
|
|---|
| 517 | * triangle - output a triangle
|
|---|
| 518 | *-------------------------------------------------------------------------
|
|---|
| 519 | */
|
|---|
| 520 | void
|
|---|
| 521 | Backend::triangle( TrimVertex *a, TrimVertex *b, TrimVertex *c )
|
|---|
| 522 | {
|
|---|
| 523 | /* bgntmesh( "spittriangle" );*/
|
|---|
| 524 | bgntfan();
|
|---|
| 525 | tmeshvert( a );
|
|---|
| 526 | tmeshvert( b );
|
|---|
| 527 | tmeshvert( c );
|
|---|
| 528 | endtfan();
|
|---|
| 529 | /* endtmesh();*/
|
|---|
| 530 | }
|
|---|
| 531 |
|
|---|
| 532 | void
|
|---|
| 533 | Backend::bgncurv( void )
|
|---|
| 534 | {
|
|---|
| 535 | curveEvaluator.bgnmap1f( 0 );
|
|---|
| 536 | }
|
|---|
| 537 |
|
|---|
| 538 | void
|
|---|
| 539 | Backend::segment( REAL ulo, REAL uhi )
|
|---|
| 540 | {
|
|---|
| 541 | curveEvaluator.domain1f( ulo, uhi );
|
|---|
| 542 | }
|
|---|
| 543 |
|
|---|
| 544 | void
|
|---|
| 545 | Backend::curvpts(
|
|---|
| 546 | long type, /* geometry, color, texture, normal */
|
|---|
| 547 | REAL *pts, /* control points */
|
|---|
| 548 | long stride, /* distance to next point */
|
|---|
| 549 | int order, /* parametric order */
|
|---|
| 550 | REAL ulo, /* lower parametric bound */
|
|---|
| 551 | REAL uhi ) /* upper parametric bound */
|
|---|
| 552 |
|
|---|
| 553 | {
|
|---|
| 554 | curveEvaluator.map1f( type, ulo, uhi, stride, order, pts );
|
|---|
| 555 | curveEvaluator.enable( type );
|
|---|
| 556 | }
|
|---|
| 557 |
|
|---|
| 558 | void
|
|---|
| 559 | Backend::curvgrid( REAL u0, REAL u1, long nu )
|
|---|
| 560 | {
|
|---|
| 561 | curveEvaluator.mapgrid1f( nu, u0, u1 );
|
|---|
| 562 | }
|
|---|
| 563 |
|
|---|
| 564 | void
|
|---|
| 565 | Backend::curvmesh( long from, long n )
|
|---|
| 566 | {
|
|---|
| 567 | curveEvaluator.mapmesh1f( N_MESHFILL, from, from+n );
|
|---|
| 568 | }
|
|---|
| 569 |
|
|---|
| 570 | void
|
|---|
| 571 | Backend::curvpt(REAL u)
|
|---|
| 572 | {
|
|---|
| 573 | curveEvaluator.evalcoord1f( 0, u );
|
|---|
| 574 | }
|
|---|
| 575 |
|
|---|
| 576 | void
|
|---|
| 577 | Backend::bgnline( void )
|
|---|
| 578 | {
|
|---|
| 579 | curveEvaluator.bgnline();
|
|---|
| 580 | }
|
|---|
| 581 |
|
|---|
| 582 | void
|
|---|
| 583 | Backend::endline( void )
|
|---|
| 584 | {
|
|---|
| 585 | curveEvaluator.endline();
|
|---|
| 586 | }
|
|---|
| 587 |
|
|---|
| 588 | void
|
|---|
| 589 | Backend::endcurv( void )
|
|---|
| 590 | {
|
|---|
| 591 | curveEvaluator.endmap1f();
|
|---|
| 592 | }
|
|---|