Panda3D
stTerrain.I
1 // Filename: stTerrain.I
2 // Created by: drose (11Oct10)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: STTerrain::is_valid
18 // Access: Published
19 // Description: Returns true if the terrain data is well-defined and
20 // ready to use.
21 ////////////////////////////////////////////////////////////////////
22 INLINE bool STTerrain::
23 is_valid() const {
24  return _is_valid && !_st_vertex_attribs.empty();
25 }
26 
27 ////////////////////////////////////////////////////////////////////
28 // Function: STTerrain::get_normal_map
29 // Access: Published
30 // Description: Returns the normal map that should be applied to the
31 // terrain. This will be loaded and supplied to the
32 // shader.
33 ////////////////////////////////////////////////////////////////////
34 INLINE const Filename &STTerrain::
35 get_normal_map() const {
36  return _normal_map;
37 }
38 
39 ////////////////////////////////////////////////////////////////////
40 // Function: STTerrain::get_splat_map
41 // Access: Published
42 // Description: Returns the splat map that should be applied to the
43 // terrain. This will be loaded and supplied to the
44 // shader. Presumably, the shader will use the channels
45 // of this map to determine which of the splat layers
46 // are to be rendered at any given point.
47 ////////////////////////////////////////////////////////////////////
48 INLINE const Filename &STTerrain::
49 get_splat_map() const {
50  return _splat_map;
51 }
52 
53 ////////////////////////////////////////////////////////////////////
54 // Function: STTerrain::get_num_splat_layers
55 // Access: Published
56 // Description: Returns the number of splat layers that are to be
57 // applied to the terrain. This must be consistent with
58 // c_nNumTerrainSplatLayers in SpeedTree's TerrainRI.h.
59 ////////////////////////////////////////////////////////////////////
60 INLINE int STTerrain::
62  return _splat_layers.size();
63 }
64 
65 ////////////////////////////////////////////////////////////////////
66 // Function: STTerrain::get_splat_layer
67 // Access: Published
68 // Description: Returns the nth splat layer that is to be applied to
69 // the terrain.
70 ////////////////////////////////////////////////////////////////////
71 INLINE const Filename &STTerrain::
72 get_splat_layer(int n) const {
73  nassertr(n >= 0 && n < (int)_splat_layers.size(), _splat_layers[0]._filename);
74  return _splat_layers[n]._filename;
75 }
76 
77 ////////////////////////////////////////////////////////////////////
78 // Function: STTerrain::get_splat_layer_tiling
79 // Access: Published
80 // Description: Returns the tiling value of the nth splat layer.
81 // This is an arbitrary UV scale that is applied to each
82 // layer individually, by the terrain shader.
83 ////////////////////////////////////////////////////////////////////
84 INLINE PN_stdfloat STTerrain::
85 get_splat_layer_tiling(int n) const {
86  nassertr(n >= 0 && n < (int)_splat_layers.size(), 0.0f);
87  return _splat_layers[n]._tiling;
88 }
89 
90 ////////////////////////////////////////////////////////////////////
91 // Function: STTerrain::get_splat_layer_color
92 // Access: Published
93 // Description: Returns the overall color of the nth splat layer. This
94 // is used just to match the color of the grass to its
95 // terrain.
96 ////////////////////////////////////////////////////////////////////
97 INLINE LColor STTerrain::
98 get_splat_layer_color(int n) const {
99  nassertr(n >= 0 && n < (int)_splat_layers.size(), _splat_layers[0]._color);
100  return LVecBase4(_splat_layers[n]._color);
101 }
102 
103 ////////////////////////////////////////////////////////////////////
104 // Function: STTerrain::get_vertex_format
105 // Access: Published
106 // Description: Returns the vertex format of the vertex array that is
107 // supported by this terrain data. A GeomVertexData of
108 // the requested format will be passed to
109 // fill_vertices().
110 ////////////////////////////////////////////////////////////////////
111 INLINE const GeomVertexFormat *STTerrain::
113  return _vertex_format;
114 }
115 
116 ////////////////////////////////////////////////////////////////////
117 // Function: STTerrain::get_min_height
118 // Access: Published
119 // Description: Returns the smallest height value that might be
120 // returned by get_height(). This is used as a culling
121 // optimization.
122 ////////////////////////////////////////////////////////////////////
123 INLINE PN_stdfloat STTerrain::
124 get_min_height() const {
125  return _min_height;
126 }
127 
128 ////////////////////////////////////////////////////////////////////
129 // Function: STTerrain::get_max_height
130 // Access: Published
131 // Description: Returns the largest height value that might be
132 // returned by get_height(). This is used as a culling
133 // optimization.
134 ////////////////////////////////////////////////////////////////////
135 INLINE PN_stdfloat STTerrain::
136 get_max_height() const {
137  return _max_height;
138 }
PN_stdfloat get_max_height() const
Returns the largest height value that might be returned by get_height().
Definition: stTerrain.I:136
const Filename & get_normal_map() const
Returns the normal map that should be applied to the terrain.
Definition: stTerrain.I:35
bool is_valid() const
Returns true if the terrain data is well-defined and ready to use.
Definition: stTerrain.I:23
const GeomVertexFormat * get_vertex_format()
Returns the vertex format of the vertex array that is supported by this terrain data.
Definition: stTerrain.I:112
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
LColor get_splat_layer_color(int n) const
Returns the overall color of the nth splat layer.
Definition: stTerrain.I:98
PN_stdfloat get_min_height() const
Returns the smallest height value that might be returned by get_height().
Definition: stTerrain.I:124
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
const Filename & get_splat_layer(int n) const
Returns the nth splat layer that is to be applied to the terrain.
Definition: stTerrain.I:72
int get_num_splat_layers() const
Returns the number of splat layers that are to be applied to the terrain.
Definition: stTerrain.I:61
const Filename & get_splat_map() const
Returns the splat map that should be applied to the terrain.
Definition: stTerrain.I:49
PN_stdfloat get_splat_layer_tiling(int n) const
Returns the tiling value of the nth splat layer.
Definition: stTerrain.I:85