kcometen4-1.0.7/0000755000000000000000000000000011424423724012111 5ustar rootrootkcometen4-1.0.7/ChangeLog0000644000000000000000000000363711424423636013676 0ustar rootrootKCometen4 ChangeLog =================== Version 1.0.7 * Work around a problem with Intel cards Version 1.0.6 * Explicitly link against libGL Version 1.0.5 * Spread out comet origination * Sync kcometen4.desktop translations with KDE 4.2.4 * Remove resize hack; bug fixed in KDE 4.2.3 * Clean up how the config changes interact with the preview * Small fixes to CMakeLists.txt files Version 1.0.4 * Change slow motion camera behavior - Slow motion effects have a selectable aspect ratio: 1.85:1, 2.40:1, and fullscreen. - Camera no longer always on the x-z plane * Possibly fix a bug that sometimes causes the background to appear black. * Update the CMakeLists files so it can build on Gentoo. Version 1.0.3 * Fix rendering of comet tails - Don't enable point smoothing. It causes problems with some drivers. - If the driver doesn't support point sprites, use textured quads. * Reorganize the settings dialog and add a "Particle density" setting. Version 1.0.2 * Link to kio Version 1.0.1 * Fix compilation problems for some distributions. * Add a very basic configure script that wraps a few common cmake settings. * Add some notes to INSTALL. * Add a hack that stops the embedded OpenGL widget from resizing to 640x480. See KDE bug #165552. Version 1.0 * Port KCometen3 to KDE4 * Plug a memory leak * Fix field of view distortions in very oblong windows * New options - set field of view (default: 76 degrees) - set whether scene dimensions should always be a cube (default: false) - use mipmaps (default: false) * Update the setup dialog - rearrange dialog and rename a few settings for clarity - add a dynamic preview - add About and Defaults buttons - add What's This? info - make it a KDialog * Improve the quality of the background image - add an option for 1024x1024 image size - use Qt::SmoothTransformation when scaling kcometen4-1.0.7/src/0000755000000000000000000000000011424423724012700 5ustar rootrootkcometen4-1.0.7/src/curvecomet.cpp0000644000000000000000000002221111064074761015561 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "curvecomet.h" CurveComet::CurveComet(CometenScene * scene, double time, double _lifeTime, const Vec3f& start, const Vec4f & _acolor, const Vec4f & _ecolor) : Comet(scene, 1.0), startTime(time), lifeTime(_lifeTime), acolor(_acolor), ecolor(_ecolor) { GLuint tex = scene->textures[T_PARTICLE]; psystem = new ParticleSystem(time, tex, start, start, 800, 0, 1.5, 2.0, true, 400, 0, 5, false, 4, acolor, ecolor); decal = new Decal(tex, start, 12.0, true, Vec3f::UNIT_X, acolor); createCurve(start); numChildren = rand(25, 30); destroyed = false; } CurveComet::~CurveComet() { delete psystem; delete decal; delete curve; } void CurveComet::process(double time, double /*unused*/) { position = curve->position((time - startTime) / lifeTime); if (!destroyed) { if (time - startTime > lifeTime) destroy(time); } decal->setPosition(position); psystem->setEmitterPos1(psystem->getEmitterPos2()); psystem->setEmitterPos2(position); psystem->process(time); if (destroyed) { psystem->stop(); } } void CurveComet::render(const Vec3f& campos) { if (!destroyed) { decal->render(campos); } psystem->render(campos); } void CurveComet::createCurve(const Vec3f& start) { Vec3f points[15]; double bw = scene->getBoxWidth() / 2; double bh = scene->getBoxHeight() / 2; int n = 15; points[0] = start; for (int k = 1; k < n; k++) { points[k] = Vec3f(frand(-bw,bw),frand(-bh,bh),frand(-bw,bw)); } Vec3f diff = points[n-1] - points[n-2]; double l = diff.normalize(); if (l > 200) { points[n-1] = points[n-2] + diff * 200; } curve = new Bezier3(points, n); } void CurveComet::destroyEffect1(double time, const Vec3f& pos, const Vec3f& vel) { Comet* newc; Vec3f points[4]; Vec3f dir, dir2, dir3; Vec3f b, c; double bw = scene->getBoxWidth()/2; double bh = scene->getBoxHeight()/2; dir = vel; dir.normalize(); Vec3f::generateOrthonormalBasis(dir, b, c); points[0] = pos; for (int i = 0; i < numChildren; i++) { dir2 = Vec3f::Vec3f::randomUnitOnPlane(b,c); dir3 = dir.cross(dir2); points[1] = points[0] + dir2 * 50; points[1][0] = clamp(points[1][0], -bw, bw); points[1][1] = clamp(points[1][1], -bh, bh); points[1][2] = clamp(points[1][2], -bw, bw); points[2] = points[0] + dir3 * 50; points[2][0] = clamp(points[2][0], -bw, bw); points[2][1] = clamp(points[2][1], -bh, bh); points[2][2] = clamp(points[2][2], -bw, bw); points[3] = points[0] + dir3 * frand(0,5); points[3][0] = clamp(points[3][0], -bw, bw); points[3][1] = clamp(points[3][1], -bh, bh); points[3][2] = clamp(points[3][2], -bw, bw); newc = new SmallCurveComet(scene, time, frand(2.75, 3.25), points, 4, acolor, ecolor); scene->addComet(newc); } } void CurveComet::destroyEffect2(double time, const Vec3f& pos, const Vec3f& /*unused*/) { Comet* newc; Vec3f points[4]; Vec3f dir, dir2, dir3; double bw = scene->getBoxWidth()/2; double bh = scene->getBoxHeight()/2; points[0] = pos; for (int i = 0; i < numChildren; i++) { dir = Vec3f::Vec3f::randomUnit(); Vec3f::generateOrthonormalBasis(dir, dir2, dir3); points[1] = points[0] + dir * 10 + Vec3f::randomUnitOnPlane(dir2, dir3) * 35; points[1][0] = clamp(points[1][0], -bw, bw); points[1][1] = clamp(points[1][1], -bh, bh); points[1][2] = clamp(points[1][2], -bw, bw); points[2] = points[0]+ dir * 20 + Vec3f::randomUnitOnPlane(dir2, dir3) * 35; points[2][0] = clamp(points[2][0], -bw, bw); points[2][1] = clamp(points[2][1], -bh, bh); points[2][2] = clamp(points[2][2], -bw, bw); points[3] = points[0]+ dir * 30 + Vec3f::randomUnitOnPlane(dir2, dir3) * 35; points[3][0] = clamp(points[3][0], -bw, bw); points[3][1] = clamp(points[3][1], -bh, bh); points[3][2] = clamp(points[3][2], -bw, bw); newc = new SmallCurveComet(scene, time, frand(1.0, 1.25), points, 4, acolor, ecolor); scene->addComet(newc); } } void CurveComet::destroyEffect3(double time, const Vec3f& pos, const Vec3f& /*unused*/) { Comet* newc; Vec3f points[4]; Vec3f dir, dir2, dir3; double bw = scene->getBoxWidth()/2; double bh = scene->getBoxHeight()/2; points[0] = pos; for (int i = 0; i < numChildren; i++) { dir = Vec3f::Vec3f::randomUnit(); Vec3f::generateOrthonormalBasis(dir, dir2, dir3); dir2 = Vec3f::randomUnitOnPlane(dir2, dir3); points[1] = points[0] + dir * 50; points[1][0] = clamp(points[1][0], -bw, bw); points[1][1] = clamp(points[1][1], -bh, bh); points[1][2] = clamp(points[1][2], -bw, bw); points[2] = points[1] + dir2 * 50; points[2][0] = clamp(points[2][0], -bw, bw); points[2][1] = clamp(points[2][1], -bh, bh); points[2][2] = clamp(points[2][2], -bw, bw); points[3] = points[0] + dir2 * 2.5; points[3][0] = clamp(points[3][0], -bw, bw); points[3][1] = clamp(points[3][1], -bh, bh); points[3][2] = clamp(points[3][2], -bw, bw); newc = new SmallCurveComet(scene, time, frand(1.75, 1.99), points, 4, acolor, ecolor); scene->addComet(newc); } } void CurveComet::destroy(double time) { Vec3f pos; Vec3f vel; Comet* newc; if (destroyed) return; pos = curve->position((time - startTime) / lifeTime); vel = curve->firstDerivate((time - startTime) / lifeTime); switch (rand() % 3) { case 0: destroyEffect1(time, pos, vel); break; case 1: destroyEffect2(time, pos, vel); break; case 2: default: destroyEffect3(time, pos, vel); break; } newc = new Explosion(scene, time, 1.0, pos, 25*size, 300, acolor, ecolor); scene->addComet(newc); psystem->stop(); destroyed = true; } bool CurveComet::isDestroyed() { return destroyed; } bool CurveComet::isDone() { return destroyed && psystem->done(); } /* * SmallCurveComet */ SmallCurveComet::SmallCurveComet(CometenScene * scene, double time, double _lifeTime, const Vec3f *points, int numPoints, const Vec4f & _acolor, const Vec4f & _ecolor) : Comet(scene, 0.25), startTime(time), lifeTime(_lifeTime), acolor(_acolor), ecolor(_ecolor) { GLuint tex = scene->textures[T_PARTICLE]; assert(points && numPoints >= 2); position = points[0]; psystem = new ParticleSystem(time, tex, points[0], points[0], 300, 0, 1.5, 2.0, true, 150, 0.0, 2.0, false, 1.75, acolor, ecolor); decal = new Decal(tex, points[0], 3.0, true, Vec3f::UNIT_X, acolor); curve = new Bezier3(points, numPoints); destroyed = false; } SmallCurveComet::~SmallCurveComet() { delete psystem; delete decal; delete curve; } void SmallCurveComet::process(double time, double /*unused*/) { position = curve->position((time - startTime) / lifeTime); decal->setPosition(position); psystem->setEmitterPos1(psystem->getEmitterPos2()); psystem->setEmitterPos2(position); psystem->process(time); if (!destroyed) { if (time - startTime > lifeTime) destroy(time); } } void SmallCurveComet::render(const Vec3f& campos) { if (!destroyed) { decal->render(campos); } psystem->render(campos); } void SmallCurveComet::destroy(double time) { Vec3f pos; Comet* newc; if (destroyed) return; pos = curve->position((time - startTime) / lifeTime); newc = new Explosion(scene, time, 1.0, pos, 25*size, 150, acolor, ecolor); scene->addComet(newc); psystem->stop(); destroyed = true; } bool SmallCurveComet::isDestroyed() { return destroyed; } bool SmallCurveComet::isDone() { return destroyed && psystem->done(); } kcometen4-1.0.7/src/kglcometen4.h0000644000000000000000000000450411215363355015271 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef KGLCOMETEN4_H #define KGLCOMETEN4_H #include #include #include #include #include #include #include "cometen3.h" #include "global.h" /** @author Peter Mueller */ class KGLCometen4 : public QGLWidget { Q_OBJECT public: KGLCometen4(QWidget *parent = 0); virtual ~KGLCometen4(); void start(); void stop(); void updateSizeScale(); void updateTextures(); void updateTimeScale(); void updateFreeCamSpeed(); void updateSlowMotionEffects(); protected: void initializeGL(); void resizeGL( int, int ); void paintGL(); void timerEvent( QTimerEvent * ); private: GLuint loadTexture(const QString& file); QString randomFileFromDir(const QString& dir); Cometen3 * cometen3; GLuint* textures; int m_timerId; QTime t; }; #endif kcometen4-1.0.7/src/cometen3.cpp0000644000000000000000000003706611204715772015140 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "cometen3.h" #include "settings.h" Cometen3::Cometen3() { scene = 0; camera = 0; cameraCurve = 0; fovx = 0; fovy = 0; matrixAngle = 0; } Cometen3::~Cometen3() { quit(); } void Cometen3::updateTimeScale(double time) { timeScale.setScale(settings->timeScale, sceneTimer.getTime(time)); } void Cometen3::updateFreeCamSpeed() { curveTime = 120.0 / (1.0 + 2*clamp(settings->freeCameraSpeed, 0, 10)); } void Cometen3::updateSlowMotionEffects(double time) { // Gracefully exits these effects if suddenly turned off in the preview. if ( ( !settings->matrix && state == S_MATRIX ) || ( !settings->slowMotion && state == S_SLOWMOTION ) ) { stateStart = time - 30.51; } } void Cometen3::init(const GLuint* text, int resX, int resY, double time) { quit(); textures = text; glShadeModel(GL_SMOOTH); glClearColor(0.0, 0.0, 0.0, 1.0); glClearDepth(1.0); glDepthFunc(GL_LEQUAL); //glEnable(GL_POINT_SMOOTH); //glEnable(GL_LINE_SMOOTH); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); //glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); //glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); //glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glFrontFace(GL_CW); QString glCaps = (char*)glGetString(GL_EXTENSIONS ); if ( glCaps.contains( "GL_ARB_point_sprite", Qt::CaseInsensitive ) && glCaps.contains( "GL_ARB_point_parameters", Qt::CaseInsensitive ) ) settings->usePointSprites = true; else settings->usePointSprites = false; if ( settings->usePointSprites ) { glPointParameterfARB(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 60.0); glPointParameterfARB(GL_POINT_SIZE_MIN_ARB, 0.0); glPointParameterfARB(GL_POINT_SIZE_MAX_ARB, 1000.0); } sceneTimer.setScale(1.0, time); sceneTimer.setTime(0.0, time); timeScale.setScale(settings->timeScale, sceneTimer.getTime(time)); timeScale.setTime(0.0, sceneTimer.getTime(time)); scene = new CometenScene(textures, timeScale.getTime(sceneTimer.getTime(time)), 1.0, 1.0); camera = new Camera(Vec3f::ZERO, Vec3f::ZERO); cameraCurve = 0; curveCreateTime = 0.0; curveTime = 120.0 / (1.0 + 2*clamp(settings->freeCameraSpeed, 0, 10)); resize(resX, resY); nextEffect = time + frand(45.0, 120.0); state = S_NORMAL; } void Cometen3::quit() { if (scene != 0) { delete scene; scene = 0; } if (camera != 0) { delete camera; camera = 0; } if (cameraCurve != 0) { delete cameraCurve; cameraCurve = 0; } } void Cometen3::changeViewport(int x, int y, int width, int height) { // a, b, c: size' = size * sqrt[1 / (a + b*d + c*d^2)] double maxFov = settings->fov; double multiplier = tanf( deg2rad( maxFov/2.0 ) ); if ( width > height ) { fovx = maxFov; fovy = rad2deg( atanf(multiplier*height/width) ) * 2.0; } else { fovy = maxFov; fovx = rad2deg( atanf(multiplier*width/height) ) * 2.0; } double fov = fovx > fovy ? fovx : fovy; int longer = width > height ? width : height; // The original formula used height^2 below, but we want a similar value // regardless of whether w or h is longer. Base it off what we'd get for // a 640x480 view: 480 = 0.75 * 640. float dist_attenuation[] = {0.0, 0.0, 4.0 * tanf(deg2rad(fov/2)) * tanf(deg2rad(fov/2)) /(0.75*longer*0.75*longer)}; glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, dist_attenuation); glViewport(x, y, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if ( width > height ) gluPerspective(fovy, (double)width / height, 1.0, 10000.0); else { double xmin, xmax, ymin, ymax; xmax = tanf( deg2rad(fovx/2) ); xmin = -xmax; ymin = xmin * (double)height/width; ymax = xmax * (double)height/width; glFrustum(xmin, xmax, ymin, ymax, 1.0, 10000.0); } glMatrixMode(GL_MODELVIEW); } void Cometen3::updateSizeScale() { double oldBw = scene->getBoxWidth() / 2 - 3; double oldBh = scene->getBoxHeight() / 2 - 3; resizeBox(); double newBw = scene->getBoxWidth() / 2 - 3; double newBh = scene->getBoxHeight() / 2 - 3; double xScaleFactor = newBw / oldBw; double yScaleFactor = newBh / oldBh; double maxAngle = atan( scene->getBoxHeight() / scene->getBoxWidth() ); if ( matrixAngle > maxAngle ) matrixAngle = maxAngle; if ( settings->freeCamera && cameraCurve ) { const Vec3f* oldPoints = cameraCurve->getPoints(); const int pointCount = cameraCurve->getPointCount(); Vec3f newPoints[ pointCount ]; for ( int i = 0; i < pointCount; i++ ) { double x, y, z; x = oldPoints[i][0] * xScaleFactor; y = oldPoints[i][1] * yScaleFactor; z = oldPoints[i][2] * xScaleFactor; newPoints[ i ] = Vec3f( x, y, z ); } delete cameraCurve; cameraCurve = new Bezier3( newPoints, pointCount ); } } void Cometen3::resize(int newResX, int newResY) { resX = newResX; resY = newResY; updateSizeScale(); } void Cometen3::resizeBox() { double boxWidth, boxHeight; changeViewport(0,0,resX, resY); if ( settings->cube ) { boxWidth = 150.0 * settings->sizeScale; boxHeight = boxWidth; } else { if ( resX > resY ) { boxWidth = 150.0 * settings->sizeScale; boxHeight = boxWidth * resY / resX; } else { boxHeight = 150.0 * settings->sizeScale; boxWidth = boxHeight * resX / resY; } } scene->resizeBox(boxWidth, boxHeight); } void Cometen3::process(double time) { processDefaultCameraPos(time); switch (state) { case S_NORMAL: processNormal(time); break; case S_MATRIX: processMatrix(time); break; case S_SLOWMOTION: processSlowmotion(time); break; default: state = S_NORMAL; stateStart = time; break; } scene->process(timeScale.getTime(sceneTimer.getTime(time))); if (state == S_NORMAL && time > nextEffect) { if (settings->matrix && settings->slowMotion) { switch(rand() % 2) { case 0: state = S_SLOWMOTION; stateStart = time; break; case 1: default: state = S_MATRIX; stateStart = time; break; } } else if (settings->matrix) { state = S_MATRIX; stateStart = time; } else if (settings->slowMotion) { state = S_SLOWMOTION; stateStart = time; } nextEffect = time + frand(120.0, 180.0); } } void Cometen3::newCameraCurve(double time) { Vec3f points[4]; double bw = scene->getBoxWidth() / 2 - 3; double bh = scene->getBoxHeight() / 2 - 3; if (cameraCurve != 0) { points[0] = cameraCurve->position(1.0); points[1] = cameraCurve->position(2.0); delete cameraCurve; } else { points[0] = Vec3f(bw,frand(-bh,bh),frand(-bw,bw)); points[1] = Vec3f(bw,frand(-bh,bh),frand(-bw,bw)); } switch (rand() % 6) { case 0: points[2] = Vec3f(bw,frand(-bh,bh),frand(-bw,bw)); points[3] = Vec3f(bw,frand(-bh,bh),frand(-bw,bw)); break; case 1: points[2] = Vec3f(bw,frand(-bh,bh),frand(-bw,bw)); points[3] = Vec3f(bw,frand(-bh,bh),frand(-bw,bw)); break; case 2: points[2] = Vec3f(frand(-bw,-bw),bh,frand(-bw,bw)); points[3] = Vec3f(frand(-bw,-bw),bh,frand(-bw,bw)); break; case 3: points[2] = Vec3f(frand(-bw,-bw),bh,frand(-bw,bw)); points[3] = Vec3f(frand(-bw,-bw),bh,frand(-bw,bw)); break; case 4: points[2] = Vec3f(frand(-bw,-bw),frand(-bh,bh),bw); points[3] = Vec3f(frand(-bw,-bw),frand(-bh,bh),bw); break; case 5: default: points[2] = Vec3f(frand(-bw,-bw),frand(-bh,bh),bw); points[3] = Vec3f(frand(-bw,-bw),frand(-bh,bh),bw); break; } points[3] = (points[3] + points[2]) * 0.5; cameraCurve = new Bezier3(points, 4); curveCreateTime = time; } void Cometen3::processDefaultCameraPos(double time) { if (settings->freeCamera) { if (cameraCurve == 0 || time > curveCreateTime + curveTime) { newCameraCurve(time); } assert(cameraCurve != 0); defaultCameraPosition = cameraCurve->position( (time - curveCreateTime) / curveTime); } else { double fov = fovx > fovy ? fovx : fovy; double width = scene->getBoxWidth(); double height = scene->getBoxHeight(); double longer = width > height ? width : height; double shorter = width < height ? width : height; if ( settings->cube ) { double boxCamDistance = shorter / 2 / tanf(deg2rad(fov/2)); defaultCameraPosition = Vec3f(0.0, 0.0, boxCamDistance + longer/2); } else { double boxCamDistance = width / 2 / tanf(deg2rad(fovx/2)); defaultCameraPosition = Vec3f(0.0, 0.0, boxCamDistance + width/2); } } } void Cometen3::processNormal(double /*unused*/) { camera->position = defaultCameraPosition; camera->viewpoint = Vec3f::ZERO; camera->fade = 0.0; camera->blackBars = false; } void Cometen3::processMatrix(double time) { double t = time - stateStart; camera->viewpoint = Vec3f::ZERO; if (t < 0.5) { camera->position = defaultCameraPosition; camera->fade = (t) / 0.5; camera->blackBars = false; sceneTimer.setScale(1.0, time); } else if (t < 1.0) { camera->position = defaultCameraPosition; camera->fade = 1.0; camera->blackBars = true; sceneTimer.setScale(0.1, time); double maxAngle = atan( scene->getBoxHeight() / scene->getBoxWidth() ) / 2.0; matrixAngle = frand(0.0, maxAngle); } else if (t < 31.0) { camera->blackBars = true; sceneTimer.setScale(0.1, time); if (t < 1.5) { camera->fade = 1 - (t - 1.0) / 0.5; } else if (t > 30.5) { camera->fade = (t - 30.5) / 0.5; } else { camera->fade = 0.0; } double fov = fovx > fovy ? fovx : fovy; double width = scene->getBoxWidth(); double height = scene->getBoxHeight(); double longer = width > height ? width : height; double boxCamDistance = longer / 2 / tanf(deg2rad(fov/2)); double w = (t - 1.0) / 30.0 * Pi * 2; camera->position[0] = sinf(w) * cosf(matrixAngle) * boxCamDistance; camera->position[1] = sinf(w) * sinf(matrixAngle) * boxCamDistance; camera->position[2] = cosf(w) * boxCamDistance; camera->viewpoint = Vec3f::ZERO; } else if (t < 31.5) { camera->position = defaultCameraPosition; camera->fade = 1.0; camera->blackBars = true; sceneTimer.setScale(0.1, time); } else if (t < 32.0) { camera->position = defaultCameraPosition; camera->fade = 1 - (t - 31.5) / 0.5; sceneTimer.setScale(1.0, time); camera->blackBars = false; } else { camera->blackBars = false; camera->fade = 0.0; camera->position = defaultCameraPosition; sceneTimer.setScale(1.0, time); nextEffect = time + frand(120.0, 180.0); state = S_NORMAL; stateStart = time; } } void Cometen3::processSlowmotion(double time) { double t = time - stateStart; camera->viewpoint = Vec3f::ZERO; if (t < 0.5) { camera->position = defaultCameraPosition; camera->fade = (t) / 0.5; camera->blackBars = false; sceneTimer.setScale(1.0, time); } else if (t < 1.0) { camera->position = defaultCameraPosition; camera->fade = 1.0; camera->blackBars = true; sceneTimer.setScale(0.25f, time); } else if (t < 16.0) { camera->blackBars = true; if (t < 1.5) { camera->fade = 1 - (t - 1.0) / 0.5; } else if (t > 15.5) { camera->fade = (t - 15.5) / 0.5; } else { camera->fade = 0.0; } camera->position = Vec3f(scene->getBoxWidth()/2 - 10, -scene->getBoxHeight()/2 + 10, scene->getBoxWidth()/2 - 10); sceneTimer.setScale(0.25f, time); } else if (t < 31.0) { camera->blackBars = true; if (t < 16.5) { camera->fade = 1 - (t - 16.0) / 0.5; } else if (t > 30.5) { camera->fade = (t - 30.5) / 0.5; } else { camera->fade = 0.0; } camera->position = Vec3f(-scene->getBoxWidth()/2 + 10, +scene->getBoxHeight()/2 - 10, -scene->getBoxWidth()/2 + 10); sceneTimer.setScale(0.25f, time); } else if (t < 31.5) { camera->position = defaultCameraPosition; camera->fade = 1.0; camera->blackBars = true; sceneTimer.setScale(0.25f, time); } else if (t < 32.0) { camera->fade = 1 - (t - 31.5) / 0.5; sceneTimer.setScale(1.0, time); camera->blackBars = false; camera->position = defaultCameraPosition; } else { camera->blackBars = false; camera->fade = 0.0; camera->position = defaultCameraPosition; sceneTimer.setScale(1.0, time); nextEffect = time + frand(120.0, 180.0); state = S_NORMAL; stateStart = time; } } void Cometen3::render() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); gluLookAt(camera->position[0],camera->position[1],camera->position[2], camera->viewpoint[0],camera->viewpoint[1],camera->viewpoint[2], 0.0, 1.0, 0.0); scene->render(camera->position); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); GLint dims[4]; glGetIntegerv( GL_VIEWPORT, dims); glOrtho(0.0, dims[2], 0.0, dims[3], 0.0, 1.0); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glDisable(GL_CULL_FACE); glDisable(GL_TEXTURE_2D); if (camera->blackBars && settings->aspectRatio != 2) { glDisable(GL_BLEND); glColor4f(0.0, 0.0, 0.0, 1.0); glBegin(GL_QUADS); double aspectRatio; switch ( settings->aspectRatio ) { case 1: // 2.40:1 is actually 2.39:1 aspectRatio = 2.39; break; default: aspectRatio = 1.85; break; } double bar_height = ( aspectRatio * dims[3] - dims[2] ) / ( 2.0 * aspectRatio ); double bar_width = ( dims[2] - aspectRatio * dims[3] ) / 2.0; if ( bar_height > 0 ) { glVertex2f(0.0, 0.0); glVertex2f(0.0, bar_height); glVertex2f(dims[2], bar_height); glVertex2f(dims[2], 0.0); glVertex2f(0.0, dims[3]); glVertex2f(0.0, dims[3]-bar_height); glVertex2f(dims[2], dims[3]-bar_height); glVertex2f(dims[2], dims[3]); } else if ( bar_width > 0 ) { glVertex2f(0.0, 0.0); glVertex2f(0.0, dims[3]); glVertex2f(bar_width, dims[3]); glVertex2f(bar_width, 0.0); glVertex2f(dims[2], 0.0); glVertex2f(dims[2], dims[3]); glVertex2f(dims[2]-bar_width, dims[3]); glVertex2f(dims[2]-bar_width, 0.0); } glEnd(); } if (camera->fade != 0.0) { glBlendFunc(GL_SRC_ALPHA, GL_ONE); glEnable(GL_BLEND); glColor4f(1.0, 1.0, 1.0, camera->fade); glBegin(GL_QUADS); glVertex2f(0.0, 0.0); glVertex2f(0.0, dims[3]); glVertex2f(dims[2], dims[3]); glVertex2f(dims[2], 0.0); glEnd(); } glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); } kcometen4-1.0.7/src/kglcometen4.cpp0000644000000000000000000001327311424423105015617 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "kglcometen4.h" #include "cometenmath.h" #include "settings.h" #include #include #include KGLCometen4::KGLCometen4(QWidget *parent) : QGLWidget(parent) { settings = new Settings(); cometen3 = new Cometen3(); textures = new GLuint[T_NUM]; } KGLCometen4::~KGLCometen4() { delete cometen3; delete[] textures; delete settings; } void KGLCometen4::start() { m_timerId = startTimer(1000/settings->maxFps); } void KGLCometen4::stop() { killTimer( m_timerId ); } void KGLCometen4::updateTimeScale() { cometen3->updateTimeScale(t.elapsed() / 1000.0); } void KGLCometen4::updateFreeCamSpeed() { cometen3->updateFreeCamSpeed(); } void KGLCometen4::updateSlowMotionEffects() { cometen3->updateSlowMotionEffects(t.elapsed() / 1000.0); } void KGLCometen4::updateTextures() { QImage image; srand(time(NULL)); if (settings->bgType == 2) { QString file = randomFileFromDir(settings->bgDir); if (!image.load(file)) { image = QPixmap::grabWindow(QApplication::desktop()->winId()).toImage(); } } else if (settings->bgType == 1) { if (!image.load(settings->bgFile)) { image = QPixmap::grabWindow(QApplication::desktop()->winId()).toImage(); } } else { image = QPixmap::grabWindow(QApplication::desktop()->winId()).toImage(); } switch (settings->bgSize) { case 0: image = image.scaled(128, 128, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); break; case 1: image = image.scaled(256, 256, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); break; case 2: image = image.scaled(512, 512, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); break; case 3: image = image.scaled(1024, 1024, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); break; case 4: default: break; } image = QGLWidget::convertToGLFormat(image); glEnable(GL_TEXTURE_2D); glGenTextures(1, &textures[T_BACKGROUND]); glBindTexture(GL_TEXTURE_2D, textures[T_BACKGROUND]); if (settings->mipmaps) { gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, image.width(), image.height(), GL_RGBA, GL_UNSIGNED_BYTE, image.bits()); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR); } else { glTexImage2D(GL_TEXTURE_2D, 0, 3, image.width(), image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, image.bits()); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); } glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); textures[T_PARTICLE] = loadTexture("particle.png"); textures[T_LIGHTMAP] = loadTexture("lightmap.png"); } void KGLCometen4::initializeGL() { qglClearColor(QColor(Qt::black)); updateTextures(); t.start(); cometen3->init(textures, 640, 480, t.elapsed() / 1000.0); } void KGLCometen4::resizeGL(int res_x, int res_y) { cometen3->resize(res_x, res_y); } void KGLCometen4::updateSizeScale() { cometen3->updateSizeScale(); } void KGLCometen4::paintGL() { cometen3->render(); } void KGLCometen4::timerEvent(QTimerEvent * ) { cometen3->process(t.elapsed() / 1000.0); updateGL(); } QString KGLCometen4::randomFileFromDir(const QString& dirname) { QDir dir(dirname, "*.jpg;*.jpeg;*.png;*.gif", QDir::Unsorted, QDir::Files | QDir::Readable); if (dir.count() < 1) { return QString(""); } int num = rand() % dir.count(); return dir.absolutePath() + "/" + dir[num]; } GLuint KGLCometen4::loadTexture(const QString& file) { QImage image; GLuint tex = 0; if (image.load(KStandardDirs::locate("data", QString("kcometen4/pixmaps/") + file))) { image = QGLWidget::convertToGLFormat(image); glEnable(GL_TEXTURE_2D); glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); if (settings->mipmaps) { gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, image.width(), image.height(), GL_RGBA, GL_UNSIGNED_BYTE, image.bits()); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR); } else { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, image.width(), image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, image.bits()); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); } glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); } return tex; } #include "kglcometen4.moc" kcometen4-1.0.7/src/cometen3.h0000644000000000000000000000673311204715772014602 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef COMETEN3_H #define COMETEN3_H #include "global.h" #include "cometenscene.h" #include "comet.h" #include "cometenmath.h" #include "bezier.h" // t'(t) = (t - t0) * time_scale + t1 class Timer { public: Timer() { t0 = 0.0; t1 = 0.0; timeScale = 1.0; } ~Timer() {} void setTime(double startTime, double realTime) { t1 = startTime; t0 = realTime; } void setScale(double ts, double realTime) { t1 = getTime(realTime); t0 = realTime; timeScale = ts; } double getTime(double realTime) { return (realTime - t0) * timeScale + t1; } double getScale() { return timeScale; } private: double t0; double t1; double timeScale; }; class Camera { public: Camera(const Vec3f& pos, const Vec3f& viewp) { position = pos; viewpoint = viewp; fade = 0.0; blackBars = false; } ~Camera() {} Vec3f position; Vec3f viewpoint; double fade; Vec4f fadeColor; double blackBars; Vec4f blackBarsColor; }; class Cometen3 { public: Cometen3(); ~Cometen3(); void init(const GLuint* textures, int resX, int resY, double time); void quit(); void process(double time); void render(); void resize(int resX, int resY); void updateTimeScale(double time); void updateFreeCamSpeed(); void updateSlowMotionEffects(double time); void updateSizeScale(); private: void changeViewport(int x, int y, int width, int height); void resizeBox(); void newCameraCurve(double time); void processDefaultCameraPos(double time); void processNormal(double time); void processMatrix(double time); void processSlowmotion(double time); const GLuint* textures; Camera *camera; CometenScene* scene; Timer timeScale; Timer sceneTimer; enum { S_NORMAL, S_MATRIX, S_SLOWMOTION, S_SPLITSCREEN, S_NUM }; int state; double stateStart; Vec3f defaultCameraPosition; int resX; int resY; double fovx; double fovy; double nextEffect; Bezier3* cameraCurve; double curveTime; double curveCreateTime; double matrixAngle; }; #endif kcometen4-1.0.7/src/settings.cpp0000644000000000000000000001054011141652537015246 0ustar rootroot/*************************************************************************** * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "settings.h" #include "cometenmath.h" #include #include #include Settings::Settings() { load(); usePointSprites = true; } void Settings::load() { KConfigGroup config( KGlobal::config(), "Settings" ); // Scene fov = clamp(config.readEntry("fov", 76.0), 10.0, 120.0); freeCamera = config.readEntry( "freecamera", true ); freeCameraSpeed = clamp(config.readEntry("freecamspeed", 1.5), 0.0, 10.0); sizeScale = clamp(config.readEntry("sizescale", 2.5), 0.5, 5.0); cube = config.readEntry( "cube", false ); slowMotion = config.readEntry( "slowmotion", true ); matrix = config.readEntry( "matrix", true ); aspectRatio = config.readEntry( "aspectratio", 0 ); maxFps = clamp(10, 999, config.readEntry("maxfps", 60)); mipmaps = config.readEntry("mipmaps", false); // Comets color = config.readEntry("color", 0); createInterval = clamp(config.readEntry("interval", 1.25), 0.1, 10.0); timeScale = clamp(config.readEntry("timescale", 1.0), 0.1, 5.0); particleDensity = clamp(config.readEntry( "particledensity", 100), 0, 100); rotateComet = config.readEntry( "rotatecomet", true ); splitComet = config.readEntry( "splitcomet", true ); curveComet = config.readEntry( "curvecomet", true ); blitz = config.readEntry( "lightning", true ); // Background bgType = config.readEntry("bgtype", 0); bgFile = config.readEntry("bgfile",""); bgDir = config.readEntry("bgdir",""); bgSize = config.readEntry("bgsize", 2); } void Settings::defaults() { // Scene fov = 76.0; freeCamera = true; freeCameraSpeed = 1.5; sizeScale = 2.5; cube = false; slowMotion = true; matrix = true; aspectRatio = 0; maxFps = 60; mipmaps = false; // Comets color = 0; createInterval = 1.25; timeScale = 1.0; particleDensity = 100; rotateComet = true; splitComet = true; curveComet = true; blitz = true; // Background bgType = 0; bgFile = QString(); bgDir = QString(); bgSize = 2; } void Settings::save() { KConfigGroup config( KGlobal::config(), "Settings" ); // Scene config.writeEntry("fov", fov); config.writeEntry("freecamera", freeCamera); config.writeEntry("freecamspeed", freeCameraSpeed); config.writeEntry("sizescale", sizeScale); config.writeEntry("cube", cube); config.writeEntry("slowmotion", slowMotion); config.writeEntry("matrix", matrix); config.writeEntry("aspectratio", aspectRatio); config.writeEntry("maxfps", maxFps); config.writeEntry("mipmaps", mipmaps); // Comets config.writeEntry("color", color); config.writeEntry("interval", createInterval); config.writeEntry("timescale", timeScale); config.writeEntry("particledensity", particleDensity); config.writeEntry("rotatecomet", rotateComet); config.writeEntry("splitcomet", splitComet); config.writeEntry("curvecomet", curveComet); config.writeEntry("lightning", blitz); // Background config.writeEntry("bgtype", bgType); config.writeEntry("bgfile", bgFile); config.writeEntry("bgdir", bgDir); config.writeEntry("bgsize", bgSize); config.sync(); } kcometen4-1.0.7/src/pcomet.h0000644000000000000000000000573711037505776014364 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef PCOMET_H #define PCOMET_H #include "global.h" #include "cometenmath.h" #include "comet.h" #include "explosion.h" #include "glow.h" class PComet : public Comet { public: PComet(CometenScene * scene, double time, double lifeTime, double size, const Vec3f& position, const Vec3f& velocity, double particlePerSec, double particleLifeTime, const Vec4f& acolor, const Vec4f& ecolor); virtual ~PComet(); virtual void process(double time, double deltat); virtual void render(const Vec3f& campos); virtual void destroy(double time); virtual bool isDestroyed(); virtual bool isDone(); protected: virtual void hitPlane(double time, const Plane & plane); bool destroyed; Vec3f velocity; Vec3f acceleration; double startTime; double lifeTime; Vec4f acolor, ecolor; ParticleSystem *psystem; Decal* decal; }; class QComet : public PComet { public: QComet(CometenScene * scene, double time, double lifeTime, const Vec3f & pos, const Vec3f & vel, bool split, const Vec4f & acolor, const Vec4f & ecolor); virtual ~QComet(); virtual void destroy(double time); protected: bool split; }; class SmallQComet : public PComet { public: SmallQComet(CometenScene * scene, double time, double lifeTime, const Vec3f & pos, const Vec3f & vel, double size, int split, const Vec4f & acolor, const Vec4f & ecolor); virtual ~SmallQComet(); virtual void destroy(double time); protected: int split; }; #endif kcometen4-1.0.7/src/cometenscene.h0000644000000000000000000000526211037505776015536 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef COMETENSCENE_H #define COMETENSCENE_H #include "global.h" #include "math.h" #include "particlesystem.h" #include "comet.h" class Comet; class CometenScene { public: CometenScene(const GLuint* textures, double time, double boxWidth, double boxHeight); ~CometenScene(); void process(double time); void render(const Vec3f& campos); void addComet(Comet * comet); list comets; void resizeBox(double boxWidth, double boxHeight); double getBoxWidth(); double getBoxHeight(); const Plane& getPlane(int i); int getNumPlanes(); const GLuint* textures; private: vector collisionPlanes; double cometInterval; double boxWidth; double boxHeight; double lastCometProcess; double nextComet; void getCometColors(Vec4f& acolor, Vec4f& ecolor); void createComet(double time); void renderBackground(); }; inline double CometenScene::getBoxWidth() { return boxWidth; } inline double CometenScene::getBoxHeight() { return boxHeight; } inline const Plane& CometenScene::getPlane(int i) { assert(i >= 0 && i < getNumPlanes()); return collisionPlanes[i]; } inline int CometenScene::getNumPlanes() { return collisionPlanes.size(); } #endif kcometen4-1.0.7/src/lightning.cpp0000644000000000000000000001732011037505776015402 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "lightning.h" Lightning::Lightning(CometenScene* _scene, double time, const Vec3f & _start, const Vec3f & _end) : Comet(_scene), startTime(time), startPoint(_start), endPoint(_end) { Vec3f diff = startPoint - endPoint; double w = diff.length() / 100; w = clamp(w, 1.0, 2.0); createLightning(startPoint, endPoint, 3, 2, w); lifeTime = frand(0.2, 0.3); done = false; transparency = 0; texture = scene->textures[T_PARTICLE]; maxVertices = 12 * max(lines.size(), lines2.size()); vertices = new LightningVertex[maxVertices]; } Lightning::~Lightning() { delete[] vertices;; } void Lightning::process(double time, double /*unused*/) { if (time > startTime + lifeTime) { done = true; transparency = 0.0; return; } transparency = sinf((time-startTime) / lifeTime * 2*Pi ); transparency *= transparency; transparency = min(1.0, 2*transparency); } int Lightning::buildVertexArray(const Vec3f& campos, double width2, const vector& lines) { Vec3f dir, up, right; LightningVertex * v; vector::const_iterator i; // line to cam direction dir = campos - ((startPoint + endPoint) / 2); dir.normalize(); v = vertices; for (i = lines.begin(); i != lines.end(); i++) { const Line & line = *i; double width = line.width * width2; assert(v + 12 <= vertices + maxVertices); right = line.dir; up = dir.cross(right); up.normalize(); v->pos = line.p1 - right * (width/2) - up * (width/2); v->uv[0] = 0.0; v->uv[1] = 0.0; v++; v->pos = line.p1 - right * (width/2) + up * (width/2); v->uv[0] = 0.0; v->uv[1] = 1.0; v++; v->pos = line.p1 + up * (width/2); v->uv[0] = 0.5; v->uv[1] = 1.0; v++; v->pos = line.p1 - up * (width/2); v->uv[0] = 0.5; v->uv[1] = 0.0; v++; //// v->pos = line.p1 - up * (width/2); v->uv[0] = 0.49; v->uv[1] = 0.0; v++; v->pos = line.p1 + up * (width/2); v->uv[0] = 0.49; v->uv[1] = 1.0; v++; v->pos = line.p2 + up * (width/2); v->uv[0] = 0.51; v->uv[1] = 1.0; v++; v->pos = line.p2 - up * (width/2); v->uv[0] = 0.51; v->uv[1] = 0.0; v++; //// v->pos = line.p2 - up * (width/2); v->uv[0] = 0.5; v->uv[1] = 0.0; v++; v->pos = line.p2 + up * (width/2); v->uv[0] = 0.5; v->uv[1] = 1.0; v++; v->pos = line.p2 + up * (width/2) + right * (width/2); v->uv[0] = 1.0; v->uv[1] = 1.0; v++; v->pos = line.p2 - up * (width/2) + right * (width/2); v->uv[0] = 1.0; v->uv[1] = 0.0; v++; } return v - vertices; } void Lightning::render(const Vec3f & campos) { int numVertices; glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(3, GL_FLOAT, sizeof(LightningVertex), &vertices[0].pos); glTexCoordPointer(2, GL_FLOAT, sizeof(LightningVertex), &vertices[0].uv); numVertices = buildVertexArray(campos, 1.0, lines); glColor4f(1.0, 1.0, 1.0, 1.0*transparency); glDrawArrays(GL_QUADS, 0, numVertices); numVertices = buildVertexArray(campos, 4.0, lines); glColor4f(0.1, 0.1, 0.4, 0.7*transparency); glDrawArrays(GL_QUADS, 0, numVertices); numVertices = buildVertexArray(campos, 12.0, lines2); glColor4f(0.99, 0.99, 0.99, 0.15*transparency); glDrawArrays(GL_QUADS, 0, numVertices); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); } void Lightning::createLightning(const Vec3f& start, const Vec3f& end, int detail, int split, double width) { const int numSteps = 4; Vec3f p1, p2, p3; Vec3f up, right; Line line; Vec3f dir = end - start; double l = dir.normalize(); double var = l / (6.5); Vec3f::generateOrthonormalBasis(dir, up, right); p2 = start; for (int i = 1; i <= numSteps; i++) { p1 = p2; p2 = start + i * (l / numSteps) * dir; if (i < numSteps) { p2 += (Vec3f::randomUnitOnPlane(up, right)*frand(var/2, var)); } if (detail == 0) { line.p1 = p1; line.p2 = p2; line.dir = p2 - p1; line.l = line.dir.normalize(); line.width = width; lines.push_back(line); } if (detail == 2) { line.p1 = p1; line.p2 = p2; line.dir = p2 - p1; line.l = line.dir.normalize(); line.width = width; lines2.push_back(line); } if (detail > 0) { createLightning(p1, p2, detail-1, 0, width); if (i > 1 && split > 0) { p3 = p1 + dir * l/numSteps * frand(); p3 += Vec3f::randomUnitOnPlane(up, right) * frand(l/numSteps / 2, l/numSteps); createLightning(p1, p3, detail-1, split-1, width/2); } } } } void Lightning::destroy(double /*unused*/) { } bool Lightning::isDestroyed() { return true; } bool Lightning::isDone() { return done; } Blitz::Blitz(CometenScene* scene, double time) : Comet(scene) { num = rand(3,6); nextBlitz = time; interval = 0.8; done = false; } Blitz::~Blitz() { } void Blitz::process(double time, double /*unused*/) { if (num < 1) { done = true; } if (!done && time >= nextBlitz) { list::iterator j; Comet * comet = 0; Comet* newc; nextBlitz = time + interval; for (j = scene->comets.begin(); j != scene->comets.end(); j++) { if (!(*j)->isDestroyed() && (*j)->getSize() >= 0.75) { comet = *j; break; } } if (comet) { Vec3f start; num--; comet->destroy(time); start[0] = frand(-scene->getBoxHeight()/6, scene->getBoxHeight()/6); start[1] = scene->getBoxHeight()/2; start[2] = frand(-scene->getBoxHeight()/6, scene->getBoxHeight()/6); newc = new Lightning(scene, time, start, comet->getPosition()); scene->addComet(newc); newc = new Glow(scene, time, start, 25.0, Vec3f(0,-1,0), Vec4f(1.0, 1.0, 1.0, 1.0)); scene->addComet(newc); newc = new Glow(scene, time, start, 40.0, Vec3f(0,-1,0), Vec4f(0.0, 0.0, 1.0, 1.0)); scene->addComet(newc); } } } void Blitz::render(const Vec3f& /*unused*/) { } void Blitz::destroy(double /*unused*/) { } bool Blitz::isDestroyed() { return true; } bool Blitz::isDone() { return done; } kcometen4-1.0.7/src/bezier.h0000644000000000000000000000402411044657400014327 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef BEZIER_H #define BEZIER_H #include "global.h" #include "vec.h" class Vec3f; class Bezier3 { public: Bezier3(const Vec3f* ctrlPoints, int num); ~Bezier3(); Vec3f position(double t) const; Vec3f firstDerivate(double t) const; Vec3f secondDerivate(double t) const; const Vec3f* getPoints() const { return ctrlPoints; } int getPointCount() { return numControlPoints; } private: Vec3f *ctrlPoints; Vec3f *firstDerCtrlPoints; Vec3f *secondDerCtrlPoints; int numControlPoints; int degree; }; #endif kcometen4-1.0.7/src/kcometen4.h0000644000000000000000000000467211215363355014754 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef KCometen4_H__ #define KCometen4_H__ #include "kscreensaver.h" #include "ui_kcometen4ui.h" #include "kglcometen4.h" class KCometen4 : public KScreenSaver { Q_OBJECT public: KCometen4( WId drawable ); virtual ~KCometen4(); protected: void resizeEvent( QResizeEvent *e ); private: KGLCometen4 * kglcometen4; }; class KCometen4Setup : public KDialog { Q_OBJECT public: KCometen4Setup( QWidget *parent = NULL ); ~KCometen4Setup(); private slots: void slotOkPressed(); void slotHelp(); void slotDefault(); void updateSimpleSettings(); void updateSlowMotionEffects(); void updateBoxShape(); void updateSizeScale(double scale); void updateFov(double scale); void updateTextures(); void updateTimeScale(); void updateFreeCamSpeed(); private: void initDialog(); KGLCometen4 *saver; Ui::KCometen4UI ui; QButtonGroup buttonGroupBackground; }; #endif kcometen4-1.0.7/src/particlesystem.h0000644000000000000000000001001011064074761016114 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef PARTICLESYSTEM_H #define PARTICLESYSTEM_H #include "global.h" #include "cometenmath.h" class ParticleSystem { private: class Particle { public: Vec3f position; Vec3f velocity; Vec4f color; double startTime; double lifeTime; double invLifeTime; bool active; }; // Particles are created on the line between emitterPos1 and emitterPos2 Vec3f emitterPos1; Vec3f emitterPos2; double minVelocity, maxVelocity; bool slowdown; double particleSize; double minLifeTime, maxLifeTime; bool createNewParticle; double newParticlePerSec; double numNewParticle; double lastUpdateTime; Vec4f startColor; Vec4f endColor; Particle* particleArr; int* indexArr; int maxParticle; int numActiveParticle; GLuint texture; static GLfloat *textureArr; Vec4f* colorArr; Vec3f* vertArr; Vec3f campos; Vec3f quadLowerLeft, quadLowerRight; void renderPoint(); void renderQuad(); public: ParticleSystem(double time, GLuint texture, const Vec3f& emitterPos1, const Vec3f& emitterPos2, int maxParticle, int numCreateAtStart, double minLifeTime, double maxLifeTime, bool createNewParticle, double newParticlePerSec, double minVelocity, double maxVelocity, bool slowdown, double particleSize, const Vec4f& startColor, const Vec4f& endColor); ~ParticleSystem(); static void setupTextureCoordArray(); void process(double time); void render(const Vec3f & campos); void stop(); bool done(); void setEmitterPos1(const Vec3f& pos); Vec3f getEmitterPos1() const; void setEmitterPos2(const Vec3f& pos); Vec3f getEmitterPos2() const; void setStartColor(const Vec4f& c); Vec4f getStartColor() const; void setEndColor(const Vec4f& c); Vec4f getEndColor() const; }; inline void ParticleSystem::setEmitterPos1(const Vec3f& p) { emitterPos1 = p; } inline Vec3f ParticleSystem::getEmitterPos1() const { return emitterPos1; } inline void ParticleSystem::setEmitterPos2(const Vec3f& p) { emitterPos2 = p; } inline Vec3f ParticleSystem::getEmitterPos2() const { return emitterPos2; } inline void ParticleSystem::setStartColor(const Vec4f& c) { startColor = c; } inline Vec4f ParticleSystem::getStartColor() const { return startColor; } inline void ParticleSystem::setEndColor(const Vec4f& c) { endColor = c; } inline Vec4f ParticleSystem::getEndColor() const { return endColor; } #endif kcometen4-1.0.7/src/global.h0000644000000000000000000000366211424423724014320 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef GLOBAL_H #define GLOBAL_H #define GL_GLEXT_PROTOTYPES #include #include #include #include #include #include #include #include #include #include #define VERSION "1.0.7" using namespace std; enum { T_PARTICLE, T_LIGHTMAP, T_BACKGROUND, T_NUM, }; enum { C_RED, C_BLUE, C_GREEN, C_BUNT, C_EXTREMBUNT }; #endif kcometen4-1.0.7/src/kcometen4.cpp0000644000000000000000000003237011424423105015273 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include #include "kcometen4.h" #include "global.h" #include "settings.h" #include static KAboutData* s_aboutData = 0; Settings* settings = 0; class KCometen4Interface : public KScreenSaverInterface { public: virtual KAboutData* aboutData() { return s_aboutData; } /** function to create screen saver object */ virtual KScreenSaver* create( WId id ) { return new KCometen4( id ); } /** function to create setup dialog for screen saver */ virtual QDialog* setup() { return new KCometen4Setup(); } }; int main( int argc, char*argv[] ) { s_aboutData = new KAboutData( "kcometen4.kss", 0, ki18n("KCometen4"), VERSION, ki18n("An OpenGL screensaver with exploding comets."), KAboutData::License_GPL, ki18n("Copyright (C) 2005 Peter Müller
Copyright (C) 2008 John Stamp"), KLocalizedString(), "http://www.mehercule.net/staticpages/index.php/kcometen4", "jstamp@users.sourceforge.net" ); s_aboutData->addAuthor( ki18n("Peter Müller"), ki18n("Original author of KCometen3."), "pmueller@cs.tu-berlin.de"); s_aboutData->addAuthor( ki18n("John Stamp"), ki18n("Ported to KDE4 as KCometen4."), "jstamp@users.sourceforge.net"); KCometen4Interface kss; return kScreenSaverMain( argc, argv, kss ); } //----------------------------------------------------------------------------- //! dialog to setup screen saver parameters KCometen4Setup::KCometen4Setup( QWidget *parent ) : KDialog( parent ) { setCaption( i18n( "Setup KCometen4 Screen Saver" ) ); setButtons( Ok|Cancel|Help|Default ); setDefaultButton( Ok ); setModal( true ); showButtonSeparator(true); setButtonText( Help, i18n( "A&bout" ) ); QWidget *main = new QWidget( this ); setMainWidget( main ); ui.setupUi( main ); ui.kURLRequesterRandomDirectory->setMode(KFile::Directory); buttonGroupBackground.addButton( ui.radioButton3 ); buttonGroupBackground.addButton( ui.radioButton4 ); buttonGroupBackground.addButton( ui.radioButton5 ); buttonGroupBackground.setId( ui.radioButton3, 0 ); buttonGroupBackground.setId( ui.radioButton4, 1 ); buttonGroupBackground.setId( ui.radioButton5, 2 ); // Try to duplicate screen's aspect ratio int width = 220; int height = 170; QRect deskSize = QApplication::desktop()->screenGeometry(); if ( deskSize.width() > 0 ) height = (double)width*deskSize.height()/deskSize.width(); ui.preview->setFixedSize( width, height ); QPalette p = palette(); p.setColor( backgroundRole(), Qt::black ); ui.preview->setPalette( p ); ui.preview->show(); // otherwise saver does not get correct size saver = new KGLCometen4( ui.preview ); saver->resize( ui.preview->size() ); saver->start(); initDialog(); // Do this after we have a saver connect( this, SIGNAL( okClicked() ), SLOT( slotOkPressed() ) ); connect( this, SIGNAL( helpClicked() ), SLOT( slotHelp() ) ); connect( this, SIGNAL( defaultClicked() ), SLOT( slotDefault() ) ); connect( ui.checkFreeCamera, SIGNAL( toggled(bool)), this, SLOT( updateSimpleSettings() ) ); connect( ui.checkIsCube, SIGNAL( toggled(bool)), this, SLOT( updateBoxShape() ) ); connect( ui.kIntNumInputFps, SIGNAL( valueChanged(int)), this, SLOT( updateSimpleSettings() ) ); connect( ui.comboBoxColor, SIGNAL( currentIndexChanged(int)), this, SLOT( updateSimpleSettings() ) ); connect( ui.kDoubleNumInputInterval, SIGNAL( valueChanged(double)), this, SLOT( updateSimpleSettings() ) ); connect( ui.kIntNumInputDensity, SIGNAL( valueChanged(int)), this, SLOT( updateSimpleSettings() ) ); connect( ui.checkRotateComet, SIGNAL( toggled(bool)), this, SLOT( updateSimpleSettings() ) ); connect( ui.checkSplitComet, SIGNAL( toggled(bool)), this, SLOT( updateSimpleSettings() ) ); connect( ui.checkCurveComet, SIGNAL( toggled(bool)), this, SLOT( updateSimpleSettings() ) ); connect( ui.checkBlitz, SIGNAL( toggled(bool)), this, SLOT( updateSimpleSettings() ) ); connect( ui.kDoubleNumInputCamSpeed, SIGNAL( valueChanged(double)), this, SLOT( updateFreeCamSpeed() ) ); connect( ui.checkSlowmotion, SIGNAL( toggled(bool)), this, SLOT( updateSlowMotionEffects() ) ); connect( ui.checkRotCam, SIGNAL( toggled(bool)), this, SLOT( updateSlowMotionEffects() ) ); connect( ui.comboBoxAspectRatio, SIGNAL( currentIndexChanged(int)), this, SLOT( updateSimpleSettings() ) ); connect( ui.kDoubleNumInputTimeScale, SIGNAL( valueChanged(double)), this, SLOT( updateTimeScale() ) ); connect( ui.kDoubleNumInputFov, SIGNAL( valueChanged(double)), this, SLOT( updateFov(double) ) ); connect( ui.kDoubleNumInputSizeScale, SIGNAL( valueChanged(double)), this, SLOT( updateSizeScale(double) ) ); connect( ui.checkMipmaps, SIGNAL( toggled(bool)), this, SLOT( updateTextures() ) ); connect( &buttonGroupBackground, SIGNAL( buttonClicked(int)), this, SLOT( updateTextures() ) ); connect( ui.kURLRequesterFile, SIGNAL( returnPressed()), this, SLOT( updateTextures() ) ); connect( ui.kURLRequesterFile, SIGNAL( urlSelected(KUrl)), this, SLOT( updateTextures() ) ); connect( ui.kURLRequesterRandomDirectory, SIGNAL( returnPressed()), this, SLOT( updateTextures() ) ); connect( ui.kURLRequesterRandomDirectory, SIGNAL( urlSelected(KUrl)), this, SLOT( updateTextures() ) ); connect( ui.comboBoxBgSize, SIGNAL( currentIndexChanged(int)), this, SLOT( updateTextures() ) ); } KCometen4Setup::~KCometen4Setup() { delete saver; } void KCometen4Setup::slotDefault() { settings->defaults(); // block signals before we update widgets ui.checkFreeCamera->blockSignals(true); ui.checkIsCube->blockSignals(true); ui.kIntNumInputFps->blockSignals(true); ui.comboBoxColor->blockSignals(true); ui.kDoubleNumInputInterval->blockSignals(true); ui.kIntNumInputDensity->blockSignals(true); ui.checkRotateComet->blockSignals(true); ui.checkSplitComet->blockSignals(true); ui.checkCurveComet->blockSignals(true); ui.checkBlitz->blockSignals(true); ui.kDoubleNumInputCamSpeed->blockSignals(true); ui.checkSlowmotion->blockSignals(true); ui.checkRotCam->blockSignals(true); ui.comboBoxAspectRatio->blockSignals(true); ui.kDoubleNumInputTimeScale->blockSignals(true); ui.kDoubleNumInputFov->blockSignals(true); ui.kDoubleNumInputSizeScale->blockSignals(true); ui.checkMipmaps->blockSignals(true); ui.kURLRequesterFile->blockSignals(true); ui.kURLRequesterRandomDirectory->blockSignals(true); ui.comboBoxBgSize->blockSignals(true); initDialog(); // ui.checkFreeCamera is checked by default // enable these by hand since we blocked signals ui.textLabel1_2->setEnabled(true); ui.kDoubleNumInputCamSpeed->setEnabled(true); // unblock ui.checkFreeCamera->blockSignals(false); ui.checkIsCube->blockSignals(false); ui.kIntNumInputFps->blockSignals(false); ui.comboBoxColor->blockSignals(false); ui.kDoubleNumInputInterval->blockSignals(false); ui.kIntNumInputDensity->blockSignals(false); ui.checkRotateComet->blockSignals(false); ui.checkSplitComet->blockSignals(false); ui.checkCurveComet->blockSignals(false); ui.checkBlitz->blockSignals(false); ui.kDoubleNumInputCamSpeed->blockSignals(false); ui.checkSlowmotion->blockSignals(false); ui.checkRotCam->blockSignals(false); ui.comboBoxAspectRatio->blockSignals(false); ui.kDoubleNumInputTimeScale->blockSignals(false); ui.kDoubleNumInputFov->blockSignals(false); ui.kDoubleNumInputSizeScale->blockSignals(false); ui.checkMipmaps->blockSignals(false); ui.kURLRequesterFile->blockSignals(false); ui.kURLRequesterRandomDirectory->blockSignals(false); ui.comboBoxBgSize->blockSignals(false); // saver now needs to process a few things saver->updateTimeScale(); saver->updateFreeCamSpeed(); saver->updateSlowMotionEffects(); saver->updateTextures(); saver->updateSizeScale(); } // The preview will have already read things into settings void KCometen4Setup::initDialog() { // Scene ui.kDoubleNumInputFov->setValue(settings->fov); ui.checkFreeCamera->setChecked(settings->freeCamera); ui.kDoubleNumInputCamSpeed->setValue(settings->freeCameraSpeed); ui.kDoubleNumInputSizeScale->setValue(settings->sizeScale); ui.checkIsCube->setChecked(settings->cube); ui.checkSlowmotion->setChecked(settings->slowMotion); ui.checkRotCam->setChecked(settings->matrix); ui.comboBoxAspectRatio->setCurrentIndex(settings->aspectRatio); ui.kIntNumInputFps->setValue(settings->maxFps); ui.checkMipmaps->setChecked(settings->mipmaps); // Comets ui.comboBoxColor->setCurrentIndex(settings->color); ui.kDoubleNumInputInterval->setValue(settings->createInterval); ui.kDoubleNumInputTimeScale->setValue(settings->timeScale); ui.kIntNumInputDensity->setValue(settings->particleDensity); ui.checkRotateComet->setChecked(settings->rotateComet); ui.checkSplitComet->setChecked(settings->splitComet); ui.checkCurveComet->setChecked(settings->curveComet); ui.checkBlitz->setChecked(settings->blitz); // Background int activeButton = settings->bgType; switch (activeButton) { case 0: ui.radioButton3->setChecked(true); break; case 1: ui.radioButton4->setChecked(true); break; case 2: ui.radioButton5->setChecked(true); break; } ui.kURLRequesterFile->setUrl(settings->bgFile); ui.kURLRequesterRandomDirectory->setUrl(settings->bgDir); ui.comboBoxBgSize->setCurrentIndex(settings->bgSize); } // Ok pressed - save settings and exit void KCometen4Setup::slotOkPressed() { settings->save(); accept(); } void KCometen4Setup::updateSimpleSettings() { settings->aspectRatio = ui.comboBoxAspectRatio->currentIndex(); settings->color = ui.comboBoxColor->currentIndex(); settings->createInterval = ui.kDoubleNumInputInterval->value(); settings->maxFps = ui.kIntNumInputFps->value(); settings->freeCamera = ui.checkFreeCamera->isChecked(); settings->curveComet = ui.checkCurveComet->isChecked(); settings->rotateComet = ui.checkRotateComet->isChecked(); settings->splitComet = ui.checkSplitComet->isChecked(); settings->blitz = ui.checkBlitz->isChecked(); settings->particleDensity = ui.kIntNumInputDensity->value(); } void KCometen4Setup::updateTimeScale() { settings->timeScale = ui.kDoubleNumInputTimeScale->value(); saver->updateTimeScale(); } void KCometen4Setup::updateFreeCamSpeed() { settings->freeCameraSpeed = ui.kDoubleNumInputCamSpeed->value(); saver->updateFreeCamSpeed(); } void KCometen4Setup::updateSlowMotionEffects() { settings->slowMotion = ui.checkSlowmotion->isChecked(); settings->matrix = ui.checkRotCam->isChecked(); saver->updateSlowMotionEffects(); } void KCometen4Setup::updateTextures() { settings->bgType = buttonGroupBackground.checkedId(); settings->bgFile = ui.kURLRequesterFile->url().path(); settings->bgDir = ui.kURLRequesterRandomDirectory->url().path(); settings->bgSize = ui.comboBoxBgSize->currentIndex(); settings->mipmaps = ui.checkMipmaps->isChecked(); saver->updateTextures(); } void KCometen4Setup::updateSizeScale( double scale ) { settings->sizeScale = scale; saver->updateSizeScale(); } void KCometen4Setup::updateFov( double fov ) { settings->fov = fov; saver->updateSizeScale(); } void KCometen4Setup::updateBoxShape() { settings->cube = ui.checkIsCube->isChecked(); saver->updateSizeScale(); } void KCometen4Setup::slotHelp() { KAboutApplicationDialog mAbout(s_aboutData, this); mAbout.exec(); } //----------------------------------------------------------------------------- KCometen4::KCometen4( WId id ) : KScreenSaver( id ) { setAttribute( Qt::WA_NoSystemBackground ); QPalette p = palette(); p.setColor( backgroundRole(), Qt::black ); setPalette( p ); kglcometen4 = new KGLCometen4(); embed(kglcometen4); kglcometen4->start(); // Show last to avoid occasional flicker on startup kglcometen4->show(); } void KCometen4::resizeEvent( QResizeEvent * ) { if ( kglcometen4 ) { kglcometen4->stop(); kglcometen4->resize( width(), height() ); kglcometen4->start(); } } KCometen4::~KCometen4() { delete kglcometen4; } #include "kcometen4.moc" kcometen4-1.0.7/src/explosion.h0000644000000000000000000000430511037505776015103 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef EXPLOSION_H #define EXPLOSION_H #include "global.h" #include "cometenmath.h" #include "decal.h" #include "particlesystem.h" #include "comet.h" class Explosion : public Comet { public: Explosion(CometenScene* scene, double time, double lifeTime, const Vec3f& position, double size, int numParticle, const Vec4f& startColor, const Vec4f& endColor); virtual ~Explosion(); virtual void process(double time, double deltat); virtual void render(const Vec3f& campos); virtual void destroy(double time); virtual bool isDestroyed(); virtual bool isDone(); private: Decal *decal; ParticleSystem *psystem; double startTime; double lifeTime; bool done; }; #endif kcometen4-1.0.7/src/decal.h0000644000000000000000000000531111037505776014131 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef DECAL_H #define DECAL_H #include "cometenmath.h" #include "global.h" #include "vec.h" class Decal { public: // normal must be normalized Decal(GLuint texture, const Vec3f & position, double size, bool billboard, const Vec3f & normal, const Vec4f & color, double transparency = 1.0); ~Decal(); void render(const Vec3f & campos); void setPosition(const Vec3f& position); Vec3f getPosition(); void setSize(double size); double getSize(); void setColor(const Vec4f& Color); Vec4f getColor(); void setTransparency(double transparency); double getTransparency(); private: GLuint texture; Vec3f position; double size; bool billboard; Vec3f normal; Vec4f color; double transparency; }; inline void Decal::setPosition(const Vec3f& pos) { position = pos; } inline Vec3f Decal::getPosition() { return position; } inline void Decal::setSize(double s) { size = s; } inline double Decal::getSize() { return size; } inline void Decal::setColor(const Vec4f& c) { color = c; } inline Vec4f Decal::getColor() { return color; } inline void Decal::setTransparency(double t){ transparency = t; } inline double Decal::getTransparency() { return transparency; } #endif kcometen4-1.0.7/src/CMakeLists.txt0000644000000000000000000000150611275707353015451 0ustar rootrootinclude_directories( ${KDE4_INCLUDES} ) set( kcometen4_SRCS bezier.cpp cometen3.cpp cometenmath.cpp cometenscene.cpp curvecomet.cpp decal.cpp explosion.cpp glow.cpp kcometen4.cpp kglcometen4.cpp lightning.cpp particlesystem.cpp pcomet.cpp rotatecomet.cpp settings.cpp vec.cpp ) kde4_add_ui_files( kcometen4_SRCS kcometen4ui.ui ) kde4_add_executable( kcometen4.kss ${kcometen4_SRCS} ) target_link_libraries( kcometen4.kss ${KDE4_KIO_LIBS} ${KSCREENSAVER_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${OPENGL_LIBRARIES} ) install( TARGETS kcometen4.kss ${INSTALL_TARGETS_DEFAULT_ARGS} ) install( FILES lightmap.png particle.png DESTINATION ${DATA_INSTALL_DIR}/kcometen4/pixmaps ) install( FILES kcometen4.desktop DESTINATION ${SERVICES_INSTALL_DIR}/ScreenSavers ) install( FILES kcometen4.kss.1 DESTINATION ${MAN_INSTALL_DIR}/man1 ) kcometen4-1.0.7/src/lightning.h0000644000000000000000000000576311037505776015057 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef LIGHTNING_H #define LIGHTNING_H #include "global.h" #include "cometenmath.h" #include "comet.h" #include "glow.h" class Lightning : public Comet { private: class Line { public: Vec3f p1, p2; Vec3f dir; // normalize dir, (p2 - p1) double l; // p1 + l*dir = p2 double width; }; class LightningVertex { public: Vec3f pos; float uv[2]; }; public: Lightning(CometenScene* scene, double time, const Vec3f& start, const Vec3f& endPoint); ~Lightning(); virtual void process(double time, double deltat); virtual void render(const Vec3f& campos); virtual void destroy(double time); virtual bool isDestroyed(); virtual bool isDone(); private: double lifeTime; double startTime; double transparency; bool done; void createLightning(const Vec3f& start, const Vec3f& end, int detail, int split, double width); int buildVertexArray(const Vec3f& campos, double width2, const vector& lines); Vec3f startPoint; Vec3f endPoint; GLuint texture; vector lines; vector lines2; LightningVertex* vertices; int maxVertices; }; class Blitz : public Comet { public: Blitz(CometenScene* scene, double time); ~Blitz(); virtual void process(double time, double deltat); virtual void render(const Vec3f& campos); virtual void destroy(double time); virtual bool isDestroyed(); virtual bool isDone(); private: double startTime; double nextBlitz; double interval; int num; bool done; }; #endif kcometen4-1.0.7/src/glow.h0000644000000000000000000000421711037505776014035 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef GLOW_H #define GLOW_H #include "global.h" #include "cometenmath.h" #include "comet.h" #include "decal.h" class Glow : public Comet { public: Glow(CometenScene* scene, double time, const Vec3f& position, double size, const Vec3f& normal, const Vec4f& color); virtual ~Glow(); virtual void process(double time, double deltat); virtual void render(const Vec3f& campos); virtual void destroy(double time); virtual bool isDestroyed(); virtual bool isDone(); protected: void calcSize(); GLuint texture; double startTime; double lifeTime; Vec3f dir, up, right; Vec4f color; double transparency; bool done; }; #endif kcometen4-1.0.7/src/particle.png0000644000000000000000000000164510765560735015232 0ustar rootrootPNG  IHDR szzbKGD pHYs  tIME5)PM7P2IDATXÝWn1,zvs! $$,av2`IpzGw*xo%!*Z QM' Z%[QƚKR1J"$j [0ޱ\ }rjK)Pٽ# ,E 6"ԺYGAm(-3uK%,te2H bn3b++"ͨm  jJÖ+sKjtH<NkNSҶsA'vˊm8`ŕZ{H8*{ * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef COMETEN_MATH_H #define COMETEN_MATH_H #include "global.h" #include "vec.h" const double Pi = 3.141592653589793238512808959406186204433; template inline T clamp(T x, T a, T b) { return min(max(x,a),b); } inline double deg2rad(double d) { return d * Pi / 180.0; } inline double rad2deg(double r) { return r * 180.0 / Pi; } inline double frand() { return (double)(rand() % RAND_MAX) / RAND_MAX; } inline double frand(double min, double max) { return min + frand() * (max - min); } inline int rand(int min, int max) { return min + rand() % (max-min+1); } class Plane { public: Plane(const Vec3f & _N, double _d) : N(_N), d(_d) {} ~Plane() {}; Vec3f N; double d; }; bool TestDynamicSpherePlane(const Vec3f & c1, double r1, const Vec3f & W, const Plane & plane, double & time); #endif kcometen4-1.0.7/src/bezier.cpp0000644000000000000000000001116111037505776014674 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "bezier.h" const int maxBinom = 15; const double binomial[maxBinom+1][maxBinom+1] = { /* n = 0 */ {1, }, /* n = 1 */ {1, 1, }, /* n = 2 */ {1, 2, 1, }, /* n = 3 */ {1, 3, 3, 1, }, /* n = 4 */ {1, 4, 6, 4, 1, }, /* n = 5 */ {1, 5, 10, 10, 5, 1, }, /* n = 6 */ {1, 6, 15, 20, 15, 6, 1, }, /* n = 7 */ {1, 7, 21, 35, 35, 21, 7, 1, }, /* n = 8 */ {1, 8, 28, 56, 70, 56, 28, 8, 1, }, /* n = 9 */ {1, 9, 36, 84, 126, 126, 84, 36, 9, 1, }, /* n = 10 */ {1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1, }, /* n = 11 */ {1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1, }, /* n = 12 */ {1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1, }, /* n = 13 */ {1, 13, 78, 286, 715, 1287, 1716, 1716, 1287, 715, 286, 78, 13, 1, }, /* n = 14 */ {1, 14, 91, 364, 1001, 2002, 3003, 3432, 3003, 2002, 1001, 364, 91, 14, 1, }, /* n = 15 */ {1, 15, 105, 455, 1365, 3003, 5005, 6435, 6435, 5005, 3003, 1365, 455, 105, 15, 1, }, }; Bezier3::Bezier3(const Vec3f* points, int num) { int i; assert(num >= 2 && num <= maxBinom+1); numControlPoints = num; degree = numControlPoints-1; ctrlPoints = new Vec3f[numControlPoints]; for (i = 0; i < numControlPoints; i++) { if (i < num) ctrlPoints[i] = points[i]; else ctrlPoints[i] = Vec3f::ZERO; } firstDerCtrlPoints = new Vec3f[numControlPoints-1]; for (i = 0; i < numControlPoints-1; i++) { firstDerCtrlPoints[i] = ctrlPoints[i+1] - ctrlPoints[i]; } if (degree >= 2) { secondDerCtrlPoints = new Vec3f[numControlPoints-2]; for (i = 0; i < numControlPoints-2; i++) { secondDerCtrlPoints[i] = firstDerCtrlPoints[i+1] - firstDerCtrlPoints[i]; } } else { secondDerCtrlPoints = 0; } } Bezier3::~Bezier3() { delete[] ctrlPoints; delete[] firstDerCtrlPoints; delete[] secondDerCtrlPoints; } Vec3f Bezier3::position(double t) const { if (t < 0.0) return t*firstDerCtrlPoints[0] + ctrlPoints[0]; if (t > 1.0) return (t-1)*firstDerCtrlPoints[degree-1] + ctrlPoints[degree]; double oneMinusT = 1-t; double powt = t; int i; Vec3f result = ctrlPoints[0] * oneMinusT; for (i = 1; i < degree; i++) { result = (result + binomial[degree][i]*powt*ctrlPoints[i])*oneMinusT; powt *= t; } result += ctrlPoints[degree] * powt; return result; } Vec3f Bezier3::firstDerivate(double t) const { if (t < 0.0) return firstDerCtrlPoints[0]; if (t > 1.0) return firstDerCtrlPoints[degree-1]; double oneMinusT = 1-t; double powt = t; int i; Vec3f result = firstDerCtrlPoints[0] * oneMinusT; for (i = 1; i < degree-1; i++) { result = (result + binomial[degree-1][i]*powt*firstDerCtrlPoints[i]) * oneMinusT; powt *= t; } result += firstDerCtrlPoints[degree-1]*powt; return result; } Vec3f Bezier3::secondDerivate(double t) const { if (t < 0.0 || t > 1.0 || degree < 2) return Vec3f::ZERO; assert(secondDerCtrlPoints != 0); double oneMinusT = 1-t; double powt = t; int i; Vec3f result = secondDerCtrlPoints[0] * oneMinusT; for (i = 1; i < degree-2; i++) { result = (result + binomial[degree-2][i]*powt*secondDerCtrlPoints[i]) * oneMinusT; powt *= t; } result += secondDerCtrlPoints[degree-2]*powt; return result; } kcometen4-1.0.7/src/vec.h0000644000000000000000000002203711037505776013642 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef VEC_H #define VEC_H #include "global.h" class Vec3f { public: Vec3f(); Vec3f(float x, float y, float z); Vec3f(const Vec3f & b); ~Vec3f(); float operator[](int i) const; float& operator[](int i); operator const float*(); operator float*(); bool operator==(const Vec3f& b) const; bool operator!=(const Vec3f& b) const; void operator+=(const Vec3f& b); void operator-=(const Vec3f& b); void operator*=(float b); void operator/=(float b); Vec3f operator+(const Vec3f& b) const; Vec3f operator-(const Vec3f& b) const; Vec3f operator-() const; Vec3f operator*(float b) const; Vec3f operator/(float b) const; float dot(const Vec3f &b) const; float length() const; float squareLength() const; float normalize(); Vec3f cross(const Vec3f& b) const; // random unit length vector static Vec3f randomUnit(); // reflect vector on plane with normal // normal must be normalized void reflect(const Vec3f& normal); // a must be normalized, b,c out static void generateOrthonormalBasis(const Vec3f& a, Vec3f& b, Vec3f& c); // b,c must be orthonormal vectors on the plane static Vec3f randomUnitOnPlane(const Vec3f& b, const Vec3f& c); static const Vec3f ZERO; static const Vec3f UNIT_X; static const Vec3f UNIT_Y; static const Vec3f UNIT_Z; private: float data[3]; }; inline Vec3f operator*(float a, const Vec3f& b) { return b * a; } class Vec4f { public: Vec4f(); Vec4f(float x, float y, float z, float w); Vec4f(const Vec4f & b); ~Vec4f(); float operator[](int i) const; float& operator[](int i); operator const float*(); operator float*(); bool operator==(const Vec4f & b) const; bool operator!=(const Vec4f & b) const; void operator+=(const Vec4f & b); void operator-=(const Vec4f & b); void operator*=(float b); void operator/=(float b); Vec4f operator+(const Vec4f & b) const; Vec4f operator-(const Vec4f & b) const; Vec4f operator-() const; Vec4f operator*(float b) const; Vec4f operator/(float b) const; float dot(const Vec4f &b) const; float length() const; float squareLength() const; float normalize(); static const Vec4f ZERO; static const Vec4f UNIT_X; static const Vec4f UNIT_Y; static const Vec4f UNIT_Z; static const Vec4f UNIT_W; private: float data[4]; }; /* * Vec3f */ inline Vec3f::Vec3f() {} inline Vec3f::Vec3f(float x, float y, float z) { data[0] = x; data[1] = y; data[2] = z; } inline Vec3f::Vec3f(const Vec3f& b) { data[0] = b.data[0]; data[1] = b.data[1]; data[2] = b.data[2]; } inline Vec3f::~Vec3f() {} inline float Vec3f::operator[](int i) const { assert(i >= 0 && i < 3); return data[i]; } inline float& Vec3f::operator[](int i) { assert(i >= 0 && i < 3); return data[i]; } inline Vec3f::operator const float*() { return data; } inline Vec3f::operator float*() { return data; } inline bool Vec3f::operator==(const Vec3f & b) const { return (data[0] == b.data[0]) && (data[1] == b.data[1]) && (data[2] == b.data[2]); } inline bool Vec3f::operator!=(const Vec3f & b) const { return (data[0] != b.data[0]) || (data[1] != b.data[1]) || (data[2] != b.data[2]); } inline void Vec3f::operator+=(const Vec3f & b) { data[0] += b.data[0]; data[1] += b.data[1]; data[2] += b.data[2]; } inline void Vec3f::operator-=(const Vec3f & b) { data[0] -= b.data[0]; data[1] -= b.data[1]; data[2] -= b.data[2]; } inline void Vec3f::operator*=(float b) { data[0] *= b; data[1] *= b; data[2] *= b; } inline void Vec3f::operator/=(float b) { float inv = 1 / b; data[0] *= inv; data[1] *= inv; data[2] *= inv; } inline Vec3f Vec3f::operator+(const Vec3f& b) const { return Vec3f(data[0] + b.data[0], data[1] + b.data[1], data[2] + b.data[2]); } inline Vec3f Vec3f::operator-(const Vec3f& b) const { return Vec3f(data[0] - b.data[0], data[1] - b.data[1], data[2] - b.data[2]); } inline Vec3f Vec3f::operator-() const { return Vec3f(-data[0], -data[1], -data[2]); } inline Vec3f Vec3f::operator*(float b) const { return Vec3f(data[0]*b, data[1]*b, data[2]*b); } inline Vec3f Vec3f::operator/(float b) const { float inv = 1 / b; return Vec3f(data[0]*inv, data[1]*inv, data[2]*inv); } inline float Vec3f::dot(const Vec3f &b) const { return data[0]*b.data[0] + data[1]*b.data[1] + data[2]*b.data[2]; } inline Vec3f Vec3f::cross(const Vec3f &b) const { return Vec3f(data[1]*b.data[2] - data[2]*b.data[1], data[2]*b.data[0] - data[0]*b.data[2], data[0]*b.data[1] - data[1]*b.data[0]); } inline float Vec3f::length() const { return sqrtf(data[0]*data[0] + data[1]*data[1] + data[2]*data[2]); } inline float Vec3f::squareLength() const { return data[0]*data[0] + data[1]*data[1] + data[2]*data[2]; } inline float Vec3f::normalize() { float l = length(); if (l > 0.0) { float inv = 1 / l; data[0] *= inv; data[1] *= inv; data[2] *= inv; } else { data[0] = 1.0; data[1] = 0.0; data[2] = 0.0; } return l; } /* * Vec4f */ inline Vec4f::Vec4f() {} inline Vec4f::Vec4f(float x, float y, float z, float w) { data[0] = x; data[1] = y; data[2] = z; data[3] = w; } inline Vec4f::Vec4f(const Vec4f& b) { data[0] = b.data[0]; data[1] = b.data[1]; data[2] = b.data[2]; data[3] = b.data[3]; } inline Vec4f::~Vec4f() {} inline float Vec4f::operator[](int i) const { assert(i >= 0 && i < 4); return data[i]; } inline float& Vec4f::operator[](int i) { assert(i >= 0 && i < 4); return data[i]; } inline bool Vec4f::operator==(const Vec4f & b) const { return (data[0] == b.data[0]) && (data[1] == b.data[1]) && (data[2] == b.data[2]) && (data[3] == b.data[3]); } inline bool Vec4f::operator!=(const Vec4f & b) const { return (data[0] != b.data[0]) || (data[1] != b.data[1]) || (data[2] != b.data[2]) || (data[3] != b.data[3]); } inline void Vec4f::operator+=(const Vec4f & b) { data[0] += b.data[0]; data[1] += b.data[1]; data[2] += b.data[2]; data[3] += b.data[3]; } inline void Vec4f::operator-=(const Vec4f & b) { data[0] -= b.data[0]; data[1] -= b.data[1]; data[2] -= b.data[2]; data[3] -= b.data[3]; } inline void Vec4f::operator*=(float b) { data[0] *= b; data[1] *= b; data[2] *= b; data[3] *= b; } inline void Vec4f::operator/=(float b) { float inv = 1 / b; data[0] *= inv; data[1] *= inv; data[2] *= inv; data[3] *= inv; } inline Vec4f Vec4f::operator+(const Vec4f & b) const { return Vec4f(data[0] + b.data[0], data[1] + b.data[1], data[2] + b.data[2], data[3] + b.data[3]); } inline Vec4f Vec4f::operator-(const Vec4f & b) const { return Vec4f(data[0] - b.data[0], data[1] - b.data[1], data[2] - b.data[2], data[3] - b.data[3]); } inline Vec4f Vec4f::operator-() const { return Vec4f(-data[0], -data[1], -data[2], -data[3]); } inline Vec4f Vec4f::operator*(float b) const { return Vec4f(data[0]*b, data[1]*b, data[2]*b, data[3]*b); } inline Vec4f Vec4f::operator/(float b) const { float inv = 1 / b; return Vec4f(data[0]*inv, data[1]*inv, data[2]*inv, data[3]*inv); } inline float Vec4f::dot(const Vec4f &b) const { return data[0]*b.data[0] + data[1]*b.data[1] + data[2]*b.data[2] + data[3]*b.data[3]; } inline float Vec4f::length() const { return sqrtf(data[0]*data[0] + data[1]*data[1] + data[2]*data[2] + data[3]*data[3]); } inline float Vec4f::squareLength() const { return data[0]*data[0] + data[1]*data[1] + data[2]*data[2] + data[3]*data[3]; } inline float Vec4f::normalize() { float l = length(); if (l > 0.0) { float inv = 1 / l; data[0] *= inv; data[1] *= inv; data[2] *= inv; data[3] *= inv; } else { data[0] = 1.0; data[1] = 0.0; data[2] = 0.0; data[3] = 0.0; } return l; } inline Vec4f operator*(float a, const Vec4f& b) { return b * a; } #endif kcometen4-1.0.7/src/rotatecomet.h0000644000000000000000000000615111037505776015412 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef ROTATECOMET_H #define ROTATECOMET_H #include "global.h" #include "cometenmath.h" #include "comet.h" #include "explosion.h" #include "glow.h" class RotateComet : public Comet { public: RotateComet(CometenScene * scene, double time, double lifeTime, const Vec3f & pos, const Vec3f & vel, const Vec4f & acolor1, const Vec4f & ecolor1, const Vec4f & acolor2, const Vec4f & ecolor2); virtual ~RotateComet(); virtual void process(double time, double deltat); virtual void render(const Vec3f& campos); virtual void destroy(double time); virtual bool isDestroyed(); virtual bool isDone(); private: virtual void hitPlane(double time, const Plane & plane); bool destroyed; double vel; Vec3f dir; Vec3f up; Vec3f right; double radius; Vec3f pos1; Vec3f pos2; double startTime; double lifeTime; Vec4f acolor1, ecolor1; Vec4f acolor2, ecolor2; ParticleSystem *psystem1; Decal* decal1; ParticleSystem *psystem2; Decal* decal2; }; class SpComet : public Comet { public: SpComet(CometenScene * scene, double time, const Vec3f & pos, const Vec3f & normal, double maxRadius, const Vec4f & acolor, const Vec4f & ecolor); virtual ~SpComet(); virtual void process(double time, double deltat); virtual void render(const Vec3f& campos); virtual void destroy(double time); virtual bool isDestroyed(); virtual bool isDone(); private: Vec3f startPos; Vec3f dir; Vec3f up; Vec3f right; double maxRadius; double startTime; double lifeTime; Vec4f acolor, ecolor; bool destroyed; ParticleSystem *psystem; Decal* decal; }; #endif kcometen4-1.0.7/src/rotatecomet.cpp0000644000000000000000000002001011064074761015726 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "rotatecomet.h" RotateComet::RotateComet(CometenScene * scene, double time, double _lifeTime, const Vec3f & _pos, const Vec3f & _vel, const Vec4f & _acolor1, const Vec4f & _ecolor1, const Vec4f & _acolor2, const Vec4f & _ecolor2) : Comet(scene, 1.0, _pos), startTime(time), lifeTime(_lifeTime), acolor1(_acolor1), ecolor1(_ecolor1), acolor2(_acolor2), ecolor2(_ecolor2) { GLuint tex = scene->textures[T_PARTICLE]; dir = _vel; vel = dir.normalize(); Vec3f::generateOrthonormalBasis(dir, up, right); radius = 1.75; psystem1 = new ParticleSystem(time, tex, _pos, _pos, 800, 0, 1.5, 2.0, true, 400, 0.0, 4.0, true, 3.0, acolor1, ecolor1); decal1 = new Decal(tex, _pos, 6.0, true, Vec3f::UNIT_X, acolor1); psystem2 = new ParticleSystem(time, tex, _pos, _pos, 800, 0, 1.5, 2.0, true, 400, 0.0, 4.0, false, 3.0, acolor2, ecolor2); decal2 = new Decal(tex, _pos, 6.0, true, Vec3f::UNIT_X, acolor2); destroyed = false; } RotateComet::~RotateComet() { delete psystem1; delete decal1; delete psystem2; delete decal2; } void RotateComet::process(double time, double deltat) { int i; int hitplane; double hittime; double t; double r; double w; if (!destroyed) { hitplane = -1; hittime = deltat; for (i = 0; i != scene->getNumPlanes(); i++) { // kill comets outside of the box if (position.dot(scene->getPlane(i).N) < scene->getPlane(i).d) { destroy(time); break; } if (TestDynamicSpherePlane(position, radius, dir*vel, scene->getPlane(i), t) && t <= hittime) { hitplane = i; hittime = t; } } position += dir * (vel * hittime); if (hitplane != -1) { hitPlane(time + hittime, scene->getPlane(hitplane)); } if (time - startTime > lifeTime) { destroy(time); } } t = (time - startTime) / lifeTime; if (t < 0.05) { r = 20 * t * radius; } else if (t > 0.95) { r = 20 * (1-t) * radius; } else { r = radius; } w = 12.0*time; pos1 = sinf(w)*r*up+cosf(w)*r*right + position; pos2 = sinf(w+Pi)*r*up+cosf(w+Pi)*r*right + position; decal1->setPosition(pos1); psystem1->setEmitterPos1(psystem1->getEmitterPos2()); psystem1->setEmitterPos2(pos1); psystem1->process(time); decal2->setPosition(pos2); psystem2->setEmitterPos1(psystem2->getEmitterPos2()); psystem2->setEmitterPos2(pos2); psystem2->process(time); if (destroyed) { psystem1->stop(); psystem2->stop(); } } void RotateComet::render(const Vec3f& campos) { if (!destroyed) { decal1->render(campos); decal2->render(campos); } psystem1->render(campos); psystem2->render(campos); } void RotateComet::hitPlane(double time, const Plane & plane) { double distance; const double e = 0.0001; Vec3f hitPoint1; Vec3f hitPoint2; double decalSize; Comet* glow; distance = pos1.dot(plane.N) - plane.d; hitPoint1 = pos1 - plane.N * (distance - 0.0001); distance = pos2.dot(plane.N) - plane.d; hitPoint2 = pos2 - plane.N * (distance - 0.0001); distance = position.dot(plane.N) - plane.d; // if comet intersects plane move along normal if (distance >= 0 && distance <= radius + e) { position += (plane.N * (radius + e - distance)); } else if (distance < 0 && distance >= -radius - e) { position += (plane.N * (-radius - e + distance)); } // bounce comet dir.reflect(plane.N); Vec3f::generateOrthonormalBasis(dir, up, right); decalSize = 50; glow = new Glow(scene, time, hitPoint1, decalSize, plane.N, acolor1); scene->addComet(glow); glow = new Glow(scene, time, hitPoint2, decalSize, plane.N, acolor2); scene->addComet(glow); } void RotateComet::destroy(double time) { Comet * newc; Vec3f pos1, pos2; int numChildren = rand(4,6); double w; Vec3f normal; for (int i = 0; i < numChildren; i++) { double t1 = frand(); double t2 = frand(); w = Pi*(double)i/numChildren; normal = sinf(w) * up + cosf(w) * right; newc = new SpComet(scene, time, position, normal, 18, t1*acolor1+(1-t1)*acolor2, t2*ecolor1+(1-t2)*ecolor2); scene->addComet(newc); } newc = new Explosion(scene, time, 1.0, position, 6, 400, acolor2, ecolor2); scene->addComet(newc); psystem1->stop(); psystem2->stop(); destroyed = true; } bool RotateComet::isDestroyed() { return destroyed; } bool RotateComet::isDone() { return destroyed && psystem1->done() && psystem2->done(); } SpComet::SpComet(CometenScene * scene, double time, const Vec3f & _pos, const Vec3f & normal, double _maxRadius, const Vec4f & _acolor, const Vec4f & _ecolor) : Comet(scene, 0.25, _pos), startPos(_pos), maxRadius(_maxRadius), startTime(time), acolor(_acolor), ecolor(_ecolor), destroyed(false) { GLuint tex = scene->textures[T_PARTICLE]; dir = normal; Vec3f::generateOrthonormalBasis(dir, up, right); up = Vec3f::randomUnitOnPlane(up, right); right = dir.cross(up); lifeTime = 0.75; psystem = new ParticleSystem(time, tex, _pos, _pos, 500, 0, 2.5, 3.0, true, 670, 0.0, 2.5, true, 2, acolor, ecolor); decal = new Decal(tex, _pos, 2.5, true, Vec3f::UNIT_X, acolor); } SpComet::~SpComet() { delete psystem; delete decal; } void SpComet::process(double time, double /*unused*/) { double t; double r; double w; double bw = scene->getBoxWidth()/2; double bh = scene->getBoxHeight()/2; t = (time - startTime) / lifeTime; if (t <= 0.25) { r = 4*t*maxRadius; } else if (t >= 0.75) { r = (1 - t) * 4 * maxRadius; } else { r = maxRadius; } w = t*4*Pi; position = sinf(w)*r*up+cosf(w)*r*right + startPos; position[0] = clamp(position[0], -bw, bw); position[1] = clamp(position[1], -bh, bh); position[2] = clamp(position[2], -bw, bw); decal->setPosition(position); psystem->setEmitterPos1(psystem->getEmitterPos2()); psystem->setEmitterPos2(position); psystem->process(time); if (!destroyed) { if (time - startTime > lifeTime) { destroy(time); } } } void SpComet::render(const Vec3f& campos) { if (!destroyed) { decal->render(campos); } psystem->render(campos); } void SpComet::destroy(double time) { Comet * newc = 0; newc = new Explosion(scene, time, 1.0, position, 6, 100, acolor, ecolor); scene->addComet(newc); psystem->stop(); destroyed = true; } bool SpComet::isDestroyed() { return destroyed; } bool SpComet::isDone() { return destroyed && psystem->done(); } kcometen4-1.0.7/src/vec.cpp0000644000000000000000000000555211037505776014200 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "vec.h" #include "global.h" #include "cometenmath.h" Vec3f Vec3f::randomUnit() { Vec3f newvec(frand(-1.0,1.0), frand(-1.0,1.0), frand(-1.0,1.0)); float l = newvec.length(); if (l == 0.0) { return Vec3f(1.0, 0.0, 0.0); } else { newvec /= l; return newvec; } } void Vec3f::reflect(const Vec3f & normal) { float a = dot(normal) * 2; data[0] = data[0] - normal.data[0] * a; data[1] = data[1] - normal.data[1] * a; data[2] = data[2] - normal.data[2] * a; } void Vec3f::generateOrthonormalBasis(const Vec3f& a, Vec3f&b, Vec3f& c) { if (fabs(a[0]) >= fabs(a[1])) { b[0] = a[2]; b[1] = 0; b[2] = -a[0]; } else { b[0] = 0; b[1] = a[2]; b[2] = -a[1]; } b.normalize(); c = a.cross(b); } Vec3f Vec3f::randomUnitOnPlane(const Vec3f& b, const Vec3f& c) { float f = frand(-1.0, 1.0); float g = frand(-1.0, 1.0); Vec3f a = b * f + c * g; float l = a.length(); if (l == 0.0) { return b; } else { a /= l; return a; } } const Vec3f Vec3f::ZERO(0.0, 0.0, 0.0); const Vec3f Vec3f::UNIT_X(1.0, 0.0, 0.0); const Vec3f Vec3f::UNIT_Y(0.0, 1.0, 0.0); const Vec3f Vec3f::UNIT_Z(0.0, 0.0, 1.0); const Vec4f Vec4f::ZERO(0.0, 0.0, 0.0, 0.0); const Vec4f Vec4f::UNIT_X(1.0, 0.0, 0.0, 0.0); const Vec4f Vec4f::UNIT_Y(0.0, 1.0, 0.0, 0.0); const Vec4f Vec4f::UNIT_Z(0.0, 0.0, 1.0, 0.0); const Vec4f Vec4f::UNIT_W(0.0, 0.0, 0.0, 1.0); kcometen4-1.0.7/src/decal.cpp0000644000000000000000000000551211037505776014467 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "decal.h" Decal::Decal(GLuint _texture, const Vec3f & _position, double _size, bool _billboard, const Vec3f & _normal, const Vec4f & _color, double _transparency) : texture(_texture), position(_position), size(_size), billboard(_billboard), normal(_normal), color(_color), transparency(_transparency) { } Decal::~Decal() { } void Decal::render(const Vec3f & campos) { Vec3f dir, up, right; if (billboard) { dir = campos - position; dir.normalize(); } else { dir = normal; } Vec3f::generateOrthonormalBasis(dir, up, right); right *= 0.5 * size; up *= 0.5 * size; glPushMatrix(); glTranslatef(position[0], position[1], position[2]); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture); glColor4f(color[0], color[1], color[2], color[3] * transparency); glBegin(GL_QUADS); glTexCoord2f(0.0, 1.0); glVertex3f((right[0] + up[0]), (right[1] + up[1]), (right[2] + up[2])); glTexCoord2f(1.0, 1.0); glVertex3f((-right[0] + up[0]), (-right[1] + up[1]), (-right[2] + up[2])); glTexCoord2f(1.0, 0.0); glVertex3f((-right[0] - up[0]), (-right[1] - up[1]), (-right[2] - up[2])); glTexCoord2f(0.0, 0.0); glVertex3f((right[0] - up[0]), (right[1] - up[1]), (right[2] - up[2])); glEnd(); glPopMatrix(); } kcometen4-1.0.7/src/particlesystem.cpp0000644000000000000000000001772611424423032016461 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "particlesystem.h" #include "settings.h" static const GLfloat texCoords[] = { 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0 }; GLfloat* ParticleSystem::textureArr = 0; ParticleSystem::ParticleSystem(double time, GLuint _texture, const Vec3f & _emPos1, const Vec3f & _emPos2, int _maxParticle, int numCreateAtStart, double _minLifeTime, double _maxLifeTime, bool _createNewParticle, double _newParticlePerSec, double _minVel, double _maxVel, bool _slowdown, double _particleSize, const Vec4f & _startColor, const Vec4f & _endColor) : emitterPos1(_emPos1), emitterPos2(_emPos2), minVelocity(_minVel), maxVelocity(_maxVel), slowdown(_slowdown), particleSize(_particleSize), minLifeTime(_minLifeTime), maxLifeTime(_maxLifeTime), createNewParticle(_createNewParticle), newParticlePerSec(_newParticlePerSec), startColor(_startColor), endColor(_endColor), maxParticle(_maxParticle), texture(_texture) { maxParticle = maxParticle * settings->particleDensity/100.0+0.5; newParticlePerSec = newParticlePerSec * settings->particleDensity/100.0+0.5; if ( !settings->usePointSprites ) { colorArr = new Vec4f[maxParticle*4]; vertArr = new Vec3f[maxParticle*4]; if ( !textureArr ) setupTextureCoordArray(); } /* Intel cards seem to have memory problems with non-integer point sizes. * Since point antialiasing is disabled anyway, we can convert to int * without affecting the appearance. */ double pointRange[2]; glGetDoublev(GL_SMOOTH_POINT_SIZE_RANGE, pointRange); particleSize += 0.5; particleSize = clamp(particleSize, pointRange[0], pointRange[1]); particleArr = new Particle[maxParticle]; indexArr = new int[maxParticle]; numCreateAtStart = min(maxParticle, numCreateAtStart); numNewParticle = (double) numCreateAtStart; numActiveParticle = 0; for (int i = 0; i < maxParticle; i++) { particleArr[i].active = false; } lastUpdateTime = time; } ParticleSystem::~ParticleSystem() { delete[] particleArr; delete[] indexArr; if ( !settings->usePointSprites ) { delete[] colorArr; delete[] vertArr; } } void ParticleSystem::setupTextureCoordArray() { int stSize = sizeof(texCoords); int m = 1; textureArr = new GLfloat[800*8]; GLfloat *tp = textureArr; memcpy( tp, texCoords, stSize ); tp += 8; while (m < 512) { memcpy( tp, textureArr, stSize*m ); tp += m*8; m *= 2; } memcpy( tp, textureArr, stSize*288 ); } void ParticleSystem::process(double time) { Vec3f dir, up, right; Particle *p; double t; int j = 0; int k = 0; double deltat = time - lastUpdateTime; lastUpdateTime = time; if ( !settings->usePointSprites ) { // billboarding dir = campos; dir.normalize(); Vec3f::generateOrthonormalBasis(dir, up, right); right *= 0.5 * particleSize; up *= 0.5 * particleSize; } if (createNewParticle) numNewParticle += newParticlePerSec * deltat; for (int i = 0; i < maxParticle; i++) { p = particleArr + i; // particle die if ( (p->active) && (p->startTime + p->lifeTime < time) ) { p->active = false; } if (!p->active && numNewParticle < 1.0) { continue; } if (!p->active) { double q = frand(); p->position = (emitterPos1 * q) + (emitterPos2 * (1-q)); p->velocity = Vec3f::randomUnit() * frand(minVelocity, maxVelocity); p->startTime = time; p->lifeTime = frand(minLifeTime, maxLifeTime); // This misbehaves when compiled with gcc-4.2: //p->lifeTime = max(0.001, p->lifeTime); // so use this instead: p->lifeTime = 0.001 > p->lifeTime ? 0.001 : p->lifeTime; p->invLifeTime = 1/ p->lifeTime; p->active = true; numNewParticle -= 1.0; t = (time - p->startTime) * p->invLifeTime; } else { t = (time - p->startTime) * p->invLifeTime; if (slowdown) p->position += p->velocity * deltat * (1-t); else p->position += p->velocity * deltat; } p->color = (startColor * (1-t)) + (endColor * t); if ( !settings->usePointSprites ) { vertArr[k] = p->position + right + up; colorArr[k] = p->color; k++; vertArr[k] = p->position - right + up; colorArr[k] = p->color; k++; vertArr[k] = p->position - right - up; colorArr[k] = p->color; k++; vertArr[k] = p->position + right - up; colorArr[k] = p->color; k++; } indexArr[j] = i; j++; } numActiveParticle = j; } void ParticleSystem::render(const Vec3f & _campos) { campos = _campos; if ( settings->usePointSprites ) renderPoint(); else renderQuad(); } void ParticleSystem::renderPoint() { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture); glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE); glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); glColorPointer(4, GL_FLOAT, sizeof(Particle), &particleArr[0].color); glVertexPointer(3, GL_FLOAT, sizeof(Particle), &particleArr[0].position); // pointparameter in cometenscene->init() glEnable(GL_POINT_SPRITE_ARB); glPointSize(particleSize); glDrawElements(GL_POINTS, numActiveParticle, GL_UNSIGNED_INT, indexArr); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); glDisable(GL_POINT_SPRITE_ARB); glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_FALSE); glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); } void ParticleSystem::renderQuad() { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glDepthMask(GL_FALSE); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture); glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glColorPointer(4, GL_FLOAT, 0, colorArr); glVertexPointer(3, GL_FLOAT, 0, vertArr); glTexCoordPointer(2, GL_FLOAT, 0, textureArr); glDrawArrays(GL_QUADS, 0, numActiveParticle*4); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisable(GL_TEXTURE_2D); glDepthMask(GL_TRUE); glDisable(GL_BLEND); } void ParticleSystem::stop() { createNewParticle = false; numNewParticle = 0.0; } bool ParticleSystem::done() { return (!createNewParticle) && (numActiveParticle == 0); } kcometen4-1.0.7/src/settings.h0000644000000000000000000000400011141652537014705 0ustar rootroot/*************************************************************************** * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef SETTINGS_H #define SETTINGS_H #include class Settings { public: Settings(); void load(); void defaults(); void save(); // Scene double fov; bool freeCamera; double freeCameraSpeed; double sizeScale; bool cube; bool slowMotion; bool matrix; int aspectRatio; int maxFps; bool mipmaps; // Comets int color; double createInterval; double timeScale; int particleDensity; bool rotateComet; bool splitComet; bool curveComet; bool blitz; // Background int bgType; QString bgFile; QString bgDir; int bgSize; // Runtime-only bool usePointSprites; }; extern Settings* settings; #endif kcometen4-1.0.7/src/cometenmath.cpp0000644000000000000000000000404211037505776015720 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "cometenmath.h" bool TestDynamicSpherePlane(const Vec3f & c, double r, const Vec3f & W, const Plane & plane, double & time) { double dist, dotNW; dist = plane.N.dot(c) - plane.d; if (dist > r) { dotNW = plane.N.dot(W); if (dotNW < 0) { time = (r - dist) / dotNW; return true; } else { return false; } } else if (dist < -r) { dotNW = plane.N.dot(W); if (dotNW > 0) { time = -(r + dist) / dotNW; return true; } else { return false; } } else { time = 0.0; return true; } } kcometen4-1.0.7/src/lightmap.png0000644000000000000000000000153710765560735015234 0ustar rootrootPNG  IHDR szzbKGD pHYs  tIME &1ީ0tEXtCommentCreated with The GIMPd%nIDATXÍW۲0DcۓY}̞ ROfىE,(oJju k{fPr3[B%'EDH :V[/S=Qr~S듘=:WJQ]!Bԏf }Dp,] CԓY=8fa "L1?m}g7dq#헢A d|@0Ԃ)"/['*M2܉5s!Nf98]Pϻc0`;X'8ER|i,xomTՀ@1 Tه+uB@0">R!i=m;v^ P5 h:G7$2=cD׳73al4R0R4vDfAbL9`*)j8_WXXQ vІsz]//[oР&\f4V/X u CiJ `!#3s3byZiЀ~ywq"‘1(SXN;8WFbbi Xz1Ob^Mc mQKa S.Ci8ϔ3h<󙢍 @Hzz`ɡ3)hҌZs41{~2IENDB`kcometen4-1.0.7/src/glow.cpp0000644000000000000000000000746611037505776014401 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "glow.h" Glow::Glow(CometenScene* scene, double time, const Vec3f& position, double size, const Vec3f& normal, const Vec4f& _color) : Comet(scene, size/2, position) { done = false; texture = scene->textures[T_PARTICLE]; color = _color; lifeTime = 1.5; startTime = time; dir = normal; Vec3f::generateOrthonormalBasis(dir, up, right); calcSize(); } Glow::~Glow() { } void Glow::calcSize() { //Plane* plane; int i; double distance; double e = 5.0; Vec3f a,b; for (i = 0; i != scene->getNumPlanes(); i++) { const Plane& plane = scene->getPlane(i); if (dir.dot(plane.N) >= 0.999) { continue; } distance = position.dot(plane.N) - plane.d + e; size = clamp(size, 0, distance / abs(plane.N.dot(up))); size = clamp(size, 0, distance / abs(plane.N.dot(right))); } } void Glow::process(double time, double /*unused*/) { double fadeinTime = min(lifeTime/2, 0.125); if (time < startTime) { transparency = 0.0; } else if (time < startTime + fadeinTime) { // fadein t 0->1 transparency = (time - startTime) / fadeinTime; } else if (time < startTime + lifeTime) { // fadeout t 1->0 transparency = 1 - (time - startTime - fadeinTime) / (lifeTime-fadeinTime); } else if (time < startTime + fadeinTime) { // fadein t 0->1 transparency = (time - startTime) / fadeinTime; } else { transparency = 0; done = true; } } void Glow::render(const Vec3f& /*unused*/) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture); glPushMatrix(); glTranslatef(position[0], position[1], position[2]); glScalef(size, size, size); glColor4f(color[0], color[1], color[2], color[3] * transparency); glBegin(GL_QUADS); glTexCoord2f(0.0, 1.0); glVertex3f((right[0] + up[0]), (right[1] + up[1]), (right[2] + up[2])); glTexCoord2f(1.0, 1.0); glVertex3f((-right[0] + up[0]), (-right[1] + up[1]), (-right[2] + up[2])); glTexCoord2f(1.0, 0.0); glVertex3f((-right[0] - up[0]), (-right[1] - up[1]), (-right[2] - up[2])); glTexCoord2f(0.0, 0.0); glVertex3f((right[0] - up[0]), (right[1] - up[1]), (right[2] - up[2])); glEnd(); glPopMatrix(); } void Glow::destroy(double /*unused*/) { } bool Glow::isDestroyed() { return true; } bool Glow::isDone() { return done; } kcometen4-1.0.7/src/kcometen4.desktop0000644000000000000000000001605311215634326016171 0ustar rootroot[Desktop Entry] Exec=kcometen4.kss Icon=preferences-desktop-screensaver Type=Service X-KDE-ServiceTypes=ScreenSaver Actions=Setup;InWindow;Root; X-KDE-Category=OpenGL Screen Savers X-KDE-Type=OpenGL Name=KCometen4 (GL) [Desktop Action Setup] Exec=kcometen4.kss -setup Name=Setup... Name[af]=Opstelling... Name[bg]=Настройки... Name[br]=Kefluniadur ... Name[ca]=Arranjament... Name[cs]=Nastavení... Name[cy]=Gosod ... Name[da]=Opsætning... Name[de]=Einrichtung ... Name[el]=Ρύθμιση... Name[eo]=Agordo... Name[es]=Configuración... Name[et]=Seadistamine... Name[eu]=Konfiguratu... Name[fa]=برپایی... Name[fi]=Asetukset... Name[fr]=Configuration... Name[fy]=Opset... Name[ga]=Socrú... Name[gl]=Configuración... Name[he]=הגדרות... Name[hne]=सेटअप... Name[hu]=Beállítás... Name[is]=Stillingar... Name[it]=Impostazioni... Name[ja]=設定... Name[lt]=Sąranka ... Name[lv]=Iestatījumi... Name[mai]=सेटअप... Name[mk]=Поставување... Name[ml]=ഒരുക്കം... Name[ms]=Setkan... Name[nb]=Innstillinger … Name[nds]=Instellen... Name[ne]=सेटअप... Name[nl]=Instellingen... Name[nn]=Oppsett … Name[pa]=ਸੈਟਅੱਪ... Name[pl]=Ustawienia... Name[pt]=Configurar... Name[pt_BR]=Configurar... Name[ro]=Configurare... Name[ru]=Настройка... Name[sk]=Nastavenie... Name[sl]=Nastavi ... Name[sr]=Подеси... Name[sr@latin]=Podesi... Name[sv]=Inställningar... Name[ta]=அமைப்பு... Name[tg]=Барпосозӣ... Name[th]=ตั้งค่า... Name[tr]=Kurulum... Name[uk]=Встановити... Name[uz]=Oʻrnatish Name[uz@cyrillic]=Ўрнатиш Name[vi]=Thiết lập... Name[xh]=Iyacwangciswa... Name[x-test]=xxSetup...xx Name[zh_CN]=设置... Name[zh_TW]=設定... Icon=preferences-desktop-screensaver [Desktop Action InWindow] Exec=kcometen4.kss -window-id %w Name=Display in Specified Window Name[bg]=Стартиране в избран прозорец Name[br]=Diskwel er prenestr spisaet Name[ca]=Mostra a la finestra especificada Name[cs]=Zobrazit v určeném okně Name[cy]=Dangos mewn Ffenestr Benodol Name[da]=Visning i angivet vindue Name[de]=In bestimmten Fenster anzeigen Name[el]=Προβολή στο καθορισμένο παράθυρο Name[eo]=Montri en indikita fenestro Name[es]=Mostrar en la ventana especificada Name[et]=Määratud aknas näitamine Name[eu]=Bistaratu zehaztutako lehioan Name[fa]=نمایش در پنجرۀ مشخص‌شده Name[fi]=Näytä määrätyssä ikkunassa Name[fr]=Affichage dans la fenêtre spécifiée Name[fy]=Werjefte yn in definiearre finster Name[ga]=Taispeáin san Fhuinneog Sonraithe Name[gl]=Mostrar na fiestra indicada Name[he]=הצג בחלון המצוין Name[hne]=निरधारित विंडो मं देखाव Name[hu]=Megjelenítés a megadott ablakban Name[is]=Birta í völdum glugga Name[it]=Mostra nella finestra specificata Name[ja]=指定したウィンドウで表示 Name[lt]=Rodyti nurodytame lange Name[lv]=Rādīt norādītajā logā Name[mai]=निर्दिष्ट विंडो मे प्रदर्शित करू Name[mk]=Прикажи во наведениот прозорец Name[ml]=പ്രത്യേകം പറഞ്ഞിരിക്കുന്ന ജാലകത്തില്‍ പ്രദര്‍ശിപ്പിക്കുക Name[ms]=Papar dalam Tetingkap Yang Dinyatakan Name[nb]=Vis i angitt vindu Name[nds]=In utsöcht Finster wiesen Name[ne]=निर्दिष्ट सञ्झ्यालमा प्रदर्शन Name[nl]=Weergeven In een opgegeven venster Name[nn]=Vis i oppgjeve vindauge Name[pa]=ਦੱਸੇ ਝਰੋਖੇ ਵਿੱਚ ਵੇਖਾਓ Name[pl]=Wyświetl w zadanym oknie Name[pt]=Mostrar na Janela Indicada Name[pt_BR]=Mostrar em janela especificada Name[ro]=Afișează în fereastra specificată Name[ru]=Показывать в указанном окне Name[sk]=Zobraziť v zadanom okne Name[sl]=Prikaz v določenemu oknu Name[sr]=Прикажи у наведеном прозору Name[sr@latin]=Prikaži u navedenom prozoru Name[sv]=Visa i angivet fönster Name[ta]=குறித்த சாளரத்தில் காட்டு Name[tg]=Дар тирезаи нишондода намоиш намоед Name[th]=แสดงในหน้าต่างที่กำหนด Name[tr]=Belirtilen Pencerede Göster Name[uk]=Відобразити у вказаному вікні Name[vi]=Hiển thị trong Cửa sổ Đã định Name[x-test]=xxDisplay in Specified Windowxx Name[zh_CN]=在指定的窗口中显示 Name[zh_TW]=在指定的視窗中顯示 NoDisplay=true [Desktop Action Root] Exec=kcometen4.kss -root Name=Display in Root Window Name[bg]=Стартиране в главния прозорец Name[br]=Diskwel er prenestr gwrizienn Name[ca]=Mostra a la finestra arrel Name[cs]=Zobrazit na pozadí plochy Name[cy]=Dangos mewn Ffenestr Wraidd Name[da]=Visning i root-vindue Name[de]=In Hintergrundfenster anzeigen Name[el]=Προβολή στο βασικό παράθυρο Name[eo]=Montri en radika fenestro Name[es]=Mostrar en la ventana raíz Name[et]=Juuraknas näitamine Name[eu]=Bistaratu erro lehioan Name[fa]=نمایش در پنجرۀ ریشه Name[fi]=Näytä juuri-ikkunassa Name[fr]=Affichage dans la fenêtre racine Name[fy]=Werjefte yn haadfinster Name[ga]=Taispeáin sa Phríomhfhuinneog Name[gl]=Mostrar na fiestra raíz Name[he]=הצג בחלון השורש Name[hne]=रूट विंडो मं देखाव Name[hu]=Megjelenítés a gyökérablakban Name[is]=Birta í rótarglugganum Name[it]=Mostra sullo sfondo Name[ja]=ルートウィンドウで表示 Name[lt]=Rodyti root lange Name[lv]=Rādīt saknes logā Name[mai]=रूट विंडो मे प्रदर्शित करू Name[mk]=Прикажи во коренскиот прозорец Name[ml]=മൂല ജാലകത്തില്‍ പ്രദര്‍ശിപ്പിക്കുക Name[ms]=Papar dalam Tetingkap Root Name[nb]=Vis i root-vindu Name[nds]=In Hööftfinster wiesen Name[ne]=मूल सञ्झ्यालमा प्रदर्शन Name[nl]=Weergeven in hoofdvenster Name[nn]=Vis i rotvindauget Name[pa]=Root ਝਰੋਖੇ ਵਿੱਚ ਵੇਖਾਓ Name[pl]=Wyświetl w oknie głównym Name[pt]=Mostrar na Janela de Fundo Name[pt_BR]=Mostrar na janela raiz Name[ro]=Afișează în fereastra rădăcină Name[ru]=Показывать в корневом окне Name[sk]=Zobraziť v koreňovom okne Name[sl]=Prikaz v korenskem oknu Name[sr]=Прикажи у кореном прозору Name[sr@latin]=Prikaži u korenom prozoru Name[sv]=Visa i rotfönstret Name[ta]=ஆரம்ப சாளரத்தில் காட்டு Name[tg]=Дар тирезаи решагӣ намоиш намоед Name[th]=แสดงในหน้าต่างราก Name[tr]=Kök Pencerede Göster Name[uk]=Відобразити в кореневому вікні Name[vi]=Hiển thị trong Cửa sổ Gốc Name[x-test]=xxDisplay in Root Windowxx Name[zh_CN]=在根窗口中显示 Name[zh_TW]=在根視窗中顯示 NoDisplay=true kcometen4-1.0.7/src/cometenscene.cpp0000644000000000000000000002105211222255152016046 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "cometenscene.h" #include "settings.h" #include "pcomet.h" #include "rotatecomet.h" #include "curvecomet.h" #include "lightning.h" CometenScene::CometenScene(const GLuint* text, double time, double boxWidth, double boxHeight) : textures(text) { resizeBox(boxWidth, boxHeight); lastCometProcess = time; nextComet = -10e20; } CometenScene::~ CometenScene() { list::iterator j; for (j = comets.begin(); j != comets.end(); j++) { delete (*j); *j = 0; } } void CometenScene::resizeBox(double w, double h) { boxWidth = w; boxHeight = h; collisionPlanes.clear(); collisionPlanes.push_back(Plane(Vec3f::UNIT_X, -boxWidth/2)); collisionPlanes.push_back(Plane(-Vec3f::UNIT_X, -boxWidth/2)); collisionPlanes.push_back(Plane(Vec3f::UNIT_Y, -boxHeight/2)); collisionPlanes.push_back(Plane(-Vec3f::UNIT_Y, -boxHeight/2)); collisionPlanes.push_back(Plane(Vec3f::UNIT_Z, -boxWidth/2)); collisionPlanes.push_back(Plane(-Vec3f::UNIT_Z, -boxWidth/2)); } void CometenScene::process(double time) { list::iterator j, k; Comet *comet; double deltat = time - lastCometProcess; lastCometProcess = time; for (j = comets.begin(); j != comets.end();) { comet = *j; if (comet) { comet->process(time, deltat); } if (!comet || comet->isDone()) { delete comet; k = j; j++; comets.erase(k); } else { j++; } } if (time > nextComet) { createComet(time); nextComet = time + frand(settings->createInterval*0.75, settings->createInterval*1.25); } } void CometenScene::getCometColors(Vec4f& acolor, Vec4f& ecolor) { switch (settings->color) { case C_RED: acolor = Vec4f(1.0, 0.5, 0.25, 1.0); ecolor = Vec4f(1.0, 0.0, 0.0, 0.0); break; case C_BLUE: acolor = Vec4f(0.25, 0.5, 1.0, 1.0); ecolor = Vec4f(0.0, 0.0, 1.0, 0.0); break; case C_GREEN: acolor = Vec4f(0.5, 1.0, 0.25, 1.0); ecolor = Vec4f(0.0, 1.0, 0.0, 0.0); break; case C_EXTREMBUNT: acolor = Vec4f(frand(), frand(), frand(), 1.0); ecolor = Vec4f(frand(), frand(), frand(), 0.0); break; case C_BUNT: default: switch (rand() % 4) { case 2: acolor = Vec4f(1.0, 0.5, 0.25, 1.0); ecolor = Vec4f(1.0, 0.0, 0.0, 0.0); break; case 1: acolor = Vec4f(0.25, 0.5, 1.0, 1.0); ecolor = Vec4f(0.0, 0.0, 1.0, 0.0); break; case 0: acolor = Vec4f(0.5, 1.0, 0.25, 1.0); ecolor = Vec4f(0.0, 1.0, 0.0, 0.0); break; case 3: default: acolor = Vec4f(1.0, 1.0, 1.0, 1.0); ecolor = Vec4f(0.0, 0.0, 0.5, 0.0); break; } } } void CometenScene::createComet(double time) { Vec4f acolor, ecolor, acolor2, ecolor2; Comet * newc = 0; getCometColors(acolor, ecolor); double d = boxWidth < boxHeight ? boxWidth : boxHeight; Vec3f start = Vec3f::randomUnit() * d/3; if (frand() >= 0.5) { newc = new QComet(this, time, frand(2.5, 10.5), start, Vec3f::randomUnit() * frand(75.0, 120.0), false, acolor, ecolor); } else if (frand() >= 0.8) { newc = new QComet(this, time, frand(2.5, 4.5), start, Vec3f::randomUnit() * frand(200.0, 300.0), false, acolor, ecolor); } else if (frand() >= 0.75) { if (settings->splitComet) { newc = new QComet(this, time, frand(2.5, 4.5), start, Vec3f::randomUnit() * frand(75.0, 120.0), true, acolor, ecolor); } else { newc = new QComet(this, time, frand(2.5, 10.5), start, Vec3f::randomUnit() * frand(50.0, 120.0), false, acolor, ecolor); } } else if (frand() >= 0.66) { if (settings->rotateComet) { getCometColors(acolor2, ecolor2); newc = new RotateComet(this, time, frand(7.8, 9.5), start, Vec3f::randomUnit() * frand(80.0, 150.0), acolor, ecolor, acolor2, ecolor2); } else { newc = new QComet(this, time, frand(2.5, 10.5), start, Vec3f::randomUnit() * frand(50.0, 120.0), false, acolor, ecolor); } } else if (frand() >= 0.15) { if (settings->curveComet) { newc = new CurveComet(this, time, frand(1.5, 3.5), start, acolor, ecolor); } else { newc = new QComet(this, time, frand(2.5, 10.5), start, Vec3f::randomUnit() * frand(50.0, 120.0), false, acolor, ecolor); } } else { if (settings->blitz) { newc = new Blitz(this, time); } else { newc = new QComet(this, time, frand(2.5, 10.5), start, Vec3f::randomUnit() * frand(50.0, 120.0), false, acolor, ecolor); } } addComet(newc); } void CometenScene::addComet(Comet* comet) { if (comet) { comets.push_back(comet); } } void CometenScene::render(const Vec3f& campos) { list::iterator i; renderBackground(); for (i = comets.begin(); i != comets.end(); i++) { if (*i) { (*i)->render(campos); } } } void CometenScene::renderBackground() { double vertex_array[] = { // vorne boxWidth/2, -boxHeight / 2, boxWidth/2, boxWidth/2, boxHeight / 2, boxWidth/2, -boxWidth/2, boxHeight / 2, boxWidth/2, -boxWidth/2, -boxHeight / 2, boxWidth/2, // hinten -boxWidth/2, -boxHeight / 2, -boxWidth/2, -boxWidth/2, boxHeight / 2, -boxWidth/2, boxWidth/2, boxHeight / 2, -boxWidth/2, boxWidth/2, -boxHeight / 2, -boxWidth/2, // links -boxWidth/2, -boxHeight / 2, boxWidth/2, -boxWidth/2, boxHeight / 2, boxWidth/2, -boxWidth/2, boxHeight / 2, -boxWidth/2, -boxWidth/2, -boxHeight / 2, -boxWidth/2, // rechts boxWidth/2, -boxHeight / 2, -boxWidth/2, boxWidth/2, boxHeight / 2, -boxWidth/2, boxWidth/2, boxHeight / 2, boxWidth/2, boxWidth/2, -boxHeight / 2, boxWidth/2, // oben -boxWidth/2, boxHeight / 2, -boxWidth/2, -boxWidth/2, boxHeight / 2, boxWidth/2, boxWidth/2, boxHeight / 2, boxWidth/2, boxWidth/2, boxHeight / 2, -boxWidth/2, // unten -boxWidth/2, -boxHeight / 2, boxWidth/2, -boxWidth/2, -boxHeight / 2, -boxWidth/2, boxWidth/2, -boxHeight / 2, -boxWidth/2, boxWidth/2, -boxHeight / 2, boxWidth/2, }; static const double texcoords_array[] = { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, }; glEnable(GL_TEXTURE_2D); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); glTexCoordPointer(2, GL_DOUBLE, 0, texcoords_array); glVertexPointer(3, GL_DOUBLE, 0, vertex_array); glEnable(GL_CULL_FACE); glColor4f(0.7, 0.7, 0.7, 1.0); glBindTexture(GL_TEXTURE_2D, textures[T_BACKGROUND]); glDisable(GL_BLEND); glDrawArrays(GL_QUADS, 0, 24); glEnable(GL_CULL_FACE); glTexCoordPointer(2, GL_DOUBLE, 0, texcoords_array); glColor4f(1.0, 1.0, 1.0, 0.99); glBindTexture(GL_TEXTURE_2D, textures[T_LIGHTMAP]); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDrawArrays(GL_QUADS, 0, 24); glDisable(GL_TEXTURE_2D); glDisable(GL_CULL_FACE); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); } kcometen4-1.0.7/src/curvecomet.h0000644000000000000000000000606011037505776015237 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef CURVECOMET_H #define CURVECOMET_H #include "global.h" #include "cometenmath.h" #include "bezier.h" #include "comet.h" #include "explosion.h" class CurveComet : public Comet { public: CurveComet(CometenScene * scene, double time, double lifeTime, const Vec3f& start, const Vec4f & acolor, const Vec4f & ecolor); virtual ~CurveComet(); virtual void process(double time, double deltat); virtual void render(const Vec3f& campos); virtual void destroy(double time); virtual bool isDestroyed(); virtual bool isDone(); protected: void createCurve(const Vec3f& start); void destroyEffect1(double time, const Vec3f& pos, const Vec3f& vel); void destroyEffect2(double time, const Vec3f& pos, const Vec3f& vel); void destroyEffect3(double time, const Vec3f& pos, const Vec3f& vel); bool destroyed; double startTime; double lifeTime; int numChildren; Vec4f acolor, ecolor; Bezier3* curve; ParticleSystem *psystem; Decal* decal; }; class SmallCurveComet : public Comet { public: SmallCurveComet(CometenScene * scene, double time, double lifeTime, const Vec3f *points, int numPoints, const Vec4f & acolor, const Vec4f & ecolor); virtual ~SmallCurveComet(); virtual void process(double time, double deltat); virtual void render(const Vec3f& campos); virtual void destroy(double time); virtual bool isDestroyed(); virtual bool isDone(); protected: bool destroyed; double startTime; double lifeTime; Vec4f acolor, ecolor; Bezier3* curve; ParticleSystem *psystem; Decal* decal; }; #endif kcometen4-1.0.7/src/kcometen4.kss.10000644000000000000000000000734611057545176015474 0ustar rootroot.\" This file was generated by kdemangen.pl .TH KCOMETEN4.KSS 1 "Sep 2008" "KCometen4" .SH NAME kcometen4.kss \- An OpenGL screensaver with exploding comets. .SH SYNOPSIS .B kcometen4.kss [\fIQt\ options\fP] [\fIKDE\ options\fP] [\fIoptions\fP] .SH DESCRIPTION KCometen4 is an OpenGL screensaver. A variety of multi-colored comets bounce inside a room until they explode. Occasionally lightning will also strike and blow them up. Meanwhile, a free-floating camera watches the action and sometimes enters a slow motion "bullet time" mode. It is suprisingly hypnotic. .SH OPTIONS .SS Options: .TP .B \-\-setup Setup screen saver .TP .BI \-\-window\-id \ wid Run in the specified XWindow .TP .B \-\-root Run in the root XWindow .TP .B \-\-demo Start screen saver in demo mode [default] .SS Generic options: .TP .B \-\-help Show help about options .TP .B \-\-help\-qt Show Qt specific options .TP .B \-\-help\-kde Show KDE specific options .TP .B \-\-help\-all Show all options .TP .B \-\-author Show author information .TP .B \-v, \-\-version Show version information .TP .B \-\-license Show license information .TP .B \-\- End of options .SS .SS KDE options: .TP .BI \-\-caption \ caption Use .IR caption as name in the titlebar .TP .BI \-\-icon \ icon Use .IR icon as the application icon .TP .BI \-\-config \ filename Use alternative configuration file .TP .B \-\-nocrashhandler Disable crash handler, to get core dumps .TP .B \-\-waitforwm Waits for a .B WM_NET compatible windowmanager .TP .BI \-\-style \ style sets the application GUI style .TP .BI \-\-geometry \ geometry sets the client geometry of the main widget - see .BR X (7) for the argument format .SS .SS Qt options: .TP .BI \-\-display \ displayname Use the X-server display .IR displayname .TP .BI \-\-session \ sessionId Restore the application for the given .IR sessionId .TP .B \-\-cmap Causes the application to install a private color map on an 8-bit display .TP .BI \-\-ncols \ count Limits the number of colors allocated in the color cube on an 8-bit display, if the application is using the .B QApplication::ManyColor color specification .TP .B \-\-nograb tells Qt to never grab the mouse or the keyboard .TP .B \-\-dograb running under a debugger can cause an implicit .BR -nograb , .RB use \ -dograb to override .TP .B \-\-sync switches to synchronous mode for debugging .TP .BI \-\-fn,\ \-\-font \ fontname defines the application font .TP .BI \-\-bg,\ \-\-background \ color sets the default background color and an application palette (light and dark shades are calculated) .TP .BI \-\-fg,\ \-\-foreground \ color sets the default foreground .RI color .TP .BI \-\-btn,\ \-\-button \ color sets the default button .RI color .TP .BI \-\-name \ name sets the application .RI name .TP .BI \-\-title \ title sets the application caption .RI title .TP .B \-\-visual TrueColor forces the application to use a TrueColor visual on an 8-bit display .TP .BI \-\-inputstyle \ inputstyle sets XIM (X Input Method) input style. Possible values are .BR onthespot , .BR overthespot , .BR offthespot , .RB and \ root .TP .BI \-\-im \ XIM\ server set XIM server .TP .B \-\-noxim disable XIM .TP .B \-\-reverse mirrors the whole layout of widgets .TP .BI \-\-stylesheet \ file.qss applies the Qt stylesheet to the application widgets .SS .SH AUTHORS Peter Müller wrote the original program for KDE3 as KCometen3. .br John Stamp ported it to KDE4 and added a few bugfixes and features. .PP This manual page was written by John Stamp . Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation. kcometen4-1.0.7/src/explosion.cpp0000644000000000000000000000566411064074761015442 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "explosion.h" Explosion::Explosion(CometenScene* scene, double time, double _lifeTime, const Vec3f& position, double size, int numParticle, const Vec4f& startColor, const Vec4f& endColor) : Comet(scene, size, position), startTime(time), lifeTime(_lifeTime) { done = false; decal = new Decal(scene->textures[T_PARTICLE], position, size, true, Vec3f::UNIT_X, Vec4f(1.0, 1.0, 1.0, 1.0), 0.0); psystem = new ParticleSystem(time, scene->textures[T_PARTICLE], position, position, numParticle, numParticle, lifeTime/2, lifeTime, false, 0.0, size/lifeTime, size*2/lifeTime, true, size/4, startColor, endColor); } Explosion::~Explosion() { delete decal; delete psystem; } void Explosion::process(double time, double /*unused*/) { double t = (time - startTime) / lifeTime; double v; if (t < 0.05) { v = 20*t; v = max(v, 0.5); } else if (t < 0.55) { v = 1-2*(t-0.05); } else { v = 0.0; } decal->setTransparency(v); psystem->process(time); if (time > startTime + lifeTime) { done = true; } } void Explosion::render(const Vec3f & campos) { decal->render(campos); psystem->render(campos); } void Explosion::destroy(double /*unused*/) { } bool Explosion::isDestroyed() { return true; } bool Explosion::isDone() { return done && psystem->done(); } kcometen4-1.0.7/src/pcomet.cpp0000644000000000000000000001471411064074761014705 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "pcomet.h" PComet::PComet(CometenScene * scene, double time, double _lifeTime, double size, const Vec3f& pos, const Vec3f& vel, double particlePerSec, double particleLifeTime, const Vec4f& _acolor, const Vec4f& _ecolor): Comet(scene, size, pos), velocity(vel), startTime(time), lifeTime(_lifeTime), acolor(_acolor), ecolor(_ecolor) { GLuint tex = scene->textures[T_PARTICLE]; int numParticle = min((int)(particlePerSec*lifeTime), (int)(particlePerSec*particleLifeTime)); psystem = new ParticleSystem(time, tex, pos, pos, numParticle, 0, max(0.0, particleLifeTime-0.5), particleLifeTime, true, particlePerSec, 4*size, 8*size, false, 4*size, acolor, ecolor); decal = new Decal(tex, pos, 10*size, true, Vec3f::UNIT_X, acolor); destroyed = false; } PComet::~PComet() { delete psystem; delete decal;; } void PComet::process(double time, double deltat) { int i; int hitplane; double hittime; double t; hitplane = -1; hittime = deltat; for (i = 0; i != scene->getNumPlanes(); i++) { // kill comets outside of the box if (position.dot(scene->getPlane(i).N) < scene->getPlane(i).d) { destroy(time); break; } if (TestDynamicSpherePlane(position, size, velocity, scene->getPlane(i), t) && t <= hittime) { hitplane = i; hittime = t; } } if (!destroyed) { position += velocity * hittime; if (hitplane != -1) { hitPlane(time + hittime, scene->getPlane(hitplane)); } } if (time - startTime > lifeTime) { destroy(time); } decal->setPosition(position); psystem->setEmitterPos1(psystem->getEmitterPos2()); psystem->setEmitterPos2(position); psystem->process(time); if (destroyed) { psystem->stop(); } } void PComet::render(const Vec3f& campos) { if (!destroyed) { decal->render(campos); } psystem->render(campos); } void PComet::hitPlane(double time, const Plane & plane) { double distance; const double e = 0.0001; Vec3f hitPoint; Comet* glow; distance = position.dot(plane.N) - plane.d; hitPoint = position - plane.N * (distance - 0.01); // if comet intersects plane move along normal if (distance >= 0 && distance <= size + e) { position += (plane.N * (size + e - distance)); } else if (distance < 0 && distance >= -size - e) { position += (plane.N * (-size - e + distance)); } // bounce comet velocity.reflect(plane.N); double decalSize = 1.0 * fabs(velocity.dot(plane.N)) * size; glow = new Glow(scene, time, hitPoint, decalSize, plane.N, acolor); scene->addComet(glow); } void PComet::destroy(double /*unused*/) { destroyed = true; psystem->stop(); } bool PComet::isDestroyed() { return destroyed; } bool PComet::isDone() { return destroyed && psystem->done(); } QComet::QComet(CometenScene * scene, double time, double lifeTime, const Vec3f & pos, const Vec3f & vel, bool _split, const Vec4f & acolor, const Vec4f & ecolor) : PComet(scene, time, lifeTime, 1.0, pos, vel, 400, 1.0, acolor, ecolor) { split = _split; } QComet::~QComet() { } void QComet::destroy(double time) { Comet * newc; if (destroyed) return; if (split) { for (int i = 0; i < 3; i++) { newc = new SmallQComet(scene, time, frand(0.2, 0.3), position, Vec3f::randomUnit() * frand(80.0, 120.0), 0.65, 3, acolor, ecolor); scene->addComet(newc); } newc = new Explosion(scene, time, 1.0, position, 25*size, 400, acolor, ecolor); scene->addComet(newc); } else { int num = rand(20,30); for (int i = 0; i < num; i++) { newc = new SmallQComet(scene, time, frand(0.2, 0.75), position, velocity /2.0 + Vec3f::randomUnit() * frand(40.0, 90.0), frand(0.3, 0.4), 0, acolor, ecolor); scene->addComet(newc); } } newc = new Explosion(scene, time, 1.0, position, 25*size, 400, acolor, ecolor); scene->addComet(newc); psystem->stop(); destroyed = true; } SmallQComet::SmallQComet(CometenScene * scene, double time, double lifeTime, const Vec3f & pos, const Vec3f & vel, double size, int _split, const Vec4f & acolor, const Vec4f & ecolor) : PComet(scene, time, lifeTime, size, pos, vel, 250, 1.0, acolor, ecolor) { split = _split; } SmallQComet::~SmallQComet() { } void SmallQComet::destroy(double time) { Comet * newc; if (!destroyed) { if (split > 0) { for (int i = 0; i < 3; i++) { newc = new SmallQComet(scene, time, frand(0.2, 0.3), position, velocity /2.0 + Vec3f::randomUnit() * frand(50.0, 60.0), max(0.25, size*0.5), split -1, acolor, ecolor); scene->addComet(newc); } } newc = new Explosion(scene, time, 1.0, position, 25*size, 100, acolor, ecolor); scene->addComet(newc); } psystem->stop(); destroyed = true; } kcometen4-1.0.7/src/kcometen4ui.ui0000644000000000000000000006170511141652537015501 0ustar rootroot KCometen4UI 0 0 308 472 Screen Saver Config 0 Scene Camera Set the field of view for the widest viewport dimension. Values range from 10 to 120 degrees. Field of view: false Set the field of view for the widest viewport dimension. Values range from 10 to 120 degrees. 76.000000000000000 10.000000000000000 120.000000000000000 ° Toggle between a free floating or fixed position camera. Free camera true Qt::Horizontal QSizePolicy::Fixed 23 29 Set the camera speed. Values range from 0 to 10.0. Camera speed: false Set the camera speed. Values range from 0 to 10.0. 1.500000000000000 10.000000000000000 x Camera Effects With this option set, a slow motion camera will occasionally watch the action from a corner of the box. Slow motion with fixed camera With this option set, a slow motion camera will occasionally rotate around the center of action. Slow motion with rotating camera Adjust the apparent aspect ratio to make the slow-motion effect more "theatrical" Effect aspect ratio: false Adjust the apparent aspect ratio to make the slow-motion effect more "theatrical" 1.85:1 2.40:1 Full Screen Adjust the size of the box relative to the comet size. Values range from 0.5 to 5.0. Size scale: false Adjust the size of box relative to the comet size. Values range from 0.5 to 5.0. 2.500000000000000 0.500000000000000 5.000000000000000 x Set the maximum frames per second. Values range from 10 to 999. Max FPS: false Set the maximum frames per second. Values range from 10 to 999. 60 10 999 Set whether the internal scene should always be a cube or whether the screensaver should adjust it match the parent window proportions. Scene is always a cube Checking this will possibly improve the image quality of the particles and background image. Use mipmaps Qt::Vertical 0 0 Comets Select the color of the comets. Comet color: false Set the approximate number of seconds that a comet will be created. Values range from 0.1 to 10.0 seconds. Comet interval: false Adjust the comet speed relative to normal time. Values range from 0.1 to 5.0. Comet speed: false 0 0 Adjust the density of the particles in the comet tails. Particle density: Select the color of the comets. Red Blue Green All Colors Random Colors Set the approximate number of seconds that a comet will be created. Values range from 0.1 to 10.0 seconds. 1.250000000000000 0.100000000000000 10.000000000000000 sec Adjust the comet speed relative to normal time. Values range from 0.1 to 5.0. 1.000000000000000 0.100000000000000 5.000000000000000 x 0 0 Adjust the density of the particles in the comet tails. 100 0 100 % Comet Types Create comets that have two heads which orbit each other. Binary comets Create comets that end in a cascade of mini-explosions. Cascading explosions Create comets that follow random curved paths. Curved comets Create comet-destroying lightning. Lightning checkBlitz checkCurveComet checkRotateComet checkSplitComet Qt::Vertical 0 0 Background Image Source Use the desktop as the box face image. Desktop Use the selected file as the box face image. File false Use the selected file as the box face image. Use random images from this directory as the box face image. Directory false Use random images from this directory as the box face image. Set the size that the background image will be scaled to. This will change the image's aspect ratio, if necessary. Scaled size: false Set the size that the background image will be scaled to. This will change the image's aspect ratio, if necessary. 128x128 256x256 512x512 1024x1024 Real Size Qt::Vertical 0 0 KDoubleNumInput QWidget
knuminput.h
KIntNumInput QWidget
knuminput.h
KUrlRequester QFrame
kurlrequester.h
radioButton5 toggled(bool) kURLRequesterRandomDirectory setEnabled(bool) 65 161 69 177 checkFreeCamera toggled(bool) textLabel1_2 setEnabled(bool) 263 148 253 182 checkFreeCamera toggled(bool) kDoubleNumInputCamSpeed setEnabled(bool) 210 139 188 206 radioButton4 toggled(bool) kURLRequesterFile setEnabled(bool) 77 85 102 112
kcometen4-1.0.7/src/comet.h0000644000000000000000000000427611037505776014201 0ustar rootroot/*************************************************************************** * Copyright (C) 2005 by Peter Müller * * pmueller@cs.tu-berlin.de * * Copyright (C) 2008 by John Stamp * * * * 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 distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef COMET_H #define COMET_H #include "global.h" #include "vec.h" #include "cometenscene.h" class CometenScene; class Comet { public: Comet(CometenScene * _scene, double _size = 0.0, const Vec3f& _position = Vec3f::ZERO): scene(_scene), size(_size), position(_position) {}; virtual ~Comet() {}; virtual void process(double time, double deltat) = 0; virtual void render(const Vec3f& campos) = 0; virtual void destroy(double time) = 0; virtual bool isDestroyed() = 0; virtual bool isDone() = 0; double getSize() { return size; } const Vec3f& getPosition() { return position; } protected: CometenScene* scene; double size; Vec3f position; }; #endif kcometen4-1.0.7/INSTALL0000644000000000000000000000227511057043255013147 0ustar rootrootTo build KCometen4 you will need a basic build system (g++, make, etc.) You will also need to install cmake and selected Qt4 and KDE4 development packages. On Debian-based systems apt-get install build-essential kdebase-workspace-dev libqt4-opengl-dev should be sufficient. KCometen4 also comes with a simple configure script that should work for a generic local install. If it doesn't suit your needs, you will need to edit the cmake settings by hand. Quick installation steps: ./configure cd build; make; make install Cmake's equivalent to 'make distclean' is 'rm -rf build'. Note: If you do a local installation, you might not see KCometen4 in the Screen Saver Settings module. In that case, you will need to do one of two things. First, you can set the $KDEDIRS environment variable in your X session startup script so it includes your local installation prefix: export KDEDIRS=/usr/local:/usr Or second, you can set this for all users by adding your local installation prefix to /etc/kde4rc: [Directories] prefixes=/usr/local After that, you may need to manually refresh the system configuration cache by running 'kbuildsycoca4'. KCometen4 should now appear in Screen Saver Settings. kcometen4-1.0.7/CMakeLists.txt0000644000000000000000000000166011275707353014663 0ustar rootrootproject( kcometen4.kss ) find_package( KDE4 REQUIRED ) find_package( OpenGL REQUIRED ) set( CMAKE_INCLUDE_CURRENT_DIR TRUE ) add_definitions( ${QT_DEFINITIONS} ${KDE4_DEFINITIONS} ) set ( libGL_FIND_REQUIRED TRUE ) set ( libGLU_FIND_REQUIRED TRUE ) set ( QtOpenGL_FIND_REQUIRED TRUE ) set ( kscreensaver_FIND_REQUIRED TRUE ) find_path( KSCREENSAVER_INCLUDE_DIR kscreensaver.h ${KDE4_INCLUDE_DIR} ) find_library( KSCREENSAVER_LIBRARY NAMES kscreensaver PATHS ${KDE4_LIB_DIR} ) include( FindPackageHandleStandardArgs ) find_package_handle_standard_args( kscreensaver DEFAULT_MSG KSCREENSAVER_LIBRARY KSCREENSAVER_INCLUDE_DIR ) find_package_handle_standard_args( libGL DEFAULT_MSG OPENGL_gl_LIBRARY OPENGL_INCLUDE_DIR ) find_package_handle_standard_args( libGLU DEFAULT_MSG OPENGL_glu_LIBRARY OPENGL_INCLUDE_DIR ) find_package_handle_standard_args( QtOpenGL DEFAULT_MSG QT_QTOPENGL_LIBRARY QT_QTOPENGL_INCLUDE_DIR ) add_subdirectory( src ) kcometen4-1.0.7/configure0000755000000000000000000000271611057043040014015 0ustar rootroot#!/bin/sh BUILD_DIR="build" INSTALL_PREFIX="/usr/local" usage () { cat << EOF \`configure' provides a very simple wrapper for a generic cmake configuration. Those needing more flexibility should run cmake directly. Usage: ./configure [OPTION]... Options: -p, --prefix PREFIX install files in PREFIX [/usr/local] -b, --build-directory BUILDDIR build the package in BUILDDIR [./build] -h, --help display this help and exit EOF } GETOPTEST=`getopt --version` case "$GETOPTEST" in getopt*) # GNU getopt ARGS=`getopt -n configure -l prefix:,build-directory:,help p:b:h "$@"` ;; *) # POSIX getopt ? ARGS=`getopt p:b:h "$@"` ;; esac RET=$? if [ $RET -ne 0 ]; then usage exit 1 fi eval set -- "$ARGS" while [ $# -gt 0 ]; do case "$1" in -p|--prefix) INSTALL_PREFIX="$2" shift 2 ;; -b|--build-directory) BUILD_DIR="$2" shift 2 ;; -h|--help) usage exit 0 ;; --) if [ $# -gt 1 ]; then echo "Unknown parameter: $2" echo "" usage exit 1 fi break ;; esac done SOURCE_DIR=`pwd` mkdir "$BUILD_DIR" cd "$BUILD_DIR" RET=$? if [ $RET -ne 0 ]; then exit $RET fi cmake "$SOURCE_DIR" \ -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" \ -DCMAKE_SKIP_RPATH=ON \ -DKDE4_USE_ALWAYS_FULL_RPATH=false \ -DCMAKE_BUILD_TYPE=Release RET=$? if [ $RET -ne 0 ]; then echo "Error running cmake" exit $RET else echo "" echo "Cmake configuration successful." echo "Now run: 'cd \"$BUILD_DIR\"; make; make install'" fi kcometen4-1.0.7/COPYING0000644000000000000000000004310311037505776013155 0ustar rootroot GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. kcometen4-1.0.7/AUTHORS0000644000000000000000000000020511032274205013147 0ustar rootrootAuthor of KCometen3: Peter Mueller Ported to KDE4 as KCometen4: John Stamp