SmallChange  1.0.0
A collection of extensions to Coin3D
Loading...
Searching...
No Matches
SmScenery.h
1#ifndef SMALLCHANGE_SCENERY_H
2#define SMALLCHANGE_SCENERY_H
3
4/**************************************************************************\
5 *
6 * This file is part of the SmallChange extension library for Coin.
7 * Copyright (C) 1998-2003 by Systems in Motion. All rights reserved.
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * ("GPL") version 2 as published by the Free Software Foundation.
12 * See the file LICENSE.GPL at the root directory of this source
13 * distribution for additional information about the GNU GPL.
14 *
15 * For using SmallChange with software that can not be combined with the
16 * GNU GPL, and for taking advantage of the additional benefits of our
17 * support services, please contact Systems in Motion about acquiring
18 * a Coin Professional Edition License.
19 *
20 * See <URL:http://www.coin3d.org> for more information.
21 *
22 * Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
23 * <URL:http://www.sim.no>.
24 *
25\**************************************************************************/
26
27#include <Inventor/SbBasic.h>
28#include <Inventor/nodes/SoSubNode.h>
29#include <Inventor/nodes/SoShape.h>
30#include <Inventor/actions/SoCallbackAction.h>
31#include <Inventor/fields/SoSFString.h>
32#include <Inventor/fields/SoSFBool.h>
33#include <Inventor/fields/SoSFEnum.h>
34#include <Inventor/fields/SoSFFloat.h>
35#include <Inventor/fields/SoSFShort.h>
36#include <Inventor/fields/SoMFInt32.h>
37#include <Inventor/fields/SoMFFloat.h>
38
39#include <SmallChange/basic.h>
40
41typedef struct ss_system ss_system;
42typedef struct ss_render_pre_cb_info ss_render_pre_cb_info;
43
44typedef uint32_t SmSceneryTexture2CB(void * closure, double * xypos, float elevation, double * spacing);
45
46class SceneryP;
47
49 typedef SoShape inherited;
50 SO_NODE_HEADER(SmScenery);
51
52public:
53 static void initClass(void);
54
55 static SmScenery * createInstance(double * origo, double * spacing, int * elements, float * values, const float undefval = 999999.0f);
56 static SmScenery * createInstance(const int cols, const int rows, double * xyzgrid, const float undefz = 999999.0f);
57 static SmScenery * createInstance(const int points, double * xyzvals, const float reach = -1.0f);
58
59 static SmScenery * createCrossAndLineInstance(double * min, double * spacing, int * elements);
60
61 SmScenery(void);
62
63 SoSFString filename;
64 SoSFFloat blockRottger;
65 SoSFFloat loadRottger;
66
67 SoMFInt32 renderSequence;
68
69 enum ColorTexturing {
70 DISABLED,
71 INTERPOLATED,
72 DISCRETE
73 };
74
76 SoMFFloat colorMap; // r, g, b, a values
77 SoMFFloat colorElevation;
78
84
85 SoSFBool visualDebug;
86
87 virtual void GLRender(SoGLRenderAction * action);
88 virtual void rayPick(SoRayPickAction * action);
89
90 void preFrame(uint32_t glcontextid);
91 int postFrame(uint32_t glcontextid);
92
93 void setBlockRottger(const float c);
94 float getBlockRottger(void) const;
95 void setLoadRottger(const float c);
96 float getLoadRottger(void) const;
97
98 void setVertexArraysRendering(const SbBool onoff);
99 SbBool getVertexArraysRendering(void) const;
100
101 SbVec3f getRenderCoordinateOffset(void) const;
102 SbVec2f getElevationRange(void) const;
103 SbVec2f getDatasetElevationRange(int dataset) const;
104
105 void set2DColorationTextureCB(SmSceneryTexture2CB * callback, void * closure);
106
107 // dynamic texture callbacks
108 static uint32_t colortexture_cb(void * node, double * xypos, float elevation, double * spacing);
109
110 // action callbacks
111 static SoCallbackAction::Response evaluateS(void * userdata, SoCallbackAction * action, const SoNode * node);
112
113 SbBool getElevation(const double x, const double y, float & elev);
114
115 void getSpacingForLodlevel(int lodlevel, double * spacing) const;
116 float getUndefElevationValue(void) const;
117
118 int addElevationDataset(const char * name);
119 int addMaterialDataset(const char * name, uint32_t color);
120 int addTextureDataset(int elevationdataset, const char * name, SmSceneryTexture2CB * cb, void * closure);
121
122 int deleteElevationDataset(int datasetid);
123 void setCrossAndLineElevationData(int datasetid, int lodlevel, int startcross, int startline, int numcross, int numline, float * elevationvalues);
124
125 void changeDatasetProximity(int datasetid, int numdatasets, int * datasets, float epsilon, float newval);
126 void cullDatasetAbove(int datasetid, int numdatasets, int * datasets, float distance);
127 void cullDatasetBelow(int datasetid, int numdatasets, int * datasets, float distance);
128 void oversampleDataset(int datasetid);
129 void smoothDataset(int datasetid);
130 void stripVerticals(int datasetid, float dropsize);
131 void stripHorizontals(int datasetid, float maxskew);
132
133 void refreshTextures(const int id);
134 void * getScenerySystemHandle();
135
136protected:
137 virtual ~SmScenery(void);
138 virtual void generatePrimitives(SoAction * action);
139 virtual void computeBBox(SoAction * action, SbBox3f & box, SbVec3f & center);
140 virtual void evaluate(SoAction * action);
141
142
143private:
144 SmScenery(ss_system * system);
145
146 SoSFBool colorTexture;
147
148 SceneryP * pimpl;
149 friend class SceneryP;
150
151};
152
153#endif // !SMALLCHANGE_SCENERY_H
Definition misc/SbList.h:69
The SmScenery class is a Coin node interface to the SIM Scenery library.
Definition SmScenery.h:48
SoSFBool visualDebug
Show information designed for debugging purposes on the viewport.
Definition SmScenery.h:85
SoMFFloat colorMap
A table of colors to use for coloring the terrain, starting with the color of the lowest elevations,...
Definition SmScenery.h:76
SoSFFloat elevationLineThickness
Make elevation lines this thick.
Definition SmScenery.h:83
SoSFFloat loadRottger
The rottger formula constant for deciding the LOD level of blocks as you remove yourself from the foc...
Definition SmScenery.h:65
SoSFFloat blockRottger
The rottger factor for tessellating the surface of a terrain block.
Definition SmScenery.h:64
SoSFFloat elevationLineOffset
Offset the elevation lines with this value.
Definition SmScenery.h:81
SoMFFloat colorElevation
A table of elevation values, which will decide where the colors given in colorMap will kick in.
Definition SmScenery.h:77
SoSFString filename
The filename for a SIM Scenery database.
Definition SmScenery.h:63
SoSFEnum colorTexturing
Decides whether or not the values of colorMap and colorElevation (optional) should be used to generat...
Definition SmScenery.h:75
SoSFShort elevationLineEmphasis
Emphasize every Nth elevation line.
Definition SmScenery.h:82
SoSFFloat elevationLineDistance
The elevation distance between elevation lines.
Definition SmScenery.h:80
SoSFBool elevationLines
Whether or not the elevation lines feature should be used.
Definition SmScenery.h:79
SoMFInt32 renderSequence
The description of how datasets in the SIM Scenery database should be merged before being rendered.
Definition SmScenery.h:67