osghello

as an example for a student, i copied the testCharacter.cpp from
Source/Contrib/Cal3D outside the tree and created a scons build file for it
(both files attached).

now, i encounter a very strange compilation problem:

[EMAIL PROTECTED]:/<1>shaegler/charactertest>scons
scons: Reading SConscript files ...
Checking for main() in C library m... yes
Checking for main() in C library GL... yes
Checking for main() in C library GLU... yes
Checking for main() in C library glut... yes
Checking for main() in C library OSGBase... yes
Checking for main() in C library OSGSystem... yes
Checking for main() in C library OSGWindowX... yes
Checking for main() in C library OSGWindowGLUT... yes
Checking for main() in C++ library cal3d... yes
Checking for C++ header file OpenSG/OSGConfig.h... yes
scons: done reading SConscript files.
scons: Building targets ...
g++ -ggdb -I. -I/usr/include -I/usr/local/include -I/usr/X11R6/include/GL
-I/usr/pack/freeglut-2.4.0-mo/include
-I/usr/pack/opensg-1.8-mo/i686-debian-linux3.1/include
-I/usr/pack/opensg-1.8-mo/i686-debian-linux3.1/include/OpenSG
-I/usr/pack/cal3d-0.11.0-mo/include -c -o testCharacter.o testCharacter.cpp
testCharacter.cpp: In function `int main(int, char**)':
testCharacter.cpp:49: error: `GLUTWindowPtr' undeclared (first use this
   function)
testCharacter.cpp:49: error: (Each undeclared identifier is reported only once
   for each function it appears in.)
testCharacter.cpp:49: error: parse error before `=' token
testCharacter.cpp:50: error: `gwin' undeclared (first use this function)
scons: *** [testCharacter.o] Error 1
scons: building terminated because of errors.

any ideas? i already checked the includes...

thanks,
simon
################################################################################
###
### scenic build system
### simon haegler ([EMAIL PROTECTED])
###
### $Id: sconstruct 138 2006-12-11 00:38:26Z shaegler $
###
################################################################################

import platform
import os

################################################################################
###
### get system information
###
################################################################################

sysinfo = platform.uname()
sysid = sysinfo[4] + '-' + sysinfo[0].lower()

################################################################################
###
### setup build options
###
################################################################################

optionscache = '.options'
opts = Options(optionscache)
opts.Add('debug', 'set to 1 to build with debug symbols', 0)
opts.Add('osgprefix', 'path to the opensg libs', 
         '/usr/pack/opensg-1.8-mo/i686-debian-linux3.1')
opts.Add('cal3dprefix', 'path to the cal3d libs',
         '/usr/pack/cal3d-0.11.0-mo')

################################################################################
###
### setup environment
###
################################################################################

# create default env
env = Environment(options = opts)

env['CXXFILESUFFIX'] = '.cpp'

# generate default help
Help(opts.GenerateHelpText(env))

# get arguments
debug = env.get('debug')
osgprefix = env.get('osgprefix')
cal3dprefix = env.get('cal3dprefix')

opts.Save(optionscache, env)

# set includes/libs
env.Append(CPPPATH = ['.',
                      '/usr/include',
                      '/usr/local/include',
                      '/usr/X11R6/include/GL',
                      '/usr/pack/freeglut-2.4.0-mo/include'])
env.Append(LIBPATH = ['/usr/lib/X11',
                      '/usr/pack/freeglut-2.4.0-mo/i686-debian-linux3.1/lib'])

# opensg
env.Append(CPPPATH = [osgprefix+'/include', osgprefix+'/include/OpenSG'])
env.Append(LIBPATH = [osgprefix+'/lib/opt'])
env.Append(RPATH = [osgprefix+'/lib/opt'])

# cal3d
env.Append(CPPPATH = [cal3dprefix+'/include'])
env.Append(LIBPATH = [cal3dprefix+'/i686-debian-linux3.1/lib'])
env.Append(RPATH = [cal3dprefix+'/i686-debian-linux3.1/lib'])


################################################################################
###
### setup CFLAGS
###
################################################################################

# TODO: detect cpu type

if debug == '1':
  env.Append(CCFLAGS = '-ggdb')
else:
  env.Append(CCFLAGS = ['-O3', '-march=i686', '-pipe'])

################################################################################
###
### check for libraries
###
################################################################################

