Skip to content

Commit

Permalink
ed ror fix vars, dont copy
Browse files Browse the repository at this point in the history
  • Loading branch information
cryham committed Feb 17, 2024
1 parent 101f474 commit c7db2f4
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/editor/ExportRoR.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class ExportRoR
float hmin = 0.f, half = 0.f; // min height, half world size
int water = 0; float Ywater = 0.f; // bool, level

Ogre::String strPos(Ogre::Vector3 pos); // util convert SR pos to RoR pos
bool CopyFile(std::string from, std::string to); // both args are path with filenames
Ogre::String strPos(const Ogre::Vector3& pos); // util convert SR pos to RoR pos
bool CopyFile(const std::string& from, const std::string& to); // both args are path with filenames

public:
ExportRoR(App* app1);
Expand Down
10 changes: 7 additions & 3 deletions src/editor/ExportRoR_Objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void ExportRoR::ExportObjects()

int iodef = 0, iObjMesh = 0;
std::map<string, int> once;
const bool hasObjects = sc->objects.empty();
hasObjects = sc->objects.empty();

for (const auto& o : sc->objects)
{
Expand All @@ -55,6 +55,9 @@ void ExportRoR::ExportObjects()
// todo no scale ??
obj << o.name +"\n";

// #define COPY_OBJS 1 // NO, once for all tracks
#ifdef COPY_OBJS

// object save .odef
//------------------------------------------------------------
const string mesh = o.name + ".mesh";
Expand All @@ -78,6 +81,7 @@ void ExportRoR::ExportObjects()

odef.close(); ++iodef;


//------------------------------------------------------------
// Find mesh in old SR dirs
//------------------------------------------------------------
Expand All @@ -103,9 +107,9 @@ void ExportRoR::ExportObjects()
// get mtr? read .mat, copy textures, write .material ...
}
}
#endif
}
obj.close();

gui->Exp(CGui::TXT, "Objects: "+toStr(sc->objects.size())+" odef: "+toStr(iodef)+" meshes: "+toStr(iObjMesh));

gui->Exp(CGui::TXT, "Objects: "+toStr(sc->objects.size())+" odef: "+toStr(iodef)+" meshes: "+toStr(iObjMesh) + "\n");
}
2 changes: 1 addition & 1 deletion src/editor/ExportRoR_Road.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,5 +234,5 @@ void ExportRoR::ExportRoad()

as.close();

gui->Exp(CGui::INFO, "Road Time: " + fToStr(ti.getMilliseconds()/1000.f,1,3) + " s");
gui->Exp(CGui::INFO, "Road Time: " + fToStr(ti.getMilliseconds()/1000.f,1,3) + " s\n");
}
10 changes: 5 additions & 5 deletions src/editor/ExportRoR_Terrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ using namespace std;


//------------------------------------------------------------------------------------------------------------------------
// Export current track for Rigs Of Rods
// ⛰️ Terrain Heightmap, Blendmap, Road image, scripts
//------------------------------------------------------------------------------------------------------------------------
void ExportRoR::ExportTerrain() // whole, full
{
Expand All @@ -41,7 +41,7 @@ void ExportRoR::ExportTerrain() // whole, full
memset(hmap, 0, hsize * 2);

// find h min, max
float hmin = 100000.f, hmax = -hmin;
hmin = 100000.f; float hmax = -hmin;
for (int y=0; y < size; ++y)
{
int a = y * size;
Expand All @@ -55,8 +55,8 @@ void ExportRoR::ExportTerrain() // whole, full

// world size
const float Ysize = (hmax - hmin);
const float XZsize = size * td.fTriangleSize,
half = XZsize * 0.5f; // half ter size offset
const float XZsize = size * td.fTriangleSize;
half = XZsize * 0.5f; // half ter size offset

gui->Exp(CGui::TXT, "Hmap size " + toStr(size));
gui->Exp(CGui::TXT, "Height min " + toStr(hmin));
Expand Down Expand Up @@ -392,5 +392,5 @@ void ExportRoR::ExportTerrain() // whole, full

otc.close();

gui->Exp(CGui::INFO, "Terrain Time: " + fToStr(ti.getMilliseconds()/1000.f,1,3) + " s");
gui->Exp(CGui::INFO, "Terrain Time: " + fToStr(ti.getMilliseconds()/1000.f,1,3) + " s\n");
}
41 changes: 28 additions & 13 deletions src/editor/ExportRoR_Veget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ void ExportRoR::ExportVeget()
ofstream veg;
veg.open(vegFile.c_str(), std::ios_base::out);

string matFile = path + name + "-veget.material";
ofstream mat;
mat.open(matFile.c_str(), std::ios_base::out);
// string matFile = path + name + "-veget.material";
// ofstream mat;
// mat.open(matFile.c_str(), std::ios_base::out);


//------------------------------------------------------------------------------------------------------------------------
Expand All @@ -53,13 +53,15 @@ void ExportRoR::ExportVeget()
veg << "// grass range, SwaySpeed, SwayLength, SwayDistribution, Density, minx, miny, maxx, maxy, fadetype, minY, maxY, material colormap densitymap\n";

const SGrassLayer* g0 = &sc->grLayersAll[0];
int igrs = 0;
for (int i=0; i < sc->ciNumGrLay; ++i)
{
const SGrassLayer* gr = &sc->grLayersAll[i];
if (gr->on)
{
const SGrassChannel* ch = &scn->sc->grChan[gr->iChan];
const string mapName = name + "-grass"+toStr(gr->iChan)+".png";
++igrs;

//grass 200, 0.5, 0.05, 10, 0.1, 0.2, 0.2, 1, 1, 1, 0, 9, seaweed none none
//grass 600, 0.5, 0.15, 10, 0.3, 0.2, 0.2, 1, 1, 1, 10, 0, grass1 aspen.jpg aspen_grass_density.png
Expand Down Expand Up @@ -117,6 +119,8 @@ void ExportRoR::ExportVeget()
gui->Exp(CGui::WARN, string("Exception in grass dens map: ") + ex.what());
}

#if 0 // NO, once for all

// copy grass*.png
//------------------------------------------------------------
String pathGrs = PATHS::Data() + "/grass/";
Expand Down Expand Up @@ -145,9 +149,13 @@ void ExportRoR::ExportVeget()
mat << " }\n";
mat << "}\n";
mat << "\n";
#endif
}
}
mat.close();
// mat.close();

