diff options
author | teravus | 2013-10-04 16:52:55 -0500 |
---|---|---|
committer | teravus | 2013-10-04 16:52:55 -0500 |
commit | 28d704599e94f4016a984b45db1ec328ff741573 (patch) | |
tree | 1881effba2b4417cbce3e39fe35d3319e5f3cf8b /OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs | |
parent | Merge branch 'master' of careminster:/var/git/careminster (diff) | |
parent | Merge branch 'master' into careminster (diff) | |
download | opensim-SC_OLD-28d704599e94f4016a984b45db1ec328ff741573.zip opensim-SC_OLD-28d704599e94f4016a984b45db1ec328ff741573.tar.gz opensim-SC_OLD-28d704599e94f4016a984b45db1ec328ff741573.tar.bz2 opensim-SC_OLD-28d704599e94f4016a984b45db1ec328ff741573.tar.xz |
Merge branch 'master' of careminster:/var/git/careminster
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs new file mode 100755 index 0000000..8e7ddff --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintSpring.cs | |||
@@ -0,0 +1,103 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyrightD | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Text; | ||
30 | using OpenMetaverse; | ||
31 | |||
32 | namespace OpenSim.Region.Physics.BulletSPlugin | ||
33 | { | ||
34 | |||
35 | public sealed class BSConstraintSpring : BSConstraint6Dof | ||
36 | { | ||
37 | public override ConstraintType Type { get { return ConstraintType.D6_SPRING_CONSTRAINT_TYPE; } } | ||
38 | |||
39 | public BSConstraintSpring(BulletWorld world, BulletBody obj1, BulletBody obj2, | ||
40 | Vector3 frame1Loc, Quaternion frame1Rot, | ||
41 | Vector3 frame2Loc, Quaternion frame2Rot, | ||
42 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | ||
43 | :base(world, obj1, obj2) | ||
44 | { | ||
45 | m_constraint = PhysicsScene.PE.Create6DofSpringConstraint(world, obj1, obj2, | ||
46 | frame1Loc, frame1Rot, frame2Loc, frame2Rot, | ||
47 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); | ||
48 | m_enabled = true; | ||
49 | |||
50 | PhysicsScene.DetailLog("{0},BSConstraintSpring,create,wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", | ||
51 | obj1.ID, world.worldID, obj1.ID, obj1.AddrString, obj2.ID, obj2.AddrString); | ||
52 | PhysicsScene.DetailLog("{0},BSConstraintSpring,create, f1Loc={1},f1Rot={2},f2Loc={3},f2Rot={4},usefA={5},disCol={6}", | ||
53 | m_body1.ID, frame1Loc, frame1Rot, frame2Loc, frame2Rot, useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); | ||
54 | } | ||
55 | |||
56 | public bool SetAxisEnable(int pIndex, bool pAxisEnable) | ||
57 | { | ||
58 | PhysicsScene.DetailLog("{0},BSConstraintSpring.SetEnable,obj1ID={1},obj2ID={2},indx={3},enable={4}", | ||
59 | m_body1.ID, m_body1.ID, m_body2.ID, pIndex, pAxisEnable); | ||
60 | PhysicsScene.PE.SpringEnable(m_constraint, pIndex, BSParam.NumericBool(pAxisEnable)); | ||
61 | return true; | ||
62 | } | ||
63 | |||
64 | public bool SetStiffness(int pIndex, float pStiffness) | ||
65 | { | ||
66 | PhysicsScene.DetailLog("{0},BSConstraintSpring.SetStiffness,obj1ID={1},obj2ID={2},indx={3},stiff={4}", | ||
67 | m_body1.ID, m_body1.ID, m_body2.ID, pIndex, pStiffness); | ||
68 | PhysicsScene.PE.SpringSetStiffness(m_constraint, pIndex, pStiffness); | ||
69 | return true; | ||
70 | } | ||
71 | |||
72 | public bool SetDamping(int pIndex, float pDamping) | ||
73 | { | ||
74 | PhysicsScene.DetailLog("{0},BSConstraintSpring.SetDamping,obj1ID={1},obj2ID={2},indx={3},damp={4}", | ||
75 | m_body1.ID, m_body1.ID, m_body2.ID, pIndex, pDamping); | ||
76 | PhysicsScene.PE.SpringSetDamping(m_constraint, pIndex, pDamping); | ||
77 | return true; | ||
78 | } | ||
79 | |||
80 | public bool SetEquilibriumPoint(int pIndex, float pEqPoint) | ||
81 | { | ||
82 | PhysicsScene.DetailLog("{0},BSConstraintSpring.SetEquilibriumPoint,obj1ID={1},obj2ID={2},indx={3},eqPoint={4}", | ||
83 | m_body1.ID, m_body1.ID, m_body2.ID, pIndex, pEqPoint); | ||
84 | PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, pIndex, pEqPoint); | ||
85 | return true; | ||
86 | } | ||
87 | |||
88 | public bool SetEquilibriumPoint(Vector3 linearEq, Vector3 angularEq) | ||
89 | { | ||
90 | PhysicsScene.DetailLog("{0},BSConstraintSpring.SetEquilibriumPoint,obj1ID={1},obj2ID={2},linearEq={3},angularEq={4}", | ||
91 | m_body1.ID, m_body1.ID, m_body2.ID, linearEq, angularEq); | ||
92 | PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, 0, linearEq.X); | ||
93 | PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, 1, linearEq.Y); | ||
94 | PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, 2, linearEq.Z); | ||
95 | PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, 3, angularEq.X); | ||
96 | PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, 4, angularEq.Y); | ||
97 | PhysicsScene.PE.SpringSetEquilibriumPoint(m_constraint, 5, angularEq.Z); | ||
98 | return true; | ||
99 | } | ||
100 | |||
101 | } | ||
102 | |||
103 | } \ No newline at end of file | ||