DYTSrouce/src/effects/ConeWave.h

91 lines
2.5 KiB
C
Raw Normal View History

2025-01-04 04:12:51 +00:00
#pragma once
2025-06-19 14:05:52 +00:00
2025-01-04 04:12:51 +00:00
#include <osg/Matrix>
#include <osg/Array>
#include <osg/Geometry>
#include <osg/Geode>
#include <osg/ShapeDrawable>
#include "effects/DrawDecorate.h"
#include "viewer/UpdateRenderStd.h"
class ConeWave : public osg::Geode
, public UpdateRenderStd {
public:
explicit ConeWave();
~ConeWave(void) override;
void Render(double dt) override;
void InitGeode();
void Destory();
2025-06-22 17:49:35 +00:00
// 雷达扫描波效果相关方法
void CreateRadarScanWave();
void CreateRadarShader();
void SetWaveRadius(float radius);
float GetWaveRadius() const { return waveRadius_; }
void SetWaveSpeed(float speed);
float GetWaveSpeed() const { return waveSpeed_; }
void SetWaveCount(int count);
int GetWaveCount() const { return waveCount_; }
void SetWaveColor(const osg::Vec4& color);
const osg::Vec4& GetWaveColor() const { return waveColor_; }
2025-01-04 04:12:51 +00:00
void SetHeight(float height);
float GetHeght() const {
return height_;
}
void SetBaseColor(const osg::Vec4& color);
const osg::Vec4 GetBaseColor() const {
return baseColor_;
}
2025-06-24 15:40:11 +00:00
// 透明度控制方法
void SetRingBrightAlpha(float alpha);
float GetRingBrightAlpha() const { return ringBrightAlpha_; }
void SetRingDarkAlpha(float alpha);
float GetRingDarkAlpha() const { return ringDarkAlpha_; }
void SetConeAlpha(float alpha);
float GetConeAlpha() const { return coneAlpha_; }
2025-01-04 04:12:51 +00:00
private:
osg::ref_ptr<osg::Cone> cone_;
osg::ref_ptr<osg::ShapeDrawable> coneDrawable_;
2025-06-22 17:49:35 +00:00
float height_{ 6.0f };
2025-01-04 04:12:51 +00:00
float radius_{ 10.0f };
2025-06-22 17:49:35 +00:00
// 雷达扫描波效果相关成员变量
osg::ref_ptr<osg::Uniform> waveTimeUniform_;
osg::ref_ptr<osg::Uniform> waveRadiusUniform_;
osg::ref_ptr<osg::Uniform> waveSpeedUniform_;
osg::ref_ptr<osg::Uniform> waveCountUniform_;
2025-06-25 00:10:01 +00:00
osg::ref_ptr<osg::Uniform> baseColorUniform_;
2025-06-22 17:49:35 +00:00
osg::ref_ptr<osg::Uniform> waveColorUniform_;
2025-06-25 00:10:01 +00:00
osg::ref_ptr<osg::Uniform> levelHeightUniform_;
2025-06-22 17:49:35 +00:00
2025-06-24 15:40:11 +00:00
// 透明度控制uniform变量
osg::ref_ptr<osg::Uniform> ringBrightAlphaUniform_;
osg::ref_ptr<osg::Uniform> ringDarkAlphaUniform_;
osg::ref_ptr<osg::Uniform> coneAlphaUniform_;
2025-06-22 17:49:35 +00:00
float waveRadius_{ 100.0f }; // 扫描波最大半径
float waveSpeed_{ 20.0f }; // 扫描波速度
int waveCount_{ 30 }; // 同时存在的波纹数量
osg::Vec4 baseColor_{ 1.0f, 0.2f, 0.5f, 1.f };
osg::Vec4 waveColor_{ 0.0f, 0.5f, 1.0f, 0.8f }; // 扫描波颜色(蓝色)
double currentTime_{ 0.0 }; // 当前时间
2025-06-24 15:40:11 +00:00
// 透明度值
float ringBrightAlpha_{ 0.8f }; // 亮环透明度
float ringDarkAlpha_{ 0.3f }; // 暗环透明度
float coneAlpha_{ 0.7f }; // 锥形透明度
2025-01-04 04:12:51 +00:00
};