modify cone wave

This commit is contained in:
jiegeaiai 2024-12-29 22:33:01 +08:00
parent 875bf988c4
commit b58690dbf7
11 changed files with 244 additions and 75 deletions

View File

@ -12,8 +12,7 @@
#include <osg/Uniform> #include <osg/Uniform>
ConeWave::ConeWave(const std::string& path) ConeWave::ConeWave() {
: txturePath_(path) {
} }
@ -23,12 +22,7 @@ ConeWave::~ConeWave(void)
} }
void ConeWave::Render(double dt) { void ConeWave::Render(double dt) {
if (timeUniform_) {
//float timeValue;
//timeUniform_->get(timeValue);
//timeValue += dt * 0.1; // ¿ØÖƹö¶¯ËÙ¶È
timeUniform_->set(static_cast<float>(dt * 0.1));
}
} }
void ConeWave::InitGeode() { void ConeWave::InitGeode() {
@ -62,6 +56,20 @@ void ConeWave::SetBaseColor(const osg::Vec4& color) {
} }
} }
void ConeWave::SetLevelCount(int count) {
levelCount_ = count;
if (levelCountUniform_) {
levelCountUniform_->set(float(levelCount_));
}
}
void ConeWave::SetLevelHeight(float height) {
levelHeight_ = height;
if (levelHeightUniform_) {
levelHeightUniform_->set(levelHeight_);
}
}
void ConeWave::CreateTexturedCone(osg::Geode* geode) { void ConeWave::CreateTexturedCone(osg::Geode* geode) {
cone_ = new osg::Cone(osg::Vec3(0, 0, 0.), radius_, height_); cone_ = new osg::Cone(osg::Vec3(0, 0, 0.), radius_, height_);
osg::TessellationHints* tesselate = new osg::TessellationHints; osg::TessellationHints* tesselate = new osg::TessellationHints;
@ -70,57 +78,59 @@ void ConeWave::CreateTexturedCone(osg::Geode* geode) {
coneDrawable_ = new osg::ShapeDrawable(cone_, tesselate); coneDrawable_ = new osg::ShapeDrawable(cone_, tesselate);
addDrawable(coneDrawable_); addDrawable(coneDrawable_);
osg::Texture2D* texture = new osg::Texture2D; static const char* vertSource = {
texture->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR); "varying vec3 pos;\n"
texture->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR); "void main()\n"
texture->setWrap(osg::Texture2D::WRAP_S, osg::Texture2D::REPEAT); "{\n"
texture->setWrap(osg::Texture2D::WRAP_T, osg::Texture2D::REPEAT); "pos.x=gl_Vertex.x;\n"
osg::Image* image = osgDB::readImageFile(txturePath_); "pos.y=gl_Vertex.y;\n"
texture->setImage(image); "pos.z=gl_Vertex.z;\n"
"gl_Position = gl_ModelViewProjectionMatrix*gl_Vertex;\n"
"}\n"
};
static const char* fragSource = {
"uniform float num; \n"
"uniform float height; \n"
"uniform vec4 baseColor;\n"
"varying vec3 pos;\n"
"float Alpha = 1.0; \n"
"float f = pos.z;\n"
"uniform float osg_FrameTime;\n"
"void main()\n"
"{\n"
"if (sin(f/height*3.14*2*num+ osg_FrameTime*10) > 0)\n"
"{\n"
" Alpha = 0.8;\n"
"}\n"
"else\n"
"{\n"
" Alpha = 0.3;\n"
"}\n"
" gl_FragColor = vec4(baseColor.rgb, Alpha);\n"
"}\n "
};
osg::ref_ptr<osg::Shader> vertexShader = new osg::Shader(osg::Shader::VERTEX); osg::ref_ptr<osg::Shader> vertexShader = new osg::Shader(osg::Shader::VERTEX);
vertexShader->setShaderSource( vertexShader->setShaderSource(vertSource);
"#version 330\n"
"in vec4 osg_Vertex;\n"
"in vec2 osg_MultiTexCoord0;\n"
"uniform mat4 osg_ModelViewProjectionMatrix;\n"
"uniform float time;\n"
"out vec2 texCoord;\n"
"void main()\n"
"{\n"
" gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;\n"
" texCoord = osg_MultiTexCoord0 + vec2(0.0, time);\n"
"}\n"
);
osg::ref_ptr<osg::Shader> fragmentShader = new osg::Shader(osg::Shader::FRAGMENT); osg::ref_ptr<osg::Shader> fragmentShader = new osg::Shader(osg::Shader::FRAGMENT);
fragmentShader->setShaderSource( fragmentShader->setShaderSource(fragSource);
"#version 330\n"
"in vec2 texCoord;\n"
"uniform sampler2D texture;\n"
"uniform vec4 baseColor;\n"
"out vec4 fragColor;\n"
"void main()\n"
"{\n"
" vec4 color = texture2D(texture, texCoord);\n"
" fragColor = clamp(texture2D(texture, texCoord) * baseColor + vec4(0,0,0, 0.2), 0.0, 1.0);\n"
"}\n"
);
osg::StateSet* stateset = coneDrawable_->getOrCreateStateSet(); osg::StateSet* stateset = coneDrawable_->getOrCreateStateSet();
stateset->setRenderBinDetails(10000, "RenderBin");
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
osg::ref_ptr<osg::BlendFunc> blendFunc = new osg::BlendFunc(); osg::ref_ptr<osg::BlendFunc> blendFunc = new osg::BlendFunc();
stateset->setAttributeAndModes(blendFunc, osg::StateAttribute::ON); stateset->setAttributeAndModes(blendFunc, osg::StateAttribute::ON);
osg::ref_ptr<osg::Program> program = new osg::Program(); osg::ref_ptr<osg::Program> program = new osg::Program();
program->addShader(vertexShader); program->addShader(vertexShader);
program->addShader(fragmentShader); program->addShader(fragmentShader);
stateset->addUniform(new osg::Uniform("texture", 0));
baseColorUniform_ = new osg::Uniform("baseColor", baseColor_); baseColorUniform_ = new osg::Uniform("baseColor", baseColor_);
stateset->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
stateset->addUniform(baseColorUniform_); stateset->addUniform(baseColorUniform_);
stateset->setAttributeAndModes(program, osg::StateAttribute::ON); stateset->setAttributeAndModes(program, osg::StateAttribute::ON);
timeUniform_ = new osg::Uniform("time", 0.0f); levelCountUniform_ = new osg::Uniform("num", float(levelCount_));
stateset->addUniform(timeUniform_); levelHeightUniform_ = new osg::Uniform("height", levelHeight_);
stateset->addUniform(levelCountUniform_);
stateset->addUniform(levelHeightUniform_.get());
} }

