8 #ifndef VRECKO_NATURE_TERRAIN_TERRAIN2DSEGMENT_H
9 #define VRECKO_NATURE_TERRAIN_TERRAIN2DSEGMENT_H
12 #include <osg/Geometry>
13 #include <osg/Texture2D>
28 osg::Vec2f _segmentPosition;
31 osg::ref_ptr<osg::Vec3Array> _pointPositions;
32 osg::ref_ptr<osg::Vec3Array> _pointNormals;
33 osg::ref_ptr<osg::Vec4Array> _pointColors;
34 osg::ref_ptr<osg::Geode> _terrainSegmentGeode;
59 inline int Width()
const {
return this->_width; }
65 inline int Height()
const {
return this->_height; }
90 inline const osg::Vec3f&
GetPoint(
int x,
int y)
const {
return (*_pointPositions)[PointIndex(x, y)]; }
98 inline void SetPoint(
int x,
int y,
const osg::Vec3f& point) { (*_pointPositions)[PointIndex(x, y)] = point; }
130 inline unsigned int PointIndex(
int x,
int y)
const {
return y * this->
_width + x;}
132 inline void SetNeighbourNorth(
Terrain2DSegment *north) { this->_north = north; }
133 inline void SetNeighbourSouth(
Terrain2DSegment *south) { this->_south = south; }
134 inline void SetNeighbourWest(
Terrain2DSegment *west) { this->_west = west; }
135 inline void SetNeighbourEast(
Terrain2DSegment *east) { this->_east = east; }
140 void AllocatePoints();
145 void AllocatePointPositions();
150 void AllocatePointNormals();
156 void ComputePointPositions();
161 void ComputePointNormals();