conf = Configure(env)
if not conf.CheckLibWithHeader('m', 'math.h', 'c'):
  print 'Did not find libm.a or m.lib, exiting!'
  Exit(1)
if not conf.CheckLib('GL'):
  print 'Did not find GL library, exiting!'
  Exit(1)
if not conf.CheckLib('GLU'):
  print 'Did not find GLU library, exiting!'
  Exit(1)
if not conf.CheckLib('glut'):
  print 'Did not find glut library, exiting!'
  Exit(1)
if not conf.CheckLib('OSGBase'):
  print 'Did not find OpenSG base library, exiting!'
  Exit(1)
if not conf.CheckLib('OSGSystem'):
  print 'Did not find OpenSG system library, exiting!'
  Exit(1)
if not conf.CheckLib('OSGWindowX'):
  print 'Did not find OpenSG X window library, exiting!'
  Exit(1)
if not conf.CheckLib('OSGWindowGLUT'):
  print 'Did not find OpenSG GLUT window library, exiting!'
  Exit(1)
if not conf.CheckLibWithHeader('cal3d', 'cal3d/cal3d.h', 'c++'):
  print 'Did not find Cal3D library, exiting!'
  Exit(1)
if not conf.CheckCXXHeader('OpenSG/OSGConfig.h'):
  print 'Did not find OpenSG headers, exiting!'
  Exit(1)
env = conf.Finish()

################################################################################
###
### build the binary
###
################################################################################

env.Program(
  target = 'testcharacter',
  source = 'testCharacter.cpp'
)
// OpenSG Example: Cal3D Character

// Standad includes
#include <OSGGLUT.h>
#include <OSGConfig.h>
#include <OSGSimpleGeometry.h>
#include <OSGGLUTWindow.h>
#include <OSGSimpleSceneManager.h>
#include <OSGSimpleGeometry.h>
#include <OSGSHLChunk.h>
#include <OSGGradientBackground.h>

// The new core
#include <OSGCharacterModel.h>
#include <OSGCharacter.h>

// Activate the OpenSG namespace
OSG_USING_NAMESPACE

// The SimpleSceneManager to manage simple applications
SimpleSceneManager *mgr;

CharacterModelPtr model;
CharacterPtr charac;
SHLChunkPtr shader;

Real32 timeScale = 1;
Int32 animation = 0;

// forward declaration so we can have the interesting stuff upfront
int setupGLUT( int *argc, char *argv[] );

// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{ 
    if(argc < 2)
    {
        std::cerr << "Usage: " << argv[0] << " <cfg file>" << std::endl;
        exit(1);
    }

    // OSG init
    osgInit(argc,argv);

    // GLUT init
    int winid = setupGLUT(&argc, argv);

    // the connection between GLUT and OpenSG
    GLUTWindowPtr gwin = GLUTWindowPtr::create();
    gwin->setId(winid);
    gwin->init();
    
    // Get the shader for hardware skinning
    
    shader = SHLChunk::create();
    
    beginEditCP(shader);
    if(!shader->readVertexProgram("bonesShader.vp"))
    {
        subRefCP(shader);
        shader = NullFC;
    }
    else
    {
        if(!shader->readFragmentProgram("bonesShader.fp"))
        {
            subRefCP(shader);
            shader = NullFC;
        }
        else
        {
            endEditCP(shader);
        }
    }
   
    // Load the character model
    
    model = CharacterModel::create();
    beginEditCP(model);
    model->setConfigFile(argv[1]);
    model->setShader(shader);
    endEditCP(model);
    
    // Create the Scene
    NodeRefPtr scene;
    scene = Node::create();
    GroupPtr grcore = Group::create();
    
    beginEditCP(scene);
    scene->setCore(grcore);

    // Add a Plane for the ground
    
    TransformNodePtr tr;
    
    tr = Transform::create();
    
    beginEditCP(tr);
    
    tr.node()->addChild(makePlane(200, 200, 16, 16));
    
    Matrix m;
    m.setTransform(Vec3f(0,0,-1));
    tr->setMatrix(m);
    
    endEditCP(tr);
    
    scene->addChild(tr.node());
   
    
    // Create a character
    
    charac = Character::create();

    beginEditCP(charac, Character::ModelFieldMask | 
                        Character::CurrentAnimationFieldMask);
    charac->setModel(model);
    charac->setCurrentAnimation(0);
    endEditCP(  charac, Character::ModelFieldMask | 
                        Character::CurrentAnimationFieldMask);
 
    scene->addChild(makeNodeFor(charac));

    endEditCP(scene);
    
    // create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // tell the manager what to manage
    mgr->setWindow(gwin );
    mgr->setRoot  (scene);


    // Background
    GradientBackgroundPtr gbkgnd = GradientBackground::create();

    beginEditCP(gbkgnd, GradientBackground::LineFieldMask);
    gbkgnd->addLine( Color3f(.7,.7,1.), 0.0 );
    gbkgnd->addLine( Color3f(0, 0, 1), 0.5 );
    gbkgnd->addLine( Color3f(0, 0, .2), 1.0 );
    endEditCP  (gbkgnd, GradientBackground::LineFieldMask);
    
    mgr->getWindow()->getPort(0)->setBackground(gbkgnd);
 
    // show the whole scene
    mgr->showAll();
    
    // GLUT main loop
    glutMainLoop();

    return 0;
}

