CEL: Crystal Entity Layer: tools/stabiliser_dist.h Source File (CEL: Crystal Entity Layer Public API Reference)

| ## Public API Reference

- Main Page
- Classes
- Files

# tools/stabiliser_dist.h

    00001 /*
    00002     Crystal Space Entity Layer
    00003     Copyright (C) 2005 by Jorrit Tyberghein
    00004
    00005     This library is free software; you can redistribute it and/or
    00006     modify it under the terms of the GNU Library General Public
    00007     License as published by the Free Software Foundation; either
    00008     version 2 of the License, or (at your option) any later version.
    00009
    00010     This library is distributed in the hope that it will be useful,
    00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013     Library General Public License for more details.
    00014
    00015     You should have received a copy of the GNU Library General Public
    00016     License along with this library; if not, write to the Free
    00017     Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    00018 */
    00019
    00020 #ifndef STABILISER_DISTRIBUTIONS_H
    00021 #define STABILISER_DISTRIBUTIONS_H
    00022
    00023 #include <csutil/array.h>
    00024 #include <csutil/ref.h>
    00025 #include <csutil/refcount.h>
    00026 #include <ivaria/script.h>
    00027
    00028 struct iPcMechanicsObject;
    00029
    00030 struct celHoverObjectInfo
    00031 {
    00032   float height, yvel, acceleration;
    00033 };
    00034
    00035
    00036 class celStabiliserFunction : public csRefCount
    00037 {
    00038 public:
    00039   virtual ~celStabiliserFunction () {};
    00040   virtual float Force (celHoverObjectInfo obj_info) = 0;
    00041 };
    00042
    00043 class celIntervalMetaDistribution : public celStabiliserFunction
    00044 {
    00045 public:
    00046   void Add (csRef<celStabiliserFunction> func , float low_int , float high_int);
    00047
    00048   float Force (celHoverObjectInfo obj_info);
    00049 private:
    00050   struct Interval
    00051   {
    00052     float low , high;
    00053     csRef<celStabiliserFunction> func;
    00054   };
    00055
    00056   csArray<Interval> funcs;
    00057 };
    00058
    00059 class celIfFallingDistribution : public celStabiliserFunction
    00060 {
    00061 public:
    00062   celIfFallingDistribution (csRef<celStabiliserFunction> ifdist , csRef<celStabiliserFunction> elsedist , float adelta = -1.0);
    00063
    00064   float Force (celHoverObjectInfo obj_info);
    00065 private:
    00066   csRef<celStabiliserFunction> if_dist , else_dist;
    00067   float delta;
    00068 };
    00069
    00070 class celFallingMultiplierDistribution : public celStabiliserFunction
    00071 {
    00072 public:
    00073   celFallingMultiplierDistribution (csRef<celStabiliserFunction> fdist, csRef<celStabiliserFunction> hdist);
    00074
    00075   float Force (celHoverObjectInfo obj_info);
    00076 private:
    00077   csRef<celStabiliserFunction> falling_dist, height_dist;
    00078 };
    00079
    00080 class celScriptedHeightFunction : public celStabiliserFunction
    00081 {
    00082 public:
    00083   celScriptedHeightFunction (csRef<iScript> iscript, csString module);
    00084
    00085   float Force (celHoverObjectInfo obj_info);
    00086 private:
    00087   csString module;
    00088   csRef<iScript> iscript;
    00089 };
    00090
    00091 class celReturnConstantValue : public celStabiliserFunction
    00092 {
    00093 public:
    00094   celReturnConstantValue (float avalue = 0.0);
    00095
    00096   float Force (celHoverObjectInfo obj_info);
    00097
    00098   float value;
    00099 };
    00100
    00101 class celLinearGradient : public celStabiliserFunction
    00102 {
    00103 public:
    00104   celLinearGradient (float m , float c) : m (m) , c (c) {}
    00105
    00106   float Force (celHoverObjectInfo obj_info) { return m*obj_info.height + c; }
    00107
    00108   float m , c;
    00109 };
    00110
    00111 class celInversePowerDistribution : public celStabiliserFunction
    00112 {
    00113 public:
    00114   celInversePowerDistribution (float h0, float f0, float h1, float f1);
    00115
    00116   float Force (celHoverObjectInfo obj_info);
    00117 private:
    00118   static float ComputeK (float h0, float f0, float h1, float f1);
    00119   static float ComputeX (float h, float f, float k);
    00120
    00121   float Formula (float h);
    00122
    00123   float k , x;
    00124 };
    00125
    00126 class celSquareDistribution : public celStabiliserFunction
    00127 {
    00128 public:
    00129   celSquareDistribution (float h0, float f0, float h1, float f1);
    00130
    00131   float Force (celHoverObjectInfo obj_info);
    00132 private:
    00133   float a , k;
    00134 };
    00135
    00136 #endif