arosg
IntroductionC-interface to OpenSceneGraph for augmented reality applications. Discussionarosg is intended to provide access to the modern plugin-based scene graph OpenSceneGraph, and its attendant model formats and graphical capabilities. arosg provides a C-based interface to a limited subset of the functionality of OpenSceneGraph. As of version 1.0 of arosg, the supported functionality is primarily 3D model loading and drawing.
Functions
arOSGDrawProcess scenegraph-related events, including drawing all visible models. AR_DLL_API int arOSGDraw( AROSG *arOsg); ParametersReturn Value0, or in case of error, a value less than 0. DiscussionThis function leaves the values of the OpenGL machine in an indeterminate state, including clobbering the OpenGL viewport, projection and modelview matrices. The user should save any sensitive state prior to calling this function, and restore that state upon return. arOSGFinalDispose of an AROSG settings structure. AR_DLL_API void arOSGFinal( AROSG *arOsg); ParametersDiscussionIf you have finished with an AROSG settings structure in your running program, you can unload its internal data by calling arOSGFinal. arOSGGetFrontFaceGet the polygon winding for front-facing polygons. AR_DLL_API int arOSGGetFrontFace( AROSG *arOsg, int *winding); ParametersReturn Value0, or in case of error, a value less than 0. Discussion-
arOSGGetModelAnimationTimeFor a model with animation, discover the animation time. AR_DLL_API int arOSGGetModelAnimationTime( AROSG *arOsg, const int index, double *animationTime); Parameters
Return Value0, or in case of error, a value less than 0. DiscussionYou may query the animation time of models with animations.
arOSGGetModelIntersectionDetermine if a model is intersected by a line segment. AR_DLL_API int arOSGGetModelIntersection( AROSG *arOsg, const int index, const ARdouble p1[3], const ARdouble p2[3]); Parameters
Return Value1 if an intersection was found, 0 if no intersection was found, or in case of error, a value less than 0. DiscussionThis calculates the intersection between a line segment (defined by two points in world coordinates) and a model (actually an OSG node and subnodes). If an intersection is found, different data types can be returned by providing pointers in parameters nodeType, nodeName, and intersectionCoords.
arOSGGetModelLightingFind out if lighting for model is on or off. AR_DLL_API int arOSGGetModelLighting( AROSG *arOsg, const int index, int *lit); ParametersReturn Value0, or in case of error, a value less than 0. DiscussionBy default, lighting is enabled for models.
arOSGGetModelLocalPoseGet the local pose (position and orientation) of an OSG-based model. AR_DLL_API int arOSGGetModelLocalPose( AROSG *arOsg, const int index, ARdouble *model); ParametersReturn Value0, or in case of error, a value less than 0. Discussion-
arOSGGetModelPoseGet the pose (position and orientation) of an OSG-based model. AR_DLL_API int arOSGGetModelPose( AROSG *arOsg, const int index, ARdouble *modelview); ParametersReturn Value0, or in case of error, a value less than 0. Discussion-
arOSGGetModelVisibilityFind out if an OSG-based model is shown or hidden. AR_DLL_API int arOSGGetModelVisibility( AROSG *arOsg, const int index, int *visible); ParametersReturn Value0, or in case of error, a value less than 0. DiscussionModels are visible by default.
arOSGGetProjectionGet the projection matrix used in OSG drawing. AR_DLL_API int arOSGGetProjection( AROSG *arOsg, ARdouble *p); ParametersReturn Value0, or in case of error, a value less than 0. Discussion-
arOSGGetVersionGet the version of ARToolKit with which the arOSG library was built. AR_DLL_API unsigned int arOSGGetVersion(); Return ValueReturns the full version number of the ARToolKit version corresponding to this OSG library, in binary coded decimal (BCD) format. BCD format allows simple tests of version number in the caller e.g. if ((arGetVersion() >> 16) > 0x0272) printf("This release is later than 2.72\n"); The major version number is encoded in the most-significant byte (bits 31-24), the minor version number in the second-most-significant byte (bits 23-16), the tiny version number in the third-most-significant byte (bits 15-8), and the build version number in the least-significant byte (bits 7-0). DiscussionIt is highly recommended that any calling program that depends on features in a certain ARToolKit version, check at runtime that it is linked to a version of ARToolKit that can supply those features. It is NOT sufficient to check the ARToolKit SDK header versions, since with ARToolKit implemented in dynamically-loaded libraries, there is no guarantee that the version of ARToolKit installed on the machine at run-time will be as recent as the version of the ARToolKit SDK which the host program was compiled against.
arOSGHandleKeyboardPass key press events to OpenSceneGraph. AR_DLL_API void arOSGHandleKeyboard( AROSG *arOsg, int key, int x, int y); Parameters
Discussion- arOSGHandleMouseDownUpPass mouse clicks to OpenSceneGraph. AR_DLL_API void arOSGHandleMouseDownUp( AROSG *arOsg, const int button, const int state, const int x, const int y); Parameters
Discussion- arOSGHandleMouseMovePass mouse motion events to OpenSceneGraph AR_DLL_API void arOSGHandleMouseMove( AROSG *arOsg, int x, int y); ParametersDiscussion- arOSGHandleReshapeInform OpenSceneGraph that a window reshape has occured (i.e. changes to window size have occured). AR_DLL_API void arOSGHandleReshape( AROSG *arOsg, const int w, const int h); ParametersDiscussionThis function should be called when the window is first created, and then whenever the operating system generates a notification that the user has changed the window size. arOSGHandleReshape2Inform OpenSceneGraph that a window reshape has occured (i.e. changes to window size have occured). AR_DLL_API void arOSGHandleReshape2( AROSG *arOsg, const int left, const int bottom, const int width, const int height); ParametersDiscussionThis function should be called when the window is first created, and then whenever the operating system generates a notification that the user has changed the window size. arOSGInitCreate a settings structure for use with all other arOSG functions. AR_DLL_API AROSG *arOSGInit(); Return ValuePointer to the new AROSG settings structure. DiscussionAll other arOSG functions require a reference to settings and global data. Use this function to create and initialise such a structure. arOSGLoadModelLoad an OSG model using a "model description file". AR_DLL_API int arOSGLoadModel( AROSG *arOsg, const char *modelDescriptionFilePath); Parameters
Return ValueAn index value with which the loaded model can be referred to, in the range [0, AR_OSG_MODELS_MAX - 1], or, in case of error, a value less than 0. Discussion- The format of this file is a simple text file. Comments may be included by prefixing the line with a "#" character. The object definition consists of the following:
arOSGLoadModel2Load an OSG model. AR_DLL_API int arOSGLoadModel2( AROSG *arOsg, const char *modelFilePath, const ARdouble translation[3], const ARdouble rotation[4], const ARdouble scale[3]); Parameters
Return ValueAn index value with which the loaded model can be referred to, in the range [0, AR_OSG_MODELS_MAX - 1], or, in case of error, a value less than 0. Discussion-
arOSGSetDrawTimeProcess scenegraph-related events, including drawing all visible models. AR_DLL_API int arOSGSetDrawTime( AROSG *arOsg, double time); ParametersReturn Value0, or in case of error, a value less than 0. DiscussionOSG maintains its own internal reference time for animation and simulation rendering. If you wish to render at particular time instants or at non-unit timescales, you can manipulate the timeline for following arOSGDraw calls by calling this function with the time (in decimal seconds) supplied in the parameter. To revert to OSG's internal reference time, pass the value AR_OSG_TIME_USE_REFERENCE_TIME. See Also arOSGSetFrontFaceSet the polygon winding for front-facing polygons. AR_DLL_API int arOSGSetFrontFace( AROSG *arOsg, int winding); ParametersReturn Value0, or in case of error, a value less than 0. Discussion-
arOSGSetModelAnimationLoopModeOverrideFor a model with animation, override the animation loop mode. AR_DLL_API int arOSGSetModelAnimationLoopModeOverride( AROSG *arOsg, const int index, const int mode); Parameters
Return Value0, or in case of error, a value less than 0. DiscussionModels with animations have a default mode set at time of creation. To override the mode at runtime, use this function.
arOSGSetModelAnimationPauseFor a model with animation, pause or resume the animation. AR_DLL_API int arOSGSetModelAnimationPause( AROSG *arOsg, const int index, const int pause); ParametersReturn Value0, or in case of error, a value less than 0. DiscussionModels with animations may have the animation paused and later resumed.
arOSGSetModelAnimationResetFor a model with animation, reset the animation. AR_DLL_API int arOSGSetModelAnimationReset( AROSG *arOsg, const int index); ParametersReturn Value0, or in case of error, a value less than 0. DiscussionModels with animations may have the animation reset to the initial state.
arOSGSetModelLightingSet lighting for a model on or off. AR_DLL_API int arOSGSetModelLighting( AROSG *arOsg, const int index, const int lit); ParametersReturn Value0, or in case of error, a value less than 0. DiscussionBy default, lighting is enabled for models.
arOSGSetModelLocalPoseSet the local pose (position and orientation) of an OSG-based model. AR_DLL_API int arOSGSetModelLocalPose( AROSG *arOsg, const int index, const ARdouble model[16]); ParametersReturn Value0, or in case of error, a value less than 0. Discussion-
arOSGSetModelOutlineTurn on or off 2D outlining of a model's boundary. AR_DLL_API int arOSGSetModelOutline( AROSG *arOsg, const int index, const int width, const unsigned char rgba[4]); Parameters
Return Value0, or in case of error, a value less than 0. DiscussionOutlining allows a model to be highlighted by drawing a 2D outline of the models extreme boundary. Outlining is not currently supported by OSG on platforms using OpenGL ES, and calling this function will produce erroneous visual results if used on an OpenGL ES platform.
arOSGSetModelPoseSet the pose (position and orientation) of an OSG-based model. AR_DLL_API int arOSGSetModelPose( AROSG *arOsg, const int index, const ARdouble modelview[16]); ParametersReturn Value0, or in case of error, a value less than 0. Discussion- arOSGSetModelTransparencySet transparency for a model on or off. AR_DLL_API int arOSGSetModelTransparency( AROSG *arOsg, const int index, const int transparent); ParametersReturn Value0, or in case of error, a value less than 0. DiscussionBy default, transparency for models depends on the state with which the model was created. However, this setting allows overriding of the transparency settings. One example usage would be to force an image texture containing an alpha channel to draw with transparency, or alternately without.
arOSGSetModelVisibilityShow or hide an OSG-based model. AR_DLL_API int arOSGSetModelVisibility( AROSG *arOsg, const int index, const int visible); ParametersReturn Value0, or in case of error, a value less than 0. DiscussionModels are visible by default. arOSGSetProjectionSet the projection matrix used in OSG drawing. AR_DLL_API int arOSGSetProjection( AROSG *arOsg, ARdouble p[16]); ParametersReturn Value0, or in case of error, a value less than 0. Discussion- arOSGUnloadModelUnload an OSG model. AR_DLL_API int arOSGUnloadModel( AROSG *arOsg, const int index); ParametersReturn Value0, or in case of error, a value less than 0. DiscussionFrees the memory associated with an OSG model. Constants
AR_OSG_TIME_USE_REFERENCE_TIMEVariable to supply to arOSGSetDrawTime to direct OpenSceneGraph to use its internal reference time. extern const double AR_OSG_TIME_USE_REFERENCE_TIME; DiscussionOSG maintains its own internal reference time for animation and simulation rendering. If you wish to render using OSG's reference time, supply this value to arOSGSetDrawTime. See Also |