Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Examples

vos/3D/a3dl/snow.cc

Go to the documentation of this file.
00001 /* $Id: snow.cc,v 1.7 2003/07/23 00:16:18 reed Exp $ */
00002 
00003 
00004 /* This file was generated by otd2cpp.pl, a script for VOS by Reed Hedges
00005   <reed@zerohour.net> and Peter Amstutz <tetron@interreality.org>.
00006 
00007     Copyright (C) 2002 Reed Hedges <reed@interreality.org>
00008 
00009     This library is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU Lesser General Public
00011     License as published by the Free Software Foundation; either
00012     version 2 of the License, or (at your option) any later version.
00013 
00014     This library is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public
00020 License along with this library; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00022 
00023 */
00024 
00025 
00026 
00027 #include <vos/corelibs/vos/site.hh>
00028 #include <vos/corelibs/vos/metaobject.hh>
00029 #include <vos/metaobjects/property/property.hh>
00030 #include "snow.hh"
00031 
00032 using namespace A3DL;
00033 
00034 /* Constructor */
00035 Snow::Snow(MetaObject* s) : MetaObject(s), Object3D(s)
00036 {
00037     accessControl = &NoPropertyAccessControl::static_;
00038 }
00039 
00040 /* Destructor */
00041 Snow::~Snow() {
00042 }
00043 
00044 /* Get/Set default AC */
00045 void Snow::setPropertyAccessControl(PropertyAccessControl* ac) {
00046     accessControl = ac;
00047 }
00048 
00049 PropertyAccessControl* Snow::getPropertyAccessControl() {
00050     return accessControl;
00051 }
00052 
00053 /* Return type string ("a3dl:object3D.snow") */
00054 
00055 const string Snow::getType() {
00056     return string("a3dl:object3D.snow");
00057 }
00058 
00059 /* Register extenders with libvos MetaFactory */
00060 void Snow::registerExtenders() {
00061     LocalSite::addLocalObjectExtension(typeid(Snow).name(), &Snow::new_Snow);
00062     LocalSite::addLocalObjectExtension("a3dl:object3D.snow", &Snow::new_Snow);
00063     RemoteSite::addRemoteObjectExtension(typeid(Snow).name(), &Snow::new_Snow);
00064     RemoteSite::addRemoteObjectExtension("a3dl:object3D.snow", &Snow::new_Snow);
00065 }
00066 
00067 /* Get and set Subproperties and other Subobjects */
00068 
00069 int Snow::getParticleDensity() {
00070     string s;
00071     int n;
00072     vRef<Property> p = meta_cast<Property*>(&findObject("a3dl:particle-density"));
00073     if(!&p) throw bad_cast();
00074     p->read(s);
00075     sscanf(s.c_str(), "%d",  &n);
00076     return n;
00077 }
00078 
00079 void Snow::setParticleDensity(int d, PropertyAccessControl* ac) {
00080     char c[128];
00081     snprintf(c, 128, "%d", d);
00082     if(ac == NULL)
00083         ac = accessControl;
00084     Property::setProperty(*this, "a3dl:particle-density", c, "text/x-int", ac);
00085 }
00086 
00087 Property* Snow::getParticleDensityObject() {
00088     Property* p = meta_cast<Property*>(&findObject("a3dl:particle-density"));
00089     if(!p) throw bad_cast();
00090     return p;
00091 }
00092 
00093 void Snow::setParticleDensityObject(Property* newobj) {
00094     try {
00095         vRef<ParentChildRelation> pcr = findChild("a3dl:particle-density");
00096         setChild(pcr->position, "a3dl:particle-density", newobj);
00097     } catch (NoSuchObjectError) {
00098         insertChild(-1, "a3dl:particle-density", newobj);
00099     }
00100 }
00101 
00102 void Snow::getParticleSize(double& x, double& y) {
00103     string s;
00104     vRef<Property> p = meta_cast<Property*>(&findObject("a3dl:particle-size"));
00105     if(!&p) throw bad_cast();
00106     p->read(s);
00107     sscanf(s.c_str(), "%lg %lg", &x, &y);
00108 }
00109 
00110 void Snow::setParticleSize(double x, double y, PropertyAccessControl* ac) {
00111     char s[256];
00112     snprintf(s, 256, "%.15g %.15g", x, y);
00113     if(ac == NULL)
00114         ac = accessControl;
00115     Property::setProperty(*this, "a3dl:particle-size", s, "text/x-vector-float", ac);
00116 }
00117 
00118 Property* Snow::getParticleSizeObject() {
00119     Property* p = meta_cast<Property*>( &findObject("a3dl:particle-size") );
00120     if(!p) throw bad_cast();
00121     return p;
00122 }
00123 
00124 void Snow::setParticleSizeObject(Property* newobj) {
00125     try {
00126         vRef<ParentChildRelation> pcr = findChild("a3dl:particle-size");
00127         setChild(pcr->position, "a3dl:particle-size", newobj);
00128     } catch (NoSuchObjectError) {
00129         insertChild(-1, "a3dl:particle-size", newobj);
00130     }
00131 }
00132 
00133 double Snow::getFallingSpeed() {
00134     string s;
00135     double r;
00136     vRef<Property> p = meta_cast<Property*>(&findObject("a3dl:falling-speed"));
00137     if(!&p) throw bad_cast();
00138     p->read(s);
00139     sscanf(s.c_str(), "%lg", &r);
00140     return r;
00141 }
00142 
00143 void Snow::setFallingSpeed(double s, PropertyAccessControl* ac) {
00144     char c[256];
00145     snprintf(c, 256, "%.15g", s);
00146     if(ac == NULL)
00147         ac = accessControl;
00148     Property::setProperty(*this, "a3dl:falling-speed", c, "text/x-float", ac);
00149 }
00150 
00151 Property* Snow::getFallingSpeedObject() {
00152     Property* p = meta_cast<Property*>( &findObject("a3dl:falling-speed") );
00153     if(!p) throw bad_cast();
00154     return p;
00155 }
00156 
00157 void Snow::setFallingSpeedObject(Property* newobj) {
00158     try {
00159         vRef<ParentChildRelation> pcr = findChild("a3dl:falling-speed");
00160         setChild(pcr->position, "a3dl:falling-speed", newobj);
00161     } catch (NoSuchObjectError) {
00162         insertChild(-1, "a3dl:falling-speed", newobj);
00163     }
00164 }
00165 
00166 double Snow::getSwirliness() {
00167     string s;
00168     double r;
00169     vRef<Property> p = meta_cast<Property*>(&findObject("a3dl:swirliness"));
00170     if(!&p) throw bad_cast();
00171     p->read(s);
00172     sscanf(s.c_str(), "%lg", &r);
00173     return r;
00174 }
00175 
00176 void Snow::setSwirliness(double value,  PropertyAccessControl* ac) {
00177     char s[256];
00178     snprintf(s, 256, "%.15g", value);
00179     if(ac == NULL)
00180         ac = accessControl;
00181     Property::setProperty(*this, "a3dl:swirliness", s, "text/x-float", ac);
00182 }
00183 
00184 Property* Snow::getSwirlinessObject() {
00185     Property* p = meta_cast<Property*>(&findObject("a3dl:swirliness"));
00186     if(!p) throw bad_cast();
00187     return p;
00188 }
00189 
00190 void Snow::setSwirlinessObject(Property* newobj) {
00191     try {
00192         vRef<ParentChildRelation> pcr = findChild("a3dl:swirliness");
00193         setChild(pcr->position, "a3dl:swirliness", newobj);
00194     } catch (NoSuchObjectError) {
00195         insertChild(-1, "a3dl:swirliness", newobj);
00196     }
00197 }
00198 
00199 /* Generators for factory */
00200 
00201 
00202 MetaObject* Snow::new_Snow(MetaObject *s, const string& type) {
00203     return new Snow(s);
00204 }
00205 
00206 

Generated on Tue Aug 12 03:55:36 2003 for Interreality Project - VOS by doxygen 1.3.2