00001 /*======================================================================= 00002 * Copyright 1991-1996, Silicon Graphics, Inc. 00003 * ALL RIGHTS RESERVED 00004 * 00005 * UNPUBLISHED -- Rights reserved under the copyright laws of the United 00006 * States. Use of a copyright notice is precautionary only and does not 00007 * imply publication or disclosure. 00008 * 00009 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND: 00010 * Use, duplication or disclosure by the Government is subject to restrictions 00011 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights 00012 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or 00013 * in similar or successor clauses in the FAR, or the DOD or NASA FAR 00014 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc., 00015 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311. 00016 * 00017 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY 00018 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, 00019 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY 00020 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON 00021 * GRAPHICS, INC. 00022 **=======================================================================*/ 00023 /*======================================================================= 00024 ** Author : Paul S. Strauss (MMM yyyy) 00025 ** Modified by : Nick Thompson (MMM yyyy) 00026 **=======================================================================*/ 00027 /*======================================================================= 00028 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00029 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00030 *** *** 00031 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00032 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00033 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00034 *** *** 00035 *** RESTRICTED RIGHTS LEGEND *** 00036 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00037 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00038 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00039 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00040 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00041 *** *** 00042 *** COPYRIGHT (C) 1996-2014 BY FEI S.A.S, *** 00043 *** BORDEAUX, FRANCE *** 00044 *** ALL RIGHTS RESERVED *** 00045 **=======================================================================*/ 00046 /*======================================================================= 00047 ** Modified by : VSG (MMM YYYY) 00048 **=======================================================================*/ 00049 00050 00051 #ifndef _SO_LEVEL_OF_DETAIL_ 00052 #define _SO_LEVEL_OF_DETAIL_ 00053 00054 #include <Inventor/fields/SoMFFloat.h> 00055 #include <Inventor/nodes/SoGroup.h> 00056 00058 // 00059 // Class: SoLevelOfDetail 00060 // 00061 // Level-of-detail group node. The children of this node typically 00062 // represent the same object or objects at varying levels of detail, 00063 // from highest detail to lowest. The size of the objects when 00064 // projected into the viewport is used to determine which version to 00065 // use (i.e., which child to traverse). 00066 // 00067 // The size is computed as the area of the screen rectangle enclosing 00068 // the projection of the 3D bounding box that encloses all of the 00069 // children. When rendering, this size is compared to the values in 00070 // the screenArea field. If the size is greater than the first value, 00071 // child 0 is traversed. If it is smaller than the first, but greater 00072 // than the second, child 1 is traversed, and so on. If there are 00073 // fewer children than are required by this rule, the last child is 00074 // traversed. The screenArea field contains just 0 by default, so the 00075 // first child is always traversed. 00076 // 00077 // The size calculation takes the current complexity into account. If 00078 // the complexity is 0 or is of type BOUNDING_BOX, the last child is 00079 // always traversed. If the complexity is less than .5, the computed 00080 // size is scaled down appropriately to use (possibly) a less 00081 // detailed representation. If the complexity is greater than .5, the 00082 // size is scaled up. At complexity 1, the first child is always used. 00083 // 00084 // Picking and the callback action use the same traversal rules as 00085 // rendering. Bounding boxes are computed to enclose all children (as 00086 // is needed to compute the projected size). All other actions are 00087 // implemented as for SoGroup, except that SoLevelOfDetail 00088 // saves/restores state (like a separator) when applying any action. 00089 // 00091 00150 class SoLevelOfDetail : public SoGroup { 00151 00152 SO_NODE_HEADER(SoLevelOfDetail); 00153 00154 public: 00155 // Fields 00160 SoMFFloat screenArea; 00161 00165 SoLevelOfDetail(); 00166 00170 SoLevelOfDetail(int nChildren); 00171 00172 private: 00173 // Implement actions: 00174 virtual void doAction(SoAction *action); 00175 virtual void callback(SoCallbackAction *action); 00176 virtual void GLRender(SoGLRenderAction *action); 00177 virtual void rayPick(SoRayPickAction *action); 00178 00179 private: 00180 static void initClass(); 00181 static void exitClass(); 00182 00183 private: 00184 virtual ~SoLevelOfDetail(); 00185 00186 private: 00187 // This action is used to compute the screen-space bbox 00188 static SoGetBoundingBoxAction *bboxAction; 00189 }; 00190 00191 #endif /* _SO_LEVEL_OF_DETAIL_ */ 00192 00193