00001 /*---------------------------------------------------------------------------*\ 00002 * OpenSG * 00003 * * 00004 * * 00005 * Copyright(C) 2000-2002 by the OpenSG Forum * 00006 * * 00007 * www.opensg.org * 00008 * * 00009 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de * 00010 * * 00011 \*---------------------------------------------------------------------------*/ 00012 /*---------------------------------------------------------------------------*\ 00013 * License * 00014 * * 00015 * * 00016 * This library is free software; you can redistribute it and/or modify it * 00017 * under the terms of the GNU Library General Public License as published * 00018 * by the Free Software Foundation, version 2. * 00019 * * 00020 * This library is distributed in the hope that it will be useful, but * 00021 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00023 * Library General Public License for more details. * 00024 * * 00025 * You should have received a copy of the GNU Library General Public * 00026 * License along with this library; if not, write to the Free Software * 00027 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00028 * * 00029 * * 00030 \*---------------------------------------------------------------------------*/ 00031 /*---------------------------------------------------------------------------*\ 00032 * Changes * 00033 * * 00034 * * 00035 * * 00036 * * 00037 * * 00038 * * 00039 \*---------------------------------------------------------------------------*/ 00040 00041 #include <stdlib.h> 00042 #include <stdio.h> 00043 00044 #include "OSGConfig.h" 00045 00046 #include "OSGGeometry.h" 00047 00048 00049 OSG_BEGIN_NAMESPACE 00050 00051 00054 inline 00055 bool PrimitiveIterator::isAtEnd(void) const 00056 { 00057 return _ended; 00058 } 00059 00060 00064 inline 00065 Int32 PrimitiveIterator::getIndex(void) const 00066 { 00067 return _primIndex; 00068 } 00069 00072 inline 00073 UInt32 PrimitiveIterator::getLength(void) const 00074 { 00075 return _actPrimLength; 00076 } 00077 00080 inline 00081 UInt32 PrimitiveIterator::getType(void) const 00082 { 00083 return _actPrimType; 00084 } 00085 00086 00091 inline 00092 Int32 PrimitiveIterator::getPositionIndex(Int32 which) const 00093 { 00094 if(_geo->getIndices() != NullFC) 00095 { 00096 if(_positionIndex != -1) 00097 { 00098 return _indices->getValue((_actPointIndex + which) * 00099 _nmappings + _positionIndex); 00100 } 00101 else 00102 { 00103 return _indices->getValue(_actPointIndex * _nmappings + which ); 00104 } 00105 } 00106 else 00107 { 00108 return _actPointIndex + which; 00109 } 00110 } 00111 00112 00116 inline 00117 Pnt3f PrimitiveIterator::getPosition(Int32 which) const 00118 { 00119 Int32 ind = getPositionIndex(which); 00120 00121 return _geo->getPositions()->getValue(ind); 00122 } 00123 00124 00131 inline 00132 Int32 PrimitiveIterator::getNormalIndex(Int32 which) const 00133 { 00134 if(_geo->getNormals() == NullFC) 00135 return -1; 00136 00137 if(_geo->getIndices() != NullFC) 00138 { 00139 if(_normalIndex != -1) 00140 { 00141 return _indices->getValue((_actPointIndex + which) * 00142 _nmappings + _normalIndex); 00143 } 00144 else 00145 { 00146 return _indices->getValue(_actPointIndex * _nmappings + which ); 00147 } 00148 } 00149 else 00150 { 00151 return _actPointIndex + which; 00152 } 00153 } 00154 00155 00161 inline 00162 Vec3f PrimitiveIterator::getNormal(Int32 which) const 00163 { 00164 Int32 ind = getNormalIndex(which); 00165 00166 if(ind < 0) 00167 return Vec3f::Null; 00168 00169 return _geo->getNormals()->getValue(ind); 00170 } 00171 00178 inline 00179 Int32 PrimitiveIterator::getColorIndex(Int32 which) const 00180 { 00181 if(_geo->getColors() == NullFC) 00182 return -1; 00183 00184 if(_geo->getIndices() != NullFC) 00185 { 00186 if(_colorIndex != -1) 00187 { 00188 return _indices->getValue((_actPointIndex + which) * 00189 _nmappings + _colorIndex); 00190 } 00191 else 00192 { 00193 return _indices->getValue(_actPointIndex * _nmappings + which ); 00194 } 00195 } 00196 else 00197 { 00198 return _actPointIndex + which; 00199 } 00200 } 00201 00207 inline 00208 Color3f PrimitiveIterator::getColor(Int32 which) const 00209 { 00210 Int32 ind = getColorIndex(which); 00211 00212 if(ind < 0) 00213 return Color3f::Null; 00214 00215 return _geo->getColors()->getValue(ind); 00216 } 00217 00218 00226 inline 00227 Int32 PrimitiveIterator::getSecondaryColorIndex(Int32 which) const 00228 { 00229 if(_geo->getSecondaryColors() == NullFC) 00230 return -1; 00231 00232 if(_geo->getIndices() != NullFC) 00233 { 00234 if(_secondaryColorIndex != -1) 00235 { 00236 return _indices->getValue((_actPointIndex + which) * 00237 _nmappings + _secondaryColorIndex); 00238 } 00239 else 00240 { 00241 return _indices->getValue(_actPointIndex * _nmappings + which ); 00242 } 00243 } 00244 else 00245 { 00246 return _actPointIndex + which; 00247 } 00248 } 00249 00255 inline 00256 Color3f PrimitiveIterator::getSecondaryColor(Int32 which) const 00257 { 00258 Int32 ind = getSecondaryColorIndex(which); 00259 00260 if(ind < 0) 00261 return Color3f::Null; 00262 00263 return _geo->getSecondaryColors()->getValue(ind); 00264 } 00265 00273 inline 00274 Int32 PrimitiveIterator::getTexCoordsIndex(Int32 which) const 00275 { 00276 if(_geo->getTexCoords() == NullFC) 00277 return -1; 00278 00279 if(_geo->getIndices() != NullFC) 00280 { 00281 if(_texcoordsIndex != -1) 00282 { 00283 return _indices->getValue((_actPointIndex + which) * 00284 _nmappings + _texcoordsIndex); 00285 } 00286 else 00287 { 00288 return _indices->getValue(_actPointIndex * _nmappings + which ); 00289 } 00290 } 00291 else 00292 { 00293 return _actPointIndex + which; 00294 } 00295 } 00296 00302 inline 00303 Vec2f PrimitiveIterator::getTexCoords(Int32 which) const 00304 { 00305 Int32 ind = getTexCoordsIndex(which); 00306 00307 if(ind < 0) 00308 return Vec2f::Null; 00309 00310 return _geo->getTexCoords()->getValue(ind); 00311 } 00312 00313 00321 inline 00322 Int32 PrimitiveIterator::getTexCoordsIndex1(Int32 which) const 00323 { 00324 if(_geo->getTexCoords1() == NullFC) 00325 return -1; 00326 00327 if(_geo->getIndices() != NullFC) 00328 { 00329 if(_texcoordsIndex1 != -1) 00330 { 00331 return _indices->getValue((_actPointIndex + which) * 00332 _nmappings + _texcoordsIndex1); 00333 } 00334 else 00335 { 00336 return _indices->getValue(_actPointIndex * _nmappings + which ); 00337 } 00338 } 00339 else 00340 { 00341 return _actPointIndex + which; 00342 } 00343 } 00344 00345 00351 inline 00352 Vec2f PrimitiveIterator::getTexCoords1(Int32 which) const 00353 { 00354 Int32 ind = getTexCoordsIndex1(which); 00355 00356 if(ind < 0) 00357 return Vec2f::Null; 00358 00359 return _geo->getTexCoords1()->getValue(ind); 00360 } 00361 00362 00370 inline 00371 Int32 PrimitiveIterator::getTexCoordsIndex2(Int32 which) const 00372 { 00373 if(_geo->getTexCoords2() == NullFC) 00374 return -1; 00375 00376 if(_geo->getIndices() != NullFC) 00377 { 00378 if(_texcoordsIndex2 != -1) 00379 { 00380 return _indices->getValue((_actPointIndex + which) * 00381 _nmappings + _texcoordsIndex2); 00382 } 00383 else 00384 { 00385 return _indices->getValue(_actPointIndex * _nmappings + which ); 00386 } 00387 } 00388 else 00389 { 00390 return _actPointIndex + which; 00391 } 00392 } 00393 00394 00400 inline 00401 Vec2f PrimitiveIterator::getTexCoords2(Int32 which) const 00402 { 00403 Int32 ind = getTexCoordsIndex2(which); 00404 00405 if(ind < 0) 00406 return Vec2f::Null; 00407 00408 return _geo->getTexCoords2()->getValue(ind); 00409 } 00410 00411 00419 inline 00420 Int32 PrimitiveIterator::getTexCoordsIndex3(Int32 which) const 00421 { 00422 if(_geo->getTexCoords3() == NullFC) 00423 return -1; 00424 00425 if(_geo->getIndices() != NullFC) 00426 { 00427 if(_texcoordsIndex3 != -1) 00428 { 00429 return _indices->getValue((_actPointIndex + which) * 00430 _nmappings + _texcoordsIndex3); 00431 } 00432 else 00433 { 00434 return _indices->getValue(_actPointIndex * _nmappings + which ); 00435 } 00436 } 00437 else 00438 { 00439 return _actPointIndex + which; 00440 } 00441 } 00442 00443 00449 inline 00450 Vec2f PrimitiveIterator::getTexCoords3(Int32 which) const 00451 { 00452 Int32 ind = getTexCoordsIndex3(which); 00453 00454 if(ind < 0) 00455 return Vec2f::Null; 00456 00457 return _geo->getTexCoords3()->getValue(ind); 00458 } 00459 00467 inline 00468 Int32 PrimitiveIterator::getTexCoordsIndex4(Int32 which) const 00469 { 00470 if(_geo->getTexCoords4() == NullFC) 00471 return -1; 00472 00473 if(_geo->getIndices() != NullFC) 00474 { 00475 if(_texcoordsIndex4 != -1) 00476 { 00477 return _indices->getValue((_actPointIndex + which) * 00478 _nmappings + _texcoordsIndex4); 00479 } 00480 else 00481 { 00482 return _indices->getValue(_actPointIndex * _nmappings + which ); 00483 } 00484 } 00485 else 00486 { 00487 return _actPointIndex + which; 00488 } 00489 } 00490 00491 00497 inline 00498 Vec2f PrimitiveIterator::getTexCoords4(Int32 which) const 00499 { 00500 Int32 ind = getTexCoordsIndex4(which); 00501 00502 if(ind < 0) 00503 return Vec2f::Null; 00504 00505 return _geo->getTexCoords4()->getValue(ind); 00506 } 00507 00515 inline 00516 Int32 PrimitiveIterator::getTexCoordsIndex5(Int32 which) const 00517 { 00518 if(_geo->getTexCoords5() == NullFC) 00519 return -1; 00520 00521 if(_geo->getIndices() != NullFC) 00522 { 00523 if(_texcoordsIndex5 != -1) 00524 { 00525 return _indices->getValue((_actPointIndex + which) * 00526 _nmappings + _texcoordsIndex5); 00527 } 00528 else 00529 { 00530 return _indices->getValue(_actPointIndex * _nmappings + which ); 00531 } 00532 } 00533 else 00534 { 00535 return _actPointIndex + which; 00536 } 00537 } 00538 00539 00545 inline 00546 Vec2f PrimitiveIterator::getTexCoords5(Int32 which) const 00547 { 00548 Int32 ind = getTexCoordsIndex5(which); 00549 00550 if(ind < 0) 00551 return Vec2f::Null; 00552 00553 return _geo->getTexCoords5()->getValue(ind); 00554 } 00555 00563 inline 00564 Int32 PrimitiveIterator::getTexCoordsIndex6(Int32 which) const 00565 { 00566 if(_geo->getTexCoords6() == NullFC) 00567 return -1; 00568 00569 if(_geo->getIndices() != NullFC) 00570 { 00571 if(_texcoordsIndex6 != -1) 00572 { 00573 return _indices->getValue((_actPointIndex + which) * 00574 _nmappings + _texcoordsIndex6); 00575 } 00576 else 00577 { 00578 return _indices->getValue(_actPointIndex * _nmappings + which ); 00579 } 00580 } 00581 else 00582 { 00583 return _actPointIndex + which; 00584 } 00585 } 00586 00587 00593 inline 00594 Vec2f PrimitiveIterator::getTexCoords6(Int32 which) const 00595 { 00596 Int32 ind = getTexCoordsIndex6(which); 00597 00598 if(ind < 0) 00599 return Vec2f::Null; 00600 00601 return _geo->getTexCoords6()->getValue(ind); 00602 } 00603 00611 inline 00612 Int32 PrimitiveIterator::getTexCoordsIndex7(Int32 which) const 00613 { 00614 if(_geo->getTexCoords7() == NullFC) 00615 return -1; 00616 00617 if(_geo->getIndices() != NullFC) 00618 { 00619 if(_texcoordsIndex7 != -1) 00620 { 00621 return _indices->getValue((_actPointIndex + which) * 00622 _nmappings + _texcoordsIndex7); 00623 } 00624 else 00625 { 00626 return _indices->getValue(_actPointIndex * _nmappings + which ); 00627 } 00628 } 00629 else 00630 { 00631 return _actPointIndex + which; 00632 } 00633 } 00634 00635 00641 inline 00642 Vec2f PrimitiveIterator::getTexCoords7(Int32 which) const 00643 { 00644 Int32 ind = getTexCoordsIndex7(which); 00645 00646 if(ind < 0) 00647 return Vec2f::Null; 00648 00649 return _geo->getTexCoords7()->getValue(ind); 00650 } 00651 00662 inline 00663 Int32 PrimitiveIterator::getIndexIndex(Int32 which) const 00664 { 00665 if(_geo->getIndices() != NullFC) 00666 { 00667 return(_actPointIndex + which) * _nmappings; 00668 } 00669 else 00670 return -1; 00671 } 00672 00675 inline 00676 GeometryPtr PrimitiveIterator::getGeometry(void) const 00677 { 00678 return _geo; 00679 } 00680 00681 OSG_END_NAMESPACE
1.5.5