View File

@ -12,7 +12,7 @@
class ConeWave : public osg::Geode class ConeWave : public osg::Geode
, public UpdateRenderStd { , public UpdateRenderStd {
public: public:
explicit ConeWave(const std::string& path); explicit ConeWave();
~ConeWave(void) override; ~ConeWave(void) override;
void Render(double dt) override; void Render(double dt) override;
@ -35,16 +35,29 @@ public:
return baseColor_; return baseColor_;
} }
void SetLevelCount(int count);
int GetLevelCount() const {
return levelCount_;
}
void SetLevelHeight(float height);
float GetLevelHeihgt() const {
return levelHeight_;
}
protected: protected:
virtual void CreateTexturedCone(osg::Geode* geode); virtual void CreateTexturedCone(osg::Geode* geode);
private: private:
std::string txturePath_;
osg::ref_ptr<osg::Cone> cone_; osg::ref_ptr<osg::Cone> cone_;
osg::ref_ptr<osg::ShapeDrawable> coneDrawable_; osg::ref_ptr<osg::ShapeDrawable> coneDrawable_;
osg::ref_ptr<osg::Uniform> timeUniform_;
osg::ref_ptr<osg::Uniform> baseColorUniform_; osg::ref_ptr<osg::Uniform> baseColorUniform_;
osg::Vec4 baseColor_{ 0.0f, 0.2f, 0.5f, 0.2f }; osg::Vec4 baseColor_{ 0.0f, 0.2f, 0.5f, 0.2f };
osg::ref_ptr<osg::Uniform> levelCountUniform_;
int levelCount_{ 4 };
osg::ref_ptr<osg::Uniform> levelHeightUniform_;
float levelHeight_{ 500.0f };
float height_{ 60.0f }; float height_{ 60.0f };
float radius_{ 10.0f }; float radius_{ 10.0f };
}; };

