Fixed positioning of miscellaneous foreground objects.

This commit is contained in:
ambidot 2020-07-26 18:01:36 -05:00
parent 853d128830
commit af846053c8
3 changed files with 29 additions and 20 deletions

View File

@ -79,10 +79,12 @@ namespace wp
irr::f32 xscale = this->m_parent->getScale ().X;
irr::f32 yscale = this->m_parent->getScale ().Y;
irr::f32 xright = this->m_parent->getOrigin ().X;
irr::f32 xleft = this->m_parent->getOrigin ().X - xsize * xscale;
irr::f32 ytop = this->m_parent->getOrigin ().Y;
irr::f32 ybottom = this->m_parent->getOrigin ().Y - ysize * yscale;
float scene_w = this->m_parent->getScene ()->getProjectionWidth ();
float scene_h = this->m_parent->getScene ()->getProjectionHeight ();
irr::f32 xright = -scene_w/2. + this->m_parent->getOrigin ().X + xsize*xscale/2.;
irr::f32 xleft = -scene_w/2. + this->m_parent->getOrigin ().X - xsize*xscale/2.;
irr::f32 ytop = -scene_h/2. + this->m_parent->getOrigin ().Y + ysize*yscale/2.;
irr::f32 ybottom = -scene_h/2. + this->m_parent->getOrigin ().Y - ysize*yscale/2.;
irr::f32 z = this->m_parent->getScene ()->getCamera ()->getEye ().Z;
m_vertices [0].Pos = irr::core::vector3df (xleft, ytop, z); // top left

View File

@ -76,9 +76,7 @@ namespace irr {
input->seek (4, true); // ignore bytes
input->read (buffer, 9);
if (input->getFileName().find("materials/flowmask.tex") != std::string::npos ||
input->getFileName().find("godrays_downsample2_mask") != std::string::npos ||
input->getFileName().find("materials/util/white.tex") != std::string::npos)
if (input->getFileName().find("materials/util/white.tex") != std::string::npos)
{
// relevant shaders are currently drawing these masks opaque; return a transparent image instead
wp::irrlicht::device->getLogger ()->log ("LOAD TEX: Skipping broken mask", input->getFileName ().c_str (), irr::ELL_INFORMATION);
@ -274,7 +272,7 @@ namespace irr {
delete [] decompressedBuffer;
#if 0
// dump image to a TGA file (adapted from maluoi's gist)
// dump image to TGA file (adapted from maluoi's gist)
u32 bytesPerPixel = image->getBytesPerPixel ();
if (bytesPerPixel != 3 && bytesPerPixel != 4)
wp::irrlicht::device->getLogger ()->log (("Unexpected bytesPerPixel of " + std::to_string (bytesPerPixel)).c_str (), input->getFileName ().c_str (), irr::ELL_ERROR);
@ -283,7 +281,7 @@ namespace irr {
std::string fileName = input->getFileName ().c_str ();
std::replace (fileName.begin (), fileName.end (), '/', '-');
std::string path = std::string (getenv("HOME")) + "/stuff/wallpaperengine-dumps/";
system(("mkdir -p " + path).c_str());
system (("mkdir -p " + path).c_str ());
path += fileName + ".tga";
FILE *dumpFile = fopen (path.c_str (), "wb");
uint8_t header[18] = { 0,0,2,0,0,0,0,0,0,0,0,0,

View File

@ -16,6 +16,14 @@ namespace wp
{
this->m_content = wp::fs::utils::loadFullFile (file);
this->m_json = json::parse (this->m_content);
#if 0
// dump scene json to file
std::string path = std::string (getenv("HOME")) + "/stuff/wallpaperengine-dumps/";
system (("mkdir -p " + path).c_str ());
path += file.c_str ();
std::ofstream out = std::ofstream (path);
out << this->m_json.dump (4) << std::endl;
#endif
// check basic elements
json::const_iterator camera_it = this->m_json.find ("camera");
@ -27,17 +35,7 @@ namespace wp
this->m_camera = new camera (*camera_it);
}
if (objects_it != this->m_json.end () && objects_it.value ().is_array () == true)
{
json::const_iterator cur = this->m_json ["objects"].begin ();
json::const_iterator end = this->m_json ["objects"].end ();
for (; cur != end; cur ++)
{
this->m_objects.push_back (new object (*cur, this));
}
}
// read orthogonalprojection before loading objects so they can set their vertices properly
json::const_iterator orthogonalprojection = (*general_it).find ("orthogonalprojection");
if (orthogonalprojection != (*general_it).end () && (*orthogonalprojection).is_object () == true)
@ -57,6 +55,17 @@ namespace wp
this->m_isOrthogonal = true;
}
if (objects_it != this->m_json.end () && objects_it.value ().is_array () == true)
{
json::const_iterator cur = this->m_json ["objects"].begin ();
json::const_iterator end = this->m_json ["objects"].end ();
for (; cur != end; cur ++)
{
this->m_objects.push_back (new object (*cur, this));
}
}
}
scene::~scene ()