Home | History | Annotate | Download | only in dynamics
      1 /*******************************************************************************
      2  * Copyright (c) 2013, Daniel Murphy
      3  * All rights reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without modification,
      6  * are permitted provided that the following conditions are met:
      7  * 	* Redistributions of source code must retain the above copyright notice,
      8  * 	  this list of conditions and the following disclaimer.
      9  * 	* Redistributions in binary form must reproduce the above copyright notice,
     10  * 	  this list of conditions and the following disclaimer in the documentation
     11  * 	  and/or other materials provided with the distribution.
     12  *
     13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
     14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     16  * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     17  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     18  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     19  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     20  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     21  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     22  * POSSIBILITY OF SUCH DAMAGE.
     23  ******************************************************************************/
     24 package org.jbox2d.dynamics;
     25 
     26 import org.jbox2d.collision.shapes.Shape;
     27 
     28 /**
     29  * A fixture definition is used to create a fixture. This class defines an abstract fixture
     30  * definition. You can reuse fixture definitions safely.
     31  *
     32  * @author daniel
     33  */
     34 public class FixtureDef {
     35   /**
     36    * The shape, this must be set. The shape will be cloned, so you can create the shape on the
     37    * stack.
     38    */
     39   public Shape shape = null;
     40 
     41   /**
     42    * Use this to store application specific fixture data.
     43    */
     44   public Object userData;
     45 
     46   /**
     47    * The friction coefficient, usually in the range [0,1].
     48    */
     49   public float friction;
     50 
     51   /**
     52    * The restitution (elasticity) usually in the range [0,1].
     53    */
     54   public float restitution;
     55 
     56   /**
     57    * The density, usually in kg/m^2
     58    */
     59   public float density;
     60 
     61   /**
     62    * A sensor shape collects contact information but never generates a collision response.
     63    */
     64   public boolean isSensor;
     65 
     66   /**
     67    * Contact filtering data;
     68    */
     69   public Filter filter;
     70 
     71   public FixtureDef() {
     72     shape = null;
     73     userData = null;
     74     friction = 0.2f;
     75     restitution = 0f;
     76     density = 0f;
     77     filter = new Filter();
     78     isSensor = false;
     79   }
     80 
     81   /**
     82    * The shape, this must be set. The shape will be cloned, so you can create the shape on the
     83    * stack.
     84    */
     85   public Shape getShape() {
     86     return shape;
     87   }
     88 
     89   /**
     90    * The shape, this must be set. The shape will be cloned, so you can create the shape on the
     91    * stack.
     92    */
     93   public void setShape(Shape shape) {
     94     this.shape = shape;
     95   }
     96 
     97   /**
     98    * Use this to store application specific fixture data.
     99    */
    100   public Object getUserData() {
    101     return userData;
    102   }
    103 
    104   /**
    105    * Use this to store application specific fixture data.
    106    */
    107   public void setUserData(Object userData) {
    108     this.userData = userData;
    109   }
    110 
    111   /**
    112    * The friction coefficient, usually in the range [0,1].
    113    */
    114   public float getFriction() {
    115     return friction;
    116   }
    117 
    118   /**
    119    * The friction coefficient, usually in the range [0,1].
    120    */
    121   public void setFriction(float friction) {
    122     this.friction = friction;
    123   }
    124 
    125   /**
    126    * The restitution (elasticity) usually in the range [0,1].
    127    */
    128   public float getRestitution() {
    129     return restitution;
    130   }
    131 
    132   /**
    133    * The restitution (elasticity) usually in the range [0,1].
    134    */
    135   public void setRestitution(float restitution) {
    136     this.restitution = restitution;
    137   }
    138 
    139   /**
    140    * The density, usually in kg/m^2
    141    */
    142   public float getDensity() {
    143     return density;
    144   }
    145 
    146   /**
    147    * The density, usually in kg/m^2
    148    */
    149   public void setDensity(float density) {
    150     this.density = density;
    151   }
    152 
    153   /**
    154    * A sensor shape collects contact information but never generates a collision response.
    155    */
    156   public boolean isSensor() {
    157     return isSensor;
    158   }
    159 
    160   /**
    161    * A sensor shape collects contact information but never generates a collision response.
    162    */
    163   public void setSensor(boolean isSensor) {
    164     this.isSensor = isSensor;
    165   }
    166 
    167   /**
    168    * Contact filtering data;
    169    */
    170   public Filter getFilter() {
    171     return filter;
    172   }
    173 
    174   /**
    175    * Contact filtering data;
    176    */
    177   public void setFilter(Filter filter) {
    178     this.filter = filter;
    179   }
    180 }
    181