gui->Exp(CGui::NOTE, "Grasses: " + toStr(igrs));



//------------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -248,6 +256,10 @@ void ExportRoR::ExportVeget()
if (!pveg) continue;
bool add = 1;


// #define COPY_VEGET 1 // NO, once for all tracks
#ifdef COPY_VEGET

//------------------------------------------------------------
// Find mesh in old SR dirs
//------------------------------------------------------------
Expand All @@ -264,8 +276,6 @@ void ExportRoR::ExportVeget()
// copy mesh from old SR ..or slow convert v2 to v1-
if (exists)
{
#if 1 // no, once for all tracks

if (once.find(mesh) == once.end())
{ once[mesh] = 1;

Expand Down Expand Up @@ -299,28 +309,33 @@ void ExportRoR::ExportVeget()
String s = "Error: loading mesh: " + mesh + " \nfrom: " + path + "\n failed ! \n" + ex.what() + "\n";
gui->Exp(CGui::WARN, s);
}
// todo read .mat,
// copy textures, write .material ...
#endif
#endif

// write ------
if (l==0)
veg << "\n// trees yawFrom, yawTo, scaleFrom, scaleTo, highDensity, distance1, distance2, meshName colormap densitymap\n";
if (add)
{ //trees 0, 360, 0.1, 0.12, 2, 60, 3000, fir05_30.mesh aspen-test.dds aspen_grass_density2.png
veg << "trees 0, 360, ";
veg << vg.minScale << ", " << vg.minScale << ", ";
veg << vg.dens * sc->densTrees * 2.f;
veg << "trees 0, 360, ";
veg << vg.minScale << ", " << vg.minScale << ", ";
veg << vg.dens * sc->densTrees * 2.f << ", ";

// veg << ", 60, 1000, "; // vis dist
veg << ", " << pveg->visDist * 0.5f << ", " << pveg->farDist << ", "; // par .. todo
veg << pveg->visDist * 0.5f << ", " << pveg->farDist << ", "; // par .. todo
veg << vg.name << " none " << mapName << "\n";
}

#ifdef COPY_OBJS
}
#else
++iVegetMesh;
#endif
}

veg.close();

gui->Exp(CGui::NOTE, "Veget meshes: " + toStr(iVegetMesh));
}

gui->Exp(CGui::INFO, "Time Veget: " + fToStr(ti.getMilliseconds()/1000.f,1,3) + " s\n");
}
8 changes: 5 additions & 3 deletions src/editor/ExportRoR_WaterSky.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ void ExportRoR::ExportWaterSky()

// 🌊 Fluids
//------------------------------------------------------------
float Ywater = 0.f;
int water = 0;
Ywater = 0.f;
water = 0;

switch (cfg->water)
{
case -1: // off
Expand Down Expand Up @@ -72,6 +73,7 @@ void ExportRoR::ExportWaterSky()
os << " ground_fog_density_multiplier 0.015\n"; // cg! no diff-
os << " scene_fog_density_multiplier 0.015\n";
os << "\n";

os << " sun {\n"; // 🌞 sun light
Vector3 la = sc->lAmb.GetRGB() * cfg->lAmb + cfg->lAmbAdd; // par bright
Vector3 ld = sc->lDiff.GetRGB() * cfg->lDiff;
Expand All @@ -84,6 +86,7 @@ void ExportRoR::ExportWaterSky()
os << " auto_disable true\n";
os << " }\n";
os << "\n";

os << " moon {\n";
os << " ambient_multiplier 0.2 0.2 0.2\n";
os << " diffuse_multiplier 1 1 0.9\n";
Expand Down Expand Up @@ -133,5 +136,4 @@ void ExportRoR::ExportWaterSky()
os << "}\n";

os.close();

}

0 comments on commit c7db2f4

Please sign in to comment.