Panda3D
Loading...
Searching...
No Matches
physxHeightFieldShapeDesc.cxx
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 physxHeightFieldShapeDesc.cxx
10 * @author enn0x
11 * @date 2009-10-15
12 */
13
15#include "physxHeightField.h"
16
17/**
18 * (re)sets the structure to the default.
19 */
22
23 _desc.setToDefault();
24 set_name("");
25
26 _desc.shapeFlags = NX_SF_FEATURE_INDICES | NX_SF_VISUALIZATION;
27 _desc.meshFlags = NX_MESH_SMOOTH_SPHERE_COLLISIONS;
28 _desc.materialIndexHighBits = (NxMaterialIndex)0;
29 _desc.holeMaterial = (NxMaterialIndex)0;
30 _desc.localPose = PhysxManager::mat4_to_nxMat34(LMatrix4f::y_to_z_up_mat());
31}
32
33/**
34 * Sets the the material index that designates holes in the height field.
35 * This number is compared directly to sample materials. Consequently the
36 * high 9 bits must be zero. Default value is 0.
37 */
39set_hole_material(unsigned short index) {
40
41 _desc.holeMaterial = (NxMaterialIndex)index;
42}
43
44/**
45 * Sets the high 9 bits of this number are used to complete the material
46 * indices in the samples. The remaining low 7 bits must be zero. Default
47 * value is 0.
48 */
50set_material_index_high_bits(unsigned short index) {
51
52 _desc.materialIndexHighBits = (NxMaterialIndex)index;
53}
54
55/**
56 * Returns the the material index that designates holes in the height field.
57 */
59get_hole_material() const {
60
61 return (unsigned short)_desc.holeMaterial;
62}
63
64/**
65 * Returns the high 9 bits of this number are used to complete the material
66 * indices in the samples.
67 */
70
71 return (unsigned short)_desc.materialIndexHighBits;
72}
73
74/**
75 *
76 */
77void PhysxHeightFieldShapeDesc::
78set_dimensions(const LVector3f &dimensions) {
79
80 NxU32 _64K = 65535; // (1<<16)-1;
81
82 NxU32 nbRows = _desc.heightField->getNbRows();
83 NxU32 nbColumns = _desc.heightField->getNbColumns();
84
85 _desc.rowScale = dimensions.get_x() / nbRows;
86 _desc.columnScale = dimensions.get_y() / nbColumns;
87 _desc.heightScale = dimensions.get_z() / _64K;
88}
89
90/**
91 *
92 */
93void PhysxHeightFieldShapeDesc::
94set_height_field(const PhysxHeightField &hf) {
95
96 _desc.heightField = hf.ptr();
97}
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.
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.
void set_to_default()
(re)sets the structure to the default.
void set_hole_material(unsigned short index)
Sets the the material index that designates holes in the height field.
unsigned short get_hole_material() const
Returns the the material index that designates holes in the height field.
A height field object.
static NxMat34 mat4_to_nxMat34(const LMatrix4f &m)
Converts from LMatrix4f to NxMat34.
void set_name(const char *name)
Sets a possible debug name.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.