|
|
@@ -13,7 +13,7 @@ using namespace Framework;
|
|
|
Model2DData::Model2DData()
|
|
|
: ReferenceCounter(),
|
|
|
polygons(0),
|
|
|
- vListen(0),
|
|
|
+ vLists(0),
|
|
|
minP(0, 0),
|
|
|
maxP(0, 0)
|
|
|
{}
|
|
|
@@ -27,15 +27,15 @@ Model2DData::~Model2DData()
|
|
|
for (int i = 0; i < anz; i++)
|
|
|
{
|
|
|
if (polygons->get(i).name) polygons->get(i).name->release();
|
|
|
- if (polygons->get(i).tKordinaten)
|
|
|
- polygons->get(i).tKordinaten->release();
|
|
|
+ if (polygons->get(i).tCoordinates)
|
|
|
+ polygons->get(i).tCoordinates->release();
|
|
|
if (polygons->get(i).vertex) polygons->get(i).vertex->release();
|
|
|
- if (polygons->get(i).schwerpunkt)
|
|
|
- delete polygons->get(i).schwerpunkt;
|
|
|
+ if (polygons->get(i).center)
|
|
|
+ delete polygons->get(i).center;
|
|
|
}
|
|
|
polygons = (Array<Polygon2D>*)polygons->release();
|
|
|
}
|
|
|
- if (vListen) vListen->release();
|
|
|
+ if (vLists) vLists->release();
|
|
|
}
|
|
|
|
|
|
// privat
|
|
|
@@ -138,28 +138,28 @@ bool Model2DData::isLineInside(Vertex a, Vertex b, int polygonId) const
|
|
|
}
|
|
|
|
|
|
// non-constant
|
|
|
-bool Model2DData::erstelleModell(Array<Polygon2D>* polygons)
|
|
|
+bool Model2DData::createModell(Array<Polygon2D>* polygons)
|
|
|
{
|
|
|
removeModell();
|
|
|
if (!polygons || !polygons->getEntryCount())
|
|
|
{
|
|
|
this->polygons = polygons;
|
|
|
- vListen = new RCArray<RCArray<TriangleList<Vertex>>>();
|
|
|
+ vLists = new RCArray<RCArray<TriangleList<Vertex>>>();
|
|
|
return 1;
|
|
|
}
|
|
|
this->polygons = polygons;
|
|
|
int pAnz = polygons->getEntryCount();
|
|
|
- vListen = new RCArray<RCArray<TriangleList<Vertex>>>();
|
|
|
+ vLists = new RCArray<RCArray<TriangleList<Vertex>>>();
|
|
|
for (int p = 0; p < pAnz; p++)
|
|
|
{
|
|
|
Polygon2D pg = polygons->get(p);
|
|
|
if (!pg.vertex || pg.vertex->getEntryCount() < 3) continue;
|
|
|
- vListen->add(new RCArray<TriangleList<Vertex>>());
|
|
|
+ vLists->add(new RCArray<TriangleList<Vertex>>());
|
|
|
outList.add(new Array<Point>);
|
|
|
int vAnz = pg.vertex->getEntryCount();
|
|
|
- bool textur = pg.tKordinaten != 0;
|
|
|
+ bool textur = pg.tCoordinates != 0;
|
|
|
for (int i = 0; i < vAnz && textur; i++)
|
|
|
- textur &= pg.tKordinaten->has(i);
|
|
|
+ textur &= pg.tCoordinates->has(i);
|
|
|
for (int i = 0; i < vAnz; i++)
|
|
|
{
|
|
|
if ((float)maxP.x < fabs(pg.vertex->get(i).x))
|
|
|
@@ -176,7 +176,7 @@ bool Model2DData::erstelleModell(Array<Polygon2D>* polygons)
|
|
|
minP = -maxP;
|
|
|
if (!textur)
|
|
|
{
|
|
|
- if (pg.tKordinaten) pg.tKordinaten->clear();
|
|
|
+ if (pg.tCoordinates) pg.tCoordinates->clear();
|
|
|
}
|
|
|
RCArray<RCArray<TriangleList<Vertex>>> lists;
|
|
|
int lauf = 0;
|
|
|
@@ -226,9 +226,9 @@ bool Model2DData::erstelleModell(Array<Polygon2D>* polygons)
|
|
|
TriangleList<Vertex>* lowL = new TriangleList<Vertex>();
|
|
|
TriangleList<Vertex>* heightL = new TriangleList<Vertex>();
|
|
|
lowL->addPoint(new Vertex(pg.vertex->get(i)),
|
|
|
- textur ? new Vertex(pg.tKordinaten->get(i)) : 0);
|
|
|
+ textur ? new Vertex(pg.tCoordinates->get(i)) : 0);
|
|
|
heightL->addPoint(new Vertex(pg.vertex->get(i)),
|
|
|
- textur ? new Vertex(pg.tKordinaten->get(i)) : 0);
|
|
|
+ textur ? new Vertex(pg.tCoordinates->get(i)) : 0);
|
|
|
int height = i + 1;
|
|
|
int low = i - 1;
|
|
|
Point outL(0, 0);
|
|
|
@@ -265,12 +265,12 @@ bool Model2DData::erstelleModell(Array<Polygon2D>* polygons)
|
|
|
if (!k)
|
|
|
lowL->addPoint(new Vertex(b),
|
|
|
textur ? new Vertex(
|
|
|
- pg.tKordinaten->get(low))
|
|
|
+ pg.tCoordinates->get(low))
|
|
|
: 0);
|
|
|
else
|
|
|
heightL->addPoint(new Vertex(b),
|
|
|
textur ? new Vertex(
|
|
|
- pg.tKordinaten->get(low))
|
|
|
+ pg.tCoordinates->get(low))
|
|
|
: 0);
|
|
|
break;
|
|
|
}
|
|
|
@@ -288,12 +288,12 @@ bool Model2DData::erstelleModell(Array<Polygon2D>* polygons)
|
|
|
if (!k)
|
|
|
lowL->addPoint(new Vertex(b),
|
|
|
textur ? new Vertex(
|
|
|
- pg.tKordinaten->get(low))
|
|
|
+ pg.tCoordinates->get(low))
|
|
|
: 0);
|
|
|
else
|
|
|
heightL->addPoint(new Vertex(b),
|
|
|
textur ? new Vertex(
|
|
|
- pg.tKordinaten->get(low))
|
|
|
+ pg.tCoordinates->get(low))
|
|
|
: 0);
|
|
|
low--;
|
|
|
}
|
|
|
@@ -301,12 +301,12 @@ bool Model2DData::erstelleModell(Array<Polygon2D>* polygons)
|
|
|
{
|
|
|
if (!k)
|
|
|
lowL->addPoint(new Vertex(a),
|
|
|
- textur ? new Vertex(pg.tKordinaten->get(
|
|
|
+ textur ? new Vertex(pg.tCoordinates->get(
|
|
|
height))
|
|
|
: 0);
|
|
|
else
|
|
|
heightL->addPoint(new Vertex(a),
|
|
|
- textur ? new Vertex(pg.tKordinaten->get(
|
|
|
+ textur ? new Vertex(pg.tCoordinates->get(
|
|
|
height))
|
|
|
: 0);
|
|
|
height++;
|
|
|
@@ -351,7 +351,7 @@ bool Model2DData::erstelleModell(Array<Polygon2D>* polygons)
|
|
|
}
|
|
|
}
|
|
|
if (!max || maxP < 0) break;
|
|
|
- vListen->z(p)->add(lists.z(lauf)->get(maxP));
|
|
|
+ vLists->z(p)->add(lists.z(lauf)->get(maxP));
|
|
|
outList.z(p)->set(tmpOutList.get(maxP), lauf);
|
|
|
if (fertig) break;
|
|
|
lauf++;
|
|
|
@@ -369,16 +369,16 @@ void Model2DData::removeModell() // resets the vertex data
|
|
|
for (int i = 0; i < anz; i++)
|
|
|
{
|
|
|
if (polygons->get(i).name) polygons->get(i).name->release();
|
|
|
- if (polygons->get(i).tKordinaten)
|
|
|
- polygons->get(i).tKordinaten->release();
|
|
|
+ if (polygons->get(i).tCoordinates)
|
|
|
+ polygons->get(i).tCoordinates->release();
|
|
|
if (polygons->get(i).vertex) polygons->get(i).vertex->release();
|
|
|
- if (polygons->get(i).schwerpunkt)
|
|
|
- delete polygons->get(i).schwerpunkt;
|
|
|
+ if (polygons->get(i).center)
|
|
|
+ delete polygons->get(i).center;
|
|
|
}
|
|
|
polygons = (Array<Polygon2D>*)polygons->release();
|
|
|
}
|
|
|
- if (vListen)
|
|
|
- vListen = (RCArray<RCArray<TriangleList<Vertex>>>*)vListen->release();
|
|
|
+ if (vLists)
|
|
|
+ vLists = (RCArray<RCArray<TriangleList<Vertex>>>*)vLists->release();
|
|
|
outList.clear();
|
|
|
minP = Point(0, 0);
|
|
|
maxP = Point(0, 0);
|
|
|
@@ -432,13 +432,13 @@ bool Model2DData::calcHitPoint(Vertex pos,
|
|
|
Vertex kNorm = Vertex(dir).normalize();
|
|
|
moveSpeed = normal * (normal * kNorm) * dir.getLength();
|
|
|
normal
|
|
|
- = (point - *polygon.schwerpunkt).CW90().normalize();
|
|
|
+ = (point - *polygon.center).CW90().normalize();
|
|
|
Vertex rotKraft
|
|
|
= normal * (normal * kNorm) * dir.getLength();
|
|
|
rotSpeed
|
|
|
= ((float)sqrt(
|
|
|
rotKraft.getLength()
|
|
|
- * (point - *polygon.schwerpunkt).getLength())
|
|
|
+ * (point - *polygon.center).getLength())
|
|
|
/ 180.f)
|
|
|
* 3.14f * (normal * kNorm);
|
|
|
hitpoint = point;
|
|
|
@@ -488,8 +488,8 @@ bool Model2DData::split(Vertex pos,
|
|
|
if ((txtChpPix.x == 0 || txtChpPix.y == 0) && b.x != 0
|
|
|
&& b.y != 0)
|
|
|
{
|
|
|
- Vertex ta = polygon.tKordinaten->get(i);
|
|
|
- Vertex tb = polygon.tKordinaten->get((i + 1) % anz);
|
|
|
+ Vertex ta = polygon.tCoordinates->get(i);
|
|
|
+ Vertex tb = polygon.tCoordinates->get((i + 1) % anz);
|
|
|
tb -= ta;
|
|
|
txtChpPix = Vertex(tb.x / b.x, tb.y / b.y);
|
|
|
}
|
|
|
@@ -512,9 +512,9 @@ bool Model2DData::split(Vertex pos,
|
|
|
leftI = i;
|
|
|
rightI = (i + 1) % anz;
|
|
|
startPoint = point;
|
|
|
- texturSP = polygon.tKordinaten->get(i)
|
|
|
- + (polygon.tKordinaten->get((i + 1) % anz)
|
|
|
- - polygon.tKordinaten->get(i))
|
|
|
+ texturSP = polygon.tCoordinates->get(i)
|
|
|
+ + (polygon.tCoordinates->get((i + 1) % anz)
|
|
|
+ - polygon.tCoordinates->get(i))
|
|
|
* offset;
|
|
|
}
|
|
|
ret = 1;
|
|
|
@@ -523,21 +523,21 @@ bool Model2DData::split(Vertex pos,
|
|
|
if (ret)
|
|
|
{
|
|
|
partA.transparent = polygon.transparent;
|
|
|
- partA.schwerpunkt = new Vertex(0, 0);
|
|
|
- partA.tKordinaten = new Array<Vertex>();
|
|
|
+ partA.center = new Vertex(0, 0);
|
|
|
+ partA.tCoordinates = new Array<Vertex>();
|
|
|
partA.name = new Text(polygon.name->getText());
|
|
|
partA.vertex = new Array<Vertex>();
|
|
|
partB.transparent = polygon.transparent;
|
|
|
- partB.schwerpunkt = new Vertex(0, 0);
|
|
|
- partB.tKordinaten = new Array<Vertex>();
|
|
|
+ partB.center = new Vertex(0, 0);
|
|
|
+ partB.tCoordinates = new Array<Vertex>();
|
|
|
partB.name = new Text(polygon.name->getText());
|
|
|
partB.vertex = new Array<Vertex>();
|
|
|
- *partA.schwerpunkt += startPoint;
|
|
|
- *partB.schwerpunkt += startPoint;
|
|
|
+ *partA.center += startPoint;
|
|
|
+ *partB.center += startPoint;
|
|
|
partA.vertex->add(startPoint);
|
|
|
partB.vertex->add(startPoint);
|
|
|
- partA.tKordinaten->add(texturSP);
|
|
|
- partB.tKordinaten->add(texturSP);
|
|
|
+ partA.tCoordinates->add(texturSP);
|
|
|
+ partB.tCoordinates->add(texturSP);
|
|
|
int leftIE = 0;
|
|
|
int rightIE = 0;
|
|
|
while (1)
|
|
|
@@ -596,9 +596,9 @@ bool Model2DData::split(Vertex pos,
|
|
|
rightIE = (i + 1) % anz;
|
|
|
startPoint = point;
|
|
|
texturSP
|
|
|
- = polygon.tKordinaten->get(i)
|
|
|
- + (polygon.tKordinaten->get((i + 1) % anz)
|
|
|
- - polygon.tKordinaten->get(i))
|
|
|
+ = polygon.tCoordinates->get(i)
|
|
|
+ + (polygon.tCoordinates->get((i + 1) % anz)
|
|
|
+ - polygon.tCoordinates->get(i))
|
|
|
* offset1;
|
|
|
}
|
|
|
ret = 1;
|
|
|
@@ -612,63 +612,63 @@ bool Model2DData::split(Vertex pos,
|
|
|
leftIE = bestI;
|
|
|
rightIE = (bestI + 1) % anz;
|
|
|
startPoint = a + (b * bo1);
|
|
|
- texturSP = polygon.tKordinaten->get(bestI)
|
|
|
- + (polygon.tKordinaten->get((bestI + 1) % anz)
|
|
|
- - polygon.tKordinaten->get(bestI))
|
|
|
+ texturSP = polygon.tCoordinates->get(bestI)
|
|
|
+ + (polygon.tCoordinates->get((bestI + 1) % anz)
|
|
|
+ - polygon.tCoordinates->get(bestI))
|
|
|
* bo1;
|
|
|
ret = 1;
|
|
|
}
|
|
|
if (ret) break;
|
|
|
- *partA.schwerpunkt += next;
|
|
|
- *partB.schwerpunkt += next;
|
|
|
+ *partA.center += next;
|
|
|
+ *partB.center += next;
|
|
|
partA.vertex->add(next);
|
|
|
partB.vertex->add(next);
|
|
|
- partA.tKordinaten->add(nextT);
|
|
|
- partB.tKordinaten->add(nextT);
|
|
|
+ partA.tCoordinates->add(nextT);
|
|
|
+ partB.tCoordinates->add(nextT);
|
|
|
startPoint = next;
|
|
|
texturSP = nextT;
|
|
|
dir = originalDir.rotation((float)(random() - 0.5));
|
|
|
}
|
|
|
- *partA.schwerpunkt += startPoint;
|
|
|
- *partB.schwerpunkt += startPoint;
|
|
|
+ *partA.center += startPoint;
|
|
|
+ *partB.center += startPoint;
|
|
|
partA.vertex->add(startPoint);
|
|
|
partB.vertex->add(startPoint);
|
|
|
- partA.tKordinaten->add(texturSP);
|
|
|
- partB.tKordinaten->add(texturSP);
|
|
|
+ partA.tCoordinates->add(texturSP);
|
|
|
+ partB.tCoordinates->add(texturSP);
|
|
|
for (int i = rightIE; i != leftI; i++)
|
|
|
{
|
|
|
i = i % anz;
|
|
|
if (i == leftI) break;
|
|
|
- *partA.schwerpunkt += polygon.vertex->get(i);
|
|
|
+ *partA.center += polygon.vertex->get(i);
|
|
|
partA.vertex->add(polygon.vertex->get(i));
|
|
|
- partA.tKordinaten->add(polygon.tKordinaten->get(i));
|
|
|
+ partA.tCoordinates->add(polygon.tCoordinates->get(i));
|
|
|
}
|
|
|
- *partA.schwerpunkt += polygon.vertex->get(leftI);
|
|
|
+ *partA.center += polygon.vertex->get(leftI);
|
|
|
partA.vertex->add(polygon.vertex->get(leftI));
|
|
|
- partA.tKordinaten->add(polygon.tKordinaten->get(leftI));
|
|
|
+ partA.tCoordinates->add(polygon.tCoordinates->get(leftI));
|
|
|
for (int i = leftIE; i != rightI; i--)
|
|
|
{
|
|
|
if (i < 0) i += anz;
|
|
|
if (i == rightI) break;
|
|
|
- *partB.schwerpunkt += polygon.vertex->get(i);
|
|
|
+ *partB.center += polygon.vertex->get(i);
|
|
|
partB.vertex->add(polygon.vertex->get(i));
|
|
|
- partB.tKordinaten->add(polygon.tKordinaten->get(i));
|
|
|
+ partB.tCoordinates->add(polygon.tCoordinates->get(i));
|
|
|
}
|
|
|
- *partB.schwerpunkt += polygon.vertex->get(rightI);
|
|
|
+ *partB.center += polygon.vertex->get(rightI);
|
|
|
partB.vertex->add(polygon.vertex->get(rightI));
|
|
|
- partB.tKordinaten->add(polygon.tKordinaten->get(rightI));
|
|
|
- *partA.schwerpunkt /= (float)partA.vertex->getEntryCount();
|
|
|
- *partB.schwerpunkt /= (float)partB.vertex->getEntryCount();
|
|
|
- posA = (Point)*partA.schwerpunkt;
|
|
|
- posB = (Point)*partB.schwerpunkt;
|
|
|
+ partB.tCoordinates->add(polygon.tCoordinates->get(rightI));
|
|
|
+ *partA.center /= (float)partA.vertex->getEntryCount();
|
|
|
+ *partB.center /= (float)partB.vertex->getEntryCount();
|
|
|
+ posA = (Point)*partA.center;
|
|
|
+ posB = (Point)*partB.center;
|
|
|
for (int i = 0; i < partA.vertex->getEntryCount(); i++)
|
|
|
partA.vertex->set(
|
|
|
- partA.vertex->get(i) - *partA.schwerpunkt, i);
|
|
|
+ partA.vertex->get(i) - *partA.center, i);
|
|
|
for (int i = 0; i < partB.vertex->getEntryCount(); i++)
|
|
|
partB.vertex->set(
|
|
|
- partB.vertex->get(i) - *partB.schwerpunkt, i);
|
|
|
- *partA.schwerpunkt = Vertex(0, 0);
|
|
|
- *partB.schwerpunkt = Vertex(0, 0);
|
|
|
+ partB.vertex->get(i) - *partB.center, i);
|
|
|
+ *partA.center = Vertex(0, 0);
|
|
|
+ *partB.center = Vertex(0, 0);
|
|
|
}
|
|
|
}
|
|
|
num++;
|
|
|
@@ -704,14 +704,14 @@ Model2DObject::Model2DObject()
|
|
|
: Object2D()
|
|
|
{
|
|
|
rData = 0;
|
|
|
- textur = new RCArray<Texture2D>();
|
|
|
+ texture = new RCArray<Texture2D>();
|
|
|
}
|
|
|
|
|
|
// Destructor
|
|
|
Model2DObject::~Model2DObject()
|
|
|
{
|
|
|
if (rData) rData->release();
|
|
|
- textur->release();
|
|
|
+ texture->release();
|
|
|
}
|
|
|
|
|
|
// non-constant
|
|
|
@@ -725,9 +725,9 @@ void Model2DObject::setTexture(Texture2D* t)
|
|
|
{
|
|
|
if (rData)
|
|
|
{
|
|
|
- textur->clear();
|
|
|
+ texture->clear();
|
|
|
for (int i = 0; i < rData->polygons->getEntryCount(); i++)
|
|
|
- textur->add(dynamic_cast<Texture2D*>(t->getThis()));
|
|
|
+ texture->add(dynamic_cast<Texture2D*>(t->getThis()));
|
|
|
}
|
|
|
t->release();
|
|
|
}
|
|
|
@@ -776,7 +776,7 @@ void Model2DObject::setTexture(Texture2D* t, const char* polygonName)
|
|
|
for (const Polygon2D& i : *rData->polygons)
|
|
|
{
|
|
|
if (i.name->isEqual(polygonName))
|
|
|
- textur->set(dynamic_cast<Texture2D*>(t->getThis()), index);
|
|
|
+ texture->set(dynamic_cast<Texture2D*>(t->getThis()), index);
|
|
|
index++;
|
|
|
}
|
|
|
t->release();
|
|
|
@@ -785,33 +785,33 @@ void Model2DObject::setTexture(Texture2D* t, const char* polygonName)
|
|
|
void Model2DObject::render(
|
|
|
Mat3<float>& kamMat, Image& zRObj, const char* kamName)
|
|
|
{
|
|
|
- if (!rData || !rData->polygons || !textur) return;
|
|
|
+ if (!rData || !rData->polygons || !texture) return;
|
|
|
int num = 0;
|
|
|
- for (auto p : *rData->vListen)
|
|
|
+ for (auto p : *rData->vLists)
|
|
|
{
|
|
|
Mat3<float> mat = kamMat * getObjectMatrix();
|
|
|
- if (textur->has(num))
|
|
|
+ if (texture->has(num))
|
|
|
{
|
|
|
- Image* txt = textur->z(num)->zTexture();
|
|
|
+ Image* txt = texture->z(num)->zTexture();
|
|
|
for (auto i = p->begin(); i && txt; i++)
|
|
|
{
|
|
|
for (auto j = i->zListe()->begin();
|
|
|
j.hasNext() && j.next().hasNext();
|
|
|
j++)
|
|
|
{
|
|
|
- Vertex a = mat * *j->punkt;
|
|
|
- Vertex b = mat * *j.next()->punkt;
|
|
|
- Vertex c = mat * *j.next().next()->punkt;
|
|
|
+ Vertex a = mat * *j->point;
|
|
|
+ Vertex b = mat * *j.next()->point;
|
|
|
+ Vertex c = mat * *j.next().next()->point;
|
|
|
Point ta = (Point)Vertex(
|
|
|
- j->textur->x * (float)(txt->getWidth() - 1),
|
|
|
- j->textur->y * (float)(txt->getHeight() - 1));
|
|
|
+ j->texture->x * (float)(txt->getWidth() - 1),
|
|
|
+ j->texture->y * (float)(txt->getHeight() - 1));
|
|
|
Point tb = (Point)Vertex(
|
|
|
- j.next()->textur->x * (float)(txt->getWidth() - 1),
|
|
|
- j.next()->textur->y * (float)(txt->getHeight() - 1));
|
|
|
+ j.next()->texture->x * (float)(txt->getWidth() - 1),
|
|
|
+ j.next()->texture->y * (float)(txt->getHeight() - 1));
|
|
|
Point tc
|
|
|
- = (Point)Vertex(j.next().next()->textur->x
|
|
|
+ = (Point)Vertex(j.next().next()->texture->x
|
|
|
* (float)(txt->getWidth() - 1),
|
|
|
- j.next().next()->textur->y
|
|
|
+ j.next().next()->texture->y
|
|
|
* (float)(txt->getHeight() - 1));
|
|
|
zRObj.drawTriangleTextureAlpha(a, b, c, ta, tb, tc, *txt);
|
|
|
}
|
|
|
@@ -829,9 +829,9 @@ void Model2DObject::render(
|
|
|
for( auto *j = &i->var->zListe()->getArray(); j->next->next &&
|
|
|
j->next->next->set; j = j->next )
|
|
|
{
|
|
|
- Vertex a = mat * *j->var->punkt;
|
|
|
- Vertex b = mat * *j->next->var->punkt;
|
|
|
- Vertex c = mat * *j->next->next->var->punkt;
|
|
|
+ Vertex a = mat * *j->var->point;
|
|
|
+ Vertex b = mat * *j->next->var->point;
|
|
|
+ Vertex c = mat * *j->next->next->var->point;
|
|
|
zRObj.drawLine( a, b, 0xFFFFFFFF );
|
|
|
zRObj.drawLine( a, c, 0xFFFFFFFF );
|
|
|
zRObj.drawLine( b, c, 0xFFFFFFFF );
|
|
|
@@ -983,13 +983,13 @@ bool Model2DObject::calcHitPoint(Vertex pos, Vertex dir, Vertex& hitpoint) const
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-float Model2DObject::getLuftWiederstand() const
|
|
|
+float Model2DObject::getAirResistance() const
|
|
|
{
|
|
|
if (!rData) return 0;
|
|
|
float angle = speed.angle(Vertex(1, 0));
|
|
|
float faktor = -1;
|
|
|
- if (getDrehung() > PI) faktor = -faktor;
|
|
|
- if (getDrehung() < -PI) faktor = -faktor;
|
|
|
+ if (getRotation() > PI) faktor = -faktor;
|
|
|
+ if (getRotation() < -PI) faktor = -faktor;
|
|
|
Mat3<float> m = Mat3<float>::rotation(rotation + faktor * angle)
|
|
|
* Mat3<float>::scaling(size);
|
|
|
float yMin = INFINITY;
|
|
|
@@ -1011,7 +1011,7 @@ float Model2DObject::getLuftWiederstand() const
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-float Model2DObject::getMasse() const
|
|
|
+float Model2DObject::getMass() const
|
|
|
{
|
|
|
if (!rData) return 0;
|
|
|
return abs(rData->getMasse() * size * size);
|
|
|
@@ -1020,7 +1020,7 @@ float Model2DObject::getMasse() const
|
|
|
// Returns the texture of the first polygon
|
|
|
Texture2D* Model2DObject::getTexture() const
|
|
|
{
|
|
|
- return textur->get(0);
|
|
|
+ return texture->get(0);
|
|
|
}
|
|
|
|
|
|
// Returns the texture of a polygon
|
|
|
@@ -1030,7 +1030,7 @@ Texture2D* Model2DObject::getTexture(const char* polygonName) const
|
|
|
int index = 0;
|
|
|
for (const Polygon2D& p : *rData->polygons)
|
|
|
{
|
|
|
- if (p.name->isEqual(polygonName)) return textur->get(index);
|
|
|
+ if (p.name->isEqual(polygonName)) return texture->get(index);
|
|
|
index++;
|
|
|
}
|
|
|
return 0;
|
|
|
@@ -1039,7 +1039,7 @@ Texture2D* Model2DObject::getTexture(const char* polygonName) const
|
|
|
// Returns the texture of the first polygon without increased reference counter
|
|
|
Texture2D* Model2DObject::zTexture() const
|
|
|
{
|
|
|
- return textur->z(0);
|
|
|
+ return texture->z(0);
|
|
|
}
|
|
|
|
|
|
// Returns the texture of a polygon without increased reference counter
|
|
|
@@ -1049,7 +1049,7 @@ Texture2D* Model2DObject::zTexture(const char* polygonName) const
|
|
|
int index = 0;
|
|
|
for (const Polygon2D& p : *rData->polygons)
|
|
|
{
|
|
|
- if (p.name->isEqual(polygonName)) return textur->z(index);
|
|
|
+ if (p.name->isEqual(polygonName)) return texture->z(index);
|
|
|
index++;
|
|
|
}
|
|
|
return 0;
|
|
|
@@ -1073,7 +1073,7 @@ Model2D::Model2D()
|
|
|
color = 0;
|
|
|
style = 0;
|
|
|
rData = 0;
|
|
|
- drehung = 0;
|
|
|
+ rotation = 0;
|
|
|
size = 1;
|
|
|
textur = new RCArray<Texture2D>;
|
|
|
}
|
|
|
@@ -1092,23 +1092,23 @@ void Model2D::setModel(Model2DData* mdl)
|
|
|
rData = mdl;
|
|
|
}
|
|
|
|
|
|
-void Model2D::setDrehung(float drehung)
|
|
|
+void Model2D::setRotation(float rotation)
|
|
|
{
|
|
|
- this->drehung = drehung;
|
|
|
- while (this->drehung > PI * 2)
|
|
|
- this->drehung -= (float)PI * 2;
|
|
|
- while (this->drehung < 0)
|
|
|
- this->drehung += (float)PI * 2;
|
|
|
+ this->rotation = rotation;
|
|
|
+ while (this->rotation > PI * 2)
|
|
|
+ this->rotation -= (float)PI * 2;
|
|
|
+ while (this->rotation < 0)
|
|
|
+ this->rotation += (float)PI * 2;
|
|
|
rend = 1;
|
|
|
}
|
|
|
|
|
|
-void Model2D::addDrehung(float drehung)
|
|
|
+void Model2D::addRotation(float rotation)
|
|
|
{
|
|
|
- this->drehung += drehung;
|
|
|
- while (this->drehung > PI * 2)
|
|
|
- this->drehung -= (float)PI * 2;
|
|
|
- while (this->drehung < 0)
|
|
|
- this->drehung += (float)PI * 2;
|
|
|
+ this->rotation += rotation;
|
|
|
+ while (this->rotation > PI * 2)
|
|
|
+ this->rotation -= (float)PI * 2;
|
|
|
+ while (this->rotation < 0)
|
|
|
+ this->rotation += (float)PI * 2;
|
|
|
rend = 1;
|
|
|
}
|
|
|
|
|
|
@@ -1163,15 +1163,15 @@ void Model2D::render(Image& zRObj)
|
|
|
return;
|
|
|
Drawable::render(zRObj);
|
|
|
int num = 0;
|
|
|
- for (auto p : *rData->vListen)
|
|
|
+ for (auto p : *rData->vLists)
|
|
|
{
|
|
|
Mat3<float> mat = Mat3<float>::translation(pos)
|
|
|
- * Mat3<float>::rotation(drehung)
|
|
|
+ * Mat3<float>::rotation(rotation)
|
|
|
* Mat3<float>::scaling(size);
|
|
|
if (hasStyle(Model2D::Style::Texture))
|
|
|
{
|
|
|
if (!textur || !textur->z(num) || !textur->z(num)->zTexture()
|
|
|
- || !rData->polygons->get(num).tKordinaten)
|
|
|
+ || !rData->polygons->get(num).tCoordinates)
|
|
|
{
|
|
|
for (auto i : *p)
|
|
|
{
|
|
|
@@ -1179,9 +1179,9 @@ void Model2D::render(Image& zRObj)
|
|
|
j.hasNext() && j.next().hasNext();
|
|
|
j++)
|
|
|
{
|
|
|
- Vertex a = mat * *j->punkt;
|
|
|
- Vertex b = mat * *j.next()->punkt;
|
|
|
- Vertex c = mat * *j.next().next()->punkt;
|
|
|
+ Vertex a = mat * *j->point;
|
|
|
+ Vertex b = mat * *j.next()->point;
|
|
|
+ Vertex c = mat * *j.next().next()->point;
|
|
|
if (hasStyle(Model2D::Style::Alpha))
|
|
|
zRObj.drawTriangleAlpha(a, b, c, color);
|
|
|
else
|
|
|
@@ -1198,20 +1198,20 @@ void Model2D::render(Image& zRObj)
|
|
|
j.hasNext() && j.next().hasNext();
|
|
|
j++)
|
|
|
{
|
|
|
- Vertex a = mat * *j->punkt;
|
|
|
- Vertex b = mat * *j.next()->punkt;
|
|
|
- Vertex c = mat * *j.next().next()->punkt;
|
|
|
+ Vertex a = mat * *j->point;
|
|
|
+ Vertex b = mat * *j.next()->point;
|
|
|
+ Vertex c = mat * *j.next().next()->point;
|
|
|
Point ta = (Point)Vertex(
|
|
|
- j->textur->x * (float)(txt->getWidth() - 1),
|
|
|
- j->textur->y * (float)(txt->getHeight() - 1));
|
|
|
+ j->texture->x * (float)(txt->getWidth() - 1),
|
|
|
+ j->texture->y * (float)(txt->getHeight() - 1));
|
|
|
Point tb = (Point)Vertex(
|
|
|
- j.next()->textur->x * (float)(txt->getWidth() - 1),
|
|
|
- j.next()->textur->y
|
|
|
+ j.next()->texture->x * (float)(txt->getWidth() - 1),
|
|
|
+ j.next()->texture->y
|
|
|
* (float)(txt->getHeight() - 1));
|
|
|
Point tc
|
|
|
- = (Point)Vertex(j.next().next()->textur->x
|
|
|
+ = (Point)Vertex(j.next().next()->texture->x
|
|
|
* (float)(txt->getWidth() - 1),
|
|
|
- j.next().next()->textur->y
|
|
|
+ j.next().next()->texture->y
|
|
|
* (float)(txt->getHeight() - 1));
|
|
|
if (hasStyle(Model2D::Style::Alpha))
|
|
|
zRObj.drawTriangleTextureAlpha(
|
|
|
@@ -1230,9 +1230,9 @@ void Model2D::render(Image& zRObj)
|
|
|
j.hasNext() && j.next().hasNext();
|
|
|
j++)
|
|
|
{
|
|
|
- Vertex a = mat * *j->punkt;
|
|
|
- Vertex b = mat * *j.next()->punkt;
|
|
|
- Vertex c = mat * *j.next().next()->punkt;
|
|
|
+ Vertex a = mat * *j->point;
|
|
|
+ Vertex b = mat * *j.next()->point;
|
|
|
+ Vertex c = mat * *j.next().next()->point;
|
|
|
if (hasStyle(Model2D::Style::Alpha))
|
|
|
{
|
|
|
zRObj.drawLineAlpha(a, b, color);
|
|
|
@@ -1277,9 +1277,9 @@ void Model2D::render(Image& zRObj)
|
|
|
}
|
|
|
|
|
|
// constant
|
|
|
-float Model2D::getDrehung() const
|
|
|
+float Model2D::getRotation() const
|
|
|
{
|
|
|
- return drehung;
|
|
|
+ return rotation;
|
|
|
}
|
|
|
|
|
|
float Model2D::getSize() const
|
|
|
@@ -1305,7 +1305,7 @@ bool Model2D::isPointInside(Vertex p) const
|
|
|
{
|
|
|
if (polygon.transparent) continue;
|
|
|
Mat3<float> mat
|
|
|
- = Mat3<float>::rotation(drehung) * Mat3<float>::scaling(size);
|
|
|
+ = Mat3<float>::rotation(rotation) * Mat3<float>::scaling(size);
|
|
|
int anz = polygon.vertex->getEntryCount();
|
|
|
bool c = 0;
|
|
|
int j = anz - 1;
|
|
|
@@ -1332,7 +1332,7 @@ bool Model2D::isLineInside(Vertex a, Vertex b) const
|
|
|
{
|
|
|
if (rData->polygons->get(p).transparent) continue;
|
|
|
Mat3<float> mat
|
|
|
- = Mat3<float>::rotation(drehung) * Mat3<float>::scaling(size);
|
|
|
+ = Mat3<float>::rotation(rotation) * Mat3<float>::scaling(size);
|
|
|
int anz = rData->polygons->get(p).vertex->getEntryCount();
|
|
|
int j = anz - 1;
|
|
|
for (int i = 0; i < anz; i++)
|
|
|
@@ -1382,7 +1382,7 @@ bool Model2D::isModelInside(const Model2D* zMdl, bool end) const
|
|
|
return 0;
|
|
|
}
|
|
|
Mat3<float> mat = Mat3<float>::translation(pos)
|
|
|
- * Mat3<float>::rotation(drehung)
|
|
|
+ * Mat3<float>::rotation(rotation)
|
|
|
* Mat3<float>::scaling(size);
|
|
|
for (const Polygon2D& polygon : *rData->polygons)
|
|
|
{
|