trackgen: check all objects for spliting

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@9110 30fe4595-0a0c-4342-8851-515496e4dcbd
This commit is contained in:
iobyte 2023-07-19 21:20:45 +00:00
parent 796c9eb386
commit fab710b243
8 changed files with 53118 additions and 355277 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<java version="17.0.6" class="java.beans.XMLDecoder">
<java version="18.0.1.1" class="java.beans.XMLDecoder">
<object class="utils.Properties" id="Properties0">
<void property="currentA">
<double>-6.283185115616205</double>
<double>-6.283185569184482</double>
</void>
<void property="currentX">
<double>-0.014730428311452215</double>
<double>-0.029902608321771496</double>
</void>
<void property="currentY">
<double>0.004475495702590883</double>
<double>-0.011803386113509748</double>
</void>
<void property="curveNameCount">
<int>78</int>
@ -28,10 +28,10 @@
</void>
</void>
<void property="path">
<string>C:\Users\Leo\Desktop\SD\code\data\tracks\circuit\jarama</string>
<string>C:\Users\Bob\speed-dreams-code\data\tracks\circuit\jarama</string>
</void>
<void property="straightNameCount">
<int>95</int>
<int>103</int>
</void>
</object>
</java>

View File

@ -1,20 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
file : jarama.xml
auto generated : by sd2-trackeditor
version : 1.2.57
copyright : (C) 2005 by Charalampos Alexopoulos
<!--
file : jarama.xml
auto generated : by sd2-trackeditor
version : 1.3.12
copyright : (C) 2005 by Charalampos Alexopoulos
-->
<!--
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
<!--
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-->
<!DOCTYPE params SYSTEM "../../../src/libs/tgf/params.dtd" [
<!-- general definitions for tracks -->
<!ENTITY default-surfaces SYSTEM "../../../data/tracks/surfaces.xml">
<!ENTITY default-objects SYSTEM "../../../data/tracks/objects.xml">
<!-- general definitions for tracks -->
<!ENTITY default-surfaces SYSTEM "../../../data/tracks/surfaces.xml">
<!ENTITY default-objects SYSTEM "../../../data/tracks/objects.xml">
]>
<params name="jarama" type="param" mode="mw">
@ -248,7 +248,7 @@ the Free Software Foundation; either version 2 of the License, or
<section name="Objects">
&default-objects;
<section name="Tree3">
<attstr name="object" val="pc-tree3.ac" />
<attstr name="object" val="pc-tree3-src.ac" />
<attnum name="color" val="0x0015FF" />
<attstr name="orientation type" val="random" />
<attnum name="delta height" val="4.0" />
@ -258,7 +258,7 @@ the Free Software Foundation; either version 2 of the License, or
<attnum name="scale max" val="1.0" />
</section>
<section name="Tree2">
<attstr name="object" val="pc-tree2.ac" />
<attstr name="object" val="pc-tree2-src.ac" />
<attnum name="color" val="0xB36519" />
<attstr name="orientation type" val="random" />
<attnum name="delta height" val="4.0" />
@ -268,7 +268,7 @@ the Free Software Foundation; either version 2 of the License, or
<attnum name="scale max" val="0.8" />
</section>
<section name="Tree5">
<attstr name="object" val="pc-tree5.ac" />
<attstr name="object" val="pc-tree5-src.ac" />
<attnum name="color" val="0xFFF000" />
<attstr name="orientation type" val="random" />
<attnum name="delta height" val="4.0" />
@ -278,7 +278,7 @@ the Free Software Foundation; either version 2 of the License, or
<attnum name="scale max" val="0.6" />
</section>
<section name="Tree7">
<attstr name="object" val="pc-tree7.ac" />
<attstr name="object" val="pc-tree7-src.ac" />
<attnum name="color" val="0xFF00FF" />
<attstr name="orientation type" val="random" />
<attnum name="delta height" val="4.0" />
@ -288,57 +288,57 @@ the Free Software Foundation; either version 2 of the License, or
<attnum name="scale max" val="3.0" />
</section>
<section name="Arc1">
<attstr name="object" val="arc1.ac" />
<attstr name="object" val="arc1-src.ac" />
<attnum name="color" val="0x424242" />
<attstr name="orientation type" val="track" />
<attstr name="scale type" val="fixed" />
<attnum name="scale" val="1.2" />
</section>
<section name="Arc2">
<attstr name="object" val="arc2.ac" />
<attstr name="object" val="arc2-src.ac" />
<attnum name="color" val="0xF30000" />
<attstr name="orientation type" val="track" />
<attstr name="scale type" val="fixed" />
<attnum name="scale" val="0.8" />
</section>
<section name="Arc3">
<attstr name="object" val="arc3.ac" />
<attstr name="object" val="arc3-src.ac" />
<attnum name="color" val="0xB7B7B7" />
<attstr name="orientation type" val="track" />
<attstr name="scale type" val="fixed" />
<attnum name="scale" val="0.7" />
</section>
<section name="tribune02">
<attstr name="object" val="tribune02.ac" />
<attstr name="object" val="tribune02-src.ac" />
<attnum name="color" val="0x06D100" />
<attstr name="orientation type" val="track" />
<attstr name="scale type" val="fixed" />
<attnum name="scale" val="0.6" />
</section>
<section name="marshallboth">
<attstr name="object" val="marshallboth.ac" />
<attstr name="object" val="marshallboth-src.ac" />
<attnum name="color" val="0x535353" />
<attstr name="orientation type" val="track" />
<attstr name="scale type" val="fixed" />
<attnum name="scale" val="0.7" />
</section>
<section name="PoleWall_Vieringe">
<attstr name="object" val="PoleWall_Vieringe.ac" />
<attstr name="object" val="PoleWall_Vieringe-src.ac" />
<attnum name="color" val="0xFFC29B" />
<attstr name="orientation type" val="track" />
</section>
<section name="PoleWall_Furia">
<attstr name="object" val="PoleWall_Furia.ac" />
<attstr name="object" val="PoleWall_Vieringe-src.ac" />
<attnum name="color" val="0x5C62C2" />
<attstr name="orientation type" val="track" />
</section>
<section name="PoleWall_Bull-NRJ">
<attstr name="object" val="PoleWall_Bull-NRJ.ac" />
<attstr name="object" val="PoleWall_Bull-NRJ-src.ac" />
<attnum name="color" val="0xFFCC00" />
<attstr name="orientation type" val="track" />
</section>
<section name="PoleWall_OlisOil">
<attstr name="object" val="PoleWall_OlisOil.ac" />
<attstr name="object" val="PoleWall_OlisOil-src.ac" />
<attnum name="color" val="0x39B44A" />
<attstr name="orientation type" val="track" />
</section>
@ -348,47 +348,47 @@ the Free Software Foundation; either version 2 of the License, or
<attstr name="orientation type" val="track" />
</section>
<section name="Wall_Tohno">
<attstr name="object" val="Wall_Tohno.ac" />
<attstr name="object" val="Wall_Tohno-src.ac" />
<attnum name="color" val="0x0072BC" />
<attstr name="orientation type" val="track" />
</section>
<section name="Wall_Kupo">
<attstr name="object" val="Wall_Kupo.ac" />
<attstr name="object" val="Wall_Kupo-src.ac" />
<attnum name="color" val="0x8100BC" />
<attstr name="orientation type" val="track" />
</section>
<section name="Wall_Tsubashi">
<attstr name="object" val="Wall_Tsubashi.ac" />
<attstr name="object" val="Wall_Tsubashi-src.ac" />
<attnum name="color" val="0x06380C" />
<attstr name="orientation type" val="track" />
</section>
<section name="Wall_Torreon">
<attstr name="object" val="Wall_Torreon.ac" />
<attstr name="object" val="Wall_Torreon-src.ac" />
<attnum name="color" val="0xE105CA" />
<attstr name="orientation type" val="track" />
</section>
<section name="PoleWall3_Casero">
<attstr name="object" val="PoleWall3_Casero.ac" />
<attstr name="object" val="PoleWall3_Casero-src.ac" />
<attnum name="color" val="0x1C6C26" />
<attstr name="orientation type" val="track" />
</section>
<section name="ja-tower">
<attstr name="object" val="ja-tower.ac" />
<attstr name="object" val="ja-tower-src.ac" />
<attnum name="color" val="0x19C5D9" />
<attstr name="orientation type" val="track" />
</section>
<section name="Wall_Reles">
<attstr name="object" val="Wall_Reles.ac" />
<attstr name="object" val="Wall_Reles-src.ac" />
<attnum name="color" val="0x077D65" />
<attstr name="orientation type" val="track" />
</section>
<section name="PoleWall-Reles">
<attstr name="object" val="PoleWall-Reles.ac" />
<attstr name="object" val="PoleWall-Reles-src.ac" />
<attnum name="color" val="0xE2DD00" />
<attstr name="orientation type" val="track" />
</section>
<section name="Tent">
<attstr name="object" val="tent.ac" />
<attstr name="object" val="tent-src.ac" />
<attnum name="color" val="0x383837" />
<attstr name="orientation type" val="track" />
<attstr name="scale type" val="fixed" />
@ -461,7 +461,6 @@ the Free Software Foundation; either version 2 of the License, or
<attnum name="scale" val="1.1" />
</section>
</section>
<section name="Header">
<attstr name="name" val="Jarama" />
<attstr name="category" val="circuit" />
@ -470,42 +469,34 @@ the Free Software Foundation; either version 2 of the License, or
<attstr name="copyright" val="Copyleft: this work of art is free, you can redistribute it and/or modify it according to terms of the Free Art license." />
<attstr name="description" val="A historic and well-known circuit in the heart of Spain." />
</section>
<section name="Local Info">
<attstr name="station" val="LEMD" />
<attnum name="time of day" unit="hour" val="14.0" />
<attnum name="sun ascension" unit="deg" val="80"/>
<attnum name="latitude" val="40.47222222222222" />
<attnum name="longitude" val="-3.560833333333333" />
<attnum name="sun ascension" unit="deg" val="80.0" />
<attnum name="altitude" unit="m" val="610.0" />
<attnum name="climat" val="6" />
<attnum name="precipitation" val="415.0" />
<attnum name="latitude" unit="deg" val="40.47222222222222" />
<attnum name="longitude" unit="deg" val="-3.560833333333333" />
<attnum name="climat" val="6" />
<attnum name="precipitation" val="415.0" />
</section>
<section name="Graphic">
<attstr name="3d description" val="jarama.acc" />
<attstr name="3d description" val="jarama.ac" />
<attstr name="background image" val="background.png" />
<attnum name="background color R" val="0.5"/>
<attnum name="background color G" val="0.5"/>
<attnum name="background color B" val="0.55"/>
<attnum name="ambient color R" val="0.2"/>
<attnum name="ambient color G" val="0.2"/>
<attnum name="ambient color B" val="0.2"/>
<attnum name="diffuse color R" val="1"/>
<attnum name="diffuse color G" val="1"/>
<attnum name="diffuse color B" val="1"/>
<attnum name="specular color R" val="0.1"/>
<attnum name="specular color G" val="0.1"/>
<attnum name="specular color B" val="0.1"/>
<attnum name="light position x" val="4400"/>
<attnum name="light position y" val="-9000"/>
<attnum name="light position z" val="3000"/>
<attnum name="background color R" val="0.5" />
<attnum name="background color G" val="0.5" />
<attnum name="background color B" val="0.55" />
<attnum name="ambient color R" val="0.2" />
<attnum name="ambient color G" val="0.2" />
<attnum name="ambient color B" val="0.2" />
<attnum name="diffuse color R" val="1.0" />
<attnum name="diffuse color G" val="1.0" />
<attnum name="diffuse color B" val="1.0" />
<attnum name="specular color R" val="0.1" />
<attnum name="specular color G" val="0.1" />
<attnum name="specular color B" val="0.1" />
<attnum name="light position x" unit="m" val="4400.0" />
<attnum name="light position y" unit="m" val="-9000.0" />
<attnum name="light position z" unit="m" val="3000.0" />
<section name="Turn Marks">
<attnum name="width" unit="m" val="2.0" />
<attnum name="height" unit="m" val="1.0" />
@ -525,6 +516,7 @@ the Free Software Foundation; either version 2 of the License, or
<attstr name="object map" val="object-map1.png" />
</section>
</section>
<section name="Objects" />
</section>
<section name="Environment Mapping">
<section name="map 1">
@ -532,7 +524,6 @@ the Free Software Foundation; either version 2 of the License, or
</section>
</section>
</section>
<section name="Starting Grid">
<attnum name="rows" val="2" />
<attstr name="pole position side" val="right" />
@ -541,7 +532,6 @@ the Free Software Foundation; either version 2 of the License, or
<attnum name="offset within a column" unit="m" val="7.0" />
<attnum name="initial height" unit="m" val="0.2" />
</section>
<section name="Main Track">
<attnum name="width" unit="m" val="12.0" />
<attnum name="profil steps length" unit="m" val="4.0" />
@ -594,7 +584,6 @@ the Free Software Foundation; either version 2 of the License, or
<attstr name="exit" val="salida" />
<attnum name="speed limit" unit="m" val="60.0" />
</section>
<section name="Track Segments">
<!--******************************-->
<!-- Segment 1 -->

