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