Changeset 54
- Timestamp:
- 04/23/07 17:09:02 (2 years ago)
- Files:
-
- trunk/pyosg/osg/Shape3.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/pyosg/osg/Shape3.cpp
r45 r54 13 13 #include <boost/python/return_value_policy.hpp> 14 14 #include <boost/python/copy_const_reference.hpp> 15 #include <boost/python/numeric.hpp> 16 #include <boost/python/tuple.hpp> 15 17 18 #include <iostream> 16 19 #include <osg/Shape> 17 20 … … 22 25 23 26 namespace PyOSG { 27 28 void osgHeightField_setData(osg::HeightField * self, numeric::array& data) 29 { 30 object shape = data.getshape(); 31 int rows = extract<int>(shape[0]); 32 int cols = extract<int>(shape[1]); 33 34 if((rows == 0) || (cols == 0)) 35 { 36 37 PyErr_SetString(PyExc_ValueError, "Invalid array dimensions"); 38 throw_error_already_set(); 39 return; 40 } 41 42 // Switch this to R,C maybe? 43 self->allocate(cols,rows); 44 45 float value = 0.0f; 46 47 for(int r = 0; r < rows; ++r) 48 { 49 for(int c = 0; c < cols; ++c) 50 { 51 value = extract<float>(data[make_tuple(r,c)]); 52 self->setHeight(c, r, value); 53 } 54 } 55 } 56 24 57 void init_Shape3() 25 58 { … … 80 113 &osg::HeightField::getHeight); 81 114 115 116 hfield.def("setHeightData", &osgHeightField_setData); 117 118 82 119 hfield.def("getVertex", &osg::HeightField::getVertex); 83 120 hfield.def("getNormal", &osg::HeightField::getNormal);