View File

@ -13,8 +13,7 @@
ConeWaveComponent::ConeWaveComponent(SceneComponent* parent) ConeWaveComponent::ConeWaveComponent(SceneComponent* parent)
: SceneComponent(parent) { : SceneComponent(parent) {
const QString txturePath = RecourceHelper::Get().GetBasePath() + "/resources/textures/stripes_h.png"; coneWave_ = new ConeWave();
coneWave_ = new ConeWave(txturePath.toStdString());
coneWave_->InitGeode(); coneWave_->InitGeode();
colorMap_[1] = osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f); colorMap_[1] = osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f);
@ -43,6 +42,10 @@ bool ConeWaveComponent::SetAttribute(const char* name, const char* value) {
SetHeight(atof(value)); SetHeight(atof(value));
} else if (0 == strcmp("event", name)) { } else if (0 == strcmp("event", name)) {
SetTimeAction(value); SetTimeAction(value);
} else if (0 == strcmp("levelCount", name)) {
SetHeight(atof(value));
} else if (0 == strcmp("levelHeihgt", name)) {
SetTimeAction(value);
} }
return SceneComponent::SetAttribute(name, value); return SceneComponent::SetAttribute(name, value);
@ -66,6 +69,8 @@ bool ConeWaveComponent::SaveAttribute(tinyxml2::XMLElement* element) {
} }
element->SetAttribute("radius", std::to_string(GetRadius()).c_str()); element->SetAttribute("radius", std::to_string(GetRadius()).c_str());
element->SetAttribute("height", std::to_string(GetHeight()).c_str()); element->SetAttribute("height", std::to_string(GetHeight()).c_str());
element->SetAttribute("levelCount", std::to_string(GetLevelCount()).c_str());
element->SetAttribute("levelHeihgt", std::to_string(GetLevelHeight()).c_str());
element->SetAttribute("event", timeAction_ == nullptr ? "" : timeAction_->GetPath().toStdString().c_str()); element->SetAttribute("event", timeAction_ == nullptr ? "" : timeAction_->GetPath().toStdString().c_str());
return SceneComponent::SaveAttribute(element); return SceneComponent::SaveAttribute(element);
} }
@ -97,6 +102,22 @@ float ConeWaveComponent::GetRadius() const {
return coneWave_->GetRadius(); return coneWave_->GetRadius();
} }
void ConeWaveComponent::SetLevelCount(int count) {
coneWave_->SetLevelCount(count);
}
float ConeWaveComponent::GetLevelCount() const {
return coneWave_->GetLevelCount();
}
void ConeWaveComponent::SetLevelHeight(float height) {
coneWave_->SetLevelHeight(height);
}
float ConeWaveComponent::GetLevelHeight() const {
return coneWave_->GetLevelHeihgt();
}
void ConeWaveComponent::SetBaseColor(const osg::Vec4& color) { void ConeWaveComponent::SetBaseColor(const osg::Vec4& color) {
coneWave_->SetBaseColor(color); coneWave_->SetBaseColor(color);
} }

View File

@ -31,6 +31,12 @@ public:
void SetRadius(float radius); void SetRadius(float radius);
float GetRadius() const; float GetRadius() const;
void SetLevelCount(int count);
float GetLevelCount() const;
void SetLevelHeight(float height);
float GetLevelHeight() const;
void SetBaseColor(const osg::Vec4& color); void SetBaseColor(const osg::Vec4& color);
const osg::Vec4 GetBaseColor() const; const osg::Vec4 GetBaseColor() const;

View File

