|
From: Mike D. <o3d...@us...> - 2005-07-24 14:11:07
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28901 Modified Files: landscape.cpp landscape.h Log Message: - sinewave changes to landscape now working Index: landscape.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/landscape.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** landscape.h 9 Jul 2005 10:47:31 -0000 1.1 --- landscape.h 24 Jul 2005 14:10:50 -0000 1.2 *************** *** 14,18 **** class SineWave { public: ! SineWave(int initialSize, Coord3D startingPoint); double yValueAtPoint(const Coord3D& point); --- 14,19 ---- class SineWave { public: ! SineWave(double initialSize, int waveLength, Coord3D startingPoint); ! SineWave(const SineWave& rhs); double yValueAtPoint(const Coord3D& point); *************** *** 22,26 **** long m_totalTicks; Coord3D m_startingPoint; ! int m_initialSize; }; --- 23,28 ---- long m_totalTicks; Coord3D m_startingPoint; ! double m_initialSize; ! int m_waveLength; }; Index: landscape.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/landscape.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** landscape.cpp 9 Jul 2005 10:47:31 -0000 1.1 --- landscape.cpp 24 Jul 2005 14:10:50 -0000 1.2 *************** *** 12,21 **** _populateMesh(); ! m_waves.push_back(SineWave(100, Coord3D(10,20,30))); ! m_waves.push_back(SineWave(100, Coord3D(20,25,25))); ! m_waves.push_back(SineWave(100, Coord3D(12,15,50))); ! m_waves.push_back(SineWave(100, Coord3D(10,20,30))); ! m_waves.push_back(SineWave(100, Coord3D(10,20,30))); ! m_waves.push_back(SineWave(100, Coord3D(10,20,30))); } --- 12,21 ---- _populateMesh(); ! m_waves.push_back(SineWave(5, 5, Coord3D(10,20,30))); ! m_waves.push_back(SineWave(15, 15, Coord3D(50,25,25))); ! m_waves.push_back(SineWave(50, 4, Coord3D(12,15,50))); ! m_waves.push_back(SineWave(40, 2, Coord3D(30,23,30))); ! m_waves.push_back(SineWave(12, 23, Coord3D(90,40,30))); ! m_waves.push_back(SineWave(50, 30, Coord3D(40,60,30))); } *************** *** 82,86 **** bool LandScape::_updateWaves() { - double curDistance; Coord3D curPoint; --- 82,85 ---- *************** *** 91,95 **** --- 90,97 ---- } + int waveCount = 0; for(vector<SineWave>::iterator i = m_waves.begin(); i != m_waves.end(); i++) { + //cerr << "<LandScape::_populateMesh>\twaveCount [" << waveCount++ << "]" << endl; + i->addTicks(SystemStateSingleton::instance().tickDiff); *************** *** 99,103 **** curPoint.m_y = 0; curPoint.m_z = z; ! m_heights[x][z] += curDistance = i->yValueAtPoint(curPoint); } } --- 101,109 ---- curPoint.m_y = 0; curPoint.m_z = z; ! double height = i->yValueAtPoint(curPoint); ! // *** NOTE *** !!!!Hard-coded limiting here!!!! ! if((m_heights[x][z] < 1000) && (height < 1000)) { ! m_heights[x][z] += height; ! } } } *************** *** 119,130 **** */ ! SineWave::SineWave(int initialSize, Coord3D startingPoint) { m_initialSize = initialSize; m_startingPoint = startingPoint; } double SineWave::yValueAtPoint(const Coord3D& point) { double distance = m_startingPoint.distanceScalar(point); ! return ((m_initialSize / (distance + 1)) * sin((distance / 10) + (m_totalTicks / 500))); } --- 125,179 ---- */ ! SineWave::SineWave(double initialSize, int waveLength, Coord3D startingPoint) { m_initialSize = initialSize; m_startingPoint = startingPoint; + m_waveLength = waveLength; + m_totalTicks = 0; + } + + SineWave::SineWave(const SineWave& rhs) { + m_initialSize = rhs.m_initialSize; + m_startingPoint = rhs.m_startingPoint; + m_waveLength = rhs.m_waveLength; + m_totalTicks = 0; } double SineWave::yValueAtPoint(const Coord3D& point) { + // distance from the point of origin double distance = m_startingPoint.distanceScalar(point); ! ! const double maxTicks = 100000; ! // linear time drop off ! double timeDropOffFactor = (maxTicks - m_totalTicks) / maxTicks; ! ! //cerr << "<SineWave::yValueAtPoint>\tm_totalTicks [" << m_totalTicks << "]" << endl; ! ! // cut off after 2000 ticks ! if(m_totalTicks > maxTicks) { ! return 0; ! } ! ! // wavelength number ! double waveLengthNumber = distance / m_waveLength; ! ! const double maxWaveLengths = 10; ! // cut off after the 10th wavelength ! if(waveLengthNumber > maxWaveLengths) { ! return 0; ! } ! ! // linear drop-off from the point of origin ! double pointWaveSize = m_initialSize * ((maxWaveLengths - waveLengthNumber) / maxWaveLengths); ! // radians/unit length ! const double radiansToUnitLength = (3.14 * 2) / m_waveLength; ! // time-based alpha offset ! double timeAlphaOffset = ((double)m_totalTicks / 1000) * 10 * radiansToUnitLength; ! // this is a sine wave after all! ! double sineFactor = sin(((100 - distance) * radiansToUnitLength) + timeAlphaOffset); ! ! //cerr << "<SineWave::yValueAtPoint>\tm_totalTicks [" << m_totalTicks << "] distance [" << distance << "] timeDropOffFactor [" << timeDropOffFactor << "] pointWaveSize [" << pointWaveSize << "] waveLengthNumber [" << waveLengthNumber << "] sineFactor [" << sineFactor << "]" << endl; ! ! // combine all of the above ! return pointWaveSize * sineFactor * timeDropOffFactor; } *************** *** 141,144 **** --- 190,197 ---- /* $Log$ + Revision 1.2 2005/07/24 14:10:50 o3dozone + - sinewave changes to landscape + now working + Revision 1.1 2005/07/09 10:47:31 o3dozone - viewpoint changes |