123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359 |
- #include "Model2D.h"
- #include "Textur2D.h"
- #include "FrameworkMath.h"
- #include "Mat3.h"
- #include "MausEreignis.h"
- #include "Bild.h"
- using namespace Framework;
- // Inhalt der Model2DData Klasse aus Model2D.h
- // Konstruktor
- Model2DData::Model2DData()
- : ReferenceCounter(),
- polygons( 0 ),
- vListen( 0 ),
- minP( 0, 0 ),
- maxP( 0, 0 )
- {}
- // Destruktor
- Model2DData::~Model2DData()
- {
- if( polygons )
- {
- int anz = polygons->getEintragAnzahl();
- 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 ).vertex )
- polygons->get( i ).vertex->release();
- if( polygons->get( i ).schwerpunkt )
- delete polygons->get( i ).schwerpunkt;
- }
- polygons = ( Array<Polygon2D> * )polygons->release();
- }
- if( vListen )
- vListen->release();
- }
- // privat
- bool Model2DData::istPunktInnen( Vertex p, int polygonId ) const
- {
- if( p < minP || p > maxP || !polygons )
- return 0;
- int num = 0;
- auto outListP = outList.begin();
- for( auto polygon = polygons->begin(); polygon; polygon++, num++, outListP++ )
- {
- if( polygonId >= 0 && num != polygonId )
- continue;
- int anz = polygon._.vertex->getEintragAnzahl();
- bool c = 0;
- int j = anz - 1;
- for( auto outListPP = outListP->begin(); outListPP; outListPP++ )
- {
- Punkt out = outListPP;
- if( out.x < out.y && j > out.x && j < out.y )
- j = out.x;
- if( out.x > out.y && ( j > out.x || j < out.y ) )
- j = out.x;
- }
- auto point = polygon._.vertex->begin();
- for( int i = 0; i < anz; i++, point++ )
- {
- bool cont = 0;
- for( auto outListPP = outListP->begin(); outListPP; outListPP++ )
- {
- Punkt out = outListPP;
- if( out.x < out.y && i > out.x && i < out.y )
- cont = 1;
- if( out.x > out.y && ( i > out.x || i < out.y ) )
- cont = 1;
- }
- if( cont )
- continue;
- Vertex a = point;
- Vertex b = polygon._.vertex->get( j );
- if( ( ( a.y >= p.y ) != ( b.y >= p.y ) ) && ( p.x <= ( b.x - a.x ) * ( p.y - a.y ) / (float)( b.y - a.y ) + a.x ) )
- c = !c;
- j = i;
- }
- if( c )
- return 1;
- }
- return 0;
- }
- bool Model2DData::istLinieInnen( Vertex a, Vertex b, int polygonId ) const
- {
- if( !polygons )
- return 0;
- int pAnz = polygons->getEintragAnzahl();
- for( int p = 0; p < pAnz; p++ )
- {
- if( polygonId >= 0 && p != polygonId )
- continue;
- int ola = outList.z( p )->getEintragAnzahl();
- int anz = polygons->get( p ).vertex->getEintragAnzahl();
- int j = anz - 1;
- for( int k = 0; k < ola; k++ )
- {
- Punkt out = outList.z( p )->get( k );
- if( out.x < out.y && j > out.x && j < out.y )
- j = out.x;
- if( out.x > out.y && ( j > out.x || j < out.y ) )
- j = out.x;
- }
- for( int i = 0; i < anz; i++ )
- {
- bool cont = 0;
- for( int k = 0; k < ola; k++ )
- {
- Punkt out = outList.z( p )->get( k );
- if( out.x < out.y && i > out.x && i < out.y )
- cont = 1;
- if( out.x > out.y && ( i > out.x || i < out.y ) )
- cont = 1;
- }
- if( cont )
- continue;
- Punkt va = polygons->get( p ).vertex->get( i );
- Punkt vb = polygons->get( p ).vertex->get( j );
- if( (Punkt)a == va && (Punkt)b == vb )
- return 1;
- if( (Punkt)a == vb && (Punkt)b == va )
- return 1;
- j = i;
- }
- Vertex len = b - a;
- Vertex speed( len.x > 0 ? 1 : -1.f, len.y > 0 ? 1 : -1.f );
- int mLen = 0;
- if( fabs( len.x ) > fabs( len.y ) )
- {
- mLen = (int)fabs( len.x );
- speed.y = len.y / (float)fabs( len.x );
- }
- else
- {
- mLen = (int)fabs( len.y );
- speed.x = len.x / (float)fabs( len.y );
- }
- int i = 1;
- bool inside = 1;
- for( Vertex vp = speed + a; (Punkt)vp != (Punkt)( b - speed ) && inside && i < mLen - 1; vp += speed, i++ )
- inside &= istPunktInnen( vp, p );
- if( inside )
- return 1;
- }
- return 0;
- }
- // nicht constant
- bool Model2DData::erstelleModell( Array< Polygon2D > *polygons )
- {
- removeModell();
- if( !polygons || !polygons->getEintragAnzahl() )
- {
- this->polygons = polygons;
- vListen = new RCArray< RCArray< DreieckListe< Vertex > > >();
- return 1;
- }
- this->polygons = polygons;
- int pAnz = polygons->getEintragAnzahl();
- vListen = new RCArray< RCArray< DreieckListe< Vertex > > >();
- for( int p = 0; p < pAnz; p++ )
- {
- Polygon2D pg = polygons->get( p );
- if( !pg.vertex || pg.vertex->getEintragAnzahl() < 3 )
- continue;
- vListen->add( new RCArray< DreieckListe< Vertex > >() );
- outList.set( new Array< Punkt >, p );
- int vAnz = pg.vertex->getEintragAnzahl();
- bool textur = pg.tKordinaten != 0;
- for( int i = 0; i < vAnz && textur; i++ )
- textur &= pg.tKordinaten->hat( i );
- for( int i = 0; i < vAnz; i++ )
- {
- if( (float)maxP.x < fabs( pg.vertex->get( i ).x ) )
- {
- maxP.x = abs( (int)pg.vertex->get( i ).x ) + 1;
- maxP.y = abs( (int)pg.vertex->get( i ).x ) + 1;
- }
- if( (float)maxP.y < fabs( pg.vertex->get( i ).y ) )
- {
- maxP.x = abs( (int)pg.vertex->get( i ).y ) + 1;
- maxP.y = abs( (int)pg.vertex->get( i ).y ) + 1;
- }
- }
- minP = -maxP;
- if( !textur )
- {
- if( pg.tKordinaten )
- pg.tKordinaten->leeren();
- }
- RCArray< RCArray< DreieckListe< Vertex > > > lists;
- int lauf = 0;
- while( 1 )
- {
- lists.set( new RCArray< DreieckListe< Vertex > >(), lauf );
- outList.z( p )->set( Punkt( 0, 0 ), lauf );
- bool fertig = 0;
- Vertex a;
- Vertex b;
- Array< Punkt > tmpOutList;
- for( int i = 0; i < vAnz; i++ )
- {
- bool cont = 0;
- int vorher = i - 1;
- int nachher = i + 1;
- if( nachher >= vAnz )
- nachher = 0;
- if( vorher < 0 )
- vorher = vAnz - 1;
- int ola = outList.z( p )->getEintragAnzahl();
- for( int j = 0; j < ola; j++ )
- {
- Punkt out = outList.z( p )->get( j );
- if( out.x < out.y )
- {
- if( nachher > out.x && nachher < out.y )
- nachher = out.y;
- if( vorher > out.x && vorher < out.y )
- vorher = out.x;
- }
- if( out.x > out.y )
- {
- if( nachher > out.x || nachher < out.y )
- nachher = out.y;
- if( vorher > out.x || vorher < out.y )
- vorher = out.x;
- }
- if( out.x < out.y && i > out.x && i < out.y )
- cont = 1;
- if( out.x > out.y && ( i > out.x || i < out.y ) )
- cont = 1;
- }
- if( cont )
- continue;
- if( vorher < 0 )
- a = pg.vertex->get( vAnz + vorher );
- else
- a = pg.vertex->get( vorher );
- if( nachher > vAnz - 1 )
- b = pg.vertex->get( nachher - vAnz + 1 );
- else
- b = pg.vertex->get( nachher );
- if( istLinieInnen( a, b, p ) )
- {
- DreieckListe< Vertex > *lowL = new DreieckListe< Vertex >();
- DreieckListe< Vertex > *heightL = new DreieckListe< Vertex >();
- lowL->addPunkt( new Vertex( pg.vertex->get( i ) ), textur ? new Vertex( pg.tKordinaten->get( i ) ) : 0 );
- heightL->addPunkt( new Vertex( pg.vertex->get( i ) ), textur ? new Vertex( pg.tKordinaten->get( i ) ) : 0 );
- int height = i + 1;
- int low = i - 1;
- Punkt outL( 0, 0 );
- Punkt outH( 0, 0 );
- for( int k = 0; k < 2; k++ )
- {
- bool lowp = !k;
- while( 1 )
- {
- if( height >= vAnz )
- height = 0;
- if( low < 0 )
- low = vAnz - 1;
- for( int j = 0; j <= lauf; j++ )
- {
- Punkt out = outList.z( p )->get( j );
- if( out.x < out.y )
- {
- if( height > out.x && height < out.y )
- height = out.y;
- if( low > out.x && low < out.y )
- low = out.x;
- }
- if( out.x > out.y )
- {
- if( height > out.x || height < out.y )
- height = out.y;
- if( low > out.x || low < out.y )
- low = out.x;
- }
- }
- Vertex a = pg.vertex->get( height );
- Vertex b = pg.vertex->get( low );
- if( low == height )
- {
- fertig = 1;
- outList.z( p )->set( Punkt( 0, 0 ), lauf );
- if( !k )
- lowL->addPunkt( new Vertex( b ), textur ? new Vertex( pg.tKordinaten->get( low ) ) : 0 );
- else
- heightL->addPunkt( new Vertex( b ), textur ? new Vertex( pg.tKordinaten->get( low ) ) : 0 );
- break;
- }
- bool inside = istLinieInnen( a, b, p );
- if( inside )
- {
- if( !k )
- outL = Punkt( low, height );
- else
- outH = Punkt( low, height );
- outList.z( p )->set( Punkt( low, height ), lauf );
- }
- if( lowp )
- {
- if( !k )
- lowL->addPunkt( new Vertex( b ), textur ? new Vertex( pg.tKordinaten->get( low ) ) : 0 );
- else
- heightL->addPunkt( new Vertex( b ), textur ? new Vertex( pg.tKordinaten->get( low ) ) : 0 );
- low--;
- }
- else
- {
- if( !k )
- lowL->addPunkt( new Vertex( a ), textur ? new Vertex( pg.tKordinaten->get( height ) ) : 0 );
- else
- heightL->addPunkt( new Vertex( a ), textur ? new Vertex( pg.tKordinaten->get( height ) ) : 0 );
- height++;
- }
- lowp = !lowp;
- if( !inside )
- {
- height = i + 1;
- low = i - 1;
- outList.z( p )->set( Punkt( 0, 0 ), lauf );
- break;
- }
- }
- if( fertig )
- break;
- }
- if( lowL->getDreieckAnzahl() > heightL->getDreieckAnzahl() )
- {
- lists.z( lauf )->set( lowL, i );
- tmpOutList.set( outL, i );
- heightL->release();
- }
- else
- {
- lists.z( lauf )->set( heightL, i );
- tmpOutList.set( outH, i );
- lowL->release();
- }
- }
- else
- lists.z( lauf )->set( new DreieckListe< Vertex >(), i );
- if( fertig )
- break;
- }
- int maxP = -1;
- int max = 0;
- for( int i = 0; i < vAnz; i++ )
- {
- if( lists.z( lauf )->z( i ) && lists.z( lauf )->z( i )->getDreieckAnzahl() > max )
- {
- max = lists.z( lauf )->z( i )->getDreieckAnzahl();
- maxP = i;
- }
- }
- if( !max || maxP < 0 )
- break;
- vListen->z( p )->add( lists.z( lauf )->get( maxP ) );
- outList.z( p )->set( tmpOutList.get( maxP ), lauf );
- if( fertig )
- break;
- lauf++;
- }
- outList.z( p )->leeren();
- }
- return 1;
- }
- void Model2DData::removeModell() // setzt die Vertex daten zurück
- {
- if( polygons )
- {
- int anz = polygons->getEintragAnzahl();
- 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 ).vertex )
- polygons->get( i ).vertex->release();
- if( polygons->get( i ).schwerpunkt )
- delete polygons->get( i ).schwerpunkt;
- }
- polygons = ( Array<Polygon2D>* )polygons->release();
- }
- if( vListen )
- vListen = ( RCArray< RCArray< DreieckListe< Vertex > > > * )vListen->release();
- outList.leeren();
- minP = Punkt( 0, 0 );
- maxP = Punkt( 0, 0 );
- }
- bool Model2DData::calcHitPoint( Vertex pos, Vertex dir, const char *polygonName, Vertex &hitpoint, Vertex &moveSpeed, float &rotSpeed ) const
- {
- if( dir.x == 0 && dir.y == 0 )
- return 0;
- bool ret = 0;
- for( Polygon2D polygon : *polygons )
- {
- if( polygon.name->istGleich( polygonName ) )
- {
- int anz = polygon.vertex->getEintragAnzahl();
- for( int i = 0; i < anz; i++ )
- {
- Vertex a = polygon.vertex->get( i );
- Vertex b = polygon.vertex->get( ( i + 1 ) % anz );
- b -= a;
- float offset = 0;
- if( dir.y != 0 && dir.x != 0 )
- offset = ( ( a.y - pos.y ) / dir.y - ( a.x - pos.x ) / dir.x ) / ( b.x / dir.x - b.y / dir.y ); // solve hitpoint equasion
- else if( dir.y == 0 )
- {
- if( b.y == 0 )
- continue;
- offset = ( pos.y - a.y ) / b.y;
- }
- else if( dir.x == 0 )
- {
- if( b.x == 0 )
- continue;
- offset = ( pos.x - a.x ) / b.x;
- }
- Vertex point = a + ( b * offset );
- if( offset >= 0 && offset <= 1 )
- {
- float f = ( point.x - pos.x ) / dir.x;
- if( !dir.x )
- f = ( point.y - pos.y ) / dir.y;
- if( ( !ret || ( hitpoint - pos ).getLengthSq() > ( point - pos ).getLengthSq() ) && f > 0 )
- {
- Vertex normal = b.CW90().normalize();
- Vertex kNorm = Vertex( dir ).normalize();
- moveSpeed = normal * ( normal * kNorm ) * dir.getLength();
- normal = ( point - *polygon.schwerpunkt ).CW90().normalize();
- Vertex rotKraft = normal * ( normal * kNorm ) * dir.getLength();
- rotSpeed = ( (float)sqrt( rotKraft.getLength() * ( point - *polygon.schwerpunkt ).getLength() ) / 180.f ) * 3.14f * ( normal * kNorm );
- hitpoint = point;
- if( isnan( moveSpeed.x ) || isnan( moveSpeed.y ) || isnan( rotSpeed ) )
- return 0;
- ret = 1;
- }
- }
- }
- }
- }
- return ret;
- }
- bool Model2DData::split( Vertex pos, Vertex dir, char *polygonName, Polygon2D &partA, Polygon2D &partB, Punkt &posA, Punkt &posB, std::function< double() > random ) const
- {
- Vertex originalDir = dir;
- bool ret = 0;
- int num = 0;
- for( Polygon2D polygon : *polygons )
- {
- if( polygon.name->istGleich( polygonName ) )
- {
- while( istPunktInnen( pos, num ) )
- {
- pos -= dir;
- }
- int anz = polygon.vertex->getEintragAnzahl();
- Vertex startPoint;
- Vertex texturSP;
- int leftI = 0;
- int rightI = 0;
- Vertex txtChpPix( 0, 0 );
- for( int i = 0; i < anz; i++ )
- {
- Vertex a = polygon.vertex->get( i );
- Vertex b = polygon.vertex->get( ( i + 1 ) % anz );
- b -= a;
- 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 );
- tb -= ta;
- txtChpPix = Vertex( tb.x / b.x, tb.y / b.y );
- }
- float offset = 0;
- if( dir.y != 0 && dir.x != 0 )
- offset = ( ( a.y - pos.y ) / dir.y - ( a.x - pos.x ) / dir.x ) / ( b.x / dir.x - b.y / dir.y ); // solve hitpoint equasion
- else if( dir.y == 0 )
- offset = ( pos.y - a.y ) / b.y;
- else if( dir.x == 0 )
- offset = ( pos.x - a.x ) / b.x;
- Vertex point = a + ( b * offset );
- if( offset >= 0 && offset <= 1 )
- {
- if( !ret || ( startPoint - pos ).getLengthSq() > ( point - pos ).getLengthSq() )
- {
- leftI = i;
- rightI = ( i + 1 ) % anz;
- startPoint = point;
- texturSP = polygon.tKordinaten->get( i ) + ( polygon.tKordinaten->get( ( i + 1 ) % anz ) - polygon.tKordinaten->get( i ) ) * offset;
- }
- ret = 1;
- }
- }
- if( ret )
- {
- partA.transparent = polygon.transparent;
- partA.schwerpunkt = new Vertex( 0, 0 );
- partA.tKordinaten = 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.name = new Text( polygon.name->getText() );
- partB.vertex = new Array< Vertex >();
- *partA.schwerpunkt += startPoint;
- *partB.schwerpunkt += startPoint;
- partA.vertex->add( startPoint );
- partB.vertex->add( startPoint );
- partA.tKordinaten->add( texturSP );
- partB.tKordinaten->add( texturSP );
- int leftIE = 0;
- int rightIE = 0;
- while( 1 )
- {
- pos = startPoint;
- Vertex next = startPoint + dir;
- Vertex nextT = texturSP + Vertex( dir.x * txtChpPix.x, dir.y * txtChpPix.y );
- ret = 0;
- bool needOne = !istPunktInnen( next );
- int bestI = -1;
- float bo1 = 1000;
- float bo2 = 1000;
- for( int i = 0; i < anz; i++ )
- {
- if( i == leftI )
- continue;
- Vertex a = polygon.vertex->get( i );
- Vertex b = polygon.vertex->get( ( i + 1 ) % anz );
- b -= a;
- float offset1 = 0;
- if( dir.y != 0 && dir.x != 0 )
- offset1 = ( ( a.y - pos.y ) / dir.y - ( a.x - pos.x ) / dir.x ) / ( b.x / dir.x - b.y / dir.y ); // solve hitpoint equasion
- else if( dir.y == 0 )
- offset1 = ( pos.y - a.y ) / b.y;
- else if( dir.x == 0 )
- offset1 = ( pos.x - a.x ) / b.x;
- Vertex point = a + ( b * offset1 );
- float offset2 = 0;
- if( dir.x != 0 )
- offset2 = ( point.x - pos.x ) / dir.x;
- else
- offset2 = ( point.y - pos.y ) / dir.y;
- if( needOne && MIN( abs( bo1 ), abs( bo1 - 1 ) ) + MIN( abs( bo2 ), bo2 - 1 ) > MIN( abs( offset1 ), abs( offset1 - 1 ) ) + MIN( abs( offset2 ), abs( offset2 - 1 ) ) )
- {
- bo1 = offset1;
- bo2 = offset2;
- bestI = i;
- }
- if( offset1 >= 0 && offset1 <= 1 && offset2 >= 0 && offset2 <= 1 )
- {
- if( !ret || ( startPoint - pos ).getLengthSq() > ( point - pos ).getLengthSq() )
- {
- leftIE = i;
- rightIE = ( i + 1 ) % anz;
- startPoint = point;
- texturSP = polygon.tKordinaten->get( i ) + ( polygon.tKordinaten->get( ( i + 1 ) % anz ) - polygon.tKordinaten->get( i ) ) * offset1;
- }
- ret = 1;
- }
- }
- if( needOne && !ret )
- {
- Vertex a = polygon.vertex->get( bestI );
- Vertex b = polygon.vertex->get( ( bestI + 1 ) % anz );
- b -= a;
- 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 ) ) * bo1;
- ret = 1;
- }
- if( ret )
- break;
- *partA.schwerpunkt += next;
- *partB.schwerpunkt += next;
- partA.vertex->add( next );
- partB.vertex->add( next );
- partA.tKordinaten->add( nextT );
- partB.tKordinaten->add( nextT );
- startPoint = next;
- texturSP = nextT;
- dir = originalDir.rotation( (float)( random() - 0.5 ) );
- }
- *partA.schwerpunkt += startPoint;
- *partB.schwerpunkt += startPoint;
- partA.vertex->add( startPoint );
- partB.vertex->add( startPoint );
- partA.tKordinaten->add( texturSP );
- partB.tKordinaten->add( texturSP );
- for( int i = rightIE; i != leftI; i++ )
- {
- i = i % anz;
- if( i == leftI )
- break;
- *partA.schwerpunkt += polygon.vertex->get( i );
- partA.vertex->add( polygon.vertex->get( i ) );
- partA.tKordinaten->add( polygon.tKordinaten->get( i ) );
- }
- *partA.schwerpunkt += polygon.vertex->get( leftI );
- partA.vertex->add( polygon.vertex->get( leftI ) );
- partA.tKordinaten->add( polygon.tKordinaten->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.vertex->add( polygon.vertex->get( i ) );
- partB.tKordinaten->add( polygon.tKordinaten->get( i ) );
- }
- *partB.schwerpunkt += polygon.vertex->get( rightI );
- partB.vertex->add( polygon.vertex->get( rightI ) );
- partB.tKordinaten->add( polygon.tKordinaten->get( rightI ) );
- *partA.schwerpunkt /= (float)partA.vertex->getEintragAnzahl();
- *partB.schwerpunkt /= (float)partB.vertex->getEintragAnzahl();
- posA = (Punkt)*partA.schwerpunkt;
- posB = (Punkt)*partB.schwerpunkt;
- for( int i = 0; i < partA.vertex->getEintragAnzahl(); i++ )
- partA.vertex->set( partA.vertex->get( i ) - *partA.schwerpunkt, i );
- for( int i = 0; i < partB.vertex->getEintragAnzahl(); i++ )
- partB.vertex->set( partB.vertex->get( i ) - *partB.schwerpunkt, i );
- *partA.schwerpunkt = Vertex( 0, 0 );
- *partB.schwerpunkt = Vertex( 0, 0 );
- }
- }
- num++;
- }
- return ret;
- }
- float Model2DData::getMasse() const
- {
- float m = 0;
- for( Polygon2D p : *polygons )
- {
- if( p.transparent )
- continue;
- int anz = p.vertex->getEintragAnzahl();
- if( anz < 3 )
- continue;
- Vertex p1 = p.vertex->get( anz - 1 );
- Vertex p2 = p.vertex->get( 0 );
- m += ( p1.y + p2.y ) * ( p1.x - p2.x );
- for( int i = 1; i < anz; i++ )
- {
- p1 = p.vertex->get( i - 1 );
- p2 = p.vertex->get( i );
- m += ( p1.y + p2.y ) * ( p1.x - p2.x );
- }
- }
- m *= 0.5f;
- return m;
- }
- // Inhalt der Model2D Klasse aus Model2D.h
- // Konstruktor
- Model2DObject::Model2DObject()
- : Object2D()
- {
- rData = 0;
- textur = new RCArray< Textur2D >();
- }
- // Destruktor
- Model2DObject::~Model2DObject()
- {
- if( rData )
- rData->release();
- textur->release();
- }
- // nicht constant
- void Model2DObject::setModel( Model2DData *mdl )
- {
- if( rData )
- rData->release();
- rData = mdl;
- }
- void Model2DObject::setTextur( Textur2D *t )
- {
- if( rData )
- {
- for( int i = 0; i< rData->polygons->getEintragAnzahl(); i++ )
- textur->set( dynamic_cast<Textur2D *>( t->getThis() ), i );
- }
- t->release();
- }
- void Model2DObject::impuls( Vertex start, Vertex speed, float strength )
- {
- start = getObjectPos( start );
- speed = getObjectDir( speed );
- if( rData )
- {
- Vertex resSpeed;
- float resRotSpeed = 0;
- Vertex hp;
- Vertex mSpeed;
- float rSpeed;
- float dist = INFINITY;
- for( Polygon2D p : *rData->polygons )
- {
- if( !p.transparent && rData->calcHitPoint( start, speed, p.name->getText(), hp, mSpeed, rSpeed ) )
- {
- float f = ( hp.x - start.x ) / speed.x;
- if( !speed.x )
- f = ( hp.y - start.y ) / speed.y;
- if( ( hp - start ).getLengthSq() < dist && f > 0 )
- {
- resSpeed = mSpeed.rotation( rotation );
- resRotSpeed = rSpeed;
- dist = ( hp - start ).getLengthSq();
- }
- }
- }
- // TODO schleife über alle polygone und translation von start und speed in Object koordinaten
- if( dist < INFINITY )
- {
- this->speed += resSpeed * strength;
- this->rSpeed += resRotSpeed * strength;
- }
- }
- }
- void Model2DObject::setTextur( Textur2D *t, const char *polygonName )
- {
- int index = 0;
- for( Polygon2D i : *rData->polygons )
- {
- if( i.name->istGleich( polygonName ) )
- textur->set( dynamic_cast<Textur2D *>( t->getThis() ), index );
- index++;
- }
- t->release();
- }
- void Model2DObject::render( Mat3< float > &kamMat, Bild &zRObj, const char *kamName )
- {
- if( !rData || !rData->polygons || !textur )
- return;
- int num = 0;
- for( auto p : *rData->vListen )
- {
- Mat3< float > mat = kamMat * getObjectMatrix();
- if( textur->z( num ) )
- {
- Bild *txt = textur->z( num )->zTextur();
- 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;
- Punkt ta = (Punkt)Vertex( j->textur->x * (float)( txt->getBreite() - 1 ), j->textur->y * (float)( txt->getHeight() - 1 ) );
- Punkt tb = (Punkt)Vertex( j.next()->textur->x * (float)( txt->getBreite() - 1 ), j.next()->textur->y * (float)( txt->getHeight() - 1 ) );
- Punkt tc = (Punkt)Vertex( j.next().next()->textur->x * (float)( txt->getBreite() - 1 ), j.next().next()->textur->y * (float)( txt->getHeight() - 1 ) );
- zRObj.drawDreieckTexturAlpha( a, b, c, ta, tb, tc, *txt );
- }
- }
- }
- num++;
- }
- /* Draws 2D Mesh
- for( auto *p = &rData->vListen->getIterator(); p && p->set; p = p->next, num++ )
- {
- Mat3< float > mat = kamMat * getObjectMatrix();
- for( auto *i = &p->var->getArray(); i && i->set; i = i->next )
- {
- 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;
- zRObj.drawLinie( a, b, 0xFFFFFFFF );
- zRObj.drawLinie( a, c, 0xFFFFFFFF );
- zRObj.drawLinie( b, c, 0xFFFFFFFF );
- }
- }
- }
- */
- }
- // constant
- bool Model2DObject::istPunktInnen( Vertex p, bool ignoreTransparent ) const
- {
- if( !rData )
- return 0;
- p -= position;
- if( p < Mat3< float >::scaling( size ) * rData->minP || p > Mat3< float >::scaling( size ) * rData->maxP || !rData->polygons )
- return 0;
- Mat3< float > mat = Mat3< float >::rotation( -rotation ) * Mat3< float >::scaling( 1 / size );
- p = mat * p;
- for( Polygon2D polygon : *rData->polygons)
- {
- if( polygon.transparent && !ignoreTransparent )
- continue;
- bool c = 0;
- for( auto point = polygon.vertex->begin(); point; point++ )
- {
- Vertex a;
- if( point.next() )
- a = point.next();
- else
- a = polygon.vertex->get( 0 );
- Vertex b = point;
- if( ( ( a.y >= p.y ) != ( b.y >= p.y ) ) && ( p.x <= ( b.x - a.x ) * ( p.y - a.y ) / (float)( b.y - a.y ) + a.x ) )
- c = !c;
- }
- if( c )
- return 1;
- }
- return 0;
- }
- bool Model2DObject::istLinieInnen( Vertex a, Vertex b, bool ignoreTransparent ) const
- {
- if( !rData || !rData->polygons )
- return 0;
- int pAnz = rData->polygons->getEintragAnzahl();
- for( int p = 0; p < pAnz; p++ )
- {
- if( rData->polygons->get( p ).transparent && !ignoreTransparent )
- continue;
- Mat3< float > mat = Mat3< float >::rotation( rotation ) * Mat3< float >::scaling( size );
- int anz = rData->polygons->get( p ).vertex->getEintragAnzahl();
- int j = anz - 1;
- for( int i = 0; i < anz; i++ )
- {
- Punkt va = mat * rData->polygons->get( p ).vertex->get( i );
- Punkt vb = mat * rData->polygons->get( p ).vertex->get( j );
- if( (Punkt)a == position + va && (Punkt)b == position + vb )
- return 1;
- if( (Punkt)a == position + vb && (Punkt)b == position + va )
- return 1;
- j = i;
- }
- Vertex len = b - a;
- Vertex speed( len.x > 0 ? 1 : -1.f, len.y > 0 ? 1 : -1.f );
- int mLen = 0;
- if( fabs( len.x ) > fabs( len.y ) )
- {
- mLen = (int)fabs( len.x );
- speed.y = len.y / (float)fabs( len.x );
- }
- else
- {
- mLen = (int)fabs( len.y );
- speed.x = len.x / (float)fabs( len.y );
- }
- int i = 1;
- bool inside = 1;
- for( Vertex vp = speed + a; (Punkt)vp != (Punkt)( b - speed ) && inside && i < mLen - 1; vp += speed, i++ )
- inside &= istPunktInnen( vp, ignoreTransparent );
- if( inside )
- return 1;
- }
- return 0;
- }
- bool Model2DObject::istModelInnen( const Object2D *zObj, Vertex *sp, bool end, bool ignoreTransparent ) const
- {
- if( !end )
- {
- if( !getBoundingBox().collidesWith( zObj->getBoundingBox() ) )
- return 0;
- }
- Mat3< float > mat = getObjectMatrix();
- for( Polygon2D polygon : *rData->polygons )
- {
- if( polygon.transparent && !ignoreTransparent )
- continue;
- int anz = polygon.vertex->getEintragAnzahl();
- for( int i = 0; i < anz; i++ )
- {
- if( zObj->istPunktInnen( mat * polygon.vertex->get( i ), ignoreTransparent ) )
- {
- if( sp )
- *sp = mat * polygon.vertex->get( i );
- return 1;
- }
- }
- }
- if( end )
- return 0;
- return zObj->istModelInnen( this, sp, 1, ignoreTransparent );
- }
- Rect2< float > Model2DObject::getBoundingBox() const
- {
- if( rData )
- return Rect2< float >{ (Vertex)rData->minP *size + position, (Vertex)rData->maxP *size + position };
- return Rect2< float >();
- }
- bool Model2DObject::calcHitPoint( Vertex pos, Vertex dir, Vertex &hitpoint ) const
- {
- pos = getObjectPos( pos );
- dir = getObjectDir( dir );
- Vertex ms;
- Vertex hp;
- float rs;
- float dist = INFINITY;
- if( rData )
- {
- for( Polygon2D p : *rData->polygons )
- {
- if( !p.transparent && rData->calcHitPoint( pos, dir, p.name->getText(), hp, ms, rs ) )
- {
- float f = ( hp.x - pos.x ) / dir.x;
- if( !speed.x )
- f = ( hp.y - pos.y ) / dir.y;
- if( ( hp - pos ).getLengthSq() < dist && f > 0 )
- {
- hitpoint = getObjectMatrix() * hp;
- dist = ( hp - pos ).getLengthSq();
- }
- }
- }
- if( dist < INFINITY )
- return 1;
- }
- return 0;
- }
- float Model2DObject::getLuftWiederstand() 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;
- Mat3< float > m = Mat3< float >::rotation( rotation + faktor * angle ) * Mat3< float >::scaling( size );
- float yMin = INFINITY;
- float yMax = -INFINITY;
- for( Polygon2D p : *rData->polygons )
- {
- if( p.transparent )
- continue;
- for( Vertex point : *p.vertex )
- {
- Vertex v = m * point;
- if( v.y > yMax )
- yMax = v.y;
- if( v.y < yMin )
- yMin = v.y;
- }
- }
- if( yMin != INFINITY )
- {
- return yMax - yMin;
- }
- return 0;
- }
- float Model2DObject::getMasse() const
- {
- if( !rData )
- return 0;
- return abs( rData->getMasse() * size * size );
- }
- // Gibt die Textur des ersten Polygons zurück
- Textur2D *Model2DObject::getTextur() const
- {
- return textur->get( 0 );
- }
- // Gibt die Textur eines Polygons zurück
- // polygonName: Der Name des Polygons
- Textur2D *Model2DObject::getTextur( const char *polygonName ) const
- {
- int index = 0;
- for( Polygon2D p : *rData->polygons )
- {
- if( p.name->istGleich( polygonName ) )
- return textur->get( index );
- index++;
- }
- return 0;
- }
- // Gibt die Textur des ersten Polygons ohne erhöhten Reference Counter zurück
- Textur2D *Model2DObject::zTextur() const
- {
- return textur->z( 0 );
- }
- // Gibt die Textur eines Polygons ohne erhöhten Reference Counter zurück
- // polygonName: Der Name des Polygons
- Textur2D *Model2DObject::zTextur( const char *polygonName ) const
- {
- int index = 0;
- for( Polygon2D p : *rData->polygons )
- {
- if( p.name->istGleich( polygonName ) )
- return textur->z( index );
- index++;
- }
- return 0;
- }
- Model2DData *Model2DObject::getModel() const
- {
- return rData ? dynamic_cast<Model2DData *>( rData->getThis() ) : 0;
- }
- Model2DData *Model2DObject::zModel() const
- {
- return rData;
- }
- // Inhalt der Model2D Klasse aus Model2D.h
- // Konstruktor
- Model2D::Model2D()
- : Zeichnung()
- {
- farbe = 0;
- style = 0;
- rData = 0;
- drehung = 0;
- size = 1;
- textur = new RCArray< Textur2D >;
- }
- // Destruktor
- Model2D::~Model2D()
- {
- if( rData )
- rData->release();
- textur->release();
- }
- // nicht constant
- void Model2D::setModel( Model2DData *mdl )
- {
- if( rData )
- rData->release();
- rData = mdl;
- }
- void Model2D::setDrehung( float drehung )
- {
- this->drehung = drehung;
- while( this->drehung > PI * 2 )
- this->drehung -= (float)PI * 2;
- while( this->drehung < 0 )
- this->drehung += (float)PI * 2;
- rend = 1;
- }
- void Model2D::addDrehung( float drehung )
- {
- this->drehung += drehung;
- while( this->drehung > PI * 2 )
- this->drehung -= (float)PI * 2;
- while( this->drehung < 0 )
- this->drehung += (float)PI * 2;
- rend = 1;
- }
- void Model2D::setSize( float size )
- {
- this->size = size;
- rend = 1;
- }
- void Model2D::addSize( float size )
- {
- this->size += size;
- rend = 1;
- }
- void Model2D::setTextur( Textur2D *t )
- {
- if( rData )
- {
- for( int i = 0; i < rData->polygons->getEintragAnzahl(); i++ )
- textur->set( dynamic_cast<Textur2D *>( t->getThis() ), i );
- }
- t->release();
- }
- void Model2D::setTextur( Textur2D *t, const char *polygonName )
- {
- int index = 0;
- for( Polygon2D p : *rData->polygons )
- {
- if( p.name->istGleich( polygonName ) )
- textur->set( dynamic_cast<Textur2D *>( t->getThis() ), index );
- index++;
- }
- t->release();
- }
- void Model2D::setFarbe( int f )
- {
- farbe = f;
- rend = 1;
- }
- bool Model2D::tick( double tickVal )
- {
- return Zeichnung::tick( tickVal );
- }
- void Model2D::render( Bild &zRObj )
- {
- if( !rData || hatStyleNicht( Model2D::Style::Sichtbar ) || !rData->polygons )
- return;
- Zeichnung::render( zRObj );
- int num = 0;
- for( auto p : *rData->vListen )
- {
- Mat3< float > mat = Mat3< float >::translation( pos ) * Mat3< float >::rotation( drehung ) * Mat3< float >::scaling( size );
- if( hatStyle( Model2D::Style::Textur ) )
- {
- if( !textur || !textur->z( num ) || !textur->z( num )->zTextur() || !rData->polygons->get( num ).tKordinaten )
- {
- for( auto i : *p )
- {
- 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;
- if( hatStyle( Model2D::Style::Alpha ) )
- zRObj.drawDreieckAlpha( a, b, c, farbe );
- else
- zRObj.drawDreieck( a, b, c, farbe );
- }
- }
- }
- else
- {
- Bild *txt = textur->z( num )->zTextur();
- for( auto i : *p )
- {
- 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;
- Punkt ta = (Punkt)Vertex( j->textur->x * (float)( txt->getBreite() - 1 ), j->textur->y * (float)( txt->getHeight() - 1 ) );
- Punkt tb = (Punkt)Vertex( j.next()->textur->x * (float)( txt->getBreite() - 1 ), j.next()->textur->y * (float)( txt->getHeight() - 1 ) );
- Punkt tc = (Punkt)Vertex( j.next().next()->textur->x * (float)( txt->getBreite() - 1 ), j.next().next()->textur->y * (float)( txt->getHeight() - 1 ) );
- if( hatStyle( Model2D::Style::Alpha ) )
- zRObj.drawDreieckTexturAlpha( a, b, c, ta, tb, tc, *txt );
- else
- zRObj.drawDreieckTextur( a, b, c, ta, tb, tc, *txt );
- }
- }
- }
- }
- if( hatStyle( Model2D::Style::Mesh ) )
- {
- for( auto i : *p )
- {
- 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;
- if( hatStyle( Model2D::Style::Alpha ) )
- {
- zRObj.drawLinieAlpha( a, b, farbe );
- zRObj.drawLinieAlpha( b, c, farbe );
- zRObj.drawLinieAlpha( c, a, farbe );
- }
- else
- {
- zRObj.drawLinie( a, b, farbe );
- zRObj.drawLinie( b, c, farbe );
- zRObj.drawLinie( c, a, farbe );
- }
- }
- }
- }
- if( hatStyle( Model2D::Style::Rahmen ) )
- {
- auto beg = rData->polygons->get( num ).vertex->begin();
- if( beg )
- {
- Vertex letzter;
- for( auto e = beg; e && e.hasNext(); e++ )
- {
- if( hatStyle( Model2D::Style::Alpha ) )
- zRObj.drawLinieAlpha( mat * e._, mat * e.next()._, farbe );
- else
- zRObj.drawLinie( mat * e._, mat * e.next()._, farbe );
- letzter = e.next();
- }
- if( beg.hasNext() )
- {
- if( hatStyle( Model2D::Style::Alpha ) )
- zRObj.drawLinieAlpha( mat * letzter, mat * beg._, farbe );
- else
- zRObj.drawLinie( mat * letzter, mat * beg._, farbe );
- }
- }
- }
- num++;
- }
- }
- // constant
- float Model2D::getDrehung() const
- {
- return drehung;
- }
- float Model2D::getSize() const
- {
- return size;
- }
- // Gibt zurück, ob ein Punkt in dem Model enthalten ist
- // p: Der Punkt
- bool Model2D::istPunktInnen( int x, int y ) const
- {
- return istPunktInnen( Vertex( (float)x, (float)y ) );
- }
- bool Model2D::istPunktInnen( Vertex p ) const
- {
- if( !rData )
- return 0;
- p -= pos;
- if( p < Mat3< float >::scaling( size ) * rData->minP || p > Mat3< float >::scaling( size ) * rData->maxP || !rData->polygons )
- return 0;
- for( Polygon2D polygon : *rData->polygons )
- {
- if( polygon.transparent )
- continue;
- Mat3< float > mat = Mat3< float >::rotation( drehung ) * Mat3< float >::scaling( size );
- int anz = polygon.vertex->getEintragAnzahl();
- bool c = 0;
- int j = anz - 1;
- for( int i = 0; i < anz; i++ )
- {
- Vertex a = mat * polygon.vertex->get( i );
- Vertex b = mat * polygon.vertex->get( j );
- if( ( ( a.y >= p.y ) != ( b.y >= p.y ) ) && ( p.x <= ( b.x - a.x ) * ( p.y - a.y ) / (float)( b.y - a.y ) + a.x ) )
- c = !c;
- j = i;
- }
- if( c )
- return 1;
- }
- return 0;
- }
- bool Model2D::istLinieInnen( Vertex a, Vertex b ) const
- {
- if( !rData || !rData->polygons )
- return 0;
- int pAnz = rData->polygons->getEintragAnzahl();
- for( int p = 0; p < pAnz; p++ )
- {
- if( rData->polygons->get( p ).transparent )
- continue;
- Mat3< float > mat = Mat3< float >::rotation( drehung ) * Mat3< float >::scaling( size );
- int anz = rData->polygons->get( p ).vertex->getEintragAnzahl();
- int j = anz - 1;
- for( int i = 0; i < anz; i++ )
- {
- Punkt va = mat * rData->polygons->get( p ).vertex->get( i );
- Punkt vb = mat * rData->polygons->get( p ).vertex->get( j );
- if( (Punkt)a == pos + va && (Punkt)b == pos + vb )
- return 1;
- if( (Punkt)a == pos + vb && (Punkt)b == pos + va )
- return 1;
- j = i;
- }
- Vertex len = b - a;
- Vertex speed( len.x > 0 ? 1 : -1.f, len.y > 0 ? 1 : -1.f );
- int mLen = 0;
- if( fabs( len.x ) > fabs( len.y ) )
- {
- mLen = (int)fabs( len.x );
- speed.y = len.y / (float)fabs( len.x );
- }
- else
- {
- mLen = (int)fabs( len.y );
- speed.x = len.x / (float)fabs( len.y );
- }
- int i = 1;
- bool inside = 1;
- for( Vertex vp = speed + a; (Punkt)vp != (Punkt)( b - speed ) && inside && i < mLen - 1; vp += speed, i++ )
- inside &= istPunktInnen( vp );
- if( inside )
- return 1;
- }
- return 0;
- }
- bool Model2D::istModelInnen( const Model2D *zMdl, bool end ) const
- {
- if( !end )
- {
- Vertex min = (Vertex)rData->minP * size + pos;
- Vertex max = (Vertex)rData->maxP * size + pos;
- Vertex min2 = (Vertex)zMdl->zModel()->minP * zMdl->getSize() + zMdl->getPosition();
- Vertex max2 = (Vertex)zMdl->zModel()->maxP * zMdl->getSize() + zMdl->getPosition();
- if( max.x < min2.x || min.x > max2.x || max.y < min2.y || min.y > max2.y )
- return 0;
- }
- Mat3< float > mat = Mat3< float >::translation( pos ) * Mat3< float >::rotation( drehung ) * Mat3< float >::scaling( size );
- for( Polygon2D polygon : *rData->polygons )
- {
- if( polygon.transparent )
- continue;
- int anz = polygon.vertex->getEintragAnzahl();
- for( int i = 0; i < anz; i++ )
- {
- if( zMdl->istPunktInnen( mat * polygon.vertex->get( i ) ) )
- return 1;
- }
- }
- if( end )
- return 0;
- return zMdl->istModelInnen( this, 1 );
- }
- Model2DData *Model2D::getModel() const
- {
- return rData ? dynamic_cast<Model2DData *>( rData->getThis() ) : 0;
- }
- Model2DData *Model2D::zModel() const
- {
- return rData;
- }
|