@ -629,12 +629,12 @@
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser.cpp" line="204"/> <location filename="../ui/PropertyBrowser.cpp" line="203"/>
<source>ModelBase</source> <source>ModelBase</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser.cpp" line="209"/> <location filename="../ui/PropertyBrowser.cpp" line="208"/>
<source>color base</source> <source>color base</source>
<translation></translation> <translation></translation>
</message> </message>
@ -761,33 +761,43 @@
<context> <context>
<name>QtConeWaveComponentManager</name> <name>QtConeWaveComponentManager</name>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8354"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8385"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8363"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8394"/>
<source>ConeWaveComponent</source> <source>ConeWaveComponent</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8444"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8481"/>
<source>Height</source> <source>Height</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8451"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8488"/>
<source>Radius</source> <source>Radius</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8458"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8495"/>
<source>levelCount</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8502"/>
<source>levelHeight</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8509"/>
<source>Color1</source> <source>Color1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8465"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8516"/>
<source>Color2</source> <source>Color2</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8472"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8523"/>
<source>Color3</source> <source>Color3</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -893,28 +903,28 @@
<context> <context>
<name>QtDashedLineComponentManager</name> <name>QtDashedLineComponentManager</name>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8643"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8708"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8652"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8717"/>
<source>DashedLineComponent</source> <source>DashedLineComponent</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8721"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8786"/>
<source>Start</source> <source>Start</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8728"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8793"/>
<source>End</source> <source>End</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8735"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8800"/>
<source>Radius</source> <source>Radius</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8742"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8807"/>
<source>Color</source> <source>Color</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View File

