rt300@0
|
1 /*
|
rt300@0
|
2 * lump.h
|
rt300@0
|
3 * simplespring
|
rt300@0
|
4 *
|
rt300@0
|
5 * Created by Robert Tubb on 01/06/2011.
|
rt300@0
|
6 * Copyright 2011 __MyCompanyName__. All rights reserved.
|
rt300@0
|
7 *
|
rt300@0
|
8 */
|
rt300@0
|
9 #ifndef _LUMPH
|
rt300@0
|
10 #define _LUMPH
|
rt300@0
|
11 #include "2dvector.h"
|
rt300@0
|
12 #include "ofMain.h"
|
rt300@0
|
13 #include "spring.h"
|
rt300@0
|
14
|
rt300@0
|
15
|
rt300@0
|
16 class Spring;
|
rt300@0
|
17 class Lump {
|
rt300@0
|
18 private:
|
rt300@0
|
19 double mass, inverseMass;
|
rt300@0
|
20 bool grabbed, highlighted;
|
rt300@4
|
21
|
rt300@0
|
22 TwoVector velocity;
|
rt300@0
|
23 TwoVector accel;
|
rt300@0
|
24 double friction;
|
rt300@0
|
25
|
rt300@0
|
26 public:
|
rt300@0
|
27 bool constrained;
|
rt300@4
|
28 vector<Spring*> attachedSprings; // pointers to all attached springs
|
rt300@0
|
29 int numAttachedSprings;
|
rt300@0
|
30
|
rt300@0
|
31 enum ConstrainMode {NOT_CONSTRAINED,CONSTRAIN_X,CONSTRAIN_Y,CONSTRAIN_XY};
|
rt300@0
|
32 ConstrainMode constrainMode;
|
rt300@0
|
33
|
rt300@0
|
34 bool isInScanPath;
|
rt300@4
|
35 bool isScanPathEnd;
|
rt300@4
|
36 bool isScanPathStart;
|
rt300@4
|
37
|
rt300@0
|
38 TwoVector position;
|
rt300@0
|
39 TwoVector previousPosition;
|
rt300@0
|
40 double totalForceMag;
|
rt300@8
|
41 //double size;
|
rt300@8
|
42 int myIndexInMesh;
|
rt300@0
|
43 int grabID; // which touch is this lump grabbed by?
|
rt300@0
|
44
|
rt300@0
|
45 Lump(); // default constructor
|
rt300@0
|
46 Lump(double aMass,double aFriction, double positionX, double positionY);
|
rt300@0
|
47 // also which spring is it attached to
|
rt300@0
|
48 ~Lump();
|
rt300@5
|
49 double radialDisplacement;
|
rt300@0
|
50 TwoVector applyForce();
|
rt300@0
|
51 void averagingFilter(double amt);
|
rt300@0
|
52 void homingFilter(double amt);
|
rt300@0
|
53 TwoVector averageOfConnected();
|
rt300@0
|
54
|
rt300@0
|
55 TwoVector zeroRefPos;
|
rt300@0
|
56 void draw();
|
rt300@0
|
57
|
rt300@0
|
58 void attachSpring(Spring* aSpring);
|
rt300@0
|
59 void setPosition(double ax, double ay);
|
rt300@0
|
60 void setVelocity(double ax, double ay);
|
rt300@0
|
61 void constrain();
|
rt300@0
|
62 void constrain(ConstrainMode aconstrainMode);
|
rt300@0
|
63 void unconstrain();
|
rt300@0
|
64
|
rt300@0
|
65 bool isGrabbed();
|
rt300@0
|
66 void grab(int aGrabID);
|
rt300@0
|
67 void drag(double ax, double ay, int aGrabID);
|
rt300@0
|
68 void unGrab();
|
rt300@0
|
69 void highlight();
|
rt300@0
|
70 void unhighlight();
|
rt300@0
|
71 void setInvMass(double aInvMass);
|
rt300@0
|
72 double getTotalForceMag();
|
rt300@0
|
73 void setZeroRefPos();
|
rt300@0
|
74 void setFriction(double aF);
|
rt300@0
|
75
|
rt300@0
|
76 Spring * checkConnectedTo(Lump * otherLump);
|
rt300@0
|
77
|
rt300@0
|
78 // interface to scan path
|
rt300@0
|
79 double scanDisplacement();
|
rt300@0
|
80 double scanRadialDisplacement();
|
rt300@0
|
81 double scanLumpSpeed();
|
rt300@0
|
82 double scanYPos();
|
rt300@0
|
83 double scanXPos();
|
rt300@0
|
84 void addToScanPath();
|
rt300@0
|
85 void removeFromScanPath();
|
rt300@0
|
86
|
rt300@0
|
87 };
|
rt300@0
|
88
|
rt300@0
|
89 #endif |