view lump.h @ 4:79c7cf39a0a0

Fixed new mesh crash - static array bounds. Made home made mutex for wavetable access. Less clicks?
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Mon, 10 Dec 2012 13:00:03 +0000
parents c667dfe12d47
children 085d80989ba7
line wrap: on
line source
/*
 *  lump.h
 *  simplespring
 *
 *  Created by Robert Tubb on 01/06/2011.
 *  Copyright 2011 __MyCompanyName__. All rights reserved.
 *
 */
#ifndef _LUMPH
#define _LUMPH
#include "2dvector.h"
#include "ofMain.h"
#include "spring.h"


class Spring;
class Lump {
private:
	double mass, inverseMass;
	bool grabbed, highlighted;

	TwoVector velocity;
	TwoVector accel;
	double friction;

public:
    bool constrained;
	vector<Spring*> attachedSprings; // pointers to all attached springs
	int numAttachedSprings;
    
    enum ConstrainMode {NOT_CONSTRAINED,CONSTRAIN_X,CONSTRAIN_Y,CONSTRAIN_XY};
    ConstrainMode constrainMode;
	
    bool isInScanPath;
    bool isScanPathEnd;
    bool isScanPathStart;
    
	TwoVector position;
    TwoVector previousPosition;
	double totalForceMag;
	double size;
    int grabID; // which touch is this lump grabbed by?
		
	Lump(); // default constructor
	Lump(double aMass,double aFriction, double positionX, double positionY);
	// also which spring is it attached to
    ~Lump();
	
	TwoVector applyForce();
    void averagingFilter(double amt);
    void homingFilter(double amt);
    TwoVector averageOfConnected();

    TwoVector zeroRefPos;
	void draw();

	void attachSpring(Spring* aSpring);
	void setPosition(double ax, double ay);
    void setVelocity(double ax, double ay);
	void constrain();
    void constrain(ConstrainMode aconstrainMode);
	void unconstrain();
	
	bool isGrabbed();
	void grab(int aGrabID);
	void drag(double ax, double ay, int aGrabID);
	void unGrab();
	void highlight();
	void unhighlight();
	void setInvMass(double aInvMass);
	double getTotalForceMag();
    void setZeroRefPos();
    void setFriction(double aF);
    
    Spring * checkConnectedTo(Lump * otherLump);
    
    // interface to scan path
    double scanDisplacement();
    double scanRadialDisplacement();
    double scanLumpSpeed();
    double scanYPos();
     double scanXPos();
    void addToScanPath();
    void removeFromScanPath();
	 
};

#endif