View File

@ -54,6 +54,13 @@ double Ac3d::V3d::length() const
return sqrt((*this)[0] * (*this)[0] + (*this)[1] * (*this)[1] + (*this)[2] * (*this)[2]);
}
void Ac3d::V3d::normalize()
{
const double l = length();
if (l != 0.0)
*this = *this / length();
}
double Ac3d::V3d::dot(const V3d &other) const
{
return (*this)[0] * other[0] + (*this)[1] * other[1] + (*this)[2] * other[2];
@ -692,7 +699,21 @@ void Ac3d::Object::parse(std::ifstream &fin, const std::string &objType)
{
const int numsurf = std::stoi(tokens.at(1));
for (int i = 0; i < numsurf; i++)
{
surfaces.emplace_back(fin);
Surface &surface = surfaces.back();
if (surface.isPolygon() && surface.refs.size() >= 3)
{
const V3d &p0 = vertices[surface.refs[0].index];
const V3d &p1 = vertices[surface.refs[1].index];
const V3d &p2 = vertices[surface.refs[2].index];
surface.normal = ((p1 - p0).cross(p2 - p1));
surface.normal.normalize();
}
}
}
else if (tokens.at(0) == "kids")
{
@ -918,12 +939,12 @@ void Ac3d::Object::splitBySURF()
for (std::list<Object>::iterator it = kids.begin(); it != kids.end(); ++it)
{
const Object &kid = *it;
Object &kid = *it;
std::set<int> surfTypes;
if (kid.type == "poly")
{
// get the different SURFs
std::set<int> surfTypes;
for (auto surface : kid.surfaces)
surfTypes.insert(surface.surf);
@ -952,6 +973,8 @@ void Ac3d::Object::splitBySURF()
it = last;
}
}
else
kid.splitBySURF();
}
}
@ -962,12 +985,12 @@ void Ac3d::Object::splitByMaterial()
for (std::list<Object>::iterator it = kids.begin(); it != kids.end(); ++it)
{
const Object &kid = *it;
Object &kid = *it;
std::set<int> materialTypes;
if (kid.type == "poly")
{
// get the different SURFs
std::set<int> materialTypes;
for (auto surface : kid.surfaces)
materialTypes.insert(surface.surf);
@ -996,6 +1019,41 @@ void Ac3d::Object::splitByMaterial()
it = last;
}
}
else
kid.splitByMaterial();
}
}
void Ac3d::Object::splitByUV()
{
if (type == "poly")
return;
for (std::list<Object>::iterator it = kids.begin(); it != kids.end(); ++it)
{
Object &kid = *it;
if (kid.type == "poly")
{
bool needSplit = false;
std::vector<std::set<V2d>> uvs(vertices.size());
for (const auto &surface : surfaces)
{
for (const auto &ref : surface.refs)
{
uvs[ref.index].insert(ref.coords[0]);
if (uvs[ref.index].size() > 1)
needSplit = true;
}
}
if (needSplit)
{
// TODO
}
}
else
kid.splitByUV();
}
}
@ -1397,3 +1455,8 @@ void Ac3d::splitByMaterial()
{
root.splitByMaterial();
}
void Ac3d::splitByUV()
{
root.splitByUV();
}

