Back to index

supertuxkart  0.5+dfsg1
skid_mark.hpp
Go to the documentation of this file.
00001 //  $Id: skid_mark.hpp 2111 2008-05-31 07:04:30Z cosmosninja $
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2004 Ingo Ruhnke <grumbel@gmx.de>
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #ifndef HEADER_SKIDMARK_CXX
00021 #define HEADER_SKIDMARK_CXX
00022 
00023 #include <vector>
00024 
00025 #include <plib/ssg.h>
00026 
00027 class SkidMark
00028 {
00029 private:
00030     float m_angle_sign;
00031 public:
00032     SkidMark(float angle_sign);
00033     ~SkidMark();
00034     void add           (const sgCoord& coord,  // Add a position where the skidmark is
00035                         float angle,
00036                         float length); 
00037     void addBreak      (const sgCoord& coord, //Begin or finish an skidmark
00038                         float angle, 
00039                         float length);  
00040     bool wasSkidMarking() const;
00041 
00042 private:
00043 
00044 class SkidMarkPos : public ssgVtxTable
00045     {
00046     public:
00047         SkidMarkPos   ();
00048         SkidMarkPos  (ssgVertexArray* vertices,
00049                       ssgNormalArray* normals,
00050                       ssgColourArray* colors,
00051                       float global_track_offset);
00052         ~SkidMarkPos ();
00053         void recalcBSphere();
00054         void add          (const sgCoord& coord,  // Add a position where the skidmark is
00055                            float angle,
00056                            float length);
00057         void addEnd       (const sgCoord& coord);
00058     private:
00059         float m_track_offset;                 // Amount of which the skidmark is lifted
00060         // above the track to avoid z-buffer errors
00061     }
00062     ;  // SkidMarkPos
00063 
00064     bool m_skid_marking;
00065     static float m_global_track_offset;       // This is to make Z-fighting between
00066     // skidmarks less likely, specially the
00067     // skidmarks made by the AI
00068 
00069     std::vector <SkidMarkPos *> m_skid_marks;
00070     ssgSimpleState *m_skid_state;
00071 };
00072 
00073 #endif
00074 
00075 /* EOF */