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/object3d.hh

Go to the documentation of this file.
00001 /*
00002     This file is part of the Virtual Object System of
00003     the Interreality project (http://interreality.org).
00004 
00005     Copyright (C) 2001, 2002 Peter Amstutz
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00020 
00021     Peter Amstutz <tetron@interreality.org>
00022 */
00023 #ifndef _OBJECT3D_HH_
00024 #define _OBJECT3D_HH_
00025 
00026 #if defined(_WIN32) && defined(_MSC_VER)
00027 # ifdef A3DL_EXPORTS
00028 #  define A3DL_API __declspec(dllexport)
00029 # else
00030 #  define A3DL_API __declspec(dllimport)
00031 # endif
00032 #else
00033 # define A3DL_API
00034 #endif
00035 
00036 #include <vos/corelibs/vos/vos.hh>
00037 #include <vos/metaobjects/property/property.hh>
00038 #include "material.hh"
00039 
00040 namespace A3DL
00041 {
00042     class A3DL_API Object3D : public virtual MetaObject
00043     {
00044     protected:
00045         PropertyAccessControl* accesscontrol;
00046     public:
00047         Object3D(MetaObject* superobject);
00048         virtual ~Object3D();
00049 
00050         void setPropertyAccessControl(PropertyAccessControl* pac) { accesscontrol = pac; }
00051         PropertyAccessControl* getPropertyAccessControl(){ return accesscontrol; }
00052 
00053         /** Set position of this 3D object.
00054             @param x X translation, relative to origin of parent object
00055             @param y Y translation, relative to origin of parent object
00056             @param z Z translation, relative to origin of parent object
00057             @throws NoSuchObjectError if "position" subobject does not exist, or is not a property.
00058         */
00059         virtual void setPosition(double x, double y, double z) throw(NoSuchObjectError, AccessControlError, RemoteError);
00060 
00061 
00062         /** Set the orientation of this 3D object in axis-angle
00063             rotation.  The first three parameters are a unit vector in
00064             world space which define an axis, the fourth parameter is
00065             a clockwise rotation about that axis.  For example, [0 1 0 20] would
00066             specify a rotation of 20 degrees around a vector pointing
00067             straight up.
00068             @note You can convert a quaternion into angle-axis
00069             rotation with the following math:
00070             @code
00071             phi = 2.0 * acos(quat.r);
00072             x = quat.x / sin(phi/2.0);
00073             y = quat.y / sin(phi/2.0);
00074             z = quat.z / sin(phi/2.0);
00075             @endcode
00076             @param x X vector component
00077             @param y Y vector component
00078             @param z Z vector component
00079             @param phi the rotation about the vector axis, in degrees
00080             @throws NoSuchObjectError if "orientation" subobject does not exist, or is not a property.
00081         */
00082         virtual void setOrientation(double x, double y, double z, double phi)
00083             throw(NoSuchObjectError, AccessControlError, RemoteError);
00084 
00085         /** Convenience function to set the orientation of this 3D object using a quaternion,
00086             which is then converted to A3DL's axis-angle notation.
00087             @param x X vector component
00088             @param y Y vector component
00089             @param z Z vector component
00090             @param phi the rotation about the vector axis, in degrees
00091             @throws NoSuchObjectError if "orientation" subobject does not exist, or is not a property.
00092         */
00093         virtual void setOrientationWithQuaternion(double x, double y, double z, double phi)
00094             throw(NoSuchObjectError, AccessControlError, RemoteError);
00095 
00096 
00097         /** Set scaling factors of this 3D object.
00098             @param x X scaling
00099             @param y Y scaling
00100             @param z Z scaling
00101             @throws NoSuchObjectError if "scaling" subobject does not exist, or is not a property.
00102         */
00103         virtual void setScaling(double x, double y, double z) throw(NoSuchObjectError, AccessControlError, RemoteError);
00104 
00105         /** Get position of this 3D object.
00106             @param x X translation, relative to origin of parent object
00107             @param y Y translation, relative to origin of parent object
00108             @param z Z translation, relative to origin of parent object
00109             @throws NoSuchObjectError if "position" subobject does not exist, or is not a property.
00110         */
00111         virtual void getPosition(double& x, double& y, double& z) throw(NoSuchObjectError, AccessControlError, RemoteError);
00112 
00113         /** Get the orientation of this 3D object in axis-angle
00114             rotation. See setOrientation() for details.
00115 
00116             @note This can be easily converted into a quaternion with
00117             the following math:
00118             @code
00119             quat.r = cos(phi/2.0);
00120             quat.x = x * sin(phi/2.0);
00121             quat.y = y * sin(phi/2.0);
00122             quat.z = z * sin(phi/2.0);
00123             @endcode
00124             @param x X vector component
00125             @param y Y vector component
00126             @param z Z vector component
00127             @param phi the rotation about the vector axis, in degrees
00128             @throws NoSuchObjectError if "orientation" subobject does not exist, or is not a property.
00129         */
00130         virtual void getOrientation(double& x, double& y, double& z, double& phi)
00131             throw (NoSuchObjectError, AccessControlError, RemoteError);
00132 
00133         /** Convenience function to get the orientation of this 3D
00134             object as a quaternion, converting from A3DL's axis-angle
00135             representation.
00136             @param x X vector component
00137             @param y Y vector component
00138             @param z Z vector component
00139             @param phi the rotation about the vector axis, in degrees
00140             @throws NoSuchObjectError if "orientation" subobject does not exist, or is not a property.
00141         */
00142         virtual void getOrientationAsQuaternion(double& x, double& y, double& z, double& w)
00143             throw (NoSuchObjectError, AccessControlError, RemoteError);
00144 
00145 
00146         /** Get scaling factors of this 3D object.
00147             @param x X scaling
00148             @param y Y scaling
00149             @param z Z scaling
00150             @throws NoSuchObjectError if "scaling" subobject does not exist, or is not a property.
00151         */
00152         virtual void getScaling(double& x, double& y, double& z) throw(NoSuchObjectError, AccessControlError, RemoteError);
00153 
00154 
00155         /** Set the hard transform (HT) position of this 3D object.
00156             This transform is applied against the object before the
00157             normal position transform is applied and is not affected
00158             by hierarchical transforms.
00159             @param x X translation, relative to origin of parent object
00160             @param y Y translation, relative to origin of parent object
00161             @param z Z translation, relative to origin of parent object
00162             @throws NoSuchObjectError if "position" subobject does not exist, or is not a property.
00163         */
00164         virtual void setPositionHT(double x, double y, double z) throw(NoSuchObjectError, AccessControlError, RemoteError);
00165 
00166 
00167         /** Set the hard transform (HT) orientation of this 3D object
00168             in axis-angle rotation.  This transform is applied against
00169             the object before the normal orientation transform is applied
00170             and is not affected by hierarchical transforms.  The first
00171             three parameters are a unit vector in world space which
00172             define an axis, the fourth parameter is a clockwise
00173             rotation about that axis.  For example, [0 1 0 20] would
00174             specify a rotation of 20 degrees around a vector pointing
00175             straight up.
00176             @note You can convert a quaternion into angle-axis
00177             rotation with the following math:
00178             @code
00179             phi = 2.0 * acos(quat.r);
00180             x = quat.x / sin(phi/2.0);
00181             y = quat.y / sin(phi/2.0);
00182             z = quat.z / sin(phi/2.0);
00183             @endcode
00184             @param x X vector component
00185             @param y Y vector component
00186             @param z Z vector component
00187             @param phi the rotation about the vector axis, in degrees
00188             @throws NoSuchObjectError if "orientation" subobject does not exist, or is not a property.
00189         */
00190         virtual void setOrientationHT(double x, double y, double z, double phi)
00191             throw(NoSuchObjectError, AccessControlError, RemoteError);
00192 
00193         /** Convenience function to set the hard transform (HT)
00194             orientation of this 3D object using a quaternion, which is
00195             then converted to A3DL's axis-angle notation.  This
00196             transform is applied against the object before the normal
00197             orientation transform is applied and is not affected by
00198             hierarchical transforms.
00199 
00200             @param x X vector component
00201             @param y Y vector component
00202             @param z Z vector component
00203             @param phi the rotation about the vector axis, in degrees
00204             @throws NoSuchObjectError if "orientation" subobject does not exist, or is not a property.
00205         */
00206         virtual void setOrientationWithQuaternionHT(double x, double y, double z, double phi)
00207             throw(NoSuchObjectError, AccessControlError, RemoteError);
00208 
00209 
00210         /** Set the hard transform (HT) scaling this 3D object.  This
00211             transform is applied against the object before the normal
00212             scaling transform is applied and is not affected by
00213             hierarchical transforms.
00214             @param x X scaling
00215             @param y Y scaling
00216             @param z Z scaling
00217             @throws NoSuchObjectError if "scaling" subobject does not exist, or is not a property.
00218         */
00219         virtual void setScalingHT(double x, double y, double z) throw(NoSuchObjectError, AccessControlError, RemoteError);
00220 
00221         /** Get the hard transform (HT) position of this 3D object.
00222             This transform is applied against the object before the
00223             normal position transform is applied and is not affected by
00224             hierarchical transforms.
00225 
00226             @param x X translation, relative to origin of parent object
00227             @param y Y translation, relative to origin of parent object
00228             @param z Z translation, relative to origin of parent object
00229             @throws NoSuchObjectError if "position" subobject does not exist, or is not a property.
00230         */
00231         virtual void getPositionHT(double& x, double& y, double& z) throw(NoSuchObjectError, AccessControlError, RemoteError);
00232 
00233         /** Get the hard transform (HT) orientation of this 3D object in axis-angle
00234             rotation. See setOrientation() for details.  This
00235             transform is applied against the object before the normal
00236             orientation transform is applied and is not affected by
00237             hierarchical transforms.
00238 
00239             @note This can be easily converted into a quaternion with
00240             the following math:
00241             @code
00242             quat.r = cos(phi/2.0);
00243             quat.x = x * sin(phi/2.0);
00244             quat.y = y * sin(phi/2.0);
00245             quat.z = z * sin(phi/2.0);
00246             @endcode
00247             @param x X vector component
00248             @param y Y vector component
00249             @param z Z vector component
00250             @param phi the rotation about the vector axis, in degrees
00251             @throws NoSuchObjectError if "orientation" subobject does not exist, or is not a property.
00252         */
00253         virtual void getOrientationHT(double& x, double& y, double& z, double& phi)
00254             throw (NoSuchObjectError, AccessControlError, RemoteError);
00255 
00256         /** Convenience function to get the hard transform (HT)
00257             orientation of this 3D object as a quaternion, converting
00258             from A3DL's axis-angle representation.  This
00259             transform is applied against the object before the normal
00260             orientation transform is applied and is not affected by
00261             hierarchical transforms.
00262 
00263             @param x X vector component
00264             @param y Y vector component
00265             @param z Z vector component
00266             @param phi the rotation about the vector axis, in degrees
00267             @throws NoSuchObjectError if "orientation" subobject does not exist, or is not a property.
00268         */
00269         virtual void getOrientationAsQuaternionHT(double& x, double& y, double& z, double& w)
00270             throw (NoSuchObjectError, AccessControlError, RemoteError);
00271 
00272 
00273         /** Get the hard transform (HT) scaling of this 3D object.
00274             This transform is applied against the object before the
00275             normal scaling transform is applied and is not
00276             affected by hierarchical transforms.
00277             @param x X scaling
00278             @param y Y scaling
00279             @param z Z scaling
00280             @throws NoSuchObjectError if "scaling" subobject does not exist, or is not a property.
00281         */
00282         virtual void getScalingHT(double& x, double& y, double& z) throw(NoSuchObjectError, AccessControlError, RemoteError);
00283 
00284 
00285         /** Initialize this object to have no property access control, position
00286          * (0,0,0), orientation (0,1,0,0) and scaling(1,1,1).
00287          */
00288         virtual void initialize();
00289 
00290         virtual const string getType();
00291         static void registerExtenders();
00292         static MetaObject* new_Object3D(MetaObject* superobject, const string& type);
00293 
00294         /** Get material vobject. */
00295         virtual Material* getMaterial(bool createIfNone = true);
00296 
00297         /** Set material vobject */
00298         virtual void setMaterial(Material* obj);
00299 
00300         virtual vector<Material*> getMaterials();
00301 
00302         void setOrInsertChild(const string& name, Vobject* obj);
00303 
00304     public:
00305 
00306         /** Utility functions for getting/setting properties */
00307         //@{
00308         static void setThreeFloatProperty(Vobject& vob, const string& name, double x, double y, double z,
00309                                           PropertyAccessControl* ac);
00310         static void getThreeFloatProperty(Vobject& vob, const string& name, double* x, double* y, double* z);
00311         //@}
00312 
00313         /** Get position property object. */
00314         virtual Property* getPositionObj();
00315 
00316         /** Set position property object */
00317         virtual void setPositionObj(Property* obj);
00318         virtual Property* getOrientationObj();
00319         virtual void setOrientationObj(Property* obj);
00320         virtual Property* getScalingObj();
00321         virtual void setScalingObj(Property* obj);
00322 
00323     };
00324 }
00325 
00326 #endif

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