@ -160,8 +160,6 @@ void PropertyBrowser::InitComponentPropertyManager() {
QtColorEditorFactory* colorFactory = new QtColorEditorFactory(this); QtColorEditorFactory* colorFactory = new QtColorEditorFactory(this);
QtFilePathFactory* filePathFactory = new QtFilePathFactory(this); QtFilePathFactory* filePathFactory = new QtFilePathFactory(this);
QtEntityUUIDEditorFactory* entityUUIDFactory = new QtEntityUUIDEditorFactory(this); QtEntityUUIDEditorFactory* entityUUIDFactory = new QtEntityUUIDEditorFactory(this);
//QtStringEdit* stringEdit = new QtStringEdit(this);
//QtStringEditorFactory* stringFactory = new QtStringEditorFactory(this);
QtMeshComponetManager* meshComponentManager = new QtMeshComponetManager(this); QtMeshComponetManager* meshComponentManager = new QtMeshComponetManager(this);
browser_->setFactoryForManager(meshComponentManager->subStringProperyManager(), lineEditFactory); browser_->setFactoryForManager(meshComponentManager->subStringProperyManager(), lineEditFactory);
@ -173,6 +171,7 @@ void PropertyBrowser::InitComponentPropertyManager() {
QtConeWaveComponentManager* coneWaveComponentManager = new QtConeWaveComponentManager(this); QtConeWaveComponentManager* coneWaveComponentManager = new QtConeWaveComponentManager(this);
browser_->setFactoryForManager(coneWaveComponentManager->subDoubleProperyManager(), doubleSpinBoxFactory); browser_->setFactoryForManager(coneWaveComponentManager->subDoubleProperyManager(), doubleSpinBoxFactory);
browser_->setFactoryForManager(coneWaveComponentManager->subIntProperyManager(), spinBoxFactory);
browser_->setFactoryForManager(coneWaveComponentManager->subColorProperyManager(), colorFactory); browser_->setFactoryForManager(coneWaveComponentManager->subColorProperyManager(), colorFactory);
componetManager_[coneWaveComponentManager->GetPropertyId()] = coneWaveComponentManager; componetManager_[coneWaveComponentManager->GetPropertyId()] = coneWaveComponentManager;

View File

@ -8248,6 +8248,7 @@ class QtConeWaveComponentManagerPrivate {
public: public:
void slotDoubleChanged(QtProperty* property, double value); void slotDoubleChanged(QtProperty* property, double value);
void slotIntChanged(QtProperty* property, int value);
void slotColorChanged(QtProperty* property, const QColor& value); void slotColorChanged(QtProperty* property, const QColor& value);
void slotPropertyDestroyed(QtProperty* property); void slotPropertyDestroyed(QtProperty* property);
@ -8257,16 +8258,21 @@ public:
QtDoublePropertyManager* m_doubleProperyManager; QtDoublePropertyManager* m_doubleProperyManager;
QtIntPropertyManager* m_intProperyManager;
QtColorPropertyManager* m_colorProperyManager; QtColorPropertyManager* m_colorProperyManager;
QMap<const QtProperty*, QtProperty*> m_properyToRadius; QMap<const QtProperty*, QtProperty*> m_properyToRadius;
QMap<const QtProperty*, QtProperty*> m_properyToHeight; QMap<const QtProperty*, QtProperty*> m_properyToHeight;
QMap<const QtProperty*, QtProperty*> m_properyToLevelCount;
QMap<const QtProperty*, QtProperty*> m_properyToLevelHeight;
QMap<const QtProperty*, QtProperty*> m_properyToColor1; QMap<const QtProperty*, QtProperty*> m_properyToColor1;
QMap<const QtProperty*, QtProperty*> m_properyToColor2; QMap<const QtProperty*, QtProperty*> m_properyToColor2;
QMap<const QtProperty*, QtProperty*> m_properyToColor3; QMap<const QtProperty*, QtProperty*> m_properyToColor3;
QMap<const QtProperty*, QtProperty*> m_radiusToPropery; QMap<const QtProperty*, QtProperty*> m_radiusToPropery;
QMap<const QtProperty*, QtProperty*> m_heightToPropery; QMap<const QtProperty*, QtProperty*> m_heightToPropery;
QMap<const QtProperty*, QtProperty*> m_levelCountToPropery;
QMap<const QtProperty*, QtProperty*> m_levelHeightToPropery;
QMap<const QtProperty*, QtProperty*> m_color1ToPropery; QMap<const QtProperty*, QtProperty*> m_color1ToPropery;
QMap<const QtProperty*, QtProperty*> m_color2ToPropery; QMap<const QtProperty*, QtProperty*> m_color2ToPropery;
QMap<const QtProperty*, QtProperty*> m_color3ToPropery; QMap<const QtProperty*, QtProperty*> m_color3ToPropery;
@ -8278,11 +8284,22 @@ void QtConeWaveComponentManagerPrivate::slotDoubleChanged(QtProperty* property,
QConeWaveComponentAttribute c = m_values[prop]; QConeWaveComponentAttribute c = m_values[prop];
c.SetRadius(value); c.SetRadius(value);
q_ptr->setValue(prop, c); q_ptr->setValue(prop, c);
} } else if (QtProperty* prop = m_heightToPropery.value(property, 0)) {
if (QtProperty* prop = m_heightToPropery.value(property, 0)) {
QConeWaveComponentAttribute c = m_values[prop]; QConeWaveComponentAttribute c = m_values[prop];
c.SetHeight(value); c.SetHeight(value);
q_ptr->setValue(prop, c); q_ptr->setValue(prop, c);
} else if (QtProperty* prop = m_levelHeightToPropery.value(property, 0)) {
QConeWaveComponentAttribute c = m_values[prop];
c.SetLevelHeight(value);
q_ptr->setValue(prop, c);
}
}
void QtConeWaveComponentManagerPrivate::slotIntChanged(QtProperty* property, int value) {
if (QtProperty* prop = m_levelCountToPropery.value(property, 0)) {
QConeWaveComponentAttribute c = m_values[prop];
c.SetLevelCount(value);
q_ptr->setValue(prop, c);
} }
} }
@ -8311,6 +8328,14 @@ void QtConeWaveComponentManagerPrivate::slotPropertyDestroyed(QtProperty* proper
m_heightToPropery[subProp] = 0; m_heightToPropery[subProp] = 0;
m_heightToPropery.remove(property); m_heightToPropery.remove(property);
} }
if (QtProperty* subProp = m_levelCountToPropery.value(property, nullptr)) {
m_levelCountToPropery[subProp] = 0;
m_levelCountToPropery.remove(property);
}
if (QtProperty* subProp = m_levelHeightToPropery.value(property, nullptr)) {
m_levelHeightToPropery[subProp] = 0;
m_levelHeightToPropery.remove(property);
}
if (QtProperty* subProp = m_color1ToPropery.value(property, nullptr)) { if (QtProperty* subProp = m_color1ToPropery.value(property, nullptr)) {
m_color1ToPropery[subProp] = 0; m_color1ToPropery[subProp] = 0;
m_color1ToPropery.remove(property); m_color1ToPropery.remove(property);
@ -8336,6 +8361,12 @@ QtConeWaveComponentManager::QtConeWaveComponentManager(QObject* parent)
connect(d_ptr->m_doubleProperyManager, SIGNAL(propertyDestroyed(QtProperty*)), connect(d_ptr->m_doubleProperyManager, SIGNAL(propertyDestroyed(QtProperty*)),
this, SLOT(slotPropertyDestroyed(QtProperty*))); this, SLOT(slotPropertyDestroyed(QtProperty*)));
d_ptr->m_intProperyManager = new QtIntPropertyManager(this);
connect(d_ptr->m_intProperyManager, SIGNAL(valueChanged(QtProperty*, int)),
this, SLOT(slotIntChanged(QtProperty*, int)));
connect(d_ptr->m_intProperyManager, SIGNAL(propertyDestroyed(QtProperty*)),
this, SLOT(slotPropertyDestroyed(QtProperty*)));
d_ptr->m_colorProperyManager = new QtColorPropertyManager(this); d_ptr->m_colorProperyManager = new QtColorPropertyManager(this);
connect(d_ptr->m_colorProperyManager, SIGNAL(valueChanged(QtProperty*, const QColor&)), connect(d_ptr->m_colorProperyManager, SIGNAL(valueChanged(QtProperty*, const QColor&)),
this, SLOT(slotColorChanged(QtProperty*, const QColor&))); this, SLOT(slotColorChanged(QtProperty*, const QColor&)));
@ -8379,6 +8410,10 @@ QtDoublePropertyManager* QtConeWaveComponentManager::subDoubleProperyManager() c
return d_ptr->m_doubleProperyManager; return d_ptr->m_doubleProperyManager;
} }
QtIntPropertyManager* QtConeWaveComponentManager::subIntProperyManager() const {
return d_ptr->m_intProperyManager;
}
QtColorPropertyManager* QtConeWaveComponentManager::subColorProperyManager() const { QtColorPropertyManager* QtConeWaveComponentManager::subColorProperyManager() const {
return d_ptr->m_colorProperyManager; return d_ptr->m_colorProperyManager;
} }
@ -8425,6 +8460,8 @@ void QtConeWaveComponentManager::setValue(QtProperty* property, const QConeWaveC
d_ptr->m_doubleProperyManager->setValue(d_ptr->m_properyToRadius[property], value.GetRadius()); d_ptr->m_doubleProperyManager->setValue(d_ptr->m_properyToRadius[property], value.GetRadius());
d_ptr->m_doubleProperyManager->setValue(d_ptr->m_properyToHeight[property], value.GetHeight()); d_ptr->m_doubleProperyManager->setValue(d_ptr->m_properyToHeight[property], value.GetHeight());
d_ptr->m_doubleProperyManager->setValue(d_ptr->m_properyToLevelHeight[property], value.GetLevelHeight());
d_ptr->m_intProperyManager->setValue(d_ptr->m_properyToLevelCount[property], value.GetLevelCount());
d_ptr->m_colorProperyManager->setValue(d_ptr->m_properyToColor1[property], value.GetColor1()); d_ptr->m_colorProperyManager->setValue(d_ptr->m_properyToColor1[property], value.GetColor1());
d_ptr->m_colorProperyManager->setValue(d_ptr->m_properyToColor2[property], value.GetColor2()); d_ptr->m_colorProperyManager->setValue(d_ptr->m_properyToColor2[property], value.GetColor2());
d_ptr->m_colorProperyManager->setValue(d_ptr->m_properyToColor3[property], value.GetColor3()); d_ptr->m_colorProperyManager->setValue(d_ptr->m_properyToColor3[property], value.GetColor3());
@ -8452,6 +8489,20 @@ void QtConeWaveComponentManager::initializeProperty(QtProperty* property) {
d_ptr->m_doubleProperyManager->setValueOnly(prop, val.GetHeight()); d_ptr->m_doubleProperyManager->setValueOnly(prop, val.GetHeight());
d_ptr->m_properyToRadius[property] = prop; d_ptr->m_properyToRadius[property] = prop;
d_ptr->m_radiusToPropery[prop] = property; d_ptr->m_radiusToPropery[prop] = property;
property->addSubProperty(prop);
prop = d_ptr->m_intProperyManager->addProperty();
prop->setPropertyName(tr("levelCount"));
d_ptr->m_intProperyManager->setValueOnly(prop, val.GetLevelCount());
d_ptr->m_properyToLevelCount[property] = prop;
d_ptr->m_levelCountToPropery[prop] = property;
property->addSubProperty(prop);
prop = d_ptr->m_doubleProperyManager->addProperty();
prop->setPropertyName(tr("levelHeight"));
d_ptr->m_doubleProperyManager->setValueOnly(prop, val.GetLevelHeight());
d_ptr->m_properyToLevelHeight[property] = prop;
d_ptr->m_levelHeightToPropery[prop] = property;
property->addSubProperty(prop); property->addSubProperty(prop);
prop = d_ptr->m_colorProperyManager->addProperty(); prop = d_ptr->m_colorProperyManager->addProperty();
@ -8492,6 +8543,20 @@ void QtConeWaveComponentManager::uninitializeProperty(QtProperty* property) {
d_ptr->m_heightToPropery.remove(prop); d_ptr->m_heightToPropery.remove(prop);
delete prop; delete prop;
} }
d_ptr->m_properyToHeight.remove(property);
prop = d_ptr->m_levelCountToPropery[property];
if (prop) {
d_ptr->m_levelCountToPropery.remove(prop);
delete prop;
}
d_ptr->m_properyToRadius.remove(property);
prop = d_ptr->m_levelHeightToPropery[property];
if (prop) {
d_ptr->m_levelHeightToPropery.remove(prop);
delete prop;
}
d_ptr->m_properyToHeight.remove(property); d_ptr->m_properyToHeight.remove(property);
prop = d_ptr->m_color1ToPropery[property]; prop = d_ptr->m_color1ToPropery[property];

View File

@ -1123,6 +1123,7 @@ public:
QConeWaveComponentAttribute value(const QtProperty* property) const; QConeWaveComponentAttribute value(const QtProperty* property) const;
QtDoublePropertyManager* subDoubleProperyManager() const; QtDoublePropertyManager* subDoubleProperyManager() const;
QtIntPropertyManager* subIntProperyManager() const;
QtColorPropertyManager* subColorProperyManager() const; QtColorPropertyManager* subColorProperyManager() const;
public Q_SLOTS: public Q_SLOTS:

View File

@ -362,6 +362,44 @@ float QConeWaveComponentAttribute::GetHeight() const {
return object_->GetHeight(); return object_->GetHeight();
} }
void QConeWaveComponentAttribute::SetLevelCount(int c) {
if (nullptr == object_) {
return;
}
if (c == object_->GetLevelCount()) {
return;
}
object_->SetLevelCount(c);
}
int QConeWaveComponentAttribute::GetLevelCount() const {
if (nullptr == object_) {
return 4;
}
return object_->GetLevelCount();
}
void QConeWaveComponentAttribute::SetLevelHeight(float h) {
if (nullptr == object_) {
return;
}
if (h == object_->GetLevelHeight()) {
return;
}
object_->SetLevelHeight(h);
}
float QConeWaveComponentAttribute::GetLevelHeight() const {
if (nullptr == object_) {
return 500.0f;
}
return object_->GetLevelHeight();
}
bool QConeWaveComponentAttribute::operator==(const QConeWaveComponentAttribute& other) { bool QConeWaveComponentAttribute::operator==(const QConeWaveComponentAttribute& other) {
return object_ == other.object_; return object_ == other.object_;
} }

