Warning, file /education/gcompris/external/qml-box2d/Box2D/Rope/b2Rope.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002 * Copyright (c) 2011 Erin Catto http://www.box2d.org
0003 *
0004 * This software is provided 'as-is', without any express or implied
0005 * warranty.  In no event will the authors be held liable for any damages
0006 * arising from the use of this software.
0007 * Permission is granted to anyone to use this software for any purpose,
0008 * including commercial applications, and to alter it and redistribute it
0009 * freely, subject to the following restrictions:
0010 * 1. The origin of this software must not be misrepresented; you must not
0011 * claim that you wrote the original software. If you use this software
0012 * in a product, an acknowledgment in the product documentation would be
0013 * appreciated but is not required.
0014 * 2. Altered source versions must be plainly marked as such, and must not be
0015 * misrepresented as being the original software.
0016 * 3. This notice may not be removed or altered from any source distribution.
0017 */
0018 
0019 #ifndef B2_ROPE_H
0020 #define B2_ROPE_H
0021 
0022 #include <Box2D/Common/b2Math.h>
0023 
0024 class b2Draw;
0025 
0026 /// 
0027 struct b2RopeDef
0028 {
0029     b2RopeDef()
0030     {
0031         vertices = NULL;
0032         count = 0;
0033         masses = NULL;
0034         gravity.SetZero();
0035         damping = 0.1f;
0036         k2 = 0.9f;
0037         k3 = 0.1f;
0038     }
0039 
0040     ///
0041     b2Vec2* vertices;
0042 
0043     ///
0044     int32 count;
0045 
0046     ///
0047     float32* masses;
0048 
0049     ///
0050     b2Vec2 gravity;
0051 
0052     ///
0053     float32 damping;
0054 
0055     /// Stretching stiffness
0056     float32 k2;
0057 
0058     /// Bending stiffness. Values above 0.5 can make the simulation blow up.
0059     float32 k3;
0060 };
0061 
0062 /// 
0063 class b2Rope
0064 {
0065 public:
0066     b2Rope();
0067     ~b2Rope();
0068 
0069     ///
0070     void Initialize(const b2RopeDef* def);
0071 
0072     ///
0073     void Step(float32 timeStep, int32 iterations);
0074 
0075     ///
0076     int32 GetVertexCount() const
0077     {
0078         return m_count;
0079     }
0080 
0081     ///
0082     const b2Vec2* GetVertices() const
0083     {
0084         return m_ps;
0085     }
0086 
0087     ///
0088     void Draw(b2Draw* draw) const;
0089 
0090     ///
0091     void SetAngle(float32 angle);
0092 
0093 private:
0094 
0095     void SolveC2();
0096     void SolveC3();
0097 
0098     int32 m_count;
0099     b2Vec2* m_ps;
0100     b2Vec2* m_p0s;
0101     b2Vec2* m_vs;
0102 
0103     float32* m_ims;
0104 
0105     float32* m_Ls;
0106     float32* m_as;
0107 
0108     b2Vec2 m_gravity;
0109     float32 m_damping;
0110 
0111     float32 m_k2;
0112     float32 m_k3;
0113 };
0114 
0115 #endif