Skip to content

Commit

Permalink
OGRE13: attached beacon lights to scenenodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ohlidalp committed Dec 29, 2022
1 parent 3205069 commit bbe0bcc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 19 deletions.
3 changes: 2 additions & 1 deletion source/main/gfx/GfxData.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,13 @@ struct Prop
Ogre::Vector3 pp_wheel_pos = Ogre::Vector3::ZERO;
Ogre::SceneNode* pp_wheel_scene_node = nullptr;
float pp_wheel_rot_degree = 0;

// Special prop - beacon
char pp_beacon_type = 0; //!< Special prop: beacon {0 = none, 'b' = user-specified, 'r' = red, 'p' = police lightbar, 'L'/'R'/'w' - aircraft wings}
Ogre::BillboardSet* pp_beacon_bbs[4] = {};
Ogre::SceneNode* pp_beacon_scene_node[4] = {};
Ogre::Light* pp_beacon_light[4] = {};
Ogre::SceneNode* pp_beacon_light_snode[4] = {};
float pp_beacon_rot_rate[4] = {}; //!< Radians per second
float pp_beacon_rot_angle[4] = {}; //!< Radians

Expand Down
48 changes: 30 additions & 18 deletions source/main/physics/ActorSpawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -994,13 +994,15 @@ void ActorSpawner::ProcessWing(RigDef::Wing & def)
left_flash_prop.pp_beacon_type='w';
//light
std::string prop_name = this->ComposeName("Prop", static_cast<int>(m_actor->m_gfx_actor->m_props.size())+1);
left_flash_prop.pp_beacon_light_snode[0] = App::GetGfxScene()->GetSceneManager()->getRootSceneNode()->createChildSceneNode();
left_flash_prop.pp_beacon_light[0]=App::GetGfxScene()->GetSceneManager()->createLight(prop_name);
left_flash_prop.pp_beacon_light[0]->setType(Ogre::Light::LT_POINT);
left_flash_prop.pp_beacon_light[0]->setDiffuseColour( Ogre::ColourValue(1.0, 1.0, 1.0));
left_flash_prop.pp_beacon_light[0]->setSpecularColour( Ogre::ColourValue(1.0, 1.0, 1.0));
left_flash_prop.pp_beacon_light[0]->setAttenuation(50.0, 1.0, 0.3, 0.0);
left_flash_prop.pp_beacon_light[0]->setCastShadows(false);
left_flash_prop.pp_beacon_light[0]->setVisible(false);
left_flash_prop.pp_beacon_light_snode[0]->attachObject(left_flash_prop.pp_beacon_light[0]);
//the flare billboard
left_flash_prop.pp_beacon_scene_node[0] = App::GetGfxScene()->GetSceneManager()->getRootSceneNode()->createChildSceneNode();
left_flash_prop.pp_beacon_bbs[0]=App::GetGfxScene()->GetSceneManager()->createBillboardSet(prop_name,1);
Expand Down Expand Up @@ -1058,13 +1060,15 @@ void ActorSpawner::ProcessWing(RigDef::Wing & def)
right_flash_prop.pp_beacon_type='w';
//light
prop_name = this->ComposeName("Prop", static_cast<int>(m_actor->m_gfx_actor->m_props.size())+1);
right_flash_prop.pp_beacon_light_snode[0] = App::GetGfxScene()->GetSceneManager()->getRootSceneNode()->createChildSceneNode();
right_flash_prop.pp_beacon_light[0]=App::GetGfxScene()->GetSceneManager()->createLight(prop_name);
right_flash_prop.pp_beacon_light[0]->setType(Ogre::Light::LT_POINT);
right_flash_prop.pp_beacon_light[0]->setDiffuseColour( Ogre::ColourValue(1.0, 1.0, 1.0));
right_flash_prop.pp_beacon_light[0]->setSpecularColour( Ogre::ColourValue(1.0, 1.0, 1.0));
right_flash_prop.pp_beacon_light[0]->setAttenuation(50.0, 1.0, 0.3, 0.0);
right_flash_prop.pp_beacon_light[0]->setCastShadows(false);
right_flash_prop.pp_beacon_light[0]->setVisible(false);
right_flash_prop.pp_beacon_light_snode[0]->attachObject(right_flash_prop.pp_beacon_light[0]);
//the flare billboard
right_flash_prop.pp_beacon_scene_node[0] = App::GetGfxScene()->GetSceneManager()->getRootSceneNode()->createChildSceneNode();
right_flash_prop.pp_beacon_bbs[0]=App::GetGfxScene()->GetSceneManager()->createBillboardSet(prop_name,1);
Expand Down Expand Up @@ -1639,14 +1643,16 @@ void ActorSpawner::ProcessProp(RigDef::Prop & def)
prop.pp_beacon_rot_angle[0] = 2.0 * 3.14 * frand();
prop.pp_beacon_rot_rate[0] = 4.0 * 3.14 + frand() - 0.5;
/* the light */
auto pp_beacon_light = App::GetGfxScene()->GetSceneManager()->createLight();
pp_beacon_light->setType(Ogre::Light::LT_SPOTLIGHT);
pp_beacon_light->setDiffuseColour(def.special_prop_beacon.color);
pp_beacon_light->setSpecularColour(def.special_prop_beacon.color);
pp_beacon_light->setAttenuation(50.0, 1.0, 0.3, 0.0);
pp_beacon_light->setSpotlightRange( Ogre::Degree(35), Ogre::Degree(45) );
pp_beacon_light->setCastShadows(false);
pp_beacon_light->setVisible(false);
auto flare_light_snode = App::GetGfxScene()->GetSceneManager()->getRootSceneNode()->createChildSceneNode();
auto flare_beacon_light = App::GetGfxScene()->GetSceneManager()->createLight();
flare_beacon_light->setType(Ogre::Light::LT_SPOTLIGHT);
flare_beacon_light->setDiffuseColour(def.special_prop_beacon.color);
flare_beacon_light->setSpecularColour(def.special_prop_beacon.color);
flare_beacon_light->setAttenuation(50.0, 1.0, 0.3, 0.0);
flare_beacon_light->setSpotlightRange( Ogre::Degree(35), Ogre::Degree(45) );
flare_beacon_light->setCastShadows(false);
flare_beacon_light->setVisible(false);
flare_light_snode->attachObject(flare_beacon_light);
/* the flare billboard */
auto flare_scene_node = App::GetGfxScene()->GetSceneManager()->getRootSceneNode()->createChildSceneNode();
auto flare_billboard_sys = App::GetGfxScene()->GetSceneManager()->createBillboardSet(1); //(propname,1);
Expand All @@ -1662,21 +1668,24 @@ void ActorSpawner::ProcessProp(RigDef::Prop & def)
// Complete
prop.pp_beacon_scene_node[0] = flare_scene_node;
prop.pp_beacon_bbs[0] = flare_billboard_sys;
prop.pp_beacon_light[0] = pp_beacon_light;
prop.pp_beacon_light[0] = flare_beacon_light;
prop.pp_beacon_light_snode[0] = flare_light_snode;
}
else if(def.special == RigDef::SpecialProp::REDBEACON)
{
prop.pp_beacon_rot_angle[0] = 0.f;
prop.pp_beacon_rot_rate[0] = 1.0;
prop.pp_beacon_type = 'r';
//the light
auto pp_beacon_light=App::GetGfxScene()->GetSceneManager()->createLight();//propname);
pp_beacon_light->setType(Ogre::Light::LT_POINT);
pp_beacon_light->setDiffuseColour( Ogre::ColourValue(1.0, 0.0, 0.0));
pp_beacon_light->setSpecularColour( Ogre::ColourValue(1.0, 0.0, 0.0));
pp_beacon_light->setAttenuation(50.0, 1.0, 0.3, 0.0);
pp_beacon_light->setCastShadows(false);
pp_beacon_light->setVisible(false);
auto flare_light_snode = App::GetGfxScene()->GetSceneManager()->getRootSceneNode()->createChildSceneNode();
auto flare_beacon_light=App::GetGfxScene()->GetSceneManager()->createLight();//propname);
flare_beacon_light->setType(Ogre::Light::LT_POINT);
flare_beacon_light->setDiffuseColour( Ogre::ColourValue(1.0, 0.0, 0.0));
flare_beacon_light->setSpecularColour( Ogre::ColourValue(1.0, 0.0, 0.0));
flare_beacon_light->setAttenuation(50.0, 1.0, 0.3, 0.0);
flare_beacon_light->setCastShadows(false);
flare_beacon_light->setVisible(false);
flare_light_snode->attachObject(flare_beacon_light);
//the flare billboard
auto flare_scene_node = App::GetGfxScene()->GetSceneManager()->getRootSceneNode()->createChildSceneNode();
auto flare_billboard_sys = App::GetGfxScene()->GetSceneManager()->createBillboardSet(1); //propname,1);
Expand All @@ -1691,10 +1700,10 @@ void ActorSpawner::ProcessProp(RigDef::Prop & def)
flare_scene_node->setVisible(false);

// Finalize
prop.pp_beacon_light[0] = pp_beacon_light;
prop.pp_beacon_light[0] = flare_beacon_light;
prop.pp_beacon_scene_node[0] = flare_scene_node;
prop.pp_beacon_bbs[0] = flare_billboard_sys;

prop.pp_beacon_light_snode[0] = flare_light_snode;
}
else if(def.special == RigDef::SpecialProp::LIGHTBAR)
{
Expand All @@ -1706,6 +1715,7 @@ void ActorSpawner::ProcessProp(RigDef::Prop & def)
prop.pp_beacon_rot_rate[k] = 4.0 * 3.14 + frand() - 0.5;
prop.pp_beacon_bbs[k] = nullptr;
//the light
prop.pp_beacon_light_snode[k] = App::GetGfxScene()->GetSceneManager()->getRootSceneNode()->createChildSceneNode();
prop.pp_beacon_light[k]=App::GetGfxScene()->GetSceneManager()->createLight();
prop.pp_beacon_light[k]->setType(Ogre::Light::LT_SPOTLIGHT);
if (k>1)
Expand All @@ -1722,6 +1732,8 @@ void ActorSpawner::ProcessProp(RigDef::Prop & def)
prop.pp_beacon_light[k]->setSpotlightRange( Ogre::Degree(35), Ogre::Degree(45) );
prop.pp_beacon_light[k]->setCastShadows(false);
prop.pp_beacon_light[k]->setVisible(false);
prop.pp_beacon_light_snode[k]->attachObject(prop.pp_beacon_light[k]);

//the flare billboard
prop.pp_beacon_scene_node[k] = App::GetGfxScene()->GetSceneManager()->getRootSceneNode()->createChildSceneNode();
prop.pp_beacon_bbs[k]=App::GetGfxScene()->GetSceneManager()->createBillboardSet(1);
Expand Down

0 comments on commit bbe0bcc

Please sign in to comment.