00001 // Filename: stTerrain.I 00002 // Created by: drose (11Oct10) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: STTerrain::is_valid 00018 // Access: Published 00019 // Description: Returns true if the terrain data is well-defined and 00020 // ready to use. 00021 //////////////////////////////////////////////////////////////////// 00022 INLINE bool STTerrain:: 00023 is_valid() const { 00024 return _is_valid && !_st_vertex_attribs.empty(); 00025 } 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Function: STTerrain::get_normal_map 00029 // Access: Published 00030 // Description: Returns the normal map that should be applied to the 00031 // terrain. This will be loaded and supplied to the 00032 // shader. 00033 //////////////////////////////////////////////////////////////////// 00034 INLINE const Filename &STTerrain:: 00035 get_normal_map() const { 00036 return _normal_map; 00037 } 00038 00039 //////////////////////////////////////////////////////////////////// 00040 // Function: STTerrain::get_splat_map 00041 // Access: Published 00042 // Description: Returns the splat map that should be applied to the 00043 // terrain. This will be loaded and supplied to the 00044 // shader. Presumably, the shader will use the channels 00045 // of this map to determine which of the splat layers 00046 // are to be rendered at any given point. 00047 //////////////////////////////////////////////////////////////////// 00048 INLINE const Filename &STTerrain:: 00049 get_splat_map() const { 00050 return _splat_map; 00051 } 00052 00053 //////////////////////////////////////////////////////////////////// 00054 // Function: STTerrain::get_num_splat_layers 00055 // Access: Published 00056 // Description: Returns the number of splat layers that are to be 00057 // applied to the terrain. This must be consistent with 00058 // c_nNumTerrainSplatLayers in SpeedTree's TerrainRI.h. 00059 //////////////////////////////////////////////////////////////////// 00060 INLINE int STTerrain:: 00061 get_num_splat_layers() const { 00062 return _splat_layers.size(); 00063 } 00064 00065 //////////////////////////////////////////////////////////////////// 00066 // Function: STTerrain::get_splat_layer 00067 // Access: Published 00068 // Description: Returns the nth splat layer that is to be applied to 00069 // the terrain. 00070 //////////////////////////////////////////////////////////////////// 00071 INLINE const Filename &STTerrain:: 00072 get_splat_layer(int n) const { 00073 nassertr(n >= 0 && n < (int)_splat_layers.size(), _splat_layers[0]._filename); 00074 return _splat_layers[n]._filename; 00075 } 00076 00077 //////////////////////////////////////////////////////////////////// 00078 // Function: STTerrain::get_splat_layer_tiling 00079 // Access: Published 00080 // Description: Returns the tiling value of the nth splat layer. 00081 // This is an arbitrary UV scale that is applied to each 00082 // layer individually, by the terrain shader. 00083 //////////////////////////////////////////////////////////////////// 00084 INLINE PN_stdfloat STTerrain:: 00085 get_splat_layer_tiling(int n) const { 00086 nassertr(n >= 0 && n < (int)_splat_layers.size(), 0.0f); 00087 return _splat_layers[n]._tiling; 00088 } 00089 00090 //////////////////////////////////////////////////////////////////// 00091 // Function: STTerrain::get_splat_layer_color 00092 // Access: Published 00093 // Description: Returns the overall color of the nth splat layer. This 00094 // is used just to match the color of the grass to its 00095 // terrain. 00096 //////////////////////////////////////////////////////////////////// 00097 INLINE LColor STTerrain:: 00098 get_splat_layer_color(int n) const { 00099 nassertr(n >= 0 && n < (int)_splat_layers.size(), _splat_layers[0]._color); 00100 return LVecBase4(_splat_layers[n]._color); 00101 } 00102 00103 //////////////////////////////////////////////////////////////////// 00104 // Function: STTerrain::get_vertex_format 00105 // Access: Published 00106 // Description: Returns the vertex format of the vertex array that is 00107 // supported by this terrain data. A GeomVertexData of 00108 // the requested format will be passed to 00109 // fill_vertices(). 00110 //////////////////////////////////////////////////////////////////// 00111 INLINE const GeomVertexFormat *STTerrain:: 00112 get_vertex_format() { 00113 return _vertex_format; 00114 } 00115 00116 //////////////////////////////////////////////////////////////////// 00117 // Function: STTerrain::get_min_height 00118 // Access: Published 00119 // Description: Returns the smallest height value that might be 00120 // returned by get_height(). This is used as a culling 00121 // optimization. 00122 //////////////////////////////////////////////////////////////////// 00123 INLINE PN_stdfloat STTerrain:: 00124 get_min_height() const { 00125 return _min_height; 00126 } 00127 00128 //////////////////////////////////////////////////////////////////// 00129 // Function: STTerrain::get_max_height 00130 // Access: Published 00131 // Description: Returns the largest height value that might be 00132 // returned by get_height(). This is used as a culling 00133 // optimization. 00134 //////////////////////////////////////////////////////////////////// 00135 INLINE PN_stdfloat STTerrain:: 00136 get_max_height() const { 00137 return _max_height; 00138 }