DYTSrouce/src/scene/SphereSegment.h
2025-01-04 12:12:51 +08:00

40 lines
951 B
C++

#pragma once
#include <osg/Geode>
#include <osg/Geometry>
class SphereSegment : public osg::Geode {
public:
SphereSegment(void);
SphereSegment(float radius,
unsigned int longitudeSteps,
unsigned int lattitudeSteps,
float longStart,
float longEnd,
float latStart,
float latEnd);
SphereSegment(const SphereSegment& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
protected:
~SphereSegment(void);
public:
// 0 >= longStart/longEnd <= 180
// 0 >= latStart/latEnd <= 360
void Compute(float radius,
unsigned int longitudeSteps,
unsigned int lattitudeSteps,
float longStart,
float longEnd,
float latStart,
float latEnd);
private:
osg::Vec2 SphereMap(osg::Vec3& vertex, float radius);
inline unsigned int Idx(unsigned int r, unsigned int c, unsigned int row_len) {
return c + r * row_len;
}
};