View File

@ -164,6 +164,12 @@ public:
void SetHeight(float h); void SetHeight(float h);
float GetHeight() const; float GetHeight() const;
void SetLevelCount(int c);
int GetLevelCount() const;
void SetLevelHeight(float h);
float GetLevelHeight() const;
private: private:
class ConeWaveComponent* object_{ nullptr }; class ConeWaveComponent* object_{ nullptr };

View File

@ -14,12 +14,12 @@
</MeshComponent> </MeshComponent>
</Entity> </Entity>
<Entity uuid="{3c48c04e-a1ac-485d-9ab8-4436b9881a4d}" name="船2"> <Entity uuid="{3c48c04e-a1ac-485d-9ab8-4436b9881a4d}" name="船2">
<MeshComponent mesh="boke/boke.ive" location="120.000000,25.000100,0.000000" rotation="0.000000,0.000000,0.000000" scale="1000.000000,1000.000000,1000.000000"> <MeshComponent mesh="boke/boke.ive" location="120.130000,25.100100,0.000000" rotation="0.000000,0.000000,0.000000" scale="1000.000000,1000.000000,1000.000000">
<PathComponent path="workspace/chuan2.txt" location="0.000000,0.000000,0.000000" rotation="0.000000,0.000000,0.000000" scale="1.000000,1.000000,1.000000"/> <PathComponent path="workspace/chuan2.txt" location="0.000000,0.000000,0.000000" rotation="0.000000,0.000000,0.000000" scale="1.000000,1.000000,1.000000"/>
</MeshComponent> </MeshComponent>
</Entity> </Entity>
<Entity uuid="{3c48c04e-a1ac-485d-9fb8-4436b9881a4d}" name="船3"> <Entity uuid="{3c48c04e-a1ac-485d-9fb8-4436b9881a4d}" name="船3">
<MeshComponent mesh="boke/boke.ive" location="120.000000,25.003000,0.000000" rotation="0.000000,0.000000,0.000000" scale="1000.000000,1000.000000,1000.000000"> <MeshComponent mesh="boke/boke.ive" location="120.300000,25.003000,0.000000" rotation="0.000000,0.000000,0.000000" scale="1000.000000,1000.000000,1000.000000">
<PathComponent path="workspace/chuan3.txt" location="0.000000,0.000000,0.000000" rotation="0.000000,0.000000,0.000000" scale="1.000000,1.000000,1.000000"/> <PathComponent path="workspace/chuan3.txt" location="0.000000,0.000000,0.000000" rotation="0.000000,0.000000,0.000000" scale="1.000000,1.000000,1.000000"/>
</MeshComponent> </MeshComponent>
<Entity uuid="{3c48c04e-a1ac-485d-9ab8-4436b9851a4d}" name="船5"> <Entity uuid="{3c48c04e-a1ac-485d-9ab8-4436b9851a4d}" name="船5">
@ -29,8 +29,8 @@
</Entity> </Entity>
</Entity> </Entity>
<Entity uuid="{b99a4401-9cc6-493e-a42e-655b81997eb3}" name="卫星"> <Entity uuid="{b99a4401-9cc6-493e-a42e-655b81997eb3}" name="卫星">
<MeshComponent mesh="satellite/satellite.ive" location="120.000000,25.000000,10000.000000" rotation="0.000000,0.000000,0.000000" scale="1.000000,1.000000,1.000000" uuid="{5b764fc4-89ad-4bac-b961-abf310a552fd}"> <MeshComponent mesh="satellite/satellite.ive" location="120.000000,25.000000,300000.000000" rotation="0.000000,0.000000,0.000000" scale="1000.000000,1000.000000,1000.000000" uuid="{5b764fc4-89ad-4bac-b961-abf310a552fd}">
<ConeWaveComponent color1="1.000000,0.200000,0.500000,0.200000" color2="0.000000,0.200000,0.500000,0.200000" color3="0.000000,1.000000,0.500000,1.000000" radius="70.000000" height="100.000000" event="workspace/jiaof.evnet.txt" location="0.000000,0.000000,0.000000" rotation="0.000000,0.000000,0.000000" scale="1.000000,1.000000,1.000000" uuid="{7a962b9c-e572-48f4-9e64-fb1742010bf6}"/> <ConeWaveComponent color1="1.000000,0.200000,0.500000,1.000000" color2="0.000000,0.200000,0.500000,1.00000" color3="0.000000,1.000000,0.500000,1.000000" radius="200.000000" height="300.000000" event="workspace/jiaof.evnet.txt" location="0.000000,0.000000,0.000000" rotation="0.000000,0.000000,0.000000" scale="1.000000,1.000000,1.000000" uuid="{7a962b9c-e572-48f4-9e64-fb1742010bf6}"/>
</MeshComponent> </MeshComponent>
</Entity> </Entity>
<Entity uuid="{3c48c04e-a1ac-485d-9ab8-4436b9881a46}" name="反射通信1"> <Entity uuid="{3c48c04e-a1ac-485d-9ab8-4436b9881a46}" name="反射通信1">