b2Rope.h
Go to the documentation of this file.
00001 /*
00002 * Copyright (c) 2011 Erin Catto http://www.box2d.org
00003 *
00004 * This software is provided 'as-is', without any express or implied
00005 * warranty.  In no event will the authors be held liable for any damages
00006 * arising from the use of this software.
00007 * Permission is granted to anyone to use this software for any purpose,
00008 * including commercial applications, and to alter it and redistribute it
00009 * freely, subject to the following restrictions:
00010 * 1. The origin of this software must not be misrepresented; you must not
00011 * claim that you wrote the original software. If you use this software
00012 * in a product, an acknowledgment in the product documentation would be
00013 * appreciated but is not required.
00014 * 2. Altered source versions must be plainly marked as such, and must not be
00015 * misrepresented as being the original software.
00016 * 3. This notice may not be removed or altered from any source distribution.
00017 */
00018 
00019 #ifndef B2_ROPE_H
00020 #define B2_ROPE_H
00021 
00022 #include <Box2D/Common/b2Math.h>
00023 
00024 class b2Draw;
00025 
00027 struct b2RopeDef
00028 {
00029         b2RopeDef()
00030         {
00031                 vertices = NULL;
00032                 count = 0;
00033                 masses = NULL;
00034                 gravity.SetZero();
00035                 damping = 0.1f;
00036                 k2 = 0.9f;
00037                 k3 = 0.1f;
00038         }
00039 
00041         b2Vec2* vertices;
00042 
00044         int32 count;
00045 
00047         float32* masses;
00048 
00050         b2Vec2 gravity;
00051 
00053         float32 damping;
00054 
00056         float32 k2;
00057 
00059         float32 k3;
00060 };
00061 
00063 class b2Rope
00064 {
00065 public:
00066         b2Rope();
00067         ~b2Rope();
00068 
00070         void Initialize(const b2RopeDef* def);
00071 
00073         void Step(float32 timeStep, int32 iterations);
00074 
00076         int32 GetVertexCount() const
00077         {
00078                 return m_count;
00079         }
00080 
00082         const b2Vec2* GetVertices() const
00083         {
00084                 return m_ps;
00085         }
00086 
00088         void Draw(b2Draw* draw) const;
00089 
00091         void SetAngle(float32 angle);
00092 
00093 private:
00094 
00095         void SolveC2();
00096         void SolveC3();
00097 
00098         int32 m_count;
00099         b2Vec2* m_ps;
00100         b2Vec2* m_p0s;
00101         b2Vec2* m_vs;
00102 
00103         float32* m_ims;
00104 
00105         float32* m_Ls;
00106         float32* m_as;
00107 
00108         b2Vec2 m_gravity;
00109         float32 m_damping;
00110 
00111         float32 m_k2;
00112         float32 m_k3;
00113 };
00114 
00115 #endif


mvsim
Author(s):
autogenerated on Thu Jun 6 2019 22:08:35