View File

@ -72,6 +72,7 @@ struct Ac3d
double dot(const V3d &other) const;
V3d cross(const V3d &other) const;
double length() const;
void normalize();
};
struct Color : public std::array<double, 3>
@ -165,6 +166,7 @@ struct Ac3d
SURF surf = PolygonSingleSidedFlat;
int mat = 0;
std::vector<Ref> refs;
V3d normal = { 0, 0, 0 };
Surface() = default;
explicit Surface(std::ifstream &fin);
@ -285,6 +287,7 @@ struct Ac3d
void flipAxes(bool in);
void splitBySURF();
void splitByMaterial();
void splitByUV();
void removeSurfacesNotSURF(int SURF);
void removeSurfacesNotMaterial(int material);
void removeUnusedVertices();
@ -312,6 +315,7 @@ struct Ac3d
void generateTriangles();
void splitBySURF();
void splitByMaterial();
void splitByUV();
void merge(const Ac3d &ac3d, bool mergeMaterials);
double getTerrainHeight(double x, double y) const;
double getTerrainAngle(double x, double y) const;

View File

@ -98,7 +98,7 @@ public:
//! Constructor.
Application::Application()
: GfApplication("TrackGen", "1.6.0.32", "Terrain generator for tracks")
: GfApplication("TrackGen", "1.6.0.33", "Terrain generator for tracks")
, HeightSteps(30)
, Bump(false)
, Raceline(false)

View File

@ -297,6 +297,7 @@ AddObject(tTrack *track, void *trackHandle, const Ac3d &terrainRoot, const Ac3d
obj.transform(m);
obj.splitBySURF();
obj.splitByMaterial();
obj.splitByUV();
objectsRoot.merge(obj, multipleMaterials);