/* ********************************************************************* This source file is a part of the standard library of Scol For the latest info, see http://www.scolring.org Copyright (c) 2013 Stephane Bisaro aka Iri, based on a work of Bastien BOURINEAU (I-Maginer). This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt ********************************************************************* */ /* * 3D errors for basic 3d manipulations * See http://redmine.scolring.org/projects/tutorials/wiki/Scol_usage * for more informations */ /*! \file base3derror.pkg * \author Scol team * \version 0.1 * \copyright GNU Lesser General Public License 2.0 or later * \brief Scol 3D Library - 3D basic error. This package is a part of basic3d.pkg * **/ var iLIB3D_ERRORENABLED = 1;; var iLIB3D_LOGTEMPFILE = 0;; var iLIB3D_LOGHARDFILE = 1;; var Lib3d_errorLastRes = 0;; // last result from std_errNumber var Lib3d_errorLastNum = 0;; // last number given to std_errNumber var Lib3d_errorLastMsg = "";; // last message given by b3d_errprintS var iLIB3D_ERR_MASK_INFO = 1;; var iLIB3D_ERR_MASK_WARN = 2;; var iLIB3D_ERR_MASK_ERROR = 4;; var iLIB3D_ERR_MASK_DEBUG = 8;; var iLIB3D_ERR_MASK_OGRE3D = 0;; var iLIB3D_ERR_OK = 0;; var szLIB3D_ERR_OK = "Successfull";; var iLIB3D_ERR_INIT = 1;; var szLIB3D_ERR_INIT = "An error occurs during the initialization";; var iLIB3D_ERR_INIT_ERR = 2;; var szLIB3D_ERR_INIT_ERR = "An error occurs during the error initialization";; // buffer var iLIB3D_ERR_BUFFER = 10;; var szLIB3D_ERR_BUFFER = "Unable to create the buffer correctly";; var iLIB3D_ERR_BUFFER_NIL = 11;; var szLIB3D_ERR_BUFFER_NIL = "The buffer object is nil";; var iLIB3D_ERR_BUFFER_SET = 12;; var szLIB3D_ERR_BUFFER_SET = "Unable to set a parameter for the given buffer object";; // 2D var iLIB3D_ERR_WINDOW = 20;; var szLIB3D_ERR_WINDOW = "The window object has not been correctly created";; var iLIB3D_ERR_WINSIZE = 21;; var szLIB3D_ERR_WINSIZE = "The window object has an invalid size";; var iLIB3D_ERR_WINNIL = 22;; var szLIB3D_ERR_WINNIL = "The window object has an invalid size";; var iLIB3D_ERR_WINNOCHANGE = 23;; var szLIB3D_ERR_WINNOCHANGE = "No change applied to the 3d window";; // Session var iLIB3D_ERR_SESSION_CREATE = 30;;var szLIB3D_ERR_SESSION_CREATE = "The session object has not been correctly created";; var iLIB3D_ERR_SESSION_NIL = 31;; var szLIB3D_ERR_SESSION_NIL = "The given session object is nil";; // resources var iLIB3D_ERR_RSC_GRP_CREATE = 40;;var szLIB3D_ERR_RSC_GRP_CREATE = "Cannot create the asked resource group";; var iLIB3D_ERR_RSC_NOTFOUND = 41;; var szLIB3D_ERR_RSC_NOTFOUND = "A 3d resource is unavailable";; var iLIB3D_ERR_RSC_NOTLOADED = 42;; var szLIB3D_ERR_RSC_NOTLOADED = "A 3d resource can not be loaded";; // camera var iLIB3D_ERR_CAM_SH_CREATE = 50;; var szLIB3D_ERR_CAM_SH_CREATE = "The shell camera object has not been correctly created";; var iLIB3D_ERR_CAM_NODEFAULT = 51;; var szLIB3D_ERR_CAM_NODEFAULT = "No default camera is stored";; var iLIB3D_ERR_CAM_FIRSTFOUND = 52;;var szLIB3D_ERR_CAM_FIRSTFOUND = "Set to the first camera found";; var iLIB3D_ERR_CAM_NIL = 53;; var szLIB3D_ERR_CAM_NIL = "The given camera is nil";; var iLIB3D_ERR_CAM_SET = 54;; var szLIB3D_ERR_CAM_SET = "Unable to perform this camera operation";; var iLIB3D_ERR_CAM_NOTORTHO = 55;; var szLIB3D_ERR_CAM_NOTORTHO = "The camera mode is not ORTHOGRAPHIC";; // 3d object var iLIB3D_ERR_OBJ_NIL = 100;; var szLIB3D_ERR_OBJ_NIL = "The given 3d object is nil";; var iLIB3D_ERR_OBJ_POS = 101;; var szLIB3D_ERR_OBJ_POS = "Unable to set the pos of an 3d object";; var iLIB3D_ERR_OBJ_ROT = 102;; var szLIB3D_ERR_OBJ_ROT = "Unable to set the rotate of an 3d object";; var iLIB3D_ERR_OBJ_LINK = 103;; var szLIB3D_ERR_OBJ_LINK = "Unable to link an 3d object";; var iLIB3D_ERR_OBJ_UKWN = 104;; var szLIB3D_ERR_OBJ_UKWN = "The 3d object is not found";; var iLIB3D_ERR_OBJ_ORIENT = 105;; var szLIB3D_ERR_OBJ_ORIENT = "Unable to set the new orientation";; var iLIB3D_ERR_OBJ_DESTROY = 106;; var szLIB3D_ERR_OBJ_DESTROY = "Unable to destroy the 3d object";; // 3d light var iLIB3D_ERR_LIGHT_SET = 200;; var szLIB3D_ERR_LIGHT_SET = "Unable to perform a light operation";; var iLIB3D_ERR_LIGHT_CR = 201;; var szLIB3D_ERR_LIGHT_CR = "Unable to create a new light";; var iLIB3D_ERR_LIGHT_NIL = 202;; var szLIB3D_ERR_LIGHT_NIL = "The given 3d light is nil";; // misc var iLIB3D_MISC_ARG_NIL = 1000;; var szLIB3D_MISC_ARG_NIL = "A given argument is nil";; var iLIB3D_MISC_LOG_OGRE = 1001;; var szLIB3D_MISC_LOG_OGRE = "Ogre error message can not be sent in this error manager.";; var iLIB3D_MISC_ARG_BAD = 1002;; var szLIB3D_MISC_ARG_BAD = "A provided argument is bad or incorrect.";; var iLIB3D_OBJ_ALREADY_DESTROYED = 1003;; var szLIB3D_OBJ_ALREADY_DESTROYED = "The given object is already destroyed or not created yet.";; // physics var iLIB3D_ERR_PHYSICS_NIL = 1100;; var szLIB3D_ERR_PHYSICS_NIL = "The given physics object is nil";; // 3d view var iLIB3D_ERR_3DVIEW_NIL = 1200;; var szLIB3D_ERR_3DVIEW_NIL = "The given 3D View object is nil";; // 3d viewport var iLIB3D_ERR_3DVIEWPORT_NIL = 1300;; var szLIB3D_ERR_3DVIEWPORT_NIL = "The given 3D Viewport object is nil";; var iLIB3D_ERR_3DVIEWPORT_SET = 1301;; var szLIB3D_ERR_3DVIEWPORT_SET = "Unable to modify a parameter to the given Viewport object.";; typeof Lib3d_error = STD_ERROR;; proto b3d_errorCBogre = fun [S STD_ERROR] I;; proto b3d_errprint = fun [I I] I;; fun b3d_initerrormsg (err)= std_errAddType err iLIB3D_ERR_OK szLIB3D_ERR_OK; std_errAddType err iLIB3D_ERR_INIT szLIB3D_ERR_INIT; std_errAddType err iLIB3D_ERR_INIT_ERR szLIB3D_ERR_INIT_ERR; std_errAddType err iLIB3D_ERR_BUFFER szLIB3D_ERR_BUFFER; std_errAddType err iLIB3D_ERR_WINDOW szLIB3D_ERR_WINDOW; std_errAddType err iLIB3D_ERR_SESSION_CREATE szLIB3D_ERR_SESSION_CREATE; std_errAddType err iLIB3D_ERR_RSC_GRP_CREATE szLIB3D_ERR_RSC_GRP_CREATE; std_errAddType err iLIB3D_ERR_CAM_SH_CREATE szLIB3D_ERR_CAM_SH_CREATE; std_errAddType err iLIB3D_ERR_OBJ_NIL szLIB3D_ERR_OBJ_NIL; std_errAddType err iLIB3D_ERR_OBJ_POS szLIB3D_ERR_OBJ_POS; std_errAddType err iLIB3D_ERR_OBJ_LINK szLIB3D_ERR_OBJ_LINK; std_errAddType err iLIB3D_ERR_SESSION_NIL szLIB3D_ERR_SESSION_NIL; std_errAddType err iLIB3D_ERR_LIGHT_SET szLIB3D_ERR_LIGHT_SET; std_errAddType err iLIB3D_ERR_OBJ_UKWN szLIB3D_ERR_OBJ_UKWN; std_errAddType err iLIB3D_MISC_ARG_NIL szLIB3D_MISC_ARG_NIL; std_errAddType err iLIB3D_ERR_RSC_NOTFOUND szLIB3D_ERR_RSC_NOTFOUND; std_errAddType err iLIB3D_ERR_RSC_NOTLOADED szLIB3D_ERR_RSC_NOTLOADED; std_errAddType err iLIB3D_MISC_LOG_OGRE szLIB3D_MISC_LOG_OGRE; std_errAddType err iLIB3D_ERR_PHYSICS_NIL szLIB3D_ERR_PHYSICS_NIL; std_errAddType err iLIB3D_ERR_WINSIZE szLIB3D_ERR_WINSIZE; std_errAddType err iLIB3D_ERR_3DVIEW_NIL szLIB3D_ERR_3DVIEW_NIL; std_errAddType err iLIB3D_ERR_BUFFER_NIL szLIB3D_ERR_BUFFER_NIL; std_errAddType err iLIB3D_ERR_BUFFER_SET szLIB3D_ERR_BUFFER_SET; std_errAddType err iLIB3D_ERR_WINNIL szLIB3D_ERR_WINNIL; std_errAddType err iLIB3D_ERR_3DVIEWPORT_NIL szLIB3D_ERR_3DVIEWPORT_NIL; std_errAddType err iLIB3D_MISC_ARG_BAD szLIB3D_MISC_ARG_BAD; std_errAddType err iLIB3D_ERR_3DVIEWPORT_SET szLIB3D_ERR_3DVIEWPORT_SET; std_errAddType err iLIB3D_OBJ_ALREADY_DESTROYED szLIB3D_OBJ_ALREADY_DESTROYED; std_errAddType err iLIB3D_ERR_OBJ_ORIENT szLIB3D_ERR_OBJ_ORIENT; std_errAddType err iLIB3D_ERR_CAM_NODEFAULT szLIB3D_ERR_CAM_NODEFAULT; std_errAddType err iLIB3D_ERR_CAM_FIRSTFOUND szLIB3D_ERR_CAM_FIRSTFOUND; std_errAddType err iLIB3D_ERR_CAM_NIL szLIB3D_ERR_CAM_NIL; std_errAddType err iLIB3D_ERR_CAM_SET szLIB3D_ERR_CAM_SET; std_errAddType err iLIB3D_ERR_CAM_NOTORTHO szLIB3D_ERR_CAM_NOTORTHO; std_errAddType err iLIB3D_ERR_LIGHT_CR szLIB3D_ERR_LIGHT_CR; std_errAddType err iLIB3D_ERR_LIGHT_NIL szLIB3D_ERR_LIGHT_NIL; std_errAddType err iLIB3D_ERR_OBJ_DESTROY szLIB3D_ERR_OBJ_DESTROY; std_errAddType err iLIB3D_ERR_WINNOCHANGE szLIB3D_ERR_WINNOCHANGE; 0;; fun b3d_errprint (number, mask)= set Lib3d_errorLastNum = number; set Lib3d_errorLastRes = std_errNumber Lib3d_error Lib3d_errorLastNum mask;; fun b3d_errprintS (msg, mask)= set Lib3d_errorLastMsg = msg; set Lib3d_errorLastRes = std_errString Lib3d_error Lib3d_errorLastMsg mask;; fun b3d_errorCBogre (szOgre, p)= b3d_errprintS szOgre 0; 0;; /*! \brief Set the OGRE3D mask error. * * \ingroup b3d_error * Prototype: fun [I] I * * \param I : the mask, one of these values : * - 0 (default) * - SO3_LL_LOW * - SO3_LL_NORMAL * - SO3_LL_BOREME * \return I : 0 if success, 1 if error. * \remark This function should be used after 'b3d_initError', if any **/ fun b3d_errSetMaskOgre3D (mask)= set iLIB3D_ERR_MASK_OGRE3D = std_clampT mask [0 SO3_LL_LOW SO3_LL_NORMAL SO3_LL_BOREME] 0; if SO3CbLogs _channel @b3d_errorCBogre Lib3d_error iLIB3D_ERR_MASK_OGRE3D then 0 else ( b3d_errprint iLIB3D_MISC_LOG_OGRE iLIB3D_ERR_MASK_ERROR; 1 );; /*! \brief Get the OGRE3D mask error * * \ingroup b3d_error * Prototype: fun [] I * * \return I : this mask value. **/ fun b3d_errGetMaskOgre3D ()= iLIB3D_ERR_MASK_OGRE3D;; /*! \brief Get the "EMPTY" mask error * * \ingroup b3d_error * Prototype: fun [] I * * \return I : this mask value. **/ fun b3d_errGetMaskNo ()= 0;; /*! \brief Get the "INFO" mask error * * \ingroup b3d_error * Prototype: fun [] I * * \return I : this mask value. **/ fun b3d_errGetMaskInfo ()= iLIB3D_ERR_MASK_INFO;; /*! \brief Get the "WARNING" mask error * * \ingroup b3d_error * Prototype: fun [] I * * \return I : this mask value. **/ fun b3d_errGetMaskWarn ()= iLIB3D_ERR_MASK_WARN;; /*! \brief Get the "ERROR" mask error * * \ingroup b3d_error * Prototype: fun [] I * * \return I : this mask value. **/ fun b3d_errGetMaskError ()= iLIB3D_ERR_MASK_ERROR;; /*! \brief Get the "DEBUG" mask error * * \ingroup b3d_error * Prototype: fun [] I * * \return I : this mask value. **/ fun b3d_errGetMaskDebug ()= iLIB3D_ERR_MASK_DEBUG;; /*! \brief Get the last internal number error received by this library * * \ingroup b3d_error * Prototype: fun [] I * * \return I : this last error. **/ fun b3d_errGetLastNum ()= Lib3d_errorLastNum;; /*! \brief Get the last internal number error received by this library * * \ingroup b3d_error * Prototype: fun [] S * * \return S : this last error message (only if an explicite error message has been provided, * b3d_errGetLastNum should be a better choice). * \see b3d_errGetLastNum **/ fun b3d_errGetLastMsg ()= Lib3d_errorLastMsg;; /*! \brief Get the last internal error returned by the error library * * \ingroup b3d_error * Prototype: fun [] I * * \return I : this last error. **/ fun b3d_erGetLastRes ()= Lib3d_errorLastRes;; /*! \brief Get the error manager. The std::error API can be used with it. * * \ingroup b3d_error * Prototype: fun [] STD_ERROR * * \return STD_ERROR : this error manager. **/ fun b3d_errManager ()= Lib3d_error;;