| 1 |
/* |
| 2 |
* |
| 3 |
* Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2.1 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* Further, this software is distributed without any warranty that it is |
| 16 |
* free of the rightful claim of any third person regarding infringement |
| 17 |
* or the like. Any license provided herein, whether implied or |
| 18 |
* otherwise, applies only to this software file. Patent licenses, if |
| 19 |
* any, provided herein do not apply to combinations of this program with |
| 20 |
* other software, or any other product whatsoever. |
| 21 |
* |
| 22 |
* You should have received a copy of the GNU Lesser General Public |
| 23 |
* License along with this library; if not, write to the Free Software |
| 24 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 |
* |
| 26 |
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
| 27 |
* Mountain View, CA 94043, or: |
| 28 |
* |
| 29 |
* http://www.sgi.com |
| 30 |
* |
| 31 |
* For further information regarding this notice, see: |
| 32 |
* |
| 33 |
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/ |
| 34 |
* |
| 35 |
*/ |
| 36 |
|
| 37 |
/*------------------------------------------------------------ |
| 38 |
* This is an example from the Inventor Mentor, |
| 39 |
* chapter 16, example 1. |
| 40 |
* |
| 41 |
* This example shows how to use the overlay planes with the |
| 42 |
* viewer components. By default color 0 is used for the |
| 43 |
* overlay planes background color (clear color), so we use |
| 44 |
* color 1 for the object. This example also shows how to |
| 45 |
* load the overlay color map with the wanted color. |
| 46 |
*----------------------------------------------------------*/ |
| 47 |
|
| 48 |
#include <cstdlib> |
| 49 |
#include <Inventor/SoDB.h> |
| 50 |
#include <Inventor/SoInput.h> |
| 51 |
#include <Inventor/nodes/SoNode.h> |
| 52 |
#include <Inventor/nodes/SoCone.h> |
| 53 |
#include <Inventor/Xt/SoXt.h> |
| 54 |
#include <Inventor/Xt/viewers/SoXtExaminerViewer.h> |
| 55 |
|
| 56 |
static char *overlayScene = "\ |
| 57 |
#Inventor V2.0 ascii\n\ |
| 58 |
\ |
| 59 |
Separator { \ |
| 60 |
OrthographicCamera { \ |
| 61 |
position 0 0 5 \ |
| 62 |
nearDistance 1.0 \ |
| 63 |
farDistance 10.0 \ |
| 64 |
height 10 \ |
| 65 |
} \ |
| 66 |
LightModel { model BASE_COLOR } \ |
| 67 |
ColorIndex { index 1 } \ |
| 68 |
Coordinate3 { point [ -1 -1 0, -1 1 0, 1 1 0, 1 -1 0] } \ |
| 69 |
FaceSet {} \ |
| 70 |
} "; |
| 71 |
|
| 72 |
int |
| 73 |
main(int , char **argv) |
| 74 |
{ |
| 75 |
// Initialize Inventor and Xt |
| 76 |
Widget myWindow = SoXt::init(argv[0]); |
| 77 |
|
| 78 |
// read the scene graph in |
| 79 |
SoInput in; |
| 80 |
SoNode *scene; |
| 81 |
in.setBuffer((void *)overlayScene, (size_t) strlen(overlayScene)); |
| 82 |
if (! SoDB::read(&in, scene) || scene == NULL) { |
| 83 |
printf("Couldn't read scene\n"); |
| 84 |
exit(1); |
| 85 |
} |
| 86 |
|
| 87 |
// Allocate the viewer, set the overlay scene and |
| 88 |
// load the overlay color map with the wanted color. |
| 89 |
SbColor color(.5, 1, .5); |
| 90 |
SoXtExaminerViewer *myViewer = new SoXtExaminerViewer(myWindow); |
| 91 |
myViewer->setSceneGraph(new SoCone); |
| 92 |
myViewer->setOverlaySceneGraph(scene); |
| 93 |
myViewer->setOverlayColorMap(1, 1, &color); |
| 94 |
myViewer->setTitle("Overlay Plane"); |
| 95 |
|
| 96 |
// Show the viewer and loop forever |
| 97 |
myViewer->show(); |
| 98 |
XtRealizeWidget(myWindow); |
| 99 |
SoXt::mainLoop(); |
| 100 |
} |