Update of /cvsroot/artoolkit/artoolkit/examples/simpleVRML
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12261
Added Files:
Makefile.in object.h object.c simpleVRML.c simpleVRML.vcproj
Log Message:
Add simpleVRML example.
--- NEW FILE: simpleVRML.vcproj ---
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="simpleVRML"
ProjectGUID="{7B5EFC13-7883-82CC-7D72-732240F68F29}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="$(ProjectDir)/../../include;$(ProjectDir)/../../OpenVRML/include;$(ProjectDir)/../../OpenVRML/dependencies/include;$(NOINHERIT)"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;OPENVRML_ENABLE_IMAGETEXTURE_NODE;OPENVRML_ENABLE_GZIP"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
BufferSecurityCheck="FALSE"
EnableFunctionLevelLinking="FALSE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE"
WarningLevel="3"
DebugInformationFormat="3"
CompileAs="2"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib opengl32.lib glu32.lib glut32.lib libjpeg.lib libpng.lib zlib.lib libarvrmld.lib openvrml.lib openvrml-gl.lib antlr.lib regex.lib libARvideod.lib libARd.lib libARgsub_lited.lib"
OutputFile="$(ProjectDir)/../../bin/$(ProjectName)d.exe"
AdditionalLibraryDirectories="$(ProjectDir)/../../lib;$(ProjectDir)/../../OpenVRML/lib;$(ProjectDir)/../../OpenVRML/dependencies/lib"
IgnoreDefaultLibraryNames="libc.lib;libcd.lib;libcmt.lib;libcmtd.lib;msvcrt.lib"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="$(ProjectDir)/../../include;$(ProjectDir)/../../OpenVRML/include;$(ProjectDir)/../../OpenVRML/dependencies/include;$(NOINHERIT)"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib opengl32.lib glu32.lib glut32.lib libjpeg.lib libpng.lib zlib.lib libARvrml.lib openvrml.lib openvrml-gl.lib antlr.lib regex.lib libARvideo.lib libAR.lib libARgsub_lite.lib"
OutputFile="$(ProjectDir)/../../bin/$(ProjectName).exe"
LinkIncremental="1"
AdditionalLibraryDirectories="$(ProjectDir)/../../lib;$(ProjectDir)/../../OpenVRML/lib;$(ProjectDir)/../../OpenVRML/dependencies/lib"
IgnoreDefaultLibraryNames="libc.lib;libcd.lib;libcmtd.lib,libcmt.lib;msvcrtd.lib"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\object.c">
</File>
<File
RelativePath=".\simpleVRML.c">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\object.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
--- NEW FILE: simpleVRML.c ---
/*
* simpleVRML.c
*
* Demonstration of ARToolKit with models rendered in VRML.
*
* Press '?' while running for help on available key commands.
*
* Copyright (c) 2002 Mark Billinghurst (MB) gr...@hi...
* Copyright (c) 2004 Raphael Grasset (RG) rap...@hi....
* Copyright (c) 2004 Philip Lamb (PRL) ph...@ed....
*
* Rev Date Who Changes
* 1.0.0 ????-??-?? MB Original from ARToolKit
* 1.0.1 2004-10-29 RG Fix for ARToolKit 2.69.
* 1.0.2 2004-11-30 PRL Various fixes.
*
*/
/*
*
* This file is part of ARToolKit.
*
* ARToolKit is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* ARToolKit 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ARToolKit; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
// ============================================================================
// Includes
// ============================================================================
#ifdef _WIN32
# include <windows.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef __APPLE__
# include <GLUT/glut.h>
#else
# include <GL/glut.h>
#endif
#include <AR/config.h>
#include <AR/video.h>
#include <AR/param.h> // arParamDisp()
#include <AR/ar.h>
#include <AR/gsub_lite.h>
#include <AR/arvrml.h>
#include "object.h"
// ============================================================================
// Constants
// ============================================================================
#define VIEW_SCALEFACTOR 0.025 // 1.0 ARToolKit unit becomes 0.025 of my OpenGL units.
#define VIEW_SCALEFACTOR_1 1.0 // 1.0 ARToolKit unit becomes 1.0 of my OpenGL units.
#define VIEW_SCALEFACTOR_4 4.0 // 1.0 ARToolKit unit becomes 4.0 of my OpenGL units.
#define VIEW_DISTANCE_MIN 4.0 // Objects closer to the camera than this will not be displayed.
#define VIEW_DISTANCE_MAX 4000.0 // Objects further away from the camera than this will not be displayed.
// ============================================================================
// Global variables
// ============================================================================
// Preferences.
static BOOL prefWindowed = FALSE;
static int prefWidth = 640; // Fullscreen mode width.
static int prefHeight = 480; // Fullscreen mode height.
//static int prefDepth = 32; // Fullscreen mode bit depth.
//static int prefRefresh = 60; // Fullscreen mode refresh rate.
// ARToolKit globals.
static long gCallCountMarkerDetect = 0;
static int gARTThreshhold = 100;
static ARParam gARTCparam;
static ARUint8 *gARTImage = NULL;
static BOOL gPatt_found;
static ARGL_CONTEXT_SETTINGS_REF gArglSettings = NULL;
// Object Data.
static char *gObjectDataFilename = "Data/object_data_vrml";
static ObjectData_T *gObjectData;
static int gObjectDataCount;
// ============================================================================
// Functions
// ============================================================================
// Sets up gARTCparam.
static BOOL demoARSetupCamera(const char *cparam_name, char *vconf)
{
ARParam wparam;
int xsize, ysize;
// Open the video path.
if (arVideoOpen(vconf) < 0) {
fprintf(stderr, "demoARSetupCamera(): Unable to open connection to camera.\n");
return (FALSE);
}
// Find the size of the window.
if (arVideoInqSize(&xsize, &ysize) < 0) return (FALSE);
fprintf(stderr, "demoARSetupCamera(): Camera image size (x,y) = (%d,%d)\n", xsize, ysize);
// Load the camera parameters, resize for the window and init.
if (arParamLoad(cparam_name, 1, &wparam) < 0) {
fprintf(stderr, "demoARSetupCamera(): Error loading parameter file %s for camera.\n", cparam_name);
return (FALSE);
}
arParamChangeSize(&wparam, xsize, ysize, &gARTCparam);
arInitCparam(&gARTCparam);
fprintf(stderr, "*** Camera Parameter ***\n");
arParamDisp(&gARTCparam);
if (arVideoCapStart() != 0) {
fprintf(stderr, "demoARSetupCamera(): Unable to begin camera data capture.\n");
return (FALSE);
}
return (TRUE);
}
static BOOL demoARSetupMarkersObjects(void)
{
// Load in the object data - trained markers and associated bitmap files.
if ((gObjectData = read_VRMLdata(gObjectDataFilename, &gObjectDataCount)) == NULL) exit(0);
printf("Object count = %d\n", gObjectDataCount);
return (TRUE);
}
// Report state of ARToolKit global variables arFittingMode,
// arImageProcMode, arglDrawMode, arTemplateMatchingMode, arMatchingPCAMode.
static void demoARDebugReportMode(void)
{
if(arFittingMode == AR_FITTING_TO_INPUT ) {
fprintf(stderr, "FittingMode (Z): INPUT IMAGE\n");
} else {
fprintf(stderr, "FittingMode (Z): COMPENSATED IMAGE\n");
}
if( arImageProcMode == AR_IMAGE_PROC_IN_FULL ) {
fprintf(stderr, "ProcMode (X) : FULL IMAGE\n");
} else {
fprintf(stderr, "ProcMode (X) : HALF IMAGE\n");
}
if( arglDrawMode == AR_DRAW_BY_GL_DRAW_PIXELS ) {
fprintf(stderr, "DrawMode (C) : GL_DRAW_PIXELS\n");
} else if( arglTexmapMode == AR_DRAW_TEXTURE_FULL_IMAGE ) {
fprintf(stderr, "DrawMode (C) : TEXTURE MAPPING (FULL RESOLUTION)\n");
} else {
fprintf(stderr, "DrawMode (C) : TEXTURE MAPPING (HALF RESOLUTION)\n");
}
if( arTemplateMatchingMode == AR_TEMPLATE_MATCHING_COLOR ) {
fprintf(stderr, "TemplateMatchingMode (M) : Color Template\n");
} else {
fprintf(stderr, "TemplateMatchingMode (M) : BW Template\n");
}
if( arMatchingPCAMode == AR_MATCHING_WITHOUT_PCA ) {
fprintf(stderr, "MatchingPCAMode (P) : Without PCA\n");
} else {
fprintf(stderr, "MatchingPCAMode (P) : With PCA\n");
}
}
static void Quit(void)
{
arglCleanup(gArglSettings);
arVideoCapStop();
arVideoClose();
#ifdef _WIN32
CoUninitialize();
#endif
exit(0);
}
static void Keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 0x1B: // Quit.
case 'Q':
case 'q':
Quit();
break;
case 'C':
case 'c':
if( arglDrawMode == AR_DRAW_BY_GL_DRAW_PIXELS ) {
arglDrawMode = AR_DRAW_BY_TEXTURE_MAPPING;
arglTexmapMode = AR_DRAW_TEXTURE_FULL_IMAGE;
} else if( arglTexmapMode == AR_DRAW_TEXTURE_FULL_IMAGE ) {
arglTexmapMode = AR_DRAW_TEXTURE_HALF_IMAGE;
} else {
arglDrawMode = AR_DRAW_BY_GL_DRAW_PIXELS;
}
fprintf(stderr, "*** Camera - %f (frame/sec)\n", (double)gCallCountMarkerDetect/arUtilTimer());
gCallCountMarkerDetect = 0;
arUtilTimerReset();
demoARDebugReportMode();
break;
break;
#ifdef AR_OPENGL_TEXTURE_RECTANGLE
case 'R':
case 'r':
arglTexRectangle = !arglTexRectangle;
fprintf(stderr, "Toggled arglTexRectangle to %d.\n", arglTexRectangle);
break;
#endif // AR_OPENGL_TEXTURE_RECTANGLE
case '?':
case '/':
printf("Keys:\n");
printf(" q or [esc] Quit demo.\n");
printf(" c Change arglDrawMode and arglTexmapMode.\n");
#ifdef AR_OPENGL_TEXTURE_RECTANGLE
printf(" r Toggle arglTexRectangle.\n");
#endif // AR_OPENGL_TEXTURE_RECTANGLE
printf(" ? or / Show this help.\n");
printf("\nAdditionally, the ARVideo library supplied the following help text:\n");
arVideoDispOption();
break;
default:
break;
}
}
static void Idle(void)
{
static int ms_prev;
int ms;
float s_elapsed;
ARUint8 *image;
ARMarkerInfo *marker_info; // Pointer to array holding the details of detected markers.
int marker_num; // Count of number of markers detected.
int i, j, k;
// Find out how long since Idle() last ran.
ms = glutGet(GLUT_ELAPSED_TIME);
s_elapsed = (float)(ms - ms_prev) * 0.001;
if (s_elapsed < 0.01f) return; // Don't update more often than 100 Hz.
ms_prev = ms;
// Update drawing.
arVrmlTimerUpdate();
// Grab a video frame.
if ((image = arVideoGetImage()) != NULL) {
gARTImage = image;
gCallCountMarkerDetect++; // Increment ARToolKit FPS counter.
// Detect the markers in the video frame.
if (arDetectMarker(gARTImage, gARTThreshhold, &marker_info, &marker_num) < 0) {
exit(-1);
}
// Check for object visibility.
gPatt_found = FALSE; // At this stage, no patterns found.
for (i = 0; i < gObjectDataCount; i++) {
gObjectData[i].visible = 0;
// Check through the marker_info array for highest confidence
// visible marker matching our object's pattern.
k = -1;
for (j = 0; j < marker_num; j++) {
if (marker_info[j].id == gObjectData[i].id) {
if( k == -1 ) k = j; // First marker detected.
else if (marker_info[k].cf < marker_info[j].cf) k = j; // Higher confidence marker detected.
}
}
if (k != -1) {
// Get the transformation between the marker and the real camera.
//fprintf(stderr, "Saw object %d.\n", i);
if (gObjectData[i].visible == 0) {
arGetTransMat(&marker_info[k],
gObjectData[i].marker_center, gObjectData[i].marker_width,
gObjectData[i].trans);
} else {
arGetTransMatCont(&marker_info[k], gObjectData[i].trans,
gObjectData[i].marker_center, gObjectData[i].marker_width,
gObjectData[i].trans);
}
gObjectData[i].visible = 1;
gPatt_found = TRUE;
}
}
}
// Tell GLUT to update the display.
glutPostRedisplay();
}
//
// The function is called on events when the visibility of the
// GLUT window changes (including when it first becomes visible).
//
static void Visibility(int visible)
{
if (visible == GLUT_VISIBLE) {
glutIdleFunc(Idle);
} else {
glutIdleFunc(NULL);
}
}
//
// The function is called when the
// GLUT window is resized.
//
static void Reshape(int w, int h)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// Call through to anyone else who needs to know about window sizing here.
}
//
// The function is called when the window needs redrawing.
//
static void Display(void)
{
int i;
static GLdouble *p = NULL;
GLdouble m[16];
// Context setup.
glDrawBuffer(GL_BACK);
arglDispImage(gARTImage, &gARTCparam, 1.0, gArglSettings); // zoom = 1.0.
arVideoCapNext();
if (gPatt_found) {
glClear(GL_DEPTH_BUFFER_BIT); // Clear the buffers for new frame.
// Projection transformation.
if (p == NULL) {
p = (GLdouble *)malloc(16 * (sizeof(GLdouble)));
arglCameraFrustum(&gARTCparam, VIEW_DISTANCE_MIN, VIEW_DISTANCE_MAX, p);
}
glMatrixMode(GL_PROJECTION);
glLoadMatrixd(p);
glMatrixMode(GL_MODELVIEW);
// Viewing transformation.
glLoadIdentity();
// Lighting and geometry that moves with the camera should go here.
// (I.e. must be specified before viewing transformations.)
//none
// All other lighting and geometry goes here.
// Calculate the camera position for each object and draw it.
for (i = 0; i < gObjectDataCount; i++) {
if ((gObjectData[i].visible != 0) && (gObjectData[i].vrml_id >= 0)) {
//fprintf(stderr, "About to draw object %i\n", i);
arglCameraView(gObjectData[i].trans, m, VIEW_SCALEFACTOR_4);
glLoadMatrixd(m);
arVrmlDraw(gObjectData[i].vrml_id);
}
}
gPatt_found = FALSE;
} // gPatt_found
// Any 2D overlays go here.
//none
glutSwapBuffers();
}
int main(int argc, char** argv)
{
char glutGamemode[32];
const char *cparam_name =
"Data/camera_para.dat";
char *vconf = // Camera configuration.
#if defined(_WIN32)
"showDlg,flipV";
#elif defined(__APPLE__)
"";
#else
"-dev=/dev/video0 -channel=0 -palette=YUV420P -width=320 -height=240";
#endif
// ----------------------------------------------------------------------------
// Library inits.
//
glutInit(&argc, argv);
// ----------------------------------------------------------------------------
// Hardware setup.
//
if (!demoARSetupCamera(cparam_name, vconf)) {
fprintf(stderr, "main(): Unable to set up AR camera.\n");
exit(-1);
}
demoARDebugReportMode();
#ifdef _WIN32
CoInitialize(NULL);
#endif
// ----------------------------------------------------------------------------
// Library setup.
//
// Set up GL context(s) for OpenGL to draw into.
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
if (!prefWindowed) { // GLUT mono fullscreen.
//sprintf(glutGamemode, "%ix%i:%i@%i", prefWidth, prefHeight, prefDepth, prefRefresh);
sprintf(glutGamemode, "%ix%i", prefWidth, prefHeight);
glutGameModeString(glutGamemode);
glutEnterGameMode();
} else { // GLUT mono windowed.
glutInitWindowSize(gARTCparam.xsize, gARTCparam.ysize);
glutCreateWindow(argv[0]);
}
// Setup argl library for current context.
if ((gArglSettings = arglSetupForCurrentContext()) == NULL) {
fprintf(stderr, "main(): arglSetupForCurrentContext() returned error.\n");
exit(-1);
}
arUtilTimerReset();
if (!demoARSetupMarkersObjects()) {
fprintf(stderr, "main(): Unable to set up AR objects and markers.\n");
}
// Register GLUT event-handling callbacks.
// NB: Idle() is registered by Visibility.
glutDisplayFunc(Display);
glutReshapeFunc(Reshape);
glutVisibilityFunc(Visibility);
glutKeyboardFunc(Keyboard);
glutMainLoop();
return (0);
}
--- NEW FILE: Makefile.in ---
UNAME = $(shell uname)
AR_HOME = ../..
AR_CPPFLAGS = -I$(AR_HOME)/include
AR_LDFLAGS = -L$(AR_HOME)/lib
VRML_HOME = /usr
ifeq "$(UNAME)" "Darwin"
VRML_HOME = /sw
endif
VRML_CPPFLAGS =
VRML_LDFLAGS = -L$(VRML_HOME)/lib
CPPFLAGS = $(AR_CPPFLAGS) $(VRML_CPPFLAGS)
CFLAGS = @CFLAG@
CXXFLAGS = @CFLAG@
LDFLAGS = $(AR_LDFLAGS) $(VRML_LDFLAGS) @LDFLAG@
LIBS = -lARvrml -lARgsub_lite -lARvideo -lAR \
-lopenvrml -lopenvrml-gl -lstdc++ -ljpeg -lpng -lz -lm \
@LIBS@
AR = ar
ARFLAGS = @ARFLAG@
RANLIB = @RANLIB@
TARGET = $(AR_HOME)/bin/simpleVRML
HEADERS = \
object.h
OBJS = \
object.o \
simpleVRML.o
default build all: $(TARGET)
$(OBJS) : $(HEADERS)
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
clean:
-rm -f *.o *~ *.bak
-rm $(TARGET)
allclean:
-rm -f *.o *~ *.bak
-rm $(TARGET)
-rm -f Makefile
--- NEW FILE: object.c ---
/*
** ARToolKit object parsing function
** - reads in object data from object file in Data/object_data
**
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <AR/ar.h>
#include <AR/arvrml.h>
#include "object.h"
static char *get_buff(char *buf, int n, FILE *fp)
{
char *ret;
for(;;) {
ret = fgets(buf, n, fp);
if (ret == NULL) return(NULL);
if (buf[0] != '\n' && buf[0] != '#') return(ret); // Skip blank lines and comments.
}
}
ObjectData_T *read_VRMLdata( char *name, int *objectnum )
{
FILE *fp;
ObjectData_T *object;
char buf[256], buf1[256];
int i;
printf("Opening model file %s\n", name);
if ((fp=fopen(name, "r")) == NULL) return(0);
get_buff(buf, 256, fp);
if (sscanf(buf, "%d", objectnum) != 1) {
fclose(fp); return(0);
}
printf("About to load %d models.\n", *objectnum);
if ((object = (ObjectData_T *)malloc(sizeof(ObjectData_T) * (*objectnum))) == NULL) exit (-1);
for (i = 0; i < *objectnum; i++) {
get_buff(buf, 256, fp);
if (sscanf(buf, "%s %s", buf1, object[i].name) != 2) {
fclose(fp); free(object); return(0);
}
printf("Model %d: %20s\n", i + 1, &(object[i].name[0]));
if (strcmp(buf1, "VRML") == 0) {
object[i].vrml_id = arVrmlLoadFile(object[i].name);
printf("VRML id - %d \n", object[i].vrml_id);
if (object[i].vrml_id < 0) {
fclose(fp); free(object); return(0);
}
} else {
object[i].vrml_id = -1;
}
object[i].vrml_id_orig = object[i].vrml_id;
object[i].visible = 0;
get_buff(buf, 256, fp);
if (sscanf(buf, "%s", buf1) != 1) {
fclose(fp); free(object); return(0);
}
if ((object[i].id = arLoadPatt(buf1)) < 0) {
fclose(fp); free(object); return(0);
}
get_buff(buf, 256, fp);
if (sscanf(buf, "%lf", &object[i].marker_width) != 1) {
fclose(fp); free(object); return(0);
}
get_buff(buf, 256, fp);
if (sscanf(buf, "%lf %lf", &object[i].marker_center[0], &object[i].marker_center[1]) != 2) {
fclose(fp); free(object); return(0);
}
}
fclose(fp);
return( object );
}
--- NEW FILE: object.h ---
#ifndef __object_h__
#define __object_h__
#define OBJECT_MAX 30
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
char name[256];
int id;
int visible;
double marker_coord[4][2];
double trans[3][4];
int vrml_id;
int vrml_id_orig;
double marker_width;
double marker_center[2];
} ObjectData_T;
ObjectData_T *read_VRMLdata (char *name, int *objectnum);
#ifdef __cplusplus
}
#endif
#endif // __object_h__
|