Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion bin/Models/Ownship/Alkmini/radar.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ radar1_blue(1)=0
radar_bg_red(1)=0
radar_bg_green(1)=0
radar_bg_blue(1)=255
radar_surround_red(1)=128
radar_surround_green(1)=128
radar_surround_blue(1)=128

radar1_red(2)=128
radar1_green(2)=0
radar1_blue(2)=0
radar_bg_red(2)=0
radar_bg_green(2)=0
radar_bg_blue(2)=0
radar_bg_blue(2)=0
radar_surround_red(2)=64
radar_surround_green(2)=64
radar_surround_blue(2)=64
14 changes: 11 additions & 3 deletions doc/newmodels.html
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,19 @@ <h3>Radar.ini</h3>
radar_bg_red(1)=0
radar_bg_green(1)=0
radar_bg_blue(1)=255
radar_surround_red(1)=128
radar_surround_green(1)=128
radar_surround_blue(1)=128

radar1_red(2)=128
radar1_green(2)=0
radar1_blue(2)=0
radar_bg_red(2)=0
radar_bg_green(2)=0
radar_bg_blue(2)=0
radar_surround_red(2)=64
radar_surround_green(2)=64
radar_surround_blue(2)=64
<!--plot_pi_data=1
radar_bg_red=0
radar_bg_green=0
Expand Down Expand Up @@ -408,9 +414,11 @@ <h3>Radar.ini</h3>
<li>radar3_red, radar3_green, radar3_blue: The colour for the parallel index lines in red, green and blue components, each in the range 0-255.</li>
-->
<li>NumberOfRadarColourSets: How many sets of colours are available on the radar (e.g. 2 if there is a daytime and a nighttime colour scheme)</li>
<li>For each radar colour set, where # is the set number (1 to NumberOfRadarColourSets):
<ul><li>radar1_red(#), radar1_green(#), radar1_blue(#): The colour for the radar plot, in red green and blue components, each in the range 0-255.</li></ul>
<ul><li>radar_bg_red(#), radar_bg_green(#), radar_bg_blue(#): The colour for the radar background, in red green and blue components, each in the range 0-255.</li></ul>
<li>
For each radar colour set, where # is the set number (1 to NumberOfRadarColourSets):
<ul><li>radar1_red(#), radar1_green(#), radar1_blue(#): The colour for the radar plot, in red green and blue components, each in the range 0-255.</li></ul>
<ul><li>radar_bg_red(#), radar_bg_green(#), radar_bg_blue(#): The colour for the radar background, in red green and blue components, each in the range 0-255.</li></ul>
<ul><li>radar_surround_red(#), radar_surround_green(#), radar_surround_blue(#): The colour for the radar surround (also used as the general background colour), in red green and blue components, each in the range 0-255.</li></ul>
</li>
</ul>
</p>
Expand Down
84 changes: 67 additions & 17 deletions src/RadarCalculation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ void RadarCalculation::load(std::string radarConfigFile, irr::IrrlichtDevice* de

irr::video::SColor radarBackgroundColour;
irr::video::SColor radarForegroundColour;
irr::video::SColor radarSurroundColour;

radarBackgroundColour.setAlpha(255);
radarBackgroundColour.setRed(0);
Expand All @@ -140,6 +141,12 @@ void RadarCalculation::load(std::string radarConfigFile, irr::IrrlichtDevice* de
radarForegroundColour.setRed(255);
radarForegroundColour.setGreen(220);
radarForegroundColour.setBlue(0);

radarSurroundColour.setAlpha(255);
radarSurroundColour.setRed(128);
radarSurroundColour.setGreen(128);
radarSurroundColour.setBlue(128);


radarBackgroundColours.push_back(radarBackgroundColour);
radarForegroundColours.push_back(radarForegroundColour);
Expand Down Expand Up @@ -187,6 +194,7 @@ void RadarCalculation::load(std::string radarConfigFile, irr::IrrlichtDevice* de
//legacy loading
irr::video::SColor radarBackgroundColour;
irr::video::SColor radarForegroundColour;
irr::video::SColor radarSurroundColour;

radarBackgroundColour.setAlpha(255);
radarBackgroundColour.setRed(IniFile::iniFileTou32(radarConfigFile,"radar_bg_red"));
Expand All @@ -198,12 +206,19 @@ void RadarCalculation::load(std::string radarConfigFile, irr::IrrlichtDevice* de
radarForegroundColour.setGreen(IniFile::iniFileTou32(radarConfigFile,"radar1_green"));
radarForegroundColour.setBlue(IniFile::iniFileTou32(radarConfigFile,"radar1_blue"));

radarSurroundColour.setAlpha(255);
radarSurroundColour.setRed(IniFile::iniFileTou32(radarConfigFile, "radar_surround_red", 128));
radarSurroundColour.setGreen(IniFile::iniFileTou32(radarConfigFile, "radar1_green", 128));
radarSurroundColour.setBlue(IniFile::iniFileTou32(radarConfigFile, "radar1_blue", 128));

radarBackgroundColours.push_back(radarBackgroundColour);
radarForegroundColours.push_back(radarForegroundColour);
radarSurroundColours.push_back(radarSurroundColour);
} else {
for (unsigned int i = 1; i <= numberOfRadarColourSets; i++) {
irr::video::SColor radarBackgroundColour;
irr::video::SColor radarForegroundColour;
irr::video::SColor radarSurroundColour;

radarBackgroundColour.setAlpha(255);
radarBackgroundColour.setRed(IniFile::iniFileTou32(radarConfigFile,IniFile::enumerate1("radar_bg_red",i)));
Expand All @@ -215,8 +230,14 @@ void RadarCalculation::load(std::string radarConfigFile, irr::IrrlichtDevice* de
radarForegroundColour.setGreen(IniFile::iniFileTou32(radarConfigFile,IniFile::enumerate1("radar1_green",i)));
radarForegroundColour.setBlue(IniFile::iniFileTou32(radarConfigFile,IniFile::enumerate1("radar1_blue",i)));

radarSurroundColour.setAlpha(255);
radarSurroundColour.setRed(IniFile::iniFileTou32(radarConfigFile, IniFile::enumerate1("radar_surround_red", i), 128));
radarSurroundColour.setGreen(IniFile::iniFileTou32(radarConfigFile, IniFile::enumerate1("radar_surround_green", i), 128));
radarSurroundColour.setBlue(IniFile::iniFileTou32(radarConfigFile, IniFile::enumerate1("radar_surround_blue", i), 128));

radarBackgroundColours.push_back(radarBackgroundColour);
radarForegroundColours.push_back(radarForegroundColour);
radarSurroundColours.push_back(radarSurroundColour);
}
}

Expand Down Expand Up @@ -645,7 +666,7 @@ void RadarCalculation::update(irr::video::IImage * radarImage, irr::video::IImag

//Reset screen if needed
if(radarScreenStale) {
radarImage->fill(irr::video::SColor(255, 128, 128, 128)); //Fill with background colour
radarImage->fill(getRadarSurroundColour());
//Reset 'previous' array so it will all get re-drawn
for(irr::u32 i = 0; i<angularResolution; i++) {
toReplot[i] = true;
Expand Down Expand Up @@ -1459,22 +1480,20 @@ void RadarCalculation::render(irr::video::IImage * radarImage, irr::video::IImag
if (pixelColour>1.0) {pixelColour = 1.0;}
if (pixelColour<0) {pixelColour = 0;}

if (currentRadarColourChoice < radarForegroundColours.size() && currentRadarColourChoice < radarBackgroundColours.size()) {
//Interpolate colour between foreground and background
irr::video::SColor thisColour = radarForegroundColours.at(currentRadarColourChoice).getInterpolated(radarBackgroundColours.at(currentRadarColourChoice), pixelColour);
drawSector(radarImage,
centrePixel,
centrePixel,
cellMinRange[currentStep],
cellMaxRange[currentStep],
cellMinAngle,
cellMaxAngle,
thisColour.getAlpha(),
thisColour.getRed(),
thisColour.getGreen(),
thisColour.getBlue(),
ownShipHeading);
}
//Interpolate colour between foreground and background
irr::video::SColor thisColour = getRadarForegroundColour().getInterpolated(getRadarBackgroundColour(), pixelColour);
drawSector(radarImage,
centrePixel,
centrePixel,
cellMinRange[currentStep],
cellMaxRange[currentStep],
cellMinAngle,
cellMaxAngle,
thisColour.getAlpha(),
thisColour.getRed(),
thisColour.getGreen(),
thisColour.getBlue(),
ownShipHeading);

scanArrayToPlotPrevious[scanLine][currentStep] = scanArrayToPlot[scanLine][currentStep]; //Record what we have plotted
}
Expand Down Expand Up @@ -1847,4 +1866,35 @@ bool RadarCalculation::isPointInEllipse(irr::f32 pointX, irr::f32 pointZ, irr::f
} else {
return false;
}

}

irr::video::SColor RadarCalculation::getRadarForegroundColour() const
{
if (currentRadarColourChoice < radarForegroundColours.size()) {
return radarForegroundColours.at(currentRadarColourChoice);
}
else {
return irr::video::SColor(255, 255, 220, 0);
}
}

irr::video::SColor RadarCalculation::getRadarBackgroundColour() const
{
if (currentRadarColourChoice < radarBackgroundColours.size()) {
return radarBackgroundColours.at(currentRadarColourChoice);
}
else {
return irr::video::SColor(255, 0, 0, 200);
}
}

irr::video::SColor RadarCalculation::getRadarSurroundColour() const
{
if (currentRadarColourChoice < radarSurroundColours.size()) {
return radarSurroundColours.at(currentRadarColourChoice);
}
else {
return irr::video::SColor(255, 128, 128, 128);
}
}
4 changes: 4 additions & 0 deletions src/RadarCalculation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ class RadarCalculation
void clearManualPoints();
void trackTargetFromCursor();
void clearTargetFromCursor();
irr::video::SColor getRadarForegroundColour() const;
irr::video::SColor getRadarBackgroundColour() const;
irr::video::SColor getRadarSurroundColour() const;
void update(irr::video::IImage * radarImage, irr::video::IImage * radarImageOverlaid, irr::core::vector3d<int64_t> offsetPosition, const Terrain& terrain, const OwnShip& ownShip, const Buoys& buoys, const OtherShips& otherShips, irr::f32 weather, irr::f32 rain, irr::f32 tideHeight, irr::f32 deltaTime, uint64_t absoluteTime, irr::core::vector2di mouseRelPosition, bool isMouseDown);

private:
Expand Down Expand Up @@ -212,6 +215,7 @@ class RadarCalculation
//colours
std::vector<irr::video::SColor> radarBackgroundColours;
std::vector<irr::video::SColor> radarForegroundColours;
std::vector<irr::video::SColor> radarSurroundColours;
irr::u32 currentRadarColourChoice;

std::vector<irr::f32> radarRangeNm;
Expand Down
11 changes: 6 additions & 5 deletions src/SimulationModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,7 @@ SimulationModel::SimulationModel(irr::IrrlichtDevice* dev,
radarImageOverlaid = driver->createImage (irr::video::ECF_A8R8G8B8, irr::core::dimension2d<irr::u32>(radarTextureSize, radarTextureSize)); //Create image for radar calculation to work on
radarImageLarge = driver->createImage (irr::video::ECF_A8R8G8B8, irr::core::dimension2d<irr::u32>(largeRadarTextureSize, largeRadarTextureSize)); //Create image for radar calculation to work on
radarImageOverlaidLarge = driver->createImage (irr::video::ECF_A8R8G8B8, irr::core::dimension2d<irr::u32>(largeRadarTextureSize, largeRadarTextureSize)); //Create image for radar calculation to work on
//fill with bg colour
radarImage->fill(irr::video::SColor(255, 128, 128, 128)); //Fill with background colour
radarImageOverlaid->fill(irr::video::SColor(255, 128, 128, 128)); //Fill with background colour
radarImageLarge->fill(irr::video::SColor(255, 128, 128, 128)); //Fill with background colour
radarImageOverlaidLarge->fill(irr::video::SColor(255, 128, 128, 128)); //Fill with background colour
//Images will be filled with background colour in RadarCalculation

//make radar camera
std::vector<irr::core::vector3df> radarViews; //Get the initial camera offset from the radar screen
Expand Down Expand Up @@ -1201,6 +1197,11 @@ SimulationModel::~SimulationModel()
return radarCalculation.isRadarOn();
}

irr::video::SColor SimulationModel::getRadarSurroundColour() const
{
return radarCalculation.getRadarSurroundColour();
}

void SimulationModel::increaseRadarRange()
{
radarCalculation.increaseRange();
Expand Down
1 change: 1 addition & 0 deletions src/SimulationModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ class SimulationModel //Start of the 'Model' part of MVC
void setAlarm(bool alarmState);
void toggleRadarOn();
bool isRadarOn() const;
irr::video::SColor getRadarSurroundColour() const;
void increaseRadarRange();
void decreaseRadarRange();
void setRadarGain(irr::f32 value);
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ int main(int argc, char ** argv)
// modelProfile.tic();
}{ IPROF("Render setup");
driver->setViewPort(irr::core::rect<irr::s32>(0,0,graphicsWidth,graphicsHeight)); //Full screen before beginScene
driver->beginScene(irr::video::ECBF_COLOR|irr::video::ECBF_DEPTH, irr::video::SColor(0,128,128,128));
driver->beginScene(irr::video::ECBF_COLOR|irr::video::ECBF_DEPTH, model.getRadarSurroundColour());
// renderSetupProfile.toc();

// renderRadarProfile.tic();
Expand Down