Panda3D
physxHeightFieldShapeDesc.cxx
1 // Filename: physxHeightFieldShapeDesc.cxx
2 // Created by: enn0x (15Oct09)
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 #include "physxHeightFieldShapeDesc.h"
16 #include "physxHeightField.h"
17 
18 ////////////////////////////////////////////////////////////////////
19 // Function: PhysxHeightFieldShapeDesc::set_to_default
20 // Access: Published
21 // Description: (re)sets the structure to the default.
22 ////////////////////////////////////////////////////////////////////
25 
26  _desc.setToDefault();
27  set_name("");
28 
29  _desc.shapeFlags = NX_SF_FEATURE_INDICES | NX_SF_VISUALIZATION;
30  _desc.meshFlags = NX_MESH_SMOOTH_SPHERE_COLLISIONS;
31  _desc.materialIndexHighBits = (NxMaterialIndex)0;
32  _desc.holeMaterial = (NxMaterialIndex)0;
34 }
35 
36 ////////////////////////////////////////////////////////////////////
37 // Function: PhysxHeightFieldShapeDesc::set_hole_material
38 // Access: Published
39 // Description: Sets the the material index that designates holes
40 // in the height field. This number is compared
41 // directly to sample materials. Consequently the
42 // high 9 bits must be zero.
43 // Default value is 0.
44 ////////////////////////////////////////////////////////////////////
46 set_hole_material(unsigned short index) {
47 
48  _desc.holeMaterial = (NxMaterialIndex)index;
49 }
50 
51 ////////////////////////////////////////////////////////////////////
52 // Function: PhysxHeightFieldShapeDesc::set_material_index_high_bits
53 // Access: Published
54 // Description: Sets the high 9 bits of this number are used to
55 // complete the material indices in the samples. The
56 // remaining low 7 bits must be zero.
57 // Default value is 0.
58 ////////////////////////////////////////////////////////////////////
60 set_material_index_high_bits(unsigned short index) {
61 
62  _desc.materialIndexHighBits = (NxMaterialIndex)index;
63 }
64 
65 ////////////////////////////////////////////////////////////////////
66 // Function: PhysxHeightFieldShapeDesc::get_hole_material
67 // Access: Published
68 // Description: Returns the the material index that designates
69 // holes in the height field.
70 ////////////////////////////////////////////////////////////////////
71 unsigned short PhysxHeightFieldShapeDesc::
73 
74  return (unsigned short)_desc.holeMaterial;
75 }
76 
77 ////////////////////////////////////////////////////////////////////
78 // Function: PhysxHeightFieldShapeDesc::get_material_index_hight_bits
79 // Access: Published
80 // Description: Returns the high 9 bits of this number are used to
81 // complete the material indices in the samples.
82 ////////////////////////////////////////////////////////////////////
83 unsigned short PhysxHeightFieldShapeDesc::
85 
86  return (unsigned short)_desc.materialIndexHighBits;
87 }
88 
89 ////////////////////////////////////////////////////////////////////
90 // Function: PhysxHeightFieldShapeDesc::set_dimensions
91 // Access: Published
92 // Description:
93 ////////////////////////////////////////////////////////////////////
94 void PhysxHeightFieldShapeDesc::
95 set_dimensions(const LVector3f &dimensions) {
96 
97  NxU32 _64K = 65535; // (1<<16)-1;
98 
99  NxU32 nbRows = _desc.heightField->getNbRows();
100  NxU32 nbColumns = _desc.heightField->getNbColumns();
101 
102  _desc.rowScale = dimensions.get_x() / nbRows;
103  _desc.columnScale = dimensions.get_y() / nbColumns;
104  _desc.heightScale = dimensions.get_z() / _64K;
105 }
106 
107 ////////////////////////////////////////////////////////////////////
108 // Function: PhysxHeightFieldShapeDesc::set_height_field
109 // Access: Published
110 // Description:
111 ////////////////////////////////////////////////////////////////////
112 void PhysxHeightFieldShapeDesc::
113 set_height_field(const PhysxHeightField &hf) {
114 
115  _desc.heightField = hf.ptr();
116 }
117 
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
static NxMat34 mat4_to_nxMat34(const LMatrix4f &m)
Converts from LMatrix4f to NxMat34.
Definition: physxManager.I:145
void set_material_index_high_bits(unsigned short index)
Sets the high 9 bits of this number are used to complete the material indices in the samples...
A height field object.
static const LMatrix4f & y_to_z_up_mat()
Returns a matrix that transforms from the Y-up coordinate system to the Z-up coordinate system...
Definition: lmatrix.h:2557
void set_to_default()
(re)sets the structure to the default.
unsigned short get_material_index_hight_bits() const
Returns the high 9 bits of this number are used to complete the material indices in the samples...
unsigned short get_hole_material() const
Returns the the material index that designates holes in the height field.
void set_name(const char *name)
Sets a possible debug name.
void set_hole_material(unsigned short index)
Sets the the material index that designates holes in the height field.