19 void PhysxHeightFieldDesc::
20 set_convex_edge_threshold(
float threshold) {
22 _desc.convexEdgeThreshold = threshold;
28 void PhysxHeightFieldDesc::
29 set_thickness(
float thickness) {
31 _desc.thickness = thickness;
37 void PhysxHeightFieldDesc::
38 set_image(
const PNMImage &image,
unsigned short materialIndex) {
46 set_size(nbRows, nbColumns);
48 NxU8 *currentByte = (NxU8 *)(_desc.samples);
50 for (NxU32 row=0; row < nbRows; row++) {
51 for (NxU32 column=0; column < nbColumns; column++) {
53 NxHeightFieldSample* currentSample = (NxHeightFieldSample *)currentByte;
56 NxI16 ivalue = (NxI16)((fvalue - 0.5f) * _32K);
58 currentSample->height = (NxI16)ivalue;
59 currentSample->tessFlag = (NxU8)0;
60 currentSample->materialIndex0 = (NxU8)materialIndex;
61 currentSample->materialIndex1 = (NxU8)materialIndex;
63 currentByte += _desc.sampleStride;
71 void PhysxHeightFieldDesc::
72 set_material_index(
unsigned int row,
unsigned int column,
unsigned short materialIndex0,
unsigned short materialIndex1) {
74 nassertv(_desc.samples);
75 nassertv(row < _desc.nbRows);
76 nassertv(column < _desc.nbColumns);
78 NxU32 idx = row * _desc.nbColumns + column;
79 NxU8 *
byte = (NxU8 *)_desc.samples + _desc.sampleStride * idx;
80 NxHeightFieldSample* sample = (NxHeightFieldSample *)byte;
85 sample->materialIndex0 = (NxU8)materialIndex0;
86 sample->materialIndex1 = (NxU8)materialIndex1;
92 void PhysxHeightFieldDesc::
93 set_height(
unsigned int row,
unsigned int column,
short height) {
95 nassertv(_desc.samples);
96 nassertv(row < _desc.nbRows);
97 nassertv(column < _desc.nbColumns);
99 NxU32 idx = row * _desc.nbColumns + column;
100 NxU8 *
byte = (NxU8 *)_desc.samples + _desc.sampleStride * idx;
101 NxHeightFieldSample* sample = (NxHeightFieldSample *)byte;
103 sample->height = (NxI16)height;
109 void PhysxHeightFieldDesc::
110 set_tess_flag(
unsigned int row,
unsigned int column,
unsigned short value) {
112 nassertv(_desc.samples);
113 nassertv(row < _desc.nbRows);
114 nassertv(column < _desc.nbColumns);
116 NxU32 idx = row * _desc.nbColumns + column;
117 NxU8 *
byte = (NxU8 *)_desc.samples + _desc.sampleStride * idx;
118 NxHeightFieldSample* sample = (NxHeightFieldSample *)byte;
121 sample->tessFlag = (NxU8)value;
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
float get_bright(int x, int y) const
Returns the linear brightness of the given xel, as a linearized float in the range 0....