teleus-cvs Mailing List for Inactive
Status: Inactive
Brought to you by:
spiffgq
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(24) |
Oct
(30) |
Nov
(4) |
Dec
(33) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(15) |
Feb
(40) |
Mar
(7) |
Apr
|
May
(17) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Daniel R. <sp...@us...> - 2004-05-25 23:13:49
|
Update of /cvsroot/teleus/teleus/src/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18409/src/util Modified Files: timer.cpp Log Message: Now allowed to 'sleep' for negative time (just return w/o sleeping). Index: timer.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/util/timer.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** timer.cpp 25 Feb 2004 06:34:00 -0000 1.4 --- timer.cpp 25 May 2004 23:13:41 -0000 1.5 *************** *** 217,225 **** void Timer::sleep (double seconds){ ! assert (seconds > 0.0, ! "Trying to sleep for a negative time period."); #ifdef __linux__ int result; double intpart, fracpart; --- 217,227 ---- void Timer::sleep (double seconds){ ! /*assert (seconds > 0.0, ! "Trying to sleep for a negative time period.");*/ #ifdef __linux__ + if (seconds < 0.0){ return; } + int result; double intpart, fracpart; |
|
From: Daniel R. <sp...@us...> - 2004-05-25 23:12:43
|
Update of /cvsroot/teleus/teleus/src/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18170/src/util Added Files: debugrecord.cpp debugrecord.hpp system.cpp system.hpp Log Message: I can't believe I didn't add these classes to CVS yet. They aren't really useful, but they are needed by teleus.pro for compliation. Oops. --- NEW FILE: debugrecord.cpp --- /* * Teleus Space Combat Simulator * Copyright 2004 Daniel Royer * sp...@us... * http://teleus.sf.net * * This package is free software; you can redistribute it and/or * modify it under the terms of the Teleus Artistic License as * detailed on the Teleus website. * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE. * * A copy of the Teleus Artistic License is provided along with * this source code package. You can also find a copy at or * http://teleus.sf.net/license.php * */ /* * $Revision: 1.1 $ * $Date: 2004/05/25 23:12:33 $ */ #include <cstdarg> #include "debugrecord.hpp" #include "debug.hpp" #define DEBUG_ON 0 namespace debugrecord { FILE *dbfptr; void keyDown (SDLKey sym){ #if DEBUG_ON fprintf (dbfptr, "Key down: %s\n", SDL_GetKeyName(sym)); #endif } void keyUp (SDLKey sym){ #if DEBUG_ON fprintf (dbfptr, "Key up: %s\n", SDL_GetKeyName(sym)); #endif } void printScalarFunc (const char* name, double val) { #if DEBUG_ON fprintf (dbfptr, "%s:\t %f\n", name, val); #endif } void printVecFunc (const char* name, const teleus::math::Vector3d& val) { #if DEBUG_ON fprintf (dbfptr, "%s:\t <%f, %f, %f> (Len = %f)\n", name, val.x, val.y, val.z, val.length()); #endif } void printQuatFunc (const char* name, const teleus::math::Vector4d& val) { #if DEBUG_ON fprintf (dbfptr, "%s:\t <%f, %f, %f, %f> (Len = %f)\n", name, val.w, val.x, val.y, val.z, val.length()); #endif } void printMatrixFunc (const char* name, const teleus::math::Matrix3d& val) { #if DEBUG_ON fprintf (dbfptr, "%s: (det = %f)\n" "\t[%f, %f, %f]\n" "\t[%f, %f, %f]\n" "\t[%f, %f, %f]\n", name, val.det(), val.f11, val.f12, val.f13, val.f21, val.f22, val.f23, val.f31, val.f32, val.f33); #endif } void printf (const char *fmt, ...) { #if DEBUG_ON assert (dbfptr, "Unable to write; file's not open"); va_list ap; if (fmt == NULL) return; va_start (ap, fmt); vfprintf (dbfptr, fmt, ap); va_end (ap); #endif } void initDebugRecord () { #if DEBUG_ON dbfptr = fopen ("debug_record.txt", "w+"); assert (dbfptr, "Unable to open debug_record.txt for writing"); #endif } void shutdownDebugRecord () { #if DEBUG_ON fclose (dbfptr); #endif } } // END NAMESPACE debugrecord --- NEW FILE: debugrecord.hpp --- /* * Teleus Space Combat Simulator * Copyright 2004 Daniel Royer * sp...@us... * http://teleus.sf.net * * This package is free software; you can redistribute it and/or * modify it under the terms of the Teleus Artistic License as * detailed on the Teleus website. * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE. * * A copy of the Teleus Artistic License is provided along with * this source code package. You can also find a copy at or * http://teleus.sf.net/license.php * */ /* * $Revision: 1.1 $ * $Date: 2004/05/25 23:12:33 $ */ #ifndef TELEUS_DEBUG_RECORD_HEADER #define TELEUS_DEBUG_RECORD_HEADER 1 #include "math/vector.hpp" #include "math/matrix.hpp" #include <cstdio> #include <SDL/SDL.h> namespace debugrecord { void keyDown (SDLKey); void keyUp (SDLKey); void printScalarFunc (const char*, double); void printVecFunc (const char*, const teleus::math::Vector3d&); void printQuatFunc (const char*, const teleus::math::Vector4d&); void printMatrixFunc (const char*, const teleus::math::Matrix3d&); void printf (const char *fmt, ...); void initDebugRecord (); void shutdownDebugRecord (); extern FILE *dbfptr; } // END NAMESPACE debugrecord #if 0 #define printScalar(a) debugrecord::printScalarFunc(#a, a) #define printVec(a) debugrecord::printVecFunc(#a, a) #define printQuat(a) debugrecord::printQuatFunc(#a, a) #define printMatrix(a) debugrecord::printMatrixFunc(#a, a) #else #define printScalar(a) #define printVec(a) #define printQuat(a) #define printMatrix(a) #endif #endif --- NEW FILE: system.cpp --- /* * Teleus Space Combat Simulator * Copyright 2004 Daniel Royer * sp...@us... * http://teleus.sf.net * * This package is free software; you can redistribute it and/or * modify it under the terms of the Teleus Artistic License as * detailed on the Teleus website. * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE. * * A copy of the Teleus Artistic License is provided along with * this source code package. You can also find a copy at or * http://teleus.sf.net/license.php * */ /* * $Revision: 1.1 $ * $Date: 2004/05/25 23:12:33 $ */ #include "system.hpp" namespace teleus { namespace util { } // END NAMESPACE util } // END NAMESPACE teleus --- NEW FILE: system.hpp --- /* * Teleus Space Combat Simulator * Copyright 2004 Daniel Royer * sp...@us... * http://teleus.sf.net * * This package is free software; you can redistribute it and/or * modify it under the terms of the Teleus Artistic License as * detailed on the Teleus website. * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE. * * A copy of the Teleus Artistic License is provided along with * this source code package. You can also find a copy at or * http://teleus.sf.net/license.php * */ /* * $Revision: 1.1 $ * $Date: 2004/05/25 23:12:33 $ */ #ifndef TELEUS_SYSTEM_HEADER #define TELEUS_SYSTEM_HEADER namespace teleus { namespace util { extern const int WORD_SIZE; extern const int SIZE_CHAR_BITS; extern const int MIN_SIGNED_CHAR; extern const int MAX_SIGNED_CHAR; extern const int MAX_UNSIGNED_CHAR; extern const int MIN_SIGNED_SHORT; extern const int MAX_SIGNED_SHORT; extern const int MAX_UNSIGNED_SHORT; extern const int MIN_SIGNED_INT; extern const int MAX_SIGNED_INT; extern const int MAX_UNSIGNED_INT; extern const bool BYTE_ORDER_HOST; extern const bool BYTE_ORDER_NETWORK; extern const bool BYTE_ORDER_LITTLE_ENDIAN; extern const bool BYTE_ORDER_BIG_ENDIAN; } // END NAMESPACE util } // END NAMESPACE teleus #endif |
|
From: Daniel R. <sp...@us...> - 2004-05-25 23:10:11
|
Update of /cvsroot/teleus/teleus/src/obj In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17475/src/obj Modified Files: cube.cpp cube.hpp object.cpp object.hpp ship.cpp ship.hpp Log Message: Modified these classes to rely on math::Mass to update physics and such. Index: object.hpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/obj/object.hpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** object.hpp 25 Feb 2004 02:23:26 -0000 1.8 --- object.hpp 25 May 2004 23:10:00 -0000 1.9 *************** *** 40,47 **** using math::Vector3d; ! using math::PointMass; using math::Quaternion; ! class Object : public PointMass { friend class gfx::Camera; --- 40,47 ---- using math::Vector3d; ! using math::Mass; using math::Quaternion; ! class Object : public Mass { friend class gfx::Camera; *************** *** 49,52 **** --- 49,54 ---- protected: + #if 0 + // Delegated to Mass class. float mWidth; float mHeight; *************** *** 63,66 **** --- 65,69 ---- Quaternion mRotation; + #endif public: *************** *** 70,73 **** --- 73,78 ---- virtual void updatePhysics (double timeInc); + + #if 0 void setBoundingBox (float height, float width, float length); void setBoundingSphere (float radius); *************** *** 87,90 **** --- 92,96 ---- void setOri (const Vector3d&); void setRot (const Quaternion&); + #endif }; Index: object.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/obj/object.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** object.cpp 25 Feb 2004 06:34:00 -0000 1.10 --- object.cpp 25 May 2004 23:10:00 -0000 1.11 *************** *** 30,34 **** #include "math/vector.hpp" #include "object.hpp" ! #include "debug.hpp" --- 30,34 ---- #include "math/vector.hpp" #include "object.hpp" ! #include "util/debugrecord.hpp" #include "debug.hpp" *************** *** 48,52 **** */ Object::Object () ! : PointMass () { //DEBUG_PRINT ("Creating object\n"); --- 48,52 ---- */ Object::Object () ! : Mass () { //DEBUG_PRINT ("Creating object\n"); *************** *** 62,65 **** --- 62,66 ---- Object::~Object (){} + #if 0 /** * \brief Changes the size of this object. *************** *** 85,88 **** --- 86,90 ---- } + /** * \brief Changes the bounding sphere radius *************** *** 99,102 **** --- 101,105 ---- mRadius = radius; } + #endif /** *************** *** 115,118 **** --- 118,124 ---- void Object::updatePhysics (double timeInc){ + Mass::updatePhysics(timeInc); + + #if 0 // Rotate the object mRotation *= Quaternion::getVector4d ( *************** *** 127,130 **** --- 133,137 ---- mForwardVector = mRotation.directionVector(); mForwardVector.normalize(); + #endif #if 0 *************** *** 142,145 **** --- 149,153 ---- #endif + #if 0 // Update rotation: for (int i = 0; i < 3; ++i){ *************** *** 151,157 **** --- 159,167 ---- } } + #endif } + #if 0 /** * \brief Returns the speed of this object. *************** *** 278,281 **** --- 288,292 ---- mRotation = newRot; } + #endif /** *************** *** 296,299 **** --- 307,311 ---- */ + #if 0 /** * \var float Object::mWidth *************** *** 353,356 **** --- 365,370 ---- */ + #endif + } // END NAMESPACE obj } // END NAMESPACE teleus Index: cube.hpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/obj/cube.hpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** cube.hpp 25 Feb 2004 02:23:26 -0000 1.6 --- cube.hpp 25 May 2004 23:10:00 -0000 1.7 *************** *** 29,32 **** --- 29,33 ---- #include "object.hpp" + #include "ship.hpp" #include "gfx/gfx.hpp" #include "gfx/color.hpp" *************** *** 35,39 **** namespace obj { ! class Cube : public Object { protected: --- 36,40 ---- namespace obj { ! class Cube : public Ship { protected: Index: cube.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/obj/cube.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** cube.cpp 11 Mar 2004 03:20:42 -0000 1.9 --- cube.cpp 25 May 2004 23:10:00 -0000 1.10 *************** *** 46,49 **** --- 46,50 ---- */ Cube::Cube (float width, float length, float depth) + : Ship () { // ok, these were bad choices for names :) *************** *** 51,54 **** --- 52,56 ---- mHeight = length; mLength = depth; + mRadius = math::boundingSphere(width, length, depth); } *************** *** 73,86 **** void Cube::updatePhysics (double timeInc){ ! // Update rotation ! Object::updatePhysics(timeInc); ! // Update position ! PointMass::updatePhysics(timeInc); ! // Reverse velocity if we get too far away from the origin. ! if (mPosition.length() > 10000.0){ ! mVelocity = -mVelocity; } } --- 75,100 ---- void Cube::updatePhysics (double timeInc){ ! //resetForces(); ! // If we are greater than 1000 units away from the center, ! // we'll apply a centripetal force. Just for fun. ! /* ! if (mPosition.lengthSquared() > 1000000.0){ ! // The force points to the origin ! Vector3d force = -mPosition.normalized(); ! ! // The force's strength depends on how far from the ! // maximum radius the Cube is. As the cube returns ! // to the appropriate spot, the force will diminish. ! force *= (mPosition.length() - 1000.0) * 100.0; ! ! // The force is world oriented. Add it to the total ! //forces acting on this body. ! addForceWorld(force, mPosition); } + */ + + Ship::updatePhysics(timeInc); } *************** *** 117,121 **** Cube * Cube::getRandomCube (){ ! math::Random rand; gfx::Color3f color; --- 131,135 ---- Cube * Cube::getRandomCube (){ ! static math::Random rand(747393); gfx::Color3f color; *************** *** 125,128 **** --- 139,143 ---- math::Vector3d velocity; math::Vector3d rotVel; + math::Vector3d moi; double mass; *************** *** 141,145 **** dimensions.z = rand.floatNumber (10.0f, 100.0f); ! const double MAX_POSITION = 4000.0f; position.x = rand.floatNumber (-MAX_POSITION, MAX_POSITION); position.y = rand.floatNumber (-MAX_POSITION, MAX_POSITION); --- 156,160 ---- dimensions.z = rand.floatNumber (10.0f, 100.0f); ! const double MAX_POSITION = 900.0f; position.x = rand.floatNumber (-MAX_POSITION, MAX_POSITION); position.y = rand.floatNumber (-MAX_POSITION, MAX_POSITION); *************** *** 156,171 **** velocity.z = 0.0; //math::randFloat(0.0f, 100.0f); #else ! velocity.x = rand.floatNumber (0.0f, 100.0f); ! velocity.y = rand.floatNumber (0.0f, 100.0f); ! velocity.z = rand.floatNumber (0.0f, 100.0f); #endif ! rotVel.x = rand.floatNumber (0.0f, 1.0f); ! rotVel.y = rand.floatNumber (0.0f, 1.0f); ! rotVel.z = rand.floatNumber (0.0f, 1.0f); mass = (dimensions.x * dimensions.y * dimensions.z) / 10.0f; radius = dimensions.length(); // Assign the generated properties --- 171,191 ---- velocity.z = 0.0; //math::randFloat(0.0f, 100.0f); #else ! velocity.x = rand.floatNumber (-100.0f, 100.0f); ! velocity.y = rand.floatNumber (-100.0f, 100.0f); ! velocity.z = rand.floatNumber (-100.0f, 100.0f); #endif ! rotVel.x = 0.0; // rand.floatNumber (0.0f, 1.0f); ! rotVel.y = 0.0; // rand.floatNumber (0.0f, 1.0f); ! rotVel.z = 0.0; // rand.floatNumber (0.0f, 1.0f); mass = (dimensions.x * dimensions.y * dimensions.z) / 10.0f; radius = dimensions.length(); + // TODO: Verify the following line. I'm pretty sure that + // the object is sitting facing down the +z axis, with +y + // up and +x to the left. + moi = math::rectanglePrismMOI(mass, dimensions.z, dimensions.x, dimensions.y); + // Assign the generated properties *************** *** 177,183 **** c->mColor = color; c->mPosition = c->mLastPosition = position; ! c->mRotation = math::Vector4d::getVector4d (angle, orientation.x, orientation.y, orientation.z); c->mVelocity = velocity; ! c->mRotationalVelocity = rotVel; return c; --- 197,204 ---- c->mColor = color; c->mPosition = c->mLastPosition = position; ! //c->mRotation = math::Vector4d::getVector4d (angle, orientation.x, orientation.y, orientation.z); c->mVelocity = velocity; ! //c->mAngVelocity = rotVel; ! c->setInertia(moi.x, moi.y, moi.z); return c; Index: ship.hpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/obj/ship.hpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ship.hpp 25 Feb 2004 02:23:26 -0000 1.6 --- ship.hpp 25 May 2004 23:10:00 -0000 1.7 *************** *** 25,29 **** */ ! #ifndef TELEUS_SHIP_HEADER #define TELEUS_SHIP_OBJECT_HEADER 1 --- 25,29 ---- */ ! #ifndef TELEUS_SHIP_OBJECT_HEADER #define TELEUS_SHIP_OBJECT_HEADER 1 Index: ship.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/obj/ship.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ship.cpp 25 Feb 2004 02:23:26 -0000 1.8 --- ship.cpp 25 May 2004 23:10:00 -0000 1.9 *************** *** 29,32 **** --- 29,33 ---- #include "math/vector.hpp" #include "math/physics.hpp" + #include "util/debugrecord.hpp" #include "debug.hpp" *************** *** 187,197 **** void Ship::killVelocity (){ ! mVelocity.x = 0.0f; ! mVelocity.y = 0.0f; ! mVelocity.z = 0.0f; - mRotationalVelocity.x = 0.0f; - mRotationalVelocity.y = 0.0f; - mRotationalVelocity.z = 0.0f; } --- 188,197 ---- void Ship::killVelocity (){ ! debugrecord::printf("Kill Velocity\n"); ! ! resetForces(); ! mAngVelocity.zero(); ! mVelocity.zero(); } *************** *** 210,213 **** --- 210,214 ---- void Ship::updatePhysics (double timeInc){ + #if 0 // TODO: Replace these constants with variables so different *************** *** 326,330 **** --- 327,399 ---- mRotationalVelocity.r = mRotationalVelocity.r + (rollAcceleration * timeInc); + #endif + + // TODO: Replace these constants with variables so different + // ships can have different thuster force. + const float MAX_FORWARD_FORCE = 10000.0; // newtons + const float MAX_ROTATIONAL_FORCE = 200.0; // newtons + + // Create force for the main engine + Vector3d mainEngineThrustForce (0.0, 0.0, 1.0); + Vector3d mainEngineThrustLoc (0.0, 0.0, -10.0); + mainEngineThrustForce *= MAX_FORWARD_FORCE * mForwardThrust; + addForceBody(mainEngineThrustForce, mainEngineThrustLoc); + + // Create force for the RCS thrusters + Vector3d RCSThrustForce; + Vector3d RCSThrustLoc; + + // YAW + RCSThrustForce.x = MAX_ROTATIONAL_FORCE * mYawThrust; + RCSThrustLoc.z = 10.0; + addForceBody(RCSThrustForce, RCSThrustLoc); + + RCSThrustForce.zero(); + RCSThrustLoc.zero(); + + RCSThrustForce.x = -(MAX_ROTATIONAL_FORCE * mYawThrust); + RCSThrustLoc.z = -10.0; + addForceBody(RCSThrustForce, RCSThrustLoc); + + RCSThrustForce.zero(); + RCSThrustLoc.zero(); + + + // PITCH + RCSThrustForce.y = MAX_ROTATIONAL_FORCE * mPitchThrust; + RCSThrustLoc.z = 10.0; + addForceBody(RCSThrustForce, RCSThrustLoc); + + RCSThrustForce.zero(); + RCSThrustLoc.zero(); + + RCSThrustForce.y = -(MAX_ROTATIONAL_FORCE * mPitchThrust); + RCSThrustLoc.z = -10.0; + addForceBody(RCSThrustForce, RCSThrustLoc); + + RCSThrustForce.zero(); + RCSThrustLoc.zero(); + + // ROLL + RCSThrustForce.y = MAX_ROTATIONAL_FORCE * mRollThrust; + RCSThrustLoc.x = 10.0; + addForceBody(RCSThrustForce, RCSThrustLoc); + + RCSThrustForce.zero(); + RCSThrustLoc.zero(); + + RCSThrustForce.y = -(MAX_ROTATIONAL_FORCE * mRollThrust); + RCSThrustLoc.x = -10.0; + addForceBody(RCSThrustForce, RCSThrustLoc); + + + /* + // A temporary centripetal force, just for fun. + + Vector3d gravVec = -mPosition.normalized(); + gravVec *= 900.0; + addForceWorld (gravVec, mPosition); + */ Object::updatePhysics (timeInc); |
|
From: Daniel R. <sp...@us...> - 2004-05-25 23:08:18
|
Update of /cvsroot/teleus/teleus/src/obj In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16978/src/obj Added Files: collision.cpp collision.hpp sphere.cpp sphere.hpp Log Message: Added obj::Sphere and obj::Collision classes. --- NEW FILE: sphere.cpp --- /* * Teleus Space Combat Simulator * Copyright 2004 Daniel Royer * sp...@us... * http://teleus.sf.net * * This package is free software; you can redistribute it and/or * modify it under the terms of the Teleus Artistic License as * detailed on the Teleus website. * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE. * * A copy of the Teleus Artistic License is provided along with * this source code package. You can also find a copy at or * http://teleus.sf.net/license.php * */ /* * $Revision: 1.1 $ * $Date: 2004/05/25 23:08:09 $ */ #include "sphere.hpp" #include "object.hpp" #include "ship.hpp" #include "math/vector.hpp" #include "math/geometry.hpp" #include "gfx/gfx.hpp" #include "gfx/color.hpp" #include "debug.hpp" namespace teleus { namespace obj { Sphere::Sphere (float radius, const gfx::Color3f& color, unsigned int slices, unsigned int stacks, const Vector3d& pos, const Vector3d& vel) : Ship(), mColor (color), mGeometry(slices, stacks) { setRadius(radius); setPos(pos); setVel (vel); } Sphere::Sphere (float radius, const gfx::Color3f& color, const Vector3d& pos, const Vector3d& vel) : Ship(), mColor (color), mGeometry(12, 12) { setRadius(radius); setPos(pos); setVel (vel); } Sphere::~Sphere () {/* geometry is deleted in ~ApproxSphere() */ } void Sphere::setStacks (unsigned int /*stacks*/) { //mGeometry = math::ApproxSphere(mGeometry.slices(), stacks); #warning Sphere::setStacks() not written assertNotReached(); } unsigned int Sphere::stacks () const { return mGeometry.stacks(); } void Sphere::setSlices (unsigned int /*slices*/) { #warning Sphere::setSlices() not written assertNotReached(); } unsigned int Sphere::slices () const { return mGeometry.slices(); } void Sphere::setGeometry (const math::ApproxSphere& /*copy*/) { #warning Sphere::setGeometry() not written assertNotReached(); } const math::ApproxSphere Sphere::geometry() const { return mGeometry; } /** * \brief Updates the physics * * Updates the location and orientation of the object using * parent class methods. * * \param timeInc the time increment in seconds * * \author Daniel Royer */ void Sphere::updatePhysics (double timeInc){ //resetForces(); Ship::updatePhysics(timeInc); } /** * \brief Changes this object's color. * * \param c the new color * \author Daniel Royer */ void Sphere::setColor (const gfx::Color3f& c){ mColor = c; } /** * \brief Returns this object's color * * \returns this object's color * \author Daniel Royer */ const gfx::Color3f& Sphere::color () const{ return mColor; } /** * \class obj::Sphere obj/sphere.hpp "obj/cube.hpp" * \brief A spherical object * * This is just a temporary class that I am using to test the * collision detection and response part of the engine. * * \author Daniel Royer */ } // END NAMESPACE obj } // END NAMESPACE teleus /** * \file obj/sphere.cpp * \brief The source file for the obj::Sphere class. * \author Daniel Royer */ /** * \file obj/sphere.hpp * \brief The header file for the obj::Sphere class. * \author Daniel Royer */ --- NEW FILE: sphere.hpp --- /* * Teleus Space Combat Simulator * Copyright 2004 Daniel Royer * sp...@us... * http://teleus.sf.net * * This package is free software; you can redistribute it and/or * modify it under the terms of the Teleus Artistic License as * detailed on the Teleus website. * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE. * * A copy of the Teleus Artistic License is provided along with * this source code package. You can also find a copy at or * http://teleus.sf.net/license.php * */ /* * $Revision: 1.1 $ * $Date: 2004/05/25 23:08:09 $ */ #ifndef TELEUS_SPHERE_OBJECT_HEADER #define TELEUS_SPHERE_OBJECT_HEADER 1 #include "object.hpp" #include "ship.hpp" #include "gfx/gfx.hpp" #include "gfx/color.hpp" #include "math/geometry.hpp" namespace teleus { namespace obj { class Sphere : public Ship { protected: gfx::Color3f mColor; math::ApproxSphere mGeometry; public: Sphere (float radius, const gfx::Color3f& color, unsigned int slices, unsigned int stacks, const Vector3d& pos, const Vector3d& vel); Sphere (float radius, const gfx::Color3f& color, const Vector3d& pos, const Vector3d& vel); virtual ~Sphere (); virtual void updatePhysics (const double timeInc); void setColor (const gfx::Color3f&); const gfx::Color3f& color () const; void setStacks (unsigned int stacks); unsigned int stacks () const; void setSlices (unsigned int slices); unsigned int slices () const; void setGeometry (const math::ApproxSphere&); const math::ApproxSphere geometry() const; }; } // END NAMESPACE obj } // END NAMESPACE teleus #endif --- NEW FILE: collision.cpp --- /* * Teleus Space Combat Simulator * Copyright 2004 Daniel Royer * sp...@us... * http://teleus.sf.net * * This package is free software; you can redistribute it and/or * modify it under the terms of the Teleus Artistic License as * detailed on the Teleus website. * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE. * * A copy of the Teleus Artistic License is provided along with * this source code package. You can also find a copy at or * http://teleus.sf.net/license.php * */ /* * $Revision: 1.1 $ * $Date: 2004/05/25 23:08:09 $ */ #include "collision.hpp" #include "object.hpp" #include "math/vector.hpp" #include "debug.hpp" namespace teleus { namespace obj { Collision::Collision () : mRefObj(0), mColObj(0), mStatus(Collision::NONE) {} Collision::Collision (Object* ref, Object* col) : mRefObj(ref), mColObj(col) { calcCollision(); } Collision::Collision (const Collision& copy) : mRefObj(copy.mRefObj), mColObj(copy.mColObj), mNormal(copy.mNormal), mPoint(copy.mPoint), mTangent(copy.mTangent), mRelVel(copy.mRelVel), mRelAccel(copy.mRelAccel), mStatus(copy.mStatus) { // TODO: Maybe it would be a good idea to validate the new // values? } const Object* Collision::refObj () const { return mRefObj; } const Object* Collision::colObj () const { return mColObj; } const Vector3d& Collision::normal() const { return mNormal; } const Vector3d& Collision::point() const { return mPoint; } const Vector3d& Collision::tangent() const { return mTangent; } const Vector3d& Collision::relVel() const { return mRelVel; } const Vector3d& Collision::relAccel() const { return mRelAccel; } Collision::STATUS Collision::status() const { return mStatus; } bool Collision::colliding() const { return mStatus == CONTACT; } bool Collision::penetrating () const { return mStatus == PENETRATION; } bool Collision::touching () const { return colliding() || penetrating(); } void Collision::setRefObj (Object * ref) { mRefObj = ref; calcCollision(); } void Collision::setColObj (Object * col) { mColObj = col; calcCollision (); } void Collision::calcCollision() { #warning Collision::calcCollision() not written yet assertNotReached(); // First, we reset the collision data. zeroData(); // we need to make sure we have two non-null objects // to check. if (mRefObj == 0 || mColObj == 0){ return; } // The bounding spheres intersect. There _may_ be a collision, // so we must run some further checks. // TODO: // Check objects' geometries to see if they are colliding or penetrating. // Calculate the collision normal // Calculate the collision point // Calculate the collision tangent // Calculate the relative velocity of the collision object // Calculate the relative acceleration of the collision object } void Collision::zeroData() { mNormal.zero(); mPoint.zero(); mTangent.zero(); mRelVel.zero(); mRelAccel.zero(); mStatus = Collision::NONE; } bool Collision::boundingSphereCheck (const Object& a, const Object& b) { // // from http://www.gamedev.net/reference/articles/article1234.asp // // TODO: This method doesn't work as written. We need to add // a check to see if the objects passed completely through // each other in a single time step. For example, consider // two spheres of radius 50 traveling toward each other from // starting points 1200 units apart at a velocity of 10,000 // units each. In a single time step of greater than 0.06 // seconds, the objects will have passed completely through // each other and this collision detection scheme won't even // have noticed. // // Not to worry, though. A simple solution is to use the // last position, stored in PointMass, and see if a line from // it to the current position intersects the path of the // other object to within bounding-sphere tolerance. Vector3d relVel = b.vel() - a.vel(); Vector3d relPos = b.pos() - a.pos(); double minDist = a.radius() + b.radius(); double pp = relPos.lengthSquared() - (minDist * minDist); /*if (pp < 0.0){ DEBUG_PRINT ("Collision::boundingSphereCheck() true by pp\n"); return true; }*/ return pp <= 0.0; /* double pv = relPos.x * relVel.x + relPos.y * relVel.y + relPos.z * relVel.z; if (pv >= 0.0){ DEBUG_PRINT ("Collision::boundingSphereCheck() true by pv\n"); return false; } double vv = relVel.lengthSquared(); if ( (pv + vv) <= 0.0 && (vv + 2.0 * pv + pp) >= 0){ DEBUG_PRINT ("Collision::boundingSphereCheck() false\n"); return false; } double tmin = -pv / vv; return (pp + pv * tmin > 0.0);*/ } } // END NAMESPACE obj } // END NAMESPACE teleus --- NEW FILE: collision.hpp --- /* * Teleus Space Combat Simulator * Copyright 2004 Daniel Royer * sp...@us... * http://teleus.sf.net * * This package is free software; you can redistribute it and/or * modify it under the terms of the Teleus Artistic License as * detailed on the Teleus website. * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE. * * A copy of the Teleus Artistic License is provided along with * this source code package. You can also find a copy at or * http://teleus.sf.net/license.php * */ /* * $Revision: 1.1 $ * $Date: 2004/05/25 23:08:09 $ */ #ifndef TELEUS_OBJECT_COLLISION_HEADER #define TELEUS_OBJECT_COLLISION_HEADER 1 #include "object.hpp" #include "math/vector.hpp" namespace teleus { namespace obj { using math::Vector3d; class Collision { public: enum STATUS{NONE, CONTACT, PENETRATION}; private: Object *mRefObj; Object *mColObj; Vector3d mNormal; Vector3d mPoint; Vector3d mTangent; Vector3d mRelVel; Vector3d mRelAccel; STATUS mStatus; void calcCollision(); void zeroData(); public: Collision (); Collision (Object*, Object*); Collision (const Collision&); const Object* refObj () const; const Object* colObj () const; const Vector3d& normal() const; const Vector3d& point() const; const Vector3d& tangent() const; const Vector3d& relVel() const; const Vector3d& relAccel() const; STATUS status() const; bool colliding() const; bool penetrating () const; bool touching () const; void setRefObj (Object *); void setColObj (Object *); // TODO: More methods: // update // impulse force static bool boundingSphereCheck (const Object& a, const Object& b); }; } // END NAMESPACE obj } // END NAMESPACE teleus #endif |
|
From: Daniel R. <sp...@us...> - 2004-05-25 23:06:35
|
Update of /cvsroot/teleus/teleus/src/math In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16628/src/math Modified Files: vector.cpp vector.hpp Log Message: A lot of internal changes, bug fixes, comment updates, etc. Index: vector.hpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/math/vector.hpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** vector.hpp 11 Mar 2004 03:14:44 -0000 1.13 --- vector.hpp 25 May 2004 23:06:24 -0000 1.14 *************** *** 37,42 **** struct Vector4d; typedef Vector4d Quaternion; ! struct Matrix_4X4; ! typedef Matrix_4X4 Matrix; struct Vector2d { --- 37,42 ---- struct Vector4d; typedef Vector4d Quaternion; ! struct Matrix3d; ! struct Matrix4d; struct Vector2d { *************** *** 76,79 **** --- 76,80 ---- const Vector3d normalized () const; bool isNormalized() const; + void verifyNormalized(); void zero (); void copy (const Vector3d &temp); *************** *** 146,152 **** inline Vector4d (double, double, double, double); inline Vector4d (const Vector4d&); ! void copy (const Vector4d& temp); ! void copy (const Matrix& temp); void normalize (); --- 147,156 ---- inline Vector4d (double, double, double, double); inline Vector4d (const Vector4d&); + /*inline Vector4d (const Matrix3d&); + inline Vector4d (const Matrix4d&);*/ ! void copy (const Vector4d&); ! /*void copy (const Matrix3d&); ! void copy (const Matrix4d&);*/ void normalize (); *************** *** 182,186 **** void setAngle (double angle, double x, double y, double z); void setValues (double x, double y, double z); ! void setEulerAngles (double r, double p, double y); const Vector3d directionVector () const; --- 186,190 ---- void setAngle (double angle, double x, double y, double z); void setValues (double x, double y, double z); ! void setEulerAngles (double, double, double); const Vector3d directionVector () const; *************** *** 194,198 **** const Vector4d& operator=(const Vector3d&); const Vector4d& operator=(const Vector4d&); ! const Vector4d& operator=(const Matrix&); const Vector4d operator-() const; --- 198,202 ---- const Vector4d& operator=(const Vector3d&); const Vector4d& operator=(const Vector4d&); ! //const Vector4d& operator=(const Matrix&); const Vector4d operator-() const; *************** *** 206,209 **** --- 210,215 ---- const Vector4d operator*(const Vector4d& v, const double d); const Vector4d operator*(const double d, const Vector4d& v); + const Vector4d operator*(const Vector4d&, const Vector3d&); + const Vector4d operator*(const Vector3d&, const Vector4d&); const Vector4d& operator*=(Vector4d& v, const double d); Index: vector.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/math/vector.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** vector.cpp 11 Mar 2004 03:14:43 -0000 1.16 --- vector.cpp 25 May 2004 23:06:24 -0000 1.17 *************** *** 25,31 **** --- 25,33 ---- */ + #include <cstdio> #include <cmath> #include "physics.hpp" #include "vector.hpp" + #include "matrix.hpp" #include "debug.hpp" *************** *** 105,112 **** void Vector3d::normalize (){ ! double l = this->length(); ! this->x = this->x / l; ! this->y = this->y / l; ! this->z = this->z / l; } --- 107,118 ---- void Vector3d::normalize (){ ! double l = lengthSquared(); ! ! if (l == 0.0) { return; } ! l = sqrt(l); ! ! x /= l; ! y /= l; ! z /= l; } *************** *** 136,139 **** --- 142,164 ---- /** + * \brief Normalizes this vector if it is not already + * + * This method checks to see if this vector is already normalized. + * If not, it normalizes it. + * + * \author Daniel Royer + */ + void Vector3d::verifyNormalized() { + + double l = lengthSquared(); + if (l != 1.0 && l != 0.0){ + l = sqrt(l); + x /= l; + y /= l; + z /= l; + } + } + + /** * \brief Sets all components to zero * *************** *** 254,258 **** * \todo write this function */ ! void Vector3d::rotate (const Vector3d& /*axis*/, const double /*angle*/){ #if 0 --- 279,283 ---- * \todo write this function */ ! void Vector3d::rotate (const Vector3d& axis, const double angle){ #if 0 *************** *** 264,276 **** *this = result; #else ! assertNotReached(); #endif } ! void Vector3d::rotate (const Quaternion& /*q*/){ ! assertNotReached(); } /** * \brief Toggles between coordinate systems. --- 289,313 ---- *this = result; #else ! Quaternion temp; ! temp.setAxisAngle(axis, angle); ! rotate(temp); #endif } ! void Vector3d::rotate (const Quaternion& q){ ! Quaternion temp = q * (*this) * q.conjugated(); ! /* ! Quaternion temp = q; ! temp = temp * (*this); ! temp = temp * q.conjugated(); ! */ ! ! x = temp.x; ! y = temp.y; ! z = temp.z; } + /** * \brief Toggles between coordinate systems. *************** *** 743,749 **** * * \f[ ! * \vec{A} \cdot \vec{b} = AB \cos \theta ! * \cos \theta = \frac{\vec{A} \cdot \vec{B}}{AB} ! * \theta = \arccos(\frac{\vec{A} \cdot \vec{B}}{AB}) * \f] * --- 780,788 ---- * * \f[ ! * \begin{array}{rcl} ! * \vec{A} \cdot \vec{b} &=& AB \cos \theta \\ ! * \cos \theta &=& \frac{\vec{A} \cdot \vec{B}}{AB} \\ ! * \theta &=& \arccos(\frac{\vec{A} \cdot \vec{B}}{AB}) ! * \end{array} * \f] * *************** *** 772,775 **** --- 811,836 ---- * functionality. * + * The triple scalar product of the three vectors, + * \f$\vec{A}\f$, \f$\vec{B}\f$, \f$\vec{C}\f$, + * denoted as \f$ \left[\vec{A},\vec{B},\vec{C}\right] \f$ + * is defined by: + * + * \f[ + * \begin{array}{lcr} + * + * \left[\vec{A},\vec{B},\vec{C}\right] &=& \vec{A} \cdot \left( \vec{B} \times \vec{C} \right) \\ + * &=& \vec{B} \cdot \left( \vec{C} \times \vec{A} \right) \\ + * &=& \vec{C} \cdot \left( \vec{A} \times \vec{B} \right) + * \end{array} + * \f] + * + * where: + * \li \f$ \cdot \f$ is the vector dot product + * \li \f$ \times \f$ is the vector cross product + * + * The volume of a parallelepiped whose sides are given by the vectors + * A, B, and C is given by the absolute value of + * \f$ \left[\vec{A},\vec{B},\vec{C}\right] \f$. + * * \param a the first operand * \param b the second operand *************** *** 778,782 **** * * \author Daniel Royer - * \todo beef up this comment block */ const double tripleScalar (const Vector3d& a, const Vector3d& b, --- 839,842 ---- *************** *** 941,945 **** void Vector4d::normalize (){ ! double l = length(); w /= l; x /= l; --- 1001,1008 ---- void Vector4d::normalize (){ ! double l = lengthSquared(); ! if (l == 0.0) { return; } ! l = sqrt(l); ! w /= l; x /= l; *************** *** 948,951 **** --- 1011,1024 ---- } + /** + * \brief Returns a normalized version of this vector. + * + * This method returns a unit vector that points in the same + * direction as this vector. If this vector is already + * normalized, then these two vectors should be equal. + * + * \returns a normalized version of this vector + * \author Daniel Royer + */ const Vector4d Vector4d::normalized () const { *************** *** 973,982 **** } ! void Vector4d::copy (const Matrix& /*temp*/){ ! #warning Vector4d::copy() not written assertNotReached(); } /** * \brief Returns the length of this vector --- 1046,1063 ---- } ! #if 0 ! void Vector4d::copy (const Matrix3d& temp) { ! #warning Vector4d::setMatrix() not written assertNotReached(); } + void Vector4d::copy (const Matrix4d& temp) { + + #warning Vector4d::setMatrix() not written + assertNotReached(); + } + #endif + /** * \brief Returns the length of this vector *************** *** 993,996 **** --- 1074,1116 ---- } + /** + * \brief Returns the square of the length of this vector + * + * This method returns the length of this vector, squared. This + * is useful for times when you don't need to know the actual + * length of the vector, but you can infer all you need to know + * from the square of the lenght. This saves the square root + * call. + * + * For example, if you want to check to see if the vector is a + * unit vector, you don't need to know the actual length of this + * vector, you only need to know if the length is not 1. + * + * \code + * double lenSqrd = vec.lengthSquared(); + * if (lenSqrd != 1.0){ + * vec.normalize(); + * } + * \endcode + * + * Or we can generalize the above. For example, if we want to + * know if the length is 10.0, then we can check to see if the + * length squared is 100.0: + * + * \code + * double lenSqrd = vec.lengthSquared(); + * // Check to see if length of vector is 10.0 + * if (lenSqrd != 100.0){ + * // Do something + * } + * \endcode + * + * However, the above uses are micro-optimizations and probably + * won't be useful except in frequently used areas, like maybe + * collision detection. + * + * \returns the square of the length of this vector + * \author Daniel Royer + */ double Vector4d::lengthSquared() const { *************** *** 998,1002 **** } - void Vector4d::setAxisAngle (double /*ax*/, double /*ay*/, double /*az*/, double /*angle*/) --- 1118,1121 ---- *************** *** 1036,1095 **** } void Vector4d::postMultiply (const Vector4d &vtx){ - /*Vector4d temp(*this);*/ - /*temp.w = w; - temp.x = x; - temp.y = y; - temp.z = z;*/ multiplyAndSet (*this, vtx); - } - void Vector4d::multiplyAndSet (const Vector4d &v1, - const Vector4d &v2) - { ! w = v2.w * v1.w - ! v2.x * v1.x - ! v2.y * v1.y - ! v2.z * v1.z; ! ! x = v2.w * v1.x + ! v2.x * v1.w + ! v2.y * v1.z - ! v2.z * v1.y; ! ! y = v2.w * v1.y - ! v2.x * v1.z + ! v2.y * v1.w + ! v2.z * v1.x; ! ! z = v2.w * v1.z + ! v2.x * v1.y - ! v2.y * v1.x + ! v2.z * v1.w; ! ! #if 0 ! w = v2.v[0] * v1.v[0] - ! v2.v[1] * v1.v[1] - ! v2.v[2] * v1.v[2] - ! v2.v[3] * v1.v[3]; ! ! x = v2.v[0] * v1.v[1] + ! v2.v[1] * v1.v[0] + ! v2.v[2] * v1.v[3] - ! v2.v[3] * v1.v[2]; ! ! y = v2.v[0] * v1.v[2] - ! v2.v[1] * v1.v[3] + ! v2.v[2] * v1.v[0] + ! v2.v[3] * v1.v[1]; ! ! z = v2.v[0] * v1.v[3] + ! v2.v[1] * v1.v[2] - ! v2.v[2] * v1.v[1] + ! v2.v[3] * v1.v[0]; ! #endif } --- 1155,1199 ---- } + /** + * \brief Multiplies the vector to this vector + * + * This method multiplies the vector \a vtx to \c this vector + * and stores the result in \c this vector. + * + * \f[ + * \vec{V_{this}} = \vec{V_{this}} \times \vec{V_tx} + * \f] + * + * \param vtx the vector to multiply + * \author Daniel Royer + */ void Vector4d::postMultiply (const Vector4d &vtx){ multiplyAndSet (*this, vtx); } ! /** ! * \brief Multiplies two vectors and stores the result in this ! * vector. ! * ! * This method multiplies two vectors, \a v1, and \a v2, and ! * stores the product in \c this vector. ! * ! * \f[ ! * \vec{V_{this}} = \vec{V_1} \times \vec{V_2} ! * \f] ! * ! * \param a the first operand ! * \param b the second operand ! * \author Daniel Royer ! */ ! void Vector4d::multiplyAndSet (const Vector4d &a, ! const Vector4d &b) ! { ! w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z; ! x = a.w * b.x + a.x * b.w + a.y * b.z - a.z * b.y; ! y = a.w * b.y + a.y * b.w + a.z * b.x - a.x * b.z; ! z = a.w * b.z + a.z * b.w + a.x * b.y - a.y * b.x; } *************** *** 1114,1117 **** --- 1218,1234 ---- } + /** + * + * + * \f[ + * \vec{Q_x} = \langle x, 1.0, 0.0, 0.0 \rangle + * \vec{Q_y} = \langle y, 0.0, 1.0, 0.0 \rangle + * \vec{Q_z} = \langle z, 0.0, 0.0, 1.0 \rangle + * \vec{Q_x} = (\vec{Q_x} \times \vec{Q_y}) \times \vec{Q_z} + * \f] + * + * \todo Finish writing this comment block + * + */ void Vector4d::setValues (double x, double y, double z) { *************** *** 1159,1177 **** * \f] * ! * \param r the roll angle (x) ! * \param p the pitch angle (y) ! * \param y the yaw angle (z) ! * ! * \todo Turns out, this method is crap. Reimplement completely. ! * \warning do not use this method, yet. * ! * \author Daniel Royer, adapted from Bourg's ! * MakeQFromEulerAngles() function. */ ! void Vector4d::setEulerAngles (double r, double p, double y) { ! double roll = degreesToRadians(r); ! double pitch = degreesToRadians(p); ! double yaw = degreesToRadians(y); double cosYaw = cos(0.5 * yaw); --- 1276,1316 ---- * \f] * ! * \param rollDeg the roll angle (x) in degrees ! * \param pitchDeg the pitch angle (y) in degrees ! * \param yawDeg the yaw angle (z) in degrees * ! * \author Daniel Royer */ ! void Vector4d::setEulerAngles (double rollDeg, double pitchDeg, double yawDeg) { ! ! // ! // Implementation note: I tested both implementations, and ! // they both return identical answers to within ! // double-precision tolerance. So I also tested them for ! // speed. The results of the speed test are ambiguous. They ! // both perform very similarly. Oddly, the second version is ! // faster for fewer iterations (less than 1e6), which implies ! // that it has less overhead even though there are several ! // hidden method calls. The first one executes faster for a ! // very large number of iterations (>=1e6), but not by much. ! // ! // Conclusion: it's a toss up. They both work and they both ! // are sufficiently fast. ! // ! // -- ! // Daniel Royer ! // sp...@us... ! // 4 May 2004 ! // ! ! double roll = degreesToRadians(rollDeg); ! double pitch = degreesToRadians(pitchDeg); ! double yaw = degreesToRadians(yawDeg); ! ! #if 1 ! ! // First version, adapted from David M. Bourge's "Physics ! // for Game Developers". double cosYaw = cos(0.5 * yaw); *************** *** 1192,1210 **** y = (cosYawSinPitch * cosRoll) + (sinYawCosPitch * sinRoll); z = (sinYawCosPitch * cosRoll) - (cosYawSinPitch * sinRoll); - } ! const Vector3d Vector4d::directionVector () const { ! Vector4d temp = this->normalized(); ! Vector3d dir; ! dir.x = 2.0f * (temp.x * temp.z - temp.w * temp.y); ! dir.y = 2.0f * (temp.y * temp.z + temp.w * temp.x); ! dir.z = 1.0f - 2.0f * (temp.x * temp.x + ! temp.y * temp.y); ! return dir; } Vector4d Vector4d::getVector4d (double angle, double x, double y, double z) --- 1331,1358 ---- y = (cosYawSinPitch * cosRoll) + (sinYawCosPitch * sinRoll); z = (sinYawCosPitch * cosRoll) - (cosYawSinPitch * sinRoll); ! #else ! // Second version, adapted from mathematical description of ! // quaternions and rotation matrices from mathworld.com. ! // Quaternion format: <w, x, y, z> ! Vector4d rollQ (cos(0.5 * roll), sin(0.5 * roll), 0.0, 0.0); ! Vector4d pitchQ (cos(0.5 * pitch), 0.0, sin(0.5 * pitch), 0.0); ! Vector4d yawQ (cos(0.5 * yaw), 0.0, 0.0, sin(0.5 * yaw)); ! *this = rollQ * pitchQ * yawQ; ! ! #endif } + + + /** + * \brief Constructs and returns a vector + * + * \deprecated Use a constructor instead + * \author Daniel Royer + */ Vector4d Vector4d::getVector4d (double angle, double x, double y, double z) *************** *** 1217,1220 **** --- 1365,1374 ---- } + /** + * \brief Constructs and returns a vector + * + * \deprecated Use a constructor instead + * \author Daniel Royer + */ Vector4d Vector4d::getVector4d (double x, double y, double z) *************** *** 1229,1233 **** * * Sets the elements of this vector to ! * \f$ \langle 0, 0, 0, 1 \rangle \f$. * * \author Daniel Royer --- 1383,1387 ---- * * Sets the elements of this vector to ! * \f$ \langle 1, 0, 0, 0 \rangle \f$. * * \author Daniel Royer *************** *** 1265,1271 **** const Quaternion Vector4d::conjugated () const { ! Quaternion result = *this; result.conjugate(); ! return result; } --- 1419,1426 ---- const Quaternion Vector4d::conjugated () const { ! /*Quaternion result = *this; result.conjugate(); ! return result;*/ ! return Quaternion (w, -x, -y, -z); } *************** *** 1422,1425 **** --- 1577,1596 ---- } + const Vector3d Vector4d::directionVector () const { + + #warning Vector4d::directionVector() is not ready for use + assertNotReached(); + + Vector4d temp = this->normalized(); + Vector3d dir; + + dir.x = 2.0f * (temp.x * temp.z - temp.w * temp.y); + dir.y = 2.0f * (temp.y * temp.z + temp.w * temp.x); + dir.z = 1.0f - 2.0f * (temp.x * temp.x + + temp.y * temp.y); + + return dir; + } + /** * \todo Figure out what the hell this method does. Is it similar *************** *** 1430,1433 **** --- 1601,1607 ---- const Vector3d Vector4d::viewAxis () const { + #warning Vector4d::viewAxis() is not ready for use + assertNotReached(); + double x2, y2, z2, xx, xz, yy, yz, wx, wy; *************** *** 1456,1459 **** --- 1630,1636 ---- const Vector3d Vector4d::upAxis () const { + #warning Vector4d::upAxis() is not ready for use + assertNotReached(); + double x2, y2, z2, xx, xy, yz, zz, wx, wz; *************** *** 1482,1485 **** --- 1659,1665 ---- const Vector3d Vector4d::rightAxis () const { + #warning Vector4d::rightAxis() is not ready for use + assertNotReached(); + double x2, y2, z2, xy, xz, yy, zz, wy, wz; *************** *** 1540,1543 **** --- 1720,1724 ---- } + #if 0 /** * \brief Matrix to Quaternion assignment operator *************** *** 1556,1560 **** --- 1737,1746 ---- return *this; } + #endif + /** + * \brief Negation operator + * \author Daniel Royer + */ const Vector4d Vector4d::operator-() const { *************** *** 1584,1588 **** const bool operator== (const Vector4d & a, const Vector4d & b){ ! return (a.x == b.x) && (a.y == b.y) && (a.z == b.z) && (a.w == b.w); } --- 1770,1775 ---- const bool operator== (const Vector4d & a, const Vector4d & b){ ! return (a.x == b.x) && (a.y == b.y) && ! (a.z == b.z) && (a.w == b.w); } *************** *** 1602,1605 **** --- 1789,1795 ---- } + /** + * \relates Vector4d + */ const Vector4d operator/(const Vector4d& v, const double d) { *************** *** 1612,1615 **** --- 1802,1808 ---- } + /** + * \relates Vector4d + */ const Vector4d operator*(const Vector4d& v, const double d) { *************** *** 1622,1625 **** --- 1815,1821 ---- } + /** + * \relates Vector4d + */ const Vector4d operator*(const double d, const Vector4d& v) { *************** *** 1632,1635 **** --- 1828,1859 ---- } + /** + * \relates Vector4d + * \relates Vector3d + */ + const Vector4d operator*(const Vector4d& v4, const Vector3d& v3) { + + return Vector4d (-(v4.x*v3.x + v4.y*v3.y + v4.z*v3.z), + v4.w*v3.x + v4.y*v3.z - v4.z*v3.y, + v4.w*v3.y + v4.z*v3.x - v4.x*v3.z, + v4.w*v3.z + v4.x*v3.y - v4.y*v3.x); + } + + + /** + * \relates Vector4d + * \relates Vector3d + */ + const Vector4d operator*(const Vector3d& v3, const Vector4d& v4) { + + return Vector4d (-(v4.x*v3.x + v4.y*v3.y + v4.z*v3.z), + v4.w*v3.x + v4.z*v3.y - v4.y*v3.z, + v4.w*v3.y + v4.x*v3.z - v4.z*v3.x, + v4.w*v3.z + v4.y*v3.x - v4.x*v3.y); + } + + /** + * \relates Vector4d + */ const Vector4d& operator*=(Vector4d& v, const double d) { *************** *** 1641,1644 **** --- 1865,1871 ---- } + /** + * \relates Vector4d + */ const Vector4d& operator/=(Vector4d& v, const double d) { *************** *** 1650,1653 **** --- 1877,1883 ---- } + /** + * \relates Vector4d + */ const Vector4d operator+(const Vector4d& a, const Vector4d& b) { *************** *** 1660,1663 **** --- 1890,1896 ---- } + /** + * \relates Vector4d + */ const Vector4d operator-(const Vector4d& a, const Vector4d& b) { *************** *** 1670,1673 **** --- 1903,1909 ---- } + /** + * \relates Vector4d + */ const Vector4d& operator+=(Vector4d& a, const Vector4d& b) { *************** *** 1679,1682 **** --- 1915,1921 ---- } + /** + * \relates Vector4d + */ const Vector4d& operator-=(Vector4d& a, const Vector4d& b) { *************** *** 1688,1691 **** --- 1927,1933 ---- } + /** + * \relates Vector4d + */ const Quaternion operator* (const Quaternion & a, const Quaternion & b){ *************** *** 1695,1698 **** --- 1937,1943 ---- } + /** + * \relates Vector4d + */ const Quaternion& operator*=(Quaternion & a, const Quaternion & b){ *************** *** 1701,1704 **** --- 1946,1952 ---- } + /** + * \relates Vector4d + */ const Quaternion slerp (const Quaternion& a, const Quaternion& b, float t){ |
|
From: Daniel R. <sp...@us...> - 2004-05-25 23:04:00
|
Update of /cvsroot/teleus/teleus/src/math In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16120/src/math Modified Files: physics.cpp physics.hpp Log Message: Added some geometry functions. Created some Index: physics.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/math/physics.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** physics.cpp 25 Feb 2004 06:34:00 -0000 1.13 --- physics.cpp 25 May 2004 23:03:34 -0000 1.14 *************** *** 384,387 **** --- 384,418 ---- /** + * \brief Returns the radius of a bounding sphere + * + * Given a bounding box of dimensions l, w, and h, this method + * returns the radius of a sphere that will enclose the box. + * + * \param l the length of the bounding box + * \param w the width + * \param h the height + * \returns the radius of the bounding sphere + * \author Daniel Royer + */ + double boundingSphere (double l, double w, double h) { + + return sqrt(l*l + w*w + h*h); + + } + + extern double volSphere (double r) { + + // V = (4/3)PI r^3 + return ((4.0/3.0)*PI) * (r * r * r); + } + + extern double surfAreaSphere (double r) { + + // S = 4PI r^2 + return 4.0 * PI * (r*r); + } + + + /** * \brief Cavendish's gravitational constant * *************** *** 695,699 **** * \author Daniel Royer */ ! double kineticEnergy (double mass, double speed) { return 0.5 * mass * square(speed); --- 726,730 ---- * \author Daniel Royer */ ! double kineticEnergy (float mass, double speed) { return 0.5 * mass * square(speed); *************** *** 703,707 **** * \overload */ ! double kineticEnergy (double mass, const Vector3d& vel) { return 0.5 * mass * vel.lengthSquared(); --- 734,738 ---- * \overload */ ! double kineticEnergy (float mass, const Vector3d& vel) { return 0.5 * mass * vel.lengthSquared(); *************** *** 709,712 **** --- 740,770 ---- /** + * \brief Calculates the impulse force acting on two colliding + * masses + */ + Vector3d impulseForce (float mass1, const Vector3d& vel1, + float mass2, const Vector3d& vel2, + const Vector3d& normal, double coeffRest, + double time) + { + + // Calculate the relative speed along the line of action of + // the collision. + Vector3d velRel = vel1 - vel2; + double speedRel = dot(velRel, normal); + + // Calculate the impulse acting on the masses + double impulse = -speedRel*(coeffRest + 1); + impulse /= (1.0 / mass1 + 1.0 / mass2); + + // Calculate the force acting on the masses + //assert (closeEnough(normal.lengthSquared(), 1.0), "Normal is not normalized"); + + Vector3d force = normal.normalized(); + force *= impulse / time; + return force; + } + + /** * * Index: physics.hpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/math/physics.hpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** physics.hpp 25 Feb 2004 06:34:00 -0000 1.9 --- physics.hpp 25 May 2004 23:03:34 -0000 1.10 *************** *** 61,65 **** extern int clamp (int v, int min, int max); extern double clamp (double v, double min, double max); ! extern bool closeEnough (double a, double b, double e); //-- PHYSICS CONSTANTS ----------------------------------------- --- 61,70 ---- extern int clamp (int v, int min, int max); extern double clamp (double v, double min, double max); ! extern bool closeEnough (double a, double b, double e = 1e-6); ! extern double boundingSphere (double l, double w, double h); ! ! //-- GENERAL GEOMETRY FUNCTIONS -------------------------------- ! extern double volSphere (double r); ! extern double surfAreaSphere (double r); //-- PHYSICS CONSTANTS ----------------------------------------- *************** *** 80,85 **** extern Vector3d linearMomentum (float mass, const Vector3d& velocity); ! extern double kineticEnergy (double mass, double speed); ! extern double kineticEnergy (double mass, const Vector3d& vel); extern double escapeSpeed (double planetMass, double planetRadius); --- 85,94 ---- extern Vector3d linearMomentum (float mass, const Vector3d& velocity); ! extern double kineticEnergy (float mass, double speed); ! extern double kineticEnergy (float mass, const Vector3d& vel); ! Vector3d impulseForce (float mass1, const Vector3d& vel1, ! float mass2, const Vector3d& vel2, ! const Vector3d& normal, double coeffRest, ! double time); extern double escapeSpeed (double planetMass, double planetRadius); |
|
From: Daniel R. <sp...@us...> - 2004-05-25 23:02:44
|
Update of /cvsroot/teleus/teleus/src/math In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15853/src/math Modified Files: matrix.cpp matrix.hpp Log Message: Enhanced Matrix3d. Renamed the Matrix classes to more typist-friendly names. Index: matrix.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/math/matrix.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** matrix.cpp 4 May 2004 18:12:39 -0000 1.8 --- matrix.cpp 25 May 2004 23:02:26 -0000 1.9 *************** *** 45,49 **** * \author Daniel Royer */ ! Matrix_3X3::Matrix_3X3 () { zero(); --- 45,49 ---- * \author Daniel Royer */ ! Matrix3d::Matrix3d () { [...1527 lines suppressed...] - /** - * \typedef typedef Matrix_4X4 Matrix; - * \brief Another more convenient name for a 4 by 4 matrix - * \author Daniel Royer - */ - } // END NAMESPACE math } // END NAMESPACE teleus --- 1580,1589 ---- /** ! * \class Matrix4d ! * \brief A 4 by 4 matrix * \author Daniel Royer */ } // END NAMESPACE math } // END NAMESPACE teleus Index: matrix.hpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/math/matrix.hpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** matrix.hpp 4 May 2004 18:12:39 -0000 1.7 --- matrix.hpp 25 May 2004 23:02:27 -0000 1.8 *************** *** 33,37 **** namespace math { ! struct Matrix_2X2 { float v[4]; --- 33,37 ---- namespace math { ! struct Matrix2d { float v[4]; *************** *** 39,43 **** }; ! struct Matrix_3X3 { union { --- 39,43 ---- }; ! struct Matrix3d { union { *************** *** 51,58 **** }; ! Matrix_3X3 (); ! Matrix_3X3 (float); ! Matrix_3X3 (const float*); ! Matrix_3X3 (const Matrix_3X3&); void zero(); --- 51,59 ---- }; ! Matrix3d (); ! Matrix3d (float); ! Matrix3d (const float*); ! Matrix3d (float, float, float, float, float, float, float, float, float); ! Matrix3d (const Matrix3d&); void zero(); *************** *** 60,64 **** void set (float); void set (const float*); ! void set (const Matrix_3X3&); void setDiag (float, bool setZero = true); void setDiag (float, float, float, bool setZero = true); --- 61,66 ---- void set (float); void set (const float*); ! void set (float, float, float, float, float, float, float, float, float); ! void set (const Matrix3d&); void setDiag (float, bool setZero = true); void setDiag (float, float, float, bool setZero = true); *************** *** 72,105 **** float det() const; void transpose(); ! Matrix_3X3 transposed() const; void inverse(); ! Matrix_3X3 inversed() const; ! Matrix_3X3& operator+= (const Matrix_3X3& m); ! Matrix_3X3& operator-= (const Matrix_3X3& m); ! Matrix_3X3& operator*= (const Matrix_3X3& m); ! Matrix_3X3& operator*= (float); ! Matrix_3X3& operator/= (float); ! Matrix_3X3& operator= (float); ! Matrix_3X3& operator= (float*); ! Matrix_3X3& operator= (const Matrix_3X3&); }; ! const Matrix_3X3 operator+ (const Matrix_3X3& m1, const Matrix_3X3& m2); ! const Matrix_3X3 operator- (const Matrix_3X3& m1, const Matrix_3X3& m2); ! const Matrix_3X3 operator* (const Matrix_3X3& m1, const Matrix_3X3& m2); ! const Vector3d operator* (const Matrix_3X3& m, const Vector3d& v); ! const Vector3d operator* (const Vector3d& v, const Matrix_3X3& m); ! const Matrix_3X3 operator* (const Matrix_3X3& m, float scalar); ! const Matrix_3X3 operator* (float scalar, const Matrix_3X3& m); ! const Matrix_3X3 operator/ (const Matrix_3X3& m, float scalar); ! typedef Matrix_3X3 Tensor; ! struct Matrix_4X4 { union { --- 74,107 ---- float det() const; void transpose(); ! Matrix3d transposed() const; void inverse(); ! Matrix3d inversed() const; ! Matrix3d& operator+= (const Matrix3d& m); ! Matrix3d& operator-= (const Matrix3d& m); ! Matrix3d& operator*= (const Matrix3d& m); ! Matrix3d& operator*= (float); ! Matrix3d& operator/= (float); ! Matrix3d& operator= (float); ! Matrix3d& operator= (float*); ! Matrix3d& operator= (const Matrix3d&); }; ! const Matrix3d operator+ (const Matrix3d& m1, const Matrix3d& m2); ! const Matrix3d operator- (const Matrix3d& m1, const Matrix3d& m2); ! const Matrix3d operator* (const Matrix3d& m1, const Matrix3d& m2); ! const Vector3d operator* (const Matrix3d& m, const Vector3d& v); ! const Vector3d operator* (const Vector3d& v, const Matrix3d& m); ! const Matrix3d operator* (const Matrix3d& m, float scalar); ! const Matrix3d operator* (float scalar, const Matrix3d& m); ! const Matrix3d operator/ (const Matrix3d& m, float scalar); ! typedef Matrix3d Tensor; ! struct Matrix4d { union { *************** *** 114,122 **** }; ! Matrix_4X4 (); ! Matrix_4X4 (const float f); ! Matrix_4X4 (const float *v); ! Matrix_4X4 (const Quaternion& q); ! Matrix_4X4 (const Matrix_4X4 &m); void zero (); --- 116,124 ---- }; ! Matrix4d (); ! Matrix4d (const float f); ! Matrix4d (const float *v); ! Matrix4d (const Quaternion& q); ! Matrix4d (const Matrix4d &m); void zero (); *************** *** 132,139 **** float operator()(unsigned int i, unsigned int j) const; ! const Matrix_4X4& operator=(const float f); ! const Matrix_4X4& operator=(const float *v); ! const Matrix_4X4& operator=(const Quaternion& q); ! const Matrix_4X4& operator=(const Matrix_4X4& m); Vector3d transform (const Vector3d& v) const; --- 134,141 ---- float operator()(unsigned int i, unsigned int j) const; ! const Matrix4d& operator=(const float f); ! const Matrix4d& operator=(const float *v); ! const Matrix4d& operator=(const Quaternion& q); ! const Matrix4d& operator=(const Matrix4d& m); Vector3d transform (const Vector3d& v) const; *************** *** 178,187 **** }; ! typedef Matrix_4X4 Matrix; ! ! const Matrix_4X4 operator* (const Matrix_4X4& a, const Matrix_4X4& b); ! const Matrix_4X4& operator*=( Matrix_4X4& a, const Matrix_4X4& b); ! const Vector3d operator* (const Matrix_4X4& a, const Vector3d& v); ! const Vector3d operator* (const Vector3d& v, const Matrix_4X4& a); } // END NAMESPACE math --- 180,187 ---- }; ! const Matrix4d operator* (const Matrix4d& a, const Matrix4d& b); ! const Matrix4d& operator*=( Matrix4d& a, const Matrix4d& b); ! const Vector3d operator* (const Matrix4d& a, const Vector3d& v); ! const Vector3d operator* (const Vector3d& v, const Matrix4d& a); } // END NAMESPACE math |
|
From: Daniel R. <sp...@us...> - 2004-05-25 23:01:35
|
Update of /cvsroot/teleus/teleus/src/math In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15591/src/math Modified Files: mass.cpp mass.hpp Log Message: Created a new class called Mass that extends PointMass. Mass gives PointMass a volume and rotational component. Index: mass.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/math/mass.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** mass.cpp 25 Feb 2004 06:34:00 -0000 1.5 --- mass.cpp 25 May 2004 23:01:25 -0000 1.6 *************** *** 26,32 **** --- 26,34 ---- #include <string> + #include <cmath> #include "mass.hpp" #include "physics.hpp" #include "vector.hpp" + #include "util/debugrecord.hpp" #include "debug.hpp" [...1450 lines suppressed...] * \file mass.cpp ! * \brief Source file for PointMass */ /** * \file mass.hpp ! * \brief Header file for PointMass */ --- 1557,1566 ---- /** * \file mass.cpp ! * \brief Source file for PointMass and Mass */ /** * \file mass.hpp ! * \brief Header file for PointMass and Mass */ Index: mass.hpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/math/mass.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** mass.hpp 25 Feb 2004 02:23:26 -0000 1.3 --- mass.hpp 25 May 2004 23:01:25 -0000 1.4 *************** *** 30,43 **** #include "vector.hpp" namespace teleus { namespace math { class PointMass { protected: double mMass; ! Vector3d mPosition; ! Vector3d mVelocity; public: --- 30,48 ---- #include "vector.hpp" + #include "matrix.hpp" namespace teleus { namespace math { + class PointMass { protected: + double mMass; ! Vector3d mPosition; // In world coordinates ! Vector3d mLastPosition; // In world coordinates ! Vector3d mVelocity; // In world coordinates ! Vector3d mNetForce; // In world coordinates public: *************** *** 50,61 **** virtual void updatePhysics(double); const Vector3d& pos() const; void setPos (const Vector3d&); const Vector3d& vel() const; void setVel (const Vector3d&); ! double mass() const; ! void setMass (double); const PointMass& operator= (const PointMass&); --- 55,73 ---- virtual void updatePhysics(double); + double mass() const; + void setMass (double); + const Vector3d& pos() const; void setPos (const Vector3d&); + const Vector3d& lastPos () const; const Vector3d& vel() const; + const float speed() const; void setVel (const Vector3d&); ! const Vector3d& netForce() const; ! void setForces (const Vector3d&); ! void addForce (const Vector3d&); ! void resetForces (); const PointMass& operator= (const PointMass&); *************** *** 64,67 **** --- 76,155 ---- }; + class Mass : public PointMass{ + + protected: + + Tensor mInertia; // In self coordinates + Tensor mInertiaInv; // In self coordinates + + Vector3d mAngVelocity; // In self coordinates + Vector3d mOrientation; // In self coordinates + Quaternion mRotation; // In world coordinates + Vector3d mNetTorqueBody; // In self coordinates + Vector3d mNetTorqueWorld; // In world coordinates + Vector3d mNetForceBody; // In self coordinates + + Vector3d mForwardVector; // In world coordinates + Vector3d mRightVector; // In world coordinates + Vector3d mUpVector; // In world coordinates + + float mRadius; + float mLength; + float mWidth; + float mHeight; + + public: + + Mass (); + Mass (double, const Vector3d&, const Vector3d&, + const Tensor&, const Vector3d&, const Quaternion&, + float, float, float, float); + Mass (const PointMass&); + //Mass (const Mass&); + + virtual void updatePhysics(double); + + const Tensor& inertia () const; + void setInertia (const Tensor&); + void setInertia (float f11, float f22, float f33); + + const Tensor& inertiaInverse() const; + void setInertiaInverse (const Tensor&); + + const Vector3d& orientation () const; + void setOrientation (const Vector3d&); + + const Quaternion& rotation () const; + void setRotation (const Quaternion&); + void setRotation (double r, double p, double y); + + const Vector3d& angVelocity () const; + void setAngVelocity (const Vector3d&); + + const Vector3d& netTorque () const; + void addForceBody (const Vector3d&, const Vector3d&); + void addForceWorld (const Vector3d&, const Vector3d&); + void resetForces (); + + const Vector3d& forward() const; + const Vector3d& right() const; + const Vector3d& up() const; + + float radius() const; + void setRadius (float); + + float length() const; + void setLength (float); + + float width() const; + void setWidth (float); + + float height() const; + void setHeight(float); + + void setDimensions(float, float, float); + + }; + } // END NAMESPACE math |
|
From: Daniel R. <sp...@us...> - 2004-05-25 23:00:07
|
Update of /cvsroot/teleus/teleus/src/gfx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15157/src/gfx Modified Files: gfx.cpp gfx.hpp Log Message: Added a few new gfx methods (renderSphere, renderQuad) Index: gfx.hpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/gfx/gfx.hpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** gfx.hpp 25 Feb 2004 06:34:01 -0000 1.14 --- gfx.hpp 25 May 2004 22:59:57 -0000 1.15 *************** *** 39,42 **** --- 39,43 ---- namespace obj{ class Cube; + class Sphere; } *************** *** 154,157 **** --- 155,160 ---- void renderWireSphere (const math::ApproxSphere&, unsigned int, float, float*); void renderSphere (const math::ApproxSphere&, unsigned int, float); + void renderSphere (const obj::Sphere&, bool solid = true); + void renderQuad (float width, float height); } // END NAMESPACE gfx Index: gfx.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/gfx/gfx.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** gfx.cpp 25 Feb 2004 06:34:01 -0000 1.18 --- gfx.cpp 25 May 2004 22:59:57 -0000 1.19 *************** *** 41,44 **** --- 41,45 ---- #include "math/geometry.hpp" #include "obj/cube.hpp" + #include "obj/sphere.hpp" #include "debug.hpp" *************** *** 833,837 **** double x, y, z, angle; ! c->rot().getAxisAngle (x, y, z, angle); glPushMatrix (); --- 834,838 ---- double x, y, z, angle; ! c->rotation().getAxisAngle (x, y, z, angle); glPushMatrix (); *************** *** 888,891 **** --- 889,893 ---- glEnd (); + glPopMatrix (); *************** *** 967,972 **** --- 969,982 ---- unsigned int rad, float angle, float* pos) { + assert (s.slices() != 0 && s.stacks() != 0, "Trying to render " "a null ApproxSphere"); + #if 0 + if (pos){ + DEBUG_PRINT("Rendering wire sphere of radius %d at pos <%f, %f, %f>\n", rad, pos[0], pos[1], pos[2]); + }else{ + DEBUG_PRINT("Rendering wire sphere of radius %d at origin\n", rad); + } + #endif double radius = (double)rad; *************** *** 1085,1088 **** --- 1095,1152 ---- //assertNotReached(); + } + + void renderSphere (const obj::Sphere& s, bool solid) { + + assert (s.geometry().slices() != 0 && s.geometry().stacks() != 0, + "Trying to render a null ApproxSphere"); + + assert (solid, "Rendering wire spheres not supported in this method yet."); + + double radius = s.radius(); + double z0, z1, r0, r1, x, y; + int stackCount = (s.geometry().stackSize() - 1)/2; + int sliceCount = s.geometry().sliceSize()-1 ; + + setColor(s.color()); + glPushMatrix(); + glTranslatef (s.pos().x, s.pos().y, s.pos().z); + + z0 = 1.0; + z1 = s.geometry().stackCos(1); + r0 = 0.0; + r1 = s.geometry().stackSin(1); + + //DEBUG_PRINT ("Drawing %d stacks:\n", stackCount); + + for (int i = 0; i <= stackCount; ++i){ + + z0 = z1; + z1 = s.geometry().stackCos(i); + + r0 = r1; + r1 = s.geometry().stackSin(i); + + //DEBUG_PRINT ("\t Drawing stack %d (z = %0.3f; r = %0.3f)\n", i, z1, r1); + //DEBUG_PRINT ("\t Drawing %d slices\n", sliceCount); + + glBegin(GL_QUAD_STRIP); + for (int j = sliceCount; j >= 0; --j){ + + x = s.geometry().sliceCos(j); + y = s.geometry().sliceSin(j); + + //DEBUG_PRINT ("\t\t Drawing slice %d (x = %0.3f; y = %0.3f)\n", j, x, y); + + glNormal3f(x*r1, y*r1, z1); + glVertex3d(x*r1*radius, y*r1*radius, z1*radius); + + glNormal3f(x*r0, y*r0, z0); + glVertex3d(x*r0*radius, y*r0*radius, z0*radius); + } + glEnd(); + } + + glPopMatrix(); } *************** *** 1126,1129 **** --- 1190,1209 ---- } + void renderQuad (float width, float height) { + + setColor(0.0, 0.0, 0.0); + glPushMatrix (); + glLoadIdentity(); + //glScalef (width, height, 1.0); + glTranslatef (0.0, screenHeight-height, 0.0); + glBegin (GL_QUADS); + glVertex3d (0.0, 0.0, 0.0); + glVertex3d (width, 0.0, 0.0); + glVertex3d (width, height, 0.0); + glVertex3d (0.0, height, 0.0); + glEnd(); + glPopMatrix(); + } + /** * \brief Enables 2D textures. |
|
From: Daniel R. <sp...@us...> - 2004-05-25 21:15:46
|
Update of /cvsroot/teleus/teleus/src/gfx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29840/src/gfx Modified Files: camera.cpp camera.hpp Log Message: gfx::Camera class needs a lot of work. I changed obj::Mass and this stopped working. It seems to be working now, but I'm not comfortable with it. Index: camera.hpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/gfx/camera.hpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** camera.hpp 25 Feb 2004 06:34:01 -0000 1.6 --- camera.hpp 25 May 2004 21:15:18 -0000 1.7 *************** *** 41,45 **** ! private: Object *mBound; --- 41,45 ---- ! public: Object *mBound; Index: camera.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/gfx/camera.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** camera.cpp 25 Feb 2004 06:34:01 -0000 1.5 --- camera.cpp 25 May 2004 21:15:17 -0000 1.6 *************** *** 30,33 **** --- 30,34 ---- #include "obj/object.hpp" #include "math/physics.hpp" + #include "math/vector.hpp" #include "debug.hpp" *************** *** 109,113 **** if (radians >= math::TWO_PI){ radians -= math::TWO_PI; ! }else if (radians < 0){ radians += math::TWO_PI; } --- 110,114 ---- if (radians >= math::TWO_PI){ radians -= math::TWO_PI; ! }else if (radians < 0.0){ radians += math::TWO_PI; } *************** *** 137,141 **** if (radians >= math::TWO_PI){ radians -= math::TWO_PI; ! }else if (radians < 0){ radians += math::TWO_PI; } --- 138,142 ---- if (radians >= math::TWO_PI){ radians -= math::TWO_PI; ! }else if (radians < 0.0){ radians += math::TWO_PI; } *************** *** 156,162 **** --- 157,173 ---- void Camera::applyRotation(){ + #if 1 double x, y, z, angle; mBound->mRotation.getAxisAngle (x, y, z, angle); + glRotatef (math::radiansToDegrees(angle), x, y, -z); + #else + + double x, y, z, angle; + math::Vector4d quat; + //quat.setEulerAngles(math::radiansToDegrees(mAzimuthAngle), math::radiansToDegrees(mHeadingAngle), 0.0); + quat.setEulerAngles(315.0, 341.0, 0.0); + quat.getAxisAngle(x, y, z, angle); glRotatef (math::radiansToDegrees(angle), -x, -y, z); + #endif } *************** *** 170,177 **** void Camera::applyTranslation(){ glTranslatef ( -mBound->mPosition.x, ! -mBound->mPosition.y, ! mBound->mPosition.z ); } --- 181,194 ---- void Camera::applyTranslation(){ + #if 1 glTranslatef ( -mBound->mPosition.x, ! -mBound->mPosition.y, ! mBound->mPosition.z ); + #else + glTranslatef(50.0, -100.0, -100.0); + #endif + + } |
|
From: Daniel R. <sp...@us...> - 2004-05-25 21:14:15
|
Update of /cvsroot/teleus/teleus/src/game In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29464/src/game Modified Files: tscript.cpp Log Message: Minor comment revisions. Index: tscript.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/game/tscript.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tscript.cpp 25 Feb 2004 06:34:02 -0000 1.7 --- tscript.cpp 25 May 2004 21:14:00 -0000 1.8 *************** *** 242,246 **** * * \retval RESULT_SUCCESS if the script was loaded successfully. ! * \retval RESULT_FAILUR if the file could not be opened. * \retval RESULT_SYNTAX_ERROR if the Lua script contains a * syntax error. --- 242,246 ---- * * \retval RESULT_SUCCESS if the script was loaded successfully. ! * \retval RESULT_FAILURE if the file could not be opened. * \retval RESULT_SYNTAX_ERROR if the Lua script contains a * syntax error. *************** *** 255,259 **** RESULT luaT_loadFile (const char *path){ ! DEBUG_PRINT ("Loading and running script [%s]\n", path); assert (path != NULL, "Can't run an empty path, bonehead\n"); --- 255,259 ---- RESULT luaT_loadFile (const char *path){ ! DEBUG_PRINT ("Loading script [%s]\n", path); assert (path != NULL, "Can't run an empty path, bonehead\n"); *************** *** 335,338 **** --- 335,340 ---- RESULT luaT_executeScript (const char *path){ + DEBUG_PRINT ("Loading and running script [%s]\n", path); + // Load the file into memory using the custom load function RESULT result = luaT_loadFile (path); *************** *** 375,378 **** --- 377,382 ---- * \warning \a vals and \a name <b>must not</b> be null. * + * \todo Should I put these in the 'teleus' table namespace? + * * \author Daniel Royer * \see createNumberVar() *************** *** 430,433 **** --- 434,438 ---- * \todo Verify this function's correctness. It works, but do * I need to pop the value off the stack at the end? + * \todo Should I put these in the 'teleus' table namespace? */ RESULT luaT_createStringVar (const char *name, const char *value){ *************** *** 463,466 **** --- 468,473 ---- * \todo Verify this function's correctness. It works, but do * I need to pop the value off the stack at the end? + * + * \todo Should I put these in the 'teleus' table namespace? */ RESULT luaT_createNumberVar (const char *name, double value){ *************** *** 499,503 **** lua_setglobal (luaVM, name); ! DEBUG_PRINT ("Done deleting variable called \"%s\"\n", name); return RESULT_SUCCESS; --- 506,510 ---- lua_setglobal (luaVM, name); ! //DEBUG_PRINT ("Done deleting variable called \"%s\"\n", name); return RESULT_SUCCESS; |
|
From: Daniel R. <sp...@us...> - 2004-05-25 21:13:27
|
Update of /cvsroot/teleus/teleus/src/game In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29276/src/game Modified Files: main.cpp Log Message: Installed UNIX signal handler for sigsegv Index: main.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/game/main.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** main.cpp 25 Feb 2004 02:19:50 -0000 1.4 --- main.cpp 25 May 2004 21:13:14 -0000 1.5 *************** *** 28,31 **** --- 28,32 ---- #include <ctime> #include <string> + #include <signal.h> #include "tnamespace.hpp" *************** *** 53,57 **** int main (int argc, char *argv[]){ ! #warning Set the segfault handler printWarning (); --- 54,59 ---- int main (int argc, char *argv[]){ ! //#warning Set the segfault handler ! signal (SIGSEGV, handler); printWarning (); |
|
From: Daniel R. <sp...@us...> - 2004-05-25 21:12:52
|
Update of /cvsroot/teleus/teleus/src/game In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29132/src/game Modified Files: game.cpp game.hpp Log Message: All kinds of changes to test the updates in other files (math::mass comes to mind). Index: game.hpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/game/game.hpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** game.hpp 22 Feb 2004 00:42:26 -0000 1.4 --- game.hpp 25 May 2004 21:12:40 -0000 1.5 *************** *** 37,40 **** --- 37,41 ---- void initFonts (); bool getInput(); + bool checkCollisions(double secondsPerFrame, double coeffRest); Index: game.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/game/game.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** game.cpp 11 Mar 2004 03:08:42 -0000 1.17 --- game.cpp 25 May 2004 21:12:40 -0000 1.18 *************** *** 2,6 **** * Teleus Space Combat Simulator * Copyright 2004 Daniel Royer ! * sp...@us... * http://teleus.sf.net * --- 2,6 ---- * Teleus Space Combat Simulator * Copyright 2004 Daniel Royer ! * sp...@us... * http://teleus.sf.net * *************** *** 8,12 **** * modify it under the terms of the Teleus Artistic License as * detailed on the Teleus website. ! * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED --- 8,12 ---- * modify it under the terms of the Teleus Artistic License as * detailed on the Teleus website. ! * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED *************** *** 42,48 **** --- 42,51 ---- #include "obj/ship.hpp" #include "obj/cube.hpp" + #include "obj/sphere.hpp" + #include "obj/collision.hpp" #include "util/timer.hpp" #include "util/log.hpp" #include "util/settings.hpp" + #include "util/debugrecord.hpp" #include "debug.hpp" *************** *** 58,65 **** util::Timer timer; ! const unsigned int NUM_CUBES = 2000; obj::Cube *cubes[NUM_CUBES]; obj::Cube *axes[3]; obj::Cube *lightCube; std::vector<std::pair<obj::Cube*, double> > laserCubes; --- 61,73 ---- util::Timer timer; ! const unsigned int NUM_CUBES = 30; obj::Cube *cubes[NUM_CUBES]; obj::Cube *axes[3]; obj::Cube *lightCube; + obj::Cube *testCube; + obj::Ship *activeObject; + + const unsigned int NUM_SPHERES = 3; + obj::Sphere *spheres[NUM_SPHERES]; std::vector<std::pair<obj::Cube*, double> > laserCubes; *************** *** 80,83 **** --- 88,93 ---- void gameloop (){ + debugrecord::initDebugRecord(); + // TODO: change this to use the Input class *************** *** 117,124 **** --- 127,142 ---- math::ApproxSphere lightSphere (10, 10); math::ApproxSphere worldSphere (12, 12); + math::ApproxSphere testSphere (32, 32); + bool sphereCollide = false; + double coeffRest = util::userSettings->getDoubleSetting ("Coefficient of Restitution", 1.0); + + //double timeStep = 1.0/60.0; + //secondsPerFrame = timeStep; while (!done){ + debugrecord::printf("Starting frame %d (%f seconds in)\n", totalFrames, totalSeconds); + // Check for the escape key // TODO: remove this SDL stuff when Input *************** *** 129,136 **** --- 147,189 ---- if (!firstFrame){ + player->resetForces(); player->updatePhysics (secondsPerFrame); + testCube->resetForces(); + testCube->updatePhysics(secondsPerFrame); + + checkCollisions(secondsPerFrame, coeffRest); + + if (obj::Collision::boundingSphereCheck(*spheres[0], *spheres[1])){ + sphereCollide = true; + + math::Vector3d normalVec = math::direction(spheres[0]->pos(), spheres[1]->pos()); + + math::Vector3d impulseForce = math::impulseForce( + spheres[0]->mass(), /* Body 1 */ + spheres[0]->vel(), /* Body 1 */ + spheres[1]->mass(), /* Body 2 */ + spheres[1]->vel(), /* Body 2 */ + normalVec, /* Normal */ + coeffRest, /* Coefficient of restitution*/ + secondsPerFrame); /* Impact time */ + + spheres[0]->addForceWorld(impulseForce, spheres[0]->pos()); + spheres[1]->addForceWorld(-impulseForce, spheres[1]->pos()); + + }else{ + sphereCollide = false; + } + + for (uint i = 0; i < NUM_SPHERES; ++i){ + spheres[i]->updatePhysics(secondsPerFrame); + spheres[i]->resetForces(); + } + + #if 1 + for (unsigned int i = 0; i < NUM_CUBES; ++i){ cubes[i]->updatePhysics (secondsPerFrame); + cubes[i]->resetForces(); } *************** *** 146,152 **** } } } ! //******************************************************// //* START FRAME RENDERING *// --- 199,206 ---- } } + #endif } ! #if 1 //******************************************************// //* START FRAME RENDERING *// *************** *** 164,171 **** --- 218,227 ---- gfx::renderWireSphere(lightSphere, 3, 0.0, lightPos); + gfx::enableLights(); gfx::modifyLight(gfx::LIGHT_ZERO, gfx::LIGHT_POSITION, lightPos); + #if 1 for (unsigned int i = 0; i < NUM_CUBES; ++i){ gfx::renderCube(cubes[i]); *************** *** 176,179 **** --- 232,251 ---- } + for (uint i = 0; i < NUM_SPHERES; ++i){ + /* + obj::Sphere &s = *spheres[i]; + //gfx::renderSphere(*spheres[i], true); + float pos[4]; + pos[0] = (float)s.pos().v[0]; + pos[1] = (float)s.pos().v[1]; + pos[2] = (float)s.pos().v[2]; + pos[3] = 1.0; + gfx::renderWireSphere(s.geometry(), (unsigned int)s.radius(), 0.0, pos); + */ + gfx::renderSphere(*spheres[i], true); + } + + #endif + gfx::renderCube (axes[0]); gfx::renderCube (axes[1]); *************** *** 190,196 **** gfx::renderWireSphere(worldSphere, 2000, 0.0, NULL); math::Vector3d velPoint, uvsc, nvsc; ! double pgOr, rgOr, orOr; // Calculate the screen coordinates for the prograde --- 262,271 ---- gfx::renderWireSphere(worldSphere, 2000, 0.0, NULL); + //gfx::drawRefGrid(); + gfx::renderCube (testCube); + math::Vector3d velPoint, uvsc, nvsc; ! double pgOr, rgOr, orOr, cubeOr; // Calculate the screen coordinates for the prograde *************** *** 227,230 **** --- 302,322 ---- orOr = math::radiansToDegrees(orOr); + // Calculate the screen coordinates of the test cube object + velPoint = testCube->pos(); + math::Vector3d testCubePoint = gfx::getScreenCoordinates(velPoint); + + // Calculate the angle between the player's forward vector + // and the test cube's location. + cubeOr = math::angle(player->forward(), + math::distance(player->pos(), testCube->pos())); + cubeOr = math::radiansToDegrees(cubeOr); + + + math::Vector3d cubeScrnPos[NUM_CUBES]; + for (uint i = 0; i < NUM_CUBES; ++i){ + velPoint = cubes[i]->pos(); + cubeScrnPos[i] = gfx::getScreenCoordinates(velPoint); + } + gfx::disableLights(); *************** *** 236,239 **** --- 328,335 ---- gfx::enableTextures2D(); + //gfx::renderQuad(550.0, 300.0); + /*math::Vector3d(gfx::screenWidth/2.0, gfx::screenHeight/2.0, 1.0), + math::Vector3d(0.0, gfx::screenHeight, 1.0));*/ + int titleHeight = textFont->baseLineDrop() + 5; *************** *** 246,270 **** } ! float yPos = gfx::screenHeight - 3 * (gfx::screenHeight / 4); ! textFont->printf (10.0f, yPos, "Position: <%+0.2f, %+0.2f, %+0.2f> %+0.2f", ! player->pos().x, ! player->pos().y, ! player->pos().z, ! player->pos().length()); yPos -= textFont->baseLineDrop() + 3; ! textFont->printf (10.0f, yPos, "Velocity: <%+0.2f, %+0.2f, %+0.2f> %+0.2f", ! player->vel().x, player->vel().y, ! player->vel().z, player->speed()); yPos -= textFont->baseLineDrop() + 3; ! textFont->printf (10.0f, yPos, "Rotational: <%+0.2f, %+0.2f, %+0.2f>", ! player->rotVel().h, player->rotVel().p, ! player->rotVel().r); yPos -= textFont->baseLineDrop() + 3; ! textFont->printf (10.0f, yPos, "Vector: <%+0.2f, %+0.2f, %+0.2f>", ! player->forward().x, player->forward().y, ! player->forward().z); yPos -= textFont->baseLineDrop() + 3; --- 342,433 ---- } ! ! if (uvsc.z < 1.0 && uvsc.z > 0.0){ ! textFont->printf (uvsc.x, uvsc.y, "o"); ! } ! ! if (nvsc.z < 1.0 && nvsc.z > 0.0){ ! textFont->printf (nvsc.x, nvsc.y, "x"); ! } ! ! if (testCubePoint.z < 1.0 && testCubePoint.z > 0.0){ ! textFont->printf (testCubePoint.x, testCubePoint.y, "TC"); ! } ! ! //math::Vector3d cubeScrnPos[NUM_CUBES]; ! for (uint i = 0; i < NUM_CUBES; ++i){ ! //cubeScrnPos[i] = gfx::getScreenCoordinates (cubes[i]->pos()); ! if (cubeScrnPos[i].z < 1.0 && cubeScrnPos[i].z > 0.0){ ! textFont->printf (cubeScrnPos[i].x, cubeScrnPos[i].y, "%d", i); ! } ! } ! ! ! float yPos = gfx::screenHeight - titleHeight - textFont->baseLineDrop() - 3; //gfx::screenHeight - 3 * (gfx::screenHeight / 4); ! /*textFont->printf (10.0f, yPos, "Main Thrust: %.0f RCS Thrust: R: %.0f; P: %.0f; Y: %.0f", ! activeObject->forwardThrust(), ! activeObject->rollThrust(), ! activeObject->pitchThrust(), ! activeObject->yawThrust()); ! yPos -= textFont->baseLineDrop() + 3;*/ ! ! ! ! textFont->printf (10.0f, yPos, "Active object: %s", activeObject == player?"player":"cube"); yPos -= textFont->baseLineDrop() + 3; ! textFont->printf (10.0f, yPos, "Net External Force: <%+0.2f, %+0.2f, %+0.2f> %+0.2f", ! activeObject->netForce().x, ! activeObject->netForce().y, ! activeObject->netForce().z, ! activeObject->netForce().length()); yPos -= textFont->baseLineDrop() + 3; ! textFont->printf (10.0f, yPos, "Velocity: <%+0.2f, %+0.2f, %+0.2f> %+0.2f", ! activeObject->vel().x, activeObject->vel().y, ! activeObject->vel().z, activeObject->speed()); yPos -= textFont->baseLineDrop() + 3; ! textFont->printf (10.0f, yPos, "Position: <%+0.2f, %+0.2f, %+0.2f> %+0.2f", ! activeObject->pos().x, ! activeObject->pos().y, ! activeObject->pos().z, ! activeObject->pos().length()); ! yPos -= textFont->baseLineDrop() + 3; ! yPos -= textFont->baseLineDrop() + 3; ! ! textFont->printf (10.0f, yPos, "Net External Torque: <%+0.2f, %+0.2f, %+0.2f> %+0.2f", ! activeObject->netTorque().x, ! activeObject->netTorque().y, ! activeObject->netTorque().z, ! activeObject->netTorque().length()); ! yPos -= textFont->baseLineDrop() + 3; ! ! textFont->printf (10.0f, yPos, "Ang Vel: R: %+0.2f; P: %+0.2f; Y: %+0.2f (Mag %+0.2f)", ! activeObject->angVelocity().r, ! activeObject->angVelocity().p, ! activeObject->angVelocity().h, ! activeObject->angVelocity().length()); ! yPos -= textFont->baseLineDrop() + 3; ! ! textFont->printf (10.0f, yPos, "Orientation: <%+0.2f, %+0.2f, %+0.2f> %+0.2f", ! activeObject->orientation().x, ! activeObject->orientation().y, ! activeObject->orientation().z, ! activeObject->orientation().length()); ! yPos -= textFont->baseLineDrop() + 3; ! ! textFont->printf (10.0f, yPos, "Quaternion: <%+0.2f, %+0.2f, %+0.2f, %+0.2f> %+0.2f", ! activeObject->rotation().w, ! activeObject->rotation().x, ! activeObject->rotation().y, ! activeObject->rotation().z, ! activeObject->rotation().length()); ! yPos -= textFont->baseLineDrop() + 3; ! ! textFont->printf (10.0f, yPos, "Forward: <%+0.2f, %+0.2f, %+0.2f>", ! activeObject->forward().x, activeObject->forward().y, ! activeObject->forward().z); ! yPos -= textFont->baseLineDrop() + 3; yPos -= textFont->baseLineDrop() + 3; *************** *** 278,291 **** yPos -= textFont->baseLineDrop() + 3; textFont->printf (10.0f, yPos, "Shots alive: %d", laserCubes.size()); yPos -= textFont->baseLineDrop() + 3; ! if (uvsc.z < 1.0 && uvsc.z > 0.0){ ! textFont->printf (uvsc.x, uvsc.y, "o"); ! } - if (nvsc.z < 1.0 && nvsc.z > 0.0){ - textFont->printf (nvsc.x, nvsc.y, "x"); - } gfx::disableTextures2D(); --- 441,549 ---- yPos -= textFont->baseLineDrop() + 3; + textFont->printf (10.0f, yPos, "TCb: %.1f°", cubeOr); + yPos -= textFont->baseLineDrop() + 3; + yPos -= textFont->baseLineDrop() + 3; + + textFont->printf (10.0f, yPos, "Spheres are %s", sphereCollide?"colliding or intersecting":"separate"); + yPos -= textFont->baseLineDrop() + 3; + + textFont->printf (10.0f, yPos, "Sphere 0 Pos: <%+0.2f, %+0.2f, %+0.2f> %+0.2f", + cubes[0]->pos().x, + cubes[0]->pos().y, + cubes[0]->pos().z, + cubes[0]->pos().length()); + yPos -= textFont->baseLineDrop() + 3; + + textFont->printf (10.0f, yPos, "Sphere 0 Vel: <%+0.2f, %+0.2f, %+0.2f> %+0.2f", + cubes[0]->vel().x, + cubes[0]->vel().y, + cubes[0]->vel().z, + cubes[0]->vel().length()); + yPos -= textFont->baseLineDrop() + 3; + + textFont->printf (10.0f, yPos, "Sphere 0 Force: <%+0.2f, %+0.2f, %+0.2f> %+0.2f", + cubes[0]->netForce().x, + cubes[0]->netForce().y, + cubes[0]->netForce().z, + cubes[0]->netForce().length()); + yPos -= textFont->baseLineDrop() + 3; + + textFont->printf (10.0f, yPos, "Sphere 0 Quaternion: <%+0.2f, %+0.2f, %+0.2f, %+0.2f> %+0.2f", + cubes[0]->rotation().w, + cubes[0]->rotation().x, + cubes[0]->rotation().y, + cubes[0]->rotation().z, + cubes[0]->rotation().length()); + yPos -= textFont->baseLineDrop() + 3; + + textFont->printf (10.0f, yPos, "Sphere 0 Ang Vel: R: %+0.2f; P: %+0.2f; Y: %+0.2f (Mag %+0.2f)", + cubes[0]->angVelocity().r, + cubes[0]->angVelocity().p, + cubes[0]->angVelocity().h, + cubes[0]->angVelocity().length()); + yPos -= textFont->baseLineDrop() + 3; + + textFont->printf (10.0f, yPos, "Sphere 0 Torque: <%+0.2f, %+0.2f, %+0.2f> %+0.2f", + cubes[0]->netTorque().x, + cubes[0]->netTorque().y, + cubes[0]->netTorque().z, + cubes[0]->netTorque().length()); + yPos -= textFont->baseLineDrop() + 3; + yPos -= textFont->baseLineDrop() + 3; + + textFont->printf (10.0f, yPos, "Sphere 1 Pos: <%+0.2f, %+0.2f, %+0.2f> %+0.2f", + cubes[1]->pos().x, + cubes[1]->pos().y, + cubes[1]->pos().z, + cubes[1]->pos().length()); + yPos -= textFont->baseLineDrop() + 3; + + textFont->printf (10.0f, yPos, "Sphere 1 Vel: <%+0.2f, %+0.2f, %+0.2f> %+0.2f", + cubes[1]->vel().x, + cubes[1]->vel().y, + cubes[1]->vel().z, + cubes[1]->vel().length()); + yPos -= textFont->baseLineDrop() + 3; + + textFont->printf (10.0f, yPos, "Sphere 1 Force: <%+0.2f, %+0.2f, %+0.2f> %+0.2f", + cubes[1]->netForce().x, + cubes[1]->netForce().y, + cubes[1]->netForce().z, + cubes[1]->netForce().length()); + yPos -= textFont->baseLineDrop() + 3; + + textFont->printf (10.0f, yPos, "Sphere 1 Quaternion: <%+0.2f, %+0.2f, %+0.2f, %+0.2f> %+0.2f", + cubes[1]->rotation().w, + cubes[1]->rotation().x, + cubes[1]->rotation().y, + cubes[1]->rotation().z, + cubes[1]->rotation().length()); + yPos -= textFont->baseLineDrop() + 3; + + textFont->printf (10.0f, yPos, "Sphere 1 Ang Vel: R: %+0.2f; P: %+0.2f; Y: %+0.2f (Mag %+0.2f)", + cubes[1]->angVelocity().r, + cubes[1]->angVelocity().p, + cubes[1]->angVelocity().h, + cubes[1]->angVelocity().length()); + yPos -= textFont->baseLineDrop() + 3; + + textFont->printf (10.0f, yPos, "Sphere 1 Torque: <%+0.2f, %+0.2f, %+0.2f> %+0.2f", + cubes[1]->netTorque().x, + cubes[1]->netTorque().y, + cubes[1]->netTorque().z, + cubes[1]->netTorque().length()); + yPos -= textFont->baseLineDrop() + 3; + /* textFont->printf (10.0f, yPos, "Shots alive: %d", laserCubes.size()); yPos -= textFont->baseLineDrop() + 3; + yPos -= textFont->baseLineDrop() + 3; ! textFont->printf (10.0f, yPos, "Azimuth: %f", math::radiansToDegrees(camera->mAzimuthAngle)); ! yPos -= textFont->baseLineDrop() + 3; ! ! textFont->printf (10.0f, yPos, "Heading: %f", math::radiansToDegrees(camera->mHeadingAngle)); ! yPos -= textFont->baseLineDrop() + 3; ! */ gfx::disableTextures2D(); *************** *** 301,309 **** --- 559,571 ---- gfx::swapBuffer (); + #endif timer.stop(); + //double elapsedTime = timer.getTime(); + //util::Timer::sleep(timeStep - elapsedTime); secondsPerFrame = timer.getTime(); timer.start(); + totalSeconds += secondsPerFrame; totalFrames++; *************** *** 320,323 **** --- 582,586 ---- Log::record ("Exited game loop after %f seconds\n", totalSeconds); Log::record ("Average frame rate: %f fps\n", totalFrames / totalSeconds); + debugrecord::shutdownDebugRecord (); } *************** *** 347,352 **** --- 610,617 ---- SDL_Event event; while (SDL_PollEvent (&event)){ + math::Vector3d thrustForce, thrustLoc; switch (event.type){ case SDL_KEYUP: + debugrecord::keyUp(event.key.keysym.sym); switch (event.key.keysym.sym){ case SDLK_ESCAPE: done = true; break; *************** *** 354,376 **** case SDLK_TAB: case SDLK_z: ! case SDLK_a: player->setForwardThrust (0.0); ! break; case SDLK_DOWN: ! case SDLK_UP: player->setPitchThrust (0.0); ! break; case SDLK_LEFT: ! case SDLK_RIGHT: player->setYawThrust (0.0); ! break; case SDLK_q: ! case SDLK_e: player->setRollThrust (0.0); ! break; case SDLK_0: ! player->killVelocity (); ! break; default: break; } --- 619,649 ---- case SDLK_TAB: case SDLK_z: ! case SDLK_a: activeObject->setForwardThrust (0.0); ! break; case SDLK_DOWN: ! case SDLK_UP: activeObject->setPitchThrust (0.0); ! break; case SDLK_LEFT: ! case SDLK_RIGHT: activeObject->setYawThrust (0.0); ! break; case SDLK_q: ! case SDLK_e: activeObject->setRollThrust (0.0); ! break; case SDLK_0: ! activeObject->killVelocity (); ! break; ! ! case SDLK_t: ! if (activeObject == player){ ! activeObject = testCube; ! }else{ ! activeObject = player; ! } ! break; default: break; } *************** *** 379,410 **** case SDL_KEYDOWN: ! switch (event.key.keysym.sym){ ! case SDLK_a: player->setForwardThrust (1.0); ! break; ! case SDLK_z: player->setForwardThrust (-0.75); ! break; ! case SDLK_TAB: player->setForwardThrust (3.0); ! break; - case SDLK_UP: player->setPitchThrust (-1.0); - break; ! case SDLK_DOWN: player->setPitchThrust (1.0); ! break; ! case SDLK_LEFT: player->setYawThrust (1.0); ! break; ! case SDLK_RIGHT: player->setYawThrust (-1.0); ! break; ! case SDLK_q: player->setRollThrust (-1.0); break; ! case SDLK_e: player->setRollThrust (1.0); ! break; /* case SDLK_SPACE: --- 652,685 ---- case SDL_KEYDOWN: ! debugrecord::keyDown(event.key.keysym.sym); ! switch (event.key.keysym.sym){ ! case SDLK_a: activeObject->setForwardThrust (1.0); ! break; ! case SDLK_z: activeObject->setForwardThrust (-0.75); ! break; + case SDLK_TAB: activeObject->setForwardThrust (3.0); + break; ! case SDLK_UP: activeObject->setPitchThrust (-1.0); ! break; ! case SDLK_DOWN: activeObject->setPitchThrust (1.0); ! break; ! case SDLK_LEFT: activeObject->setYawThrust (-1.0); ! break; ! case SDLK_RIGHT: activeObject->setYawThrust (1.0); break; ! case SDLK_q: activeObject->setRollThrust (-1.0); ! break; ! ! case SDLK_e: activeObject->setRollThrust (1.0); ! break; /* case SDLK_SPACE: *************** *** 427,431 **** unsigned char *keystate = SDL_GetKeyState(NULL); if (keystate[SDLK_SPACE] ){ ! shootCube(*player); } --- 702,706 ---- unsigned char *keystate = SDL_GetKeyState(NULL); if (keystate[SDLK_SPACE] ){ ! //shootCube(*player); } *************** *** 446,460 **** DEBUG_PRINT ("Initializing player object\n"); player = new obj::Ship; ! player->setMass (1000.0); ! player->setBoundingBox (3.0, 7.0, 10.0); ! player->setBoundingSphere (5.0); DEBUG_PRINT ("Generating random cubes\n"); for (uint i = 0; i < NUM_CUBES; ++i){ //DEBUG_PRINT ("\t Generating cube %d\n", i); cubes[i] = obj::Cube::getRandomCube(); } DEBUG_PRINT ("Done generating random cubes\n"); DEBUG_PRINT ("Creating Axis Cubes\n"); --- 721,791 ---- DEBUG_PRINT ("Initializing player object\n"); + { + double mass = util::userSettings->getDoubleSetting ("Player Mass", 1000.0); + double length = util::userSettings->getDoubleSetting ("Player Length", 3.0); + double width = util::userSettings->getDoubleSetting ("Player Width", 7.0); + double height = util::userSettings->getDoubleSetting ("Player Height", 10.0); + double radius = util::userSettings->getDoubleSetting ("Player Radius", 12.6); + math::Vector3d startPos ( + util::userSettings->getDoubleSetting ("Player Pos X", 0.0), + util::userSettings->getDoubleSetting ("Player Pos Y", 0.0), + util::userSettings->getDoubleSetting ("Player Pos Z", 0.0)); + double roll = util::userSettings->getDoubleSetting ("Player Roll", 0.0); + double pitch = util::userSettings->getDoubleSetting ("Player Pitch", 0.0); + double yaw = util::userSettings->getDoubleSetting ("Player Yaw", 0.0); + player = new obj::Ship; ! activeObject = player; ! player->setMass (mass); ! player->setDimensions (length, width, height); ! player->setRadius (radius); ! math::Vector3d moi = math::rectanglePrismMOI(mass, length, width, height); ! player->setInertia(moi.x, moi.y, moi.z); ! player->setPos (startPos); ! player->setRotation(roll, pitch, yaw); ! } ! + { DEBUG_PRINT ("Generating random cubes\n"); + + #if 1 for (uint i = 0; i < NUM_CUBES; ++i){ //DEBUG_PRINT ("\t Generating cube %d\n", i); cubes[i] = obj::Cube::getRandomCube(); + if (i == 1 || i == 16){ + DEBUG_PRINT("Generating Cube %d\n", i); + DEBUG_PRINT("\t Mass = %f\n", cubes[i]->mass()); + DEBUG_PRINT("\t Dim = <w: %f, h: %f, l: %f>\n", cubes[i]->width(), cubes[i]->height(), cubes[i]->length()); + DEBUG_PRINT("\t Pos = <%f ,%f, %f>\n", cubes[i]->pos().x, cubes[i]->pos().y, cubes[i]->pos().z); + DEBUG_PRINT("\t Vel = <%f, %f, %f>\n", cubes[i]->vel().x, cubes[i]->vel().y, cubes[i]->vel().z); + } } + + #else + + + cubes[0] = new obj::Cube (33.852158, 49.578415, 72.558426); + cubes[0]->setPos(math::Vector3d (-182.245306, 425.234981, 47.340701)); + cubes[0]->setVel(math::Vector3d (77.942532, 42.429180, 99.970549)); + cubes[0]->setMass(12177.743947); + math::Vector3d moi = math::rectanglePrismMOI(cubes[0]->mass(), + cubes[0]->width(), cubes[0]->height(), cubes[0]->length()); + cubes[0]->setInertia (moi.x, moi.y, moi.z); + cubes[0]->setColor (gfx::Color3f (1.0, 0.0, 0.0)); + + cubes[1] = new obj::Cube (46.640263, 65.248253, 32.662235); + cubes[1]->setPos(math::Vector3d (-80.855301, 588.687454, 346.158765)); + cubes[1]->setVel(math::Vector3d (80.984930, 10.641954, 14.499654)); + cubes[1]->setMass(9939.756969); + moi = math::rectanglePrismMOI(cubes[1]->mass(), + cubes[1]->width(), cubes[1]->height(), cubes[1]->length()); + cubes[1]->setInertia (moi.x, moi.y, moi.z); + cubes[1]->setColor (gfx::Color3f (1.0, 1.0, 0.0)); + + #endif + DEBUG_PRINT ("Done generating random cubes\n"); + } DEBUG_PRINT ("Creating Axis Cubes\n"); *************** *** 471,475 **** --- 802,908 ---- DEBUG_PRINT ("Done creating axis cubes\n"); + DEBUG_PRINT ("Creating test cube\n"); + + testCube = new obj::Cube (3.0, 7.0, 10.0); + testCube->setColor (gfx::Color3f(1.0f, 1.0f, 0.0f)); + testCube->setMass (1000.0); + testCube->setDimensions (3.0, 7.0, 10.0); + testCube->setRadius (12.6); + math::Vector3d moi = math::rectanglePrismMOI(1000.0, 7.0, 10.0, 3.0); + testCube->setInertia(moi.x, moi.y, moi.z); + + DEBUG_PRINT ("Done creating test cube\n"); + + { + DEBUG_PRINT ("Creating test spheres\n"); + + double radius = util::userSettings->getDoubleSetting ("Sphere 0 Radius", 50.0); + math::Vector3d startPos ( + util::userSettings->getDoubleSetting ("Sphere 0 Pos X", 200.0), + util::userSettings->getDoubleSetting ("Sphere 0 Pos Y", 0.0), + util::userSettings->getDoubleSetting ("Sphere 0 Pos Z", 0.0)); + math::Vector3d startVel ( + util::userSettings->getDoubleSetting ("Sphere 0 Vel X", -70.0), + util::userSettings->getDoubleSetting ("Sphere 0 Vel Y", 0.0), + util::userSettings->getDoubleSetting ("Sphere 0 Vel Z", 0.0)); + double mass = util::userSettings->getDoubleSetting ("Sphere 0 Mass", math::volSphere(radius) * 1000.0); + spheres[0] = new obj::Sphere (radius, gfx::Color3f(1.0, 0.0, 0.0), startPos, startVel); + spheres[0]->setMass(mass); + + radius = util::userSettings->getDoubleSetting ("Sphere 1 Radius", 50.0); + startPos = math::Vector3d( + util::userSettings->getDoubleSetting ("Sphere 1 Pos X", -200.0), + util::userSettings->getDoubleSetting ("Sphere 1 Pos Y", 0.0), + util::userSettings->getDoubleSetting ("Sphere 1 Pos Z", 0.0)); + startVel = math::Vector3d( + util::userSettings->getDoubleSetting ("Sphere 1 Vel X", 70.0), + util::userSettings->getDoubleSetting ("Sphere 1 Vel Y", 0.0), + util::userSettings->getDoubleSetting ("Sphere 1 Vel Z", 0.0)); + mass = util::userSettings->getDoubleSetting ("Sphere 1 Mass", math::volSphere(radius) * 1000.0); + + spheres[1] = new obj::Sphere (radius, gfx::Color3f(1.0, 1.0, 0.0), startPos, startVel); + spheres[1]->setMass(mass); + + spheres[2] = new obj::Sphere (110.0, gfx::Color3f(0.0, 0.0, 1.0), + math::Vector3d( 500.0, 500.0, 500.0), + math::Vector3d(0.0, 0.0, 0.0)); + spheres[2]->setMass(math::volSphere(110.0) * 1000.0); + + DEBUG_PRINT ("Done creating test spheres\n"); + } + } + + bool checkCollisions(double secondsPerFrame, double coeffRest) { + + bool cd = false; + + for (uint i = 0; i < NUM_CUBES; ++i){ + for (uint j = i+1; j < NUM_CUBES; ++j){ + + assert (i != j, "Checking for collision with self"); + + if (obj::Collision::boundingSphereCheck(*cubes[i], *cubes[j])){ + + cd = true; + + if (i == 1 || j == 1){ + DEBUG_PRINT ("6 in collision (i == %d; j == %d)\n", i, j); + DEBUG_PRINT ("\t %d) Radius = %f; Pos = <%f, %f, %f> (%f)\n", i, + cubes[i]->radius(), + cubes[i]->pos().x, + cubes[i]->pos().y, + cubes[i]->pos().z, + cubes[i]->pos().length()); + + DEBUG_PRINT ("\t %d) Radius = %f; Pos = <%f, %f, %f> (%f)\n", j, + cubes[j]->radius(), + cubes[j]->pos().x, + cubes[j]->pos().y, + cubes[j]->pos().z, + cubes[j]->pos().length()); + + DEBUG_PRINT ("\t Distance between the two is %f\n", + math::distance(cubes[i]->pos(), cubes[j]->pos()).length()); + } + + math::Vector3d normalVec = math::direction(cubes[i]->pos(), cubes[j]->pos()); + math::Vector3d impulseForce = math::impulseForce( + cubes[i]->mass(), /* Body 1 */ + cubes[i]->vel(), /* Body 1 */ + cubes[j]->mass(), /* Body 2 */ + cubes[j]->vel(), /* Body 2 */ + normalVec, /* Normal */ + coeffRest, /* Coefficient of restitution*/ + secondsPerFrame); /* Impact time */ + + cubes[i]->addForceWorld(impulseForce, cubes[i]->pos()); + cubes[j]->addForceWorld(-impulseForce, cubes[j]->pos()); + + } + } + } + + return cd; } |
|
From: Daniel R. <sp...@us...> - 2004-05-25 21:12:17
|
Update of /cvsroot/teleus/teleus/src/game In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29058/src/game Modified Files: debug.cpp Log Message: Modified sigsegv handler to be more conspicuous. Index: debug.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/game/debug.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** debug.cpp 11 Mar 2004 03:08:42 -0000 1.11 --- debug.cpp 25 May 2004 21:12:07 -0000 1.12 *************** *** 193,208 **** count++; if (count > 1){ ! // Just in case any of this method creates a segfault. exit (1); } printBacktrace(); - fprintf (stderr, "Segfault caught (SIGNUM == %d). Attempting to exit\n", signum); - // In the future, add some shut down routines. ! ! fprintf (stderr, "Exiting program\n"); exit (1); - } --- 193,214 ---- count++; if (count > 1){ ! // Just in case any of this function creates a segfault. exit (1); } + fprintf (stderr, + "========================================\n" + "========================================\n" + "==== SEGFAULT ====\n" + "========================================\n" + "========================================\n"); + fprintf (stderr, "Segfault caught (SIGNUM == %d).\n", signum); + fprintf (stderr, "Stack back trace:\n"); printBacktrace(); // In the future, add some shut down routines. ! fprintf (stderr, "Exiting program\n" ! "========================================\n" ! "========================================\n"); exit (1); } |
|
From: Daniel R. <sp...@us...> - 2004-05-25 21:11:13
|
Update of /cvsroot/teleus/teleus In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28753 Modified Files: Doxyfile Log Message: Changed config of Doxygen so some of the graphs won't be generated. Index: Doxyfile =================================================================== RCS file: /cvsroot/teleus/teleus/Doxyfile,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Doxyfile 25 Feb 2004 06:20:48 -0000 1.3 --- Doxyfile 25 May 2004 21:11:03 -0000 1.4 *************** *** 987,991 **** CLASS_DIAGRAMS = YES ! # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. --- 987,991 ---- CLASS_DIAGRAMS = YES ! # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. *************** *** 1012,1016 **** # class references variables) of the class with other documented classes. ! COLLABORATION_GRAPH = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and --- 1012,1016 ---- # class references variables) of the class with other documented classes. ! COLLABORATION_GRAPH = NO # If the UML_LOOK tag is set to YES doxygen will generate inheritance and |
|
From: Daniel R. <sp...@us...> - 2004-05-25 21:10:26
|
Update of /cvsroot/teleus/teleus In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28490 Modified Files: teleus.pro Log Message: Added entries for obj::sphere, obj::collision, and util::debugrecord files. Index: teleus.pro =================================================================== RCS file: /cvsroot/teleus/teleus/teleus.pro,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** teleus.pro 15 Feb 2004 23:15:47 -0000 1.11 --- teleus.pro 25 May 2004 21:10:02 -0000 1.12 *************** *** 79,82 **** --- 79,85 ---- #--------------------------------------- + SOURCES += src/obj/collision.cpp + HEADERS += src/obj/collision.hpp + SOURCES += src/obj/cube.cpp HEADERS += src/obj/cube.hpp *************** *** 88,91 **** --- 91,97 ---- HEADERS += src/obj/ship.hpp + SOURCES += src/obj/sphere.cpp + HEADERS += src/obj/sphere.hpp + #--------------------------------------- SOURCES += src/rs/imageresource.cpp *************** *** 114,116 **** --- 120,125 ---- HEADERS += src/util/timer.hpp + SOURCES += src/util/debugrecord.cpp + HEADERS += src/util/debugrecord.hpp + unix:LIBS += /usr/local/lib/liblua.a /usr/local/lib/liblualib.a /usr/local/lib/libphysfs.a |
|
From: Daniel R. <sp...@us...> - 2004-05-04 18:13:19
|
Update of /cvsroot/teleus/teleus/src/math In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15903/src/math Modified Files: matrix.cpp matrix.hpp Log Message: Updated the comments for Matrix_3X3 Index: matrix.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/math/matrix.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** matrix.cpp 25 Feb 2004 06:34:00 -0000 1.7 --- matrix.cpp 4 May 2004 18:12:39 -0000 1.8 *************** *** 40,45 **** /** * ! * \todo Write comments for this function */ Matrix_3X3::Matrix_3X3 () { --- 40,47 ---- /** + * \brief Default ctor [...1106 lines suppressed...] + * + * * \author Daniel Royer */ *************** *** 921,924 **** --- 1546,1558 ---- * \typedef typedef Matrix_3X3 Tensor; * \brief Another name for a 3 by 3 matrix + * + * Tensors are actually a generalization of scalars (0D + * tensors), vectors (1D tensors), and matrices (2D tensors). + * The more common usage for tensors is as a 3x3 matrix. + * + * Tensors are useful for solving problems involving things like + * elasticity, fluid dynamics, general relativity, or inertia + * for non-symetric objects. + * * \author Daniel Royer */ Index: matrix.hpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/math/matrix.hpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** matrix.hpp 25 Feb 2004 06:34:00 -0000 1.6 --- matrix.hpp 4 May 2004 18:12:39 -0000 1.7 *************** *** 8,12 **** * modify it under the terms of the Teleus Artistic License as * detailed on the Teleus website. ! * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED --- 8,12 ---- * modify it under the terms of the Teleus Artistic License as * detailed on the Teleus website. ! * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED *************** *** 61,64 **** --- 61,66 ---- void set (const float*); void set (const Matrix_3X3&); + void setDiag (float, bool setZero = true); + void setDiag (float, float, float, bool setZero = true); float& operator[](unsigned int n); *************** *** 69,73 **** --- 71,77 ---- float det() const; + void transpose(); Matrix_3X3 transposed() const; + void inverse(); Matrix_3X3 inversed() const; |
|
From: <sp...@us...> - 2004-03-11 03:48:54
|
Update of /cvsroot/teleus/teleus/src/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11029/src/util Modified Files: timer.hpp Log Message: Minor change. Index: timer.hpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/util/timer.hpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** timer.hpp 25 Feb 2004 06:34:00 -0000 1.6 --- timer.hpp 11 Mar 2004 03:30:25 -0000 1.7 *************** *** 47,51 **** #ifdef __linux__ struct timezone mTimezone; ! struct timeval mStart, mEnd; #else LARGE_INTEGER mStartTime; --- 47,52 ---- #ifdef __linux__ struct timezone mTimezone; ! struct timeval mStart; ! struct timeval mEnd; #else LARGE_INTEGER mStartTime; |
|
From: <sp...@us...> - 2004-03-11 03:39:07
|
Update of /cvsroot/teleus/teleus/src/obj In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9439/src/obj Modified Files: cube.cpp Log Message: Removed randFloat(); replaced with math::Random class. We have a problem, though. The Random class uses /dev/urandom to randomly seed the generator. A new generator is created each time the method is called, so it needs a new seed each time. No problem. But if the platform has no /dev/urandom (*cough*windows*cough*), then Random falls back to the time() function. If Random uses the time() function, then all of the randomly generated cubes will be identical. 2000 identical cubes. The optimal solution would be to replace the time() call with an equivalent to /dev/urandom. If that is impossible, then we will have to replace the Random class in Cube::getRandomCube() with a static instance that is only seeded once. Index: cube.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/obj/cube.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** cube.cpp 25 Feb 2004 02:23:26 -0000 1.8 --- cube.cpp 11 Mar 2004 03:20:42 -0000 1.9 *************** *** 29,32 **** --- 29,33 ---- #include "math/vector.hpp" #include "math/physics.hpp" + #include "math/random.hpp" #include "debug.hpp" *************** *** 116,119 **** --- 117,122 ---- Cube * Cube::getRandomCube (){ + math::Random rand; + gfx::Color3f color; math::Vector3d dimensions; *************** *** 130,150 **** color = gfx::Color3f( ! math::randFloat (0.0f, 1.0f), ! math::randFloat (0.0f, 1.0f), ! math::randFloat (0.0f, 1.0f)); ! dimensions.x = math::randFloat (10.0f, 100.0f); ! dimensions.y = math::randFloat (10.0f, 100.0f); ! dimensions.z = math::randFloat (10.0f, 100.0f); const double MAX_POSITION = 4000.0f; ! position.x = math::randFloat (-MAX_POSITION, MAX_POSITION); ! position.y = math::randFloat (-MAX_POSITION, MAX_POSITION); ! position.z = math::randFloat (-MAX_POSITION, MAX_POSITION); ! orientation.x = math::randFloat (0.0f, 360.0f); ! orientation.y = math::randFloat (0.0f, 360.0f); ! orientation.z = math::randFloat (0.0f, 360.0f); ! angle = math::randFloat (0.0f, 360.0f); #if 0 --- 133,153 ---- color = gfx::Color3f( ! rand.floatNumber (0.0f, 1.0f), ! rand.floatNumber (0.0f, 1.0f), ! rand.floatNumber (0.0f, 1.0f)); ! dimensions.x = rand.floatNumber (10.0f, 100.0f); ! dimensions.y = rand.floatNumber (10.0f, 100.0f); ! dimensions.z = rand.floatNumber (10.0f, 100.0f); const double MAX_POSITION = 4000.0f; ! position.x = rand.floatNumber (-MAX_POSITION, MAX_POSITION); ! position.y = rand.floatNumber (-MAX_POSITION, MAX_POSITION); ! position.z = rand.floatNumber (-MAX_POSITION, MAX_POSITION); ! orientation.x = rand.floatNumber (0.0f, 360.0f); ! orientation.y = rand.floatNumber (0.0f, 360.0f); ! orientation.z = rand.floatNumber (0.0f, 360.0f); ! angle = rand.floatNumber (0.0f, 360.0f); #if 0 *************** *** 153,164 **** velocity.z = 0.0; //math::randFloat(0.0f, 100.0f); #else ! velocity.x = math::randFloat(0.0f, 100.0f); ! velocity.y = math::randFloat(0.0f, 100.0f); ! velocity.z = math::randFloat(0.0f, 100.0f); #endif ! rotVel.x = math::randFloat (0.0f, 1.0f); ! rotVel.y = math::randFloat (0.0f, 1.0f); ! rotVel.z = math::randFloat (0.0f, 1.0f); mass = (dimensions.x * dimensions.y * dimensions.z) / 10.0f; --- 156,167 ---- velocity.z = 0.0; //math::randFloat(0.0f, 100.0f); #else ! velocity.x = rand.floatNumber (0.0f, 100.0f); ! velocity.y = rand.floatNumber (0.0f, 100.0f); ! velocity.z = rand.floatNumber (0.0f, 100.0f); #endif ! rotVel.x = rand.floatNumber (0.0f, 1.0f); ! rotVel.y = rand.floatNumber (0.0f, 1.0f); ! rotVel.z = rand.floatNumber (0.0f, 1.0f); mass = (dimensions.x * dimensions.y * dimensions.z) / 10.0f; |
|
From: <sp...@us...> - 2004-03-11 03:33:09
|
Update of /cvsroot/teleus/teleus/src/math In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8511/src/math Modified Files: vector.cpp vector.hpp Log Message: Modified Vector4d::multAndSet() to use the named variables instead of the array. I don't know why I used an array in the first place, but it was a potential bug waiting to happen. Index: vector.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/math/vector.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** vector.cpp 25 Feb 2004 06:34:00 -0000 1.15 --- vector.cpp 11 Mar 2004 03:14:43 -0000 1.16 *************** *** 941,949 **** void Vector4d::normalize (){ ! double l = this->length(); ! this->w = this->w / l; ! this->x = this->x / l; ! this->y = this->y / l; ! this->z = this->z / l; } --- 941,949 ---- void Vector4d::normalize (){ ! double l = length(); ! w /= l; ! x /= l; ! y /= l; ! z /= l; } *************** *** 1051,1054 **** --- 1051,1075 ---- { + w = v2.w * v1.w - + v2.x * v1.x - + v2.y * v1.y - + v2.z * v1.z; + + x = v2.w * v1.x + + v2.x * v1.w + + v2.y * v1.z - + v2.z * v1.y; + + y = v2.w * v1.y - + v2.x * v1.z + + v2.y * v1.w + + v2.z * v1.x; + + z = v2.w * v1.z + + v2.x * v1.y - + v2.y * v1.x + + v2.z * v1.w; + + #if 0 w = v2.v[0] * v1.v[0] - v2.v[1] * v1.v[1] - *************** *** 1070,1073 **** --- 1091,1095 ---- v2.v[2] * v1.v[1] + v2.v[3] * v1.v[0]; + #endif } *************** *** 1261,1266 **** * \li \f$ \vec{t} \f$ is the resultant quaternion (\c this quaternion after this method is completed). * \li \f$ \vec{q} \f$ is the original quaternion (\c this quaternion before this method). ! * \li \f$ \overline{\vec{q}} \f$ is the conjugate of \$f \vec{q} \f$. ! * \li \f$ |\vec{q}| \f$ is the magnitude of the quaternion \$f \vec{q} \f$. * * \author Daniel Royer --- 1283,1288 ---- * \li \f$ \vec{t} \f$ is the resultant quaternion (\c this quaternion after this method is completed). * \li \f$ \vec{q} \f$ is the original quaternion (\c this quaternion before this method). ! * \li \f$ \overline{\vec{q}} \f$ is the conjugate of \f$ \vec{q} \f$. ! * \li \f$ |\vec{q}| \f$ is the magnitude of the quaternion \f$ \vec{q} \f$. * * \author Daniel Royer Index: vector.hpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/math/vector.hpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** vector.hpp 25 Feb 2004 02:23:26 -0000 1.12 --- vector.hpp 11 Mar 2004 03:14:44 -0000 1.13 *************** *** 139,143 **** double v[4]; struct { - // If you modifiy this order, change multiplyAndSet, too. double w, x, y, z; }; --- 139,142 ---- |
|
From: <sp...@us...> - 2004-03-11 03:31:15
|
Update of /cvsroot/teleus/teleus/src/math In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8181/src/math Modified Files: random.cpp Log Message: Changed /dev/random to /dev/urandom. Index: random.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/math/random.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** random.cpp 25 Feb 2004 06:34:00 -0000 1.3 --- random.cpp 11 Mar 2004 03:12:51 -0000 1.4 *************** *** 117,121 **** // Attempt to open /dev/random ! FILE *fp = fopen ("/dev/random", "r"); if (fp == NULL){ --- 117,121 ---- // Attempt to open /dev/random ! FILE *fp = fopen ("/dev/urandom", "r"); if (fp == NULL){ *************** *** 128,131 **** --- 128,133 ---- }else{ + + #if 1 // If we could open /dev/random, we'll read in four // bytes and convert that into an integer to use as *************** *** 140,143 **** --- 142,149 ---- fread (temp.buffer, 4, 1, fp); generatedSeed = temp.integer; + fclose(fp); + #else + assertNotReached(); + #endif } |
|
From: <sp...@us...> - 2004-03-11 03:29:53
|
Update of /cvsroot/teleus/teleus/src/input In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7914/src/input Modified Files: keybinding.cpp Log Message: Removed some minor output for now. Index: keybinding.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/input/keybinding.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** keybinding.cpp 25 Feb 2004 06:34:01 -0000 1.3 --- keybinding.cpp 11 Mar 2004 03:11:27 -0000 1.4 *************** *** 63,68 **** --- 63,70 ---- KeyBinding::~KeyBinding () { + #if 0 DEBUG_PRINT ("Destroying keybinding with action \"%s\"\n", actionCodeToString (action)); + #endif } |
|
From: <sp...@us...> - 2004-03-11 03:28:48
|
Update of /cvsroot/teleus/teleus/src/gfx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7774/src/gfx Modified Files: sphere.cpp sphere.hpp Log Message: Syntax error. Oops. :-S Index: sphere.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/gfx/sphere.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sphere.cpp 25 Feb 2004 06:34:01 -0000 1.2 --- sphere.cpp 11 Mar 2004 03:10:25 -0000 1.3 *************** *** 96,100 **** */ Sphere::Sphere(const Sphere& copy) ! : ApproxSphere(copy.slices(), copy.stacks()) // <-- I'm not happy with that. mPos(copy.mPos), mColor(copy.mColor) --- 96,100 ---- */ Sphere::Sphere(const Sphere& copy) ! : ApproxSphere(copy.slices(), copy.stacks()), // <-- I'm not happy with that. mPos(copy.mPos), mColor(copy.mColor) Index: sphere.hpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/gfx/sphere.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sphere.hpp 18 Feb 2004 07:49:15 -0000 1.1 --- sphere.hpp 11 Mar 2004 03:10:25 -0000 1.2 *************** *** 65,67 **** } // END NAMESPACE teleus ! #endif \ No newline at end of file --- 65,68 ---- } // END NAMESPACE teleus ! #endif ! |
|
From: <sp...@us...> - 2004-03-11 03:27:09
|
Update of /cvsroot/teleus/teleus/src/game In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7479/src/game Modified Files: debug.cpp game.cpp Log Message: Minor comment changes. Index: debug.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/game/debug.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** debug.cpp 25 Feb 2004 06:21:27 -0000 1.10 --- debug.cpp 11 Mar 2004 03:08:42 -0000 1.11 *************** *** 124,129 **** * * \verbatim ! * TELEUS debug: filename: linenumber custom message ! * \endverbatim * * The caller should supply a newline at the end of the custom --- 124,129 ---- * * \verbatim ! TELEUS debug: filename: linenumber custom message ! \endverbatim * * The caller should supply a newline at the end of the custom Index: game.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/game/game.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** game.cpp 25 Feb 2004 06:34:02 -0000 1.16 --- game.cpp 11 Mar 2004 03:08:42 -0000 1.17 *************** *** 453,456 **** --- 453,457 ---- DEBUG_PRINT ("Generating random cubes\n"); for (uint i = 0; i < NUM_CUBES; ++i){ + //DEBUG_PRINT ("\t Generating cube %d\n", i); cubes[i] = obj::Cube::getRandomCube(); } *************** *** 594,599 **** a sub-namespace called <tt>inscript</tt>. These functions are very recognizable because they all have the same prototype: ! <tt>int teleus::inscript::luaT_<i>functionname</i> (lua_State ! *luaVM)</tt>. The <tt><i>functionname</i></tt> part of the function's name is --- 595,600 ---- a sub-namespace called <tt>inscript</tt>. These functions are very recognizable because they all have the same prototype: ! <tt>int teleus::inscript::luaT_functionname (lua_State *luaVM) ! </tt>. The <tt><i>functionname</i></tt> part of the function's name is *************** *** 672,676 **** contain mathematical geometry classes (these classes are not intended to be rendered directly). The <tt>math/matrix.?pp</tt> ! and <tt>math/vector.?pp> files contain typical matrix and vector classes. --- 673,677 ---- contain mathematical geometry classes (these classes are not intended to be rendered directly). The <tt>math/matrix.?pp</tt> ! and <tt>math/vector.?pp</tt> files contain typical matrix and vector classes. |
|
From: <sp...@us...> - 2004-02-25 06:41:00
|
Update of /cvsroot/teleus/teleus/src/game In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6480/src/game Modified Files: game.cpp tscript.cpp Log Message: Code reviewed and comments updated. Index: game.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/game/game.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** game.cpp 25 Feb 2004 02:25:44 -0000 1.15 --- game.cpp 25 Feb 2004 06:34:02 -0000 1.16 *************** *** 516,517 **** --- 516,716 ---- } // END NAMESPACE teleus + /** + \mainpage + + \section intro Introduction + + This is the documentation for the Teleus Space Combat Game. + The official website is located at <a + href="http://teleus.sf.net">teleus.sf.net</a>. Please visit + that site for more information about the game in general. + + This documentation is intended for developers working on the + Teleus game. All of the code is available on these pages (also, + you can download the code from the <a + href="http://sourceforge.net/projects/teleus/">Teleus CVS + server</a> provided by <a + href="http://www.sourceforge.net">Sourceforge.net</a>). + + On this main page, I'll overview the engine's current structure. + The details of the engine and all of its constituent classes, + structs, functions, <i>et cetera</i> can be found on the other + pages; the generated comments take precedence over this page. + + \section form Code Format + + The code is divided into a number of namespaces. The + <tt>teleus</tt> namespace is the top-level namespace in which + most of the game's code is located. There are a number of + sub-namespaces inside the <tt>teleus</tt> namespace, such as + <tt>rs</tt> (resource), <tt>math</tt>, <tt>gfx</tt>, + <tt>input</tt>, and so on. All of the code under a certain + namespace is located in files in directories of the same name as + the namespace. For example, all </tt>gfx</tt> code is located + in <tt>src/gfx/</tt>. + + The <tt>src/game</tt> directory is for the <tt>teleus</tt> + namespace. The <tt>game/</tt> directory stores all of the + global files that are located directly in the teleus namespace + (except for some lua/c interfacing functions, which are located + in the <tt>inscript</tt> namespace). + + When including a file from another namespace, you must include + the directory. For example: + + \code + #include "gfx/camera.hpp" + #include "math/vector.hpp" + \endcode + + This does not apply to the stuff in the <tt>src/game/</tt> + directory. For example: + + \code + #include "debug.hpp" + #include "tnamespace.hpp" + \endcode + + \section ns Namespaces + + There are currently seven sub-namespaces inside of the teleus + namespace: inscript, gfx, input, math, obj, rs, and util. You + can find brief descriptions of all namespaces in the Teleus + Namespace List. + + \subsection ns-inscript Lua/C Interface + + All <a href="http://www.lua.org/">Lua</a> specific code is + located in the <tt>src/game/tscript.?pp</tt> files (where + <tt>?</tt> is either <tt>c</tt> or <tt>h</tt>). Most of it is + code that allows C/C++ functions and methods access to the Lua + virtual machine. For example, luaT_loadFile() loads a script + file into the LuaVM. luaT_executeScript() loads and runs a + script. + + All of the exported C/C++ functions are located directly in the + teleus namespace since Lua is a fundamental part of the engine. + All of the C functions that are exported as Lua functions are in + a sub-namespace called <tt>inscript</tt>. These functions are + very recognizable because they all have the same prototype: + <tt>int teleus::inscript::luaT_<i>functionname</i> (lua_State + *luaVM)</tt>. + + The <tt><i>functionname</i></tt> part of the function's name is + a hint to what the Lua name is. The Lua function is registered + in the Lua namespace teleus with a function name equivalent to + the C function's name, except the Lua function is all lowercase. + For example, luaT_logError() is registered as + <tt>teleus.logerror</tt>. The names of the exported functions + are usually included in the function's comments. And you can + always check out the luaopen_teleus() function to see the + exported functions being registered. + + All Teleus Lua function names are prefixed with <tt>luaT_</tt> + to follow the Lua naming convention (except the luaopen_teleus() + function, which is named so to follow suit of + the luaopen_base, luaopen_math, <i>et + cetera</i>). + + \subsection ns-gfx Graphics Code + + All graphics specific code is located in the + <tt>src/gfx</tt> files. The current heavy hitters in the + gfx namespace are the gfx.cpp, gfx.hpp, wm.cpp, + wm.hpp, camera.cpp, and camera.hpp files. All + OpenGL code is located in these files (and + <i>only</i> these files). + + The <tt>gfx.?pp</tt> files contain thin wrapper functions for + OpenGL. These functions are not intended to allow the game to + be ported to Direct3d or other such 3d APIs. These functions + are intended only to localize all OpenGL calls. (It might be + possible to create a Direct3d version of these functions for + compile-time switching, but I don't know enough about Direct3d.) + + The <tt>camera.?pp</tt> files contain a Camera class. The + Camera class just encapsulates all OpenGL camera functionality. + I have decided that setting the viewing mode (ortho or + perspective) is not a camera operation; it is a standard + graphics operation. The Camera class's purview is limited to + the location and orientation of the 3D perspective camera. GUI + stuff, for example, is not part of the 3D perspective stuff, so + it won't be part of the camera. + + The <tt>wm.?pp</tt> files contain thin wrapper functions for + SDL. Again, these functions are not intended to allow the game + to be ported to other windows manager interface APIs. These + functions are intended only to localize all SDL calls. + + Currently, SDL serves two primary functions: providing an OpenGL + rendering context, and interfacing with the underlying operating + system for things like input. The former is taken care of in + the <tt>gfx/wm.?pp</tt> files; the latter is taken care of in + the <tt>input/</tt> files. + + \subsection ns-input Input Management + + As of this writing, the input files have not yet been worked + out. Eventually, all user input functionality will be localized + in these files. Physics and interface update functions can + query these classes for information about the input devices' + current states. + + Due to the wide variety of input hardware (especially with + keyboards), all input will be changeable via Lua scripted + bindings. These bindings will be changeable in-game and by + editing the Lua scripts manually. + + \subsection ns-math Math and Physics + + Obviously, the math namespace is where all of the math and + physics functions and classes are located. The physics + functions and the <tt>obj</tt> classes are closely tied, and the + division line is fuzzy. The <tt>math/physics.?pp</tt> files + contain functions and constants for general math and physics + related calculations. The <tt>math/geometry.?pp</tt> files + contain mathematical geometry classes (these classes are not + intended to be rendered directly). The <tt>math/matrix.?pp</tt> + and <tt>math/vector.?pp> files contain typical matrix and vector + classes. + + The <tt>math/random.?pp</tt> files contain a Random number + class. This class is platform independent, so it should be + useful for determinism across platforms. <tt>std::rand()</tt> + is, unfortunately, not standard across platforms. This class + also allows the user to determine the random number's data type + and bounds. + + Basically, anything that relates to pure, abstract mathematics + goes in this namespace. Some classes are parents for gfx and + obj classes that provide more functionality. For example, the + gfx::Sphere class is derived from a math class. + + \subsection ns-obj In-Game Objects + + The <tt>obj</tt> namespace contains all of the classes that + represent in-game objects. These classes are a median between + the math classes and the gfx classes. They aren't drawn, but + they contain more information than just mathematical attributes. + These classes also contain data that only makes sense in the + context of a game (for example, damage points for a ship or the + name of the owner, etc). + + \subsection ns-rs Data Files and Resource Management + + The <tt>rs</tt> namespace holds classes that load, unload, and + manage "resources". A resource is basically media loaded from + files. Scripts are not resources, and fonts are handled in the + gfx subsystem. Since there is yet no media, this subsystem is + rather neglected. There are a few classes, but none of them are + used and all will probably be replaced and reworked before they + are integrated into the engine. + + \section moreinfo More Information + + Visit the <a href="http://teleus.sf.net">Teleus website</a> + first. Email one of the developers second (email addresses of + all the developers are on the website; currently it's just <a + href="mailto:sp...@us...">me</a>). + + */ Index: tscript.cpp =================================================================== RCS file: /cvsroot/teleus/teleus/src/game/tscript.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tscript.cpp 25 Feb 2004 02:19:50 -0000 1.6 --- tscript.cpp 25 Feb 2004 06:34:02 -0000 1.7 *************** *** 514,523 **** * This function loads and executes a script. * - * \param file the file path to the script - * \returns the result of the run - * * \author Daniel Royer ! * \note The param and returns information are for the Lua ! * function, not for the C function. * \todo Double-check the return value of lua_tostring. Do I * need to free that memory? --- 514,519 ---- * This function loads and executes a script. * * \author Daniel Royer ! * * \todo Double-check the return value of lua_tostring. Do I * need to free that memory? *************** *** 636,652 **** * log. This function works just like the Lua \c print function. * - * \param str the string to be written to the log. This function - * accepts any number of strings, just like lua's print() function. - * Use Lua's \c string.format function to get printf-like formating - * capabilities. - * - * \returns nothing - * * \note Unlike Log::record(), this function appends a newline * character to the output, just like Lua's \c print function * does. - * - * \note The param and returns information are for the Lua - * function, not for the C function. */ int inscript::luaT_logRecord (lua_State *luaVM){ --- 632,638 ---- *************** *** 665,682 **** * log. This function works just like the Lua \c print function. * - * \param str the string to be written to the log. This function - * accepts any number of strings, just like Lua's \c print function. - * Use Lua's \c format function to get printf-like formating - * capabilities. - * - * \returns nothing * * \note Unlike Log::error(), this function appends a newline * character to the output, just like Lua's print() function * does. - * - * \note The param and returns information are for the lua - * function, not for the c function. - * */ int inscript::luaT_logError (lua_State *luaVM){ --- 651,658 ---- *************** *** 727,739 **** * disparity between the c++ code and the lua code. * - * \param key the key of the setting to be written - * \param value the new value (a number, string, or boolean) - * \returns nothing - * * \todo This function does not yet change the lua variable * - * \note The param and returns information are for the lua - * function, not for the c function. - * */ int inscript::luaT_writeUserSetting (lua_State *luaVM){ --- 703,708 ---- *************** *** 772,784 **** * disparity between the c++ code and the lua code. * - * \param key the key of the setting to be written - * \param value the new value (a number, string, or boolean) - * \returns nothing - * * \todo This function does not yet change the lua variable - * - * \note The param and returns information are for the lua - * function, not for the c function. - * */ int inscript::luaT_writeGlobalSetting (lua_State *luaVM){ --- 741,745 ---- |