1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
13// Written by Wang Rui, (C) 2010
15#ifndef OSGPARTICLE_BOUNCEOPERATOR
16#define OSGPARTICLE_BOUNCEOPERATOR
18#include <osgParticle/Particle>
19#include <osgParticle/DomainOperator>
25/** A bounce operator can affect the particle's velocity to make it rebound.
26 Refer to David McAllister's Particle System API (http://www.particlesystems.org)
28class OSGPARTICLE_EXPORT BounceOperator : public DomainOperator
32 : DomainOperator(), _friction(1.0f), _resilience(0.0f), _cutoff(0.0f)
35 BounceOperator( const BounceOperator& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY )
36 : DomainOperator(copy, copyop),
37 _friction(copy._friction), _resilience(copy._resilience), _cutoff(copy._cutoff)
40 META_Object( osgParticle, BounceOperator );
43 void setFriction( float f ) { _friction = f; }
46 float getFriction() const { return _friction; }
48 /// Set the resilience
49 void setResilience( float r ) { _resilience = r; }
51 /// Get the velocity cutoff factor
52 float getResilience() const { return _resilience; }
54 /// Set the velocity cutoff factor
55 void setCutoff( float v ) { _cutoff = v; }
57 /// Get the velocity cutoff factor
58 float getCutoff() const { return _cutoff; }
61 virtual ~BounceOperator() {}
62 BounceOperator& operator=( const BounceOperator& ) { return *this; }
64 virtual void handleTriangle( const Domain& domain, Particle* P, double dt );
65 virtual void handleRectangle( const Domain& domain, Particle* P, double dt );
66 virtual void handlePlane( const Domain& domain, Particle* P, double dt );
67 virtual void handleSphere( const Domain& domain, Particle* P, double dt );
68 virtual void handleDisk( const Domain& domain, Particle* P, double dt );