//
// GLUT callback functions
//

// redraw the window
void display(void)
{
    mgr->redraw();
}

// react to size changes
void reshape(int w, int h)
{
    mgr->resize(w, h);
    glutPostRedisplay();
}

// react to mouse button presses
void mouse(int button, int state, int x, int y)
{
    if (state)
        mgr->mouseButtonRelease(button, x, y);
    else
        mgr->mouseButtonPress(button, x, y);
        
    glutPostRedisplay();
}

// react to mouse motions with pressed buttons
void motion(int x, int y)
{
    mgr->mouseMove(x, y);
    glutPostRedisplay();
}

// react to keys
void keyboard(unsigned char k, int x, int y)
{
    switch(k)
    {
    case 27:    exit(1);
    
    case ' ':   
                beginEditCP(charac, Character::TimeScaleFieldMask);
                if(charac->getTimeScale() == 0)
                    charac->setTimeScale(timeScale);
                else
                    charac->setTimeScale(0);
                endEditCP(charac, Character::TimeScaleFieldMask);
                break;
    
    case 'a':   animation = (++animation) % model->getNumAnimations();
                beginEditCP(charac, Character::CurrentAnimationFieldMask);
                charac->setCurrentAnimation(animation);
                endEditCP(charac, Character::CurrentAnimationFieldMask);
                SLOG << "Animation set to " << animation << endLog;
                break;
    
    case 's':   animation = (--animation < 0) ? model->getNumAnimations() - 1
                                              : animation;
                beginEditCP(charac, Character::CurrentAnimationFieldMask);
                charac->setCurrentAnimation(animation);
                endEditCP(charac, Character::CurrentAnimationFieldMask);
                SLOG << "Animation set to " << animation << endLog;
                break;
    
    case 'z':   timeScale *= 0.9;
                beginEditCP(charac, Character::TimeScaleFieldMask);
                charac->setTimeScale(timeScale);
                endEditCP(charac, Character::TimeScaleFieldMask);
                SLOG << "Time scale set to " << timeScale << endLog;
                break;
    
    case 'x':   timeScale *= 1.1;
                beginEditCP(charac, Character::TimeScaleFieldMask);
                charac->setTimeScale(timeScale);
                endEditCP(charac, Character::TimeScaleFieldMask);
                SLOG << "Time scale set to " << timeScale << endLog;
                break;
    
    case 'h':   beginEditCP(charac, Character::UseShaderForGeometryFieldMask);
                charac->setUseShaderForGeometry(true);
                endEditCP(charac, Character::UseShaderForGeometryFieldMask);
                SLOG << "Switched to shaders" << endLog;
                break;
    
    case 'r':   
                beginEditCP(shader);
                if(!shader->readVertexProgram("bonesShader.vp"))
                    fprintf(stderr, "Couldn't read vertex program "
                                    "'bonesShader.vp'\n");
                if(!shader->readFragmentProgram("bonesShader.fp"))
                    fprintf(stderr, "Couldn't read vertex program "
                                    "'bonesShader.fp'\n");
                endEditCP(shader);
                SLOG << "Shader reloaded" << endLog;
                break;                
    }
}

// setup the GLUT library which handles the windows for us
int setupGLUT(int *argc, char *argv[])
{
    glutInit(argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
    
    int winid = glutCreateWindow("OpenSG");
    
    glutReshapeFunc(reshape);
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutKeyboardFunc(keyboard);

    return winid;
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to