Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

appear.C

Go to the documentation of this file.
00001 /*!
00002  *  \file appear.C
00003  *  \brief Contains the implementation of the APPEAR class.
00004  *
00005  *  \sa appear.H
00006  *
00007  */
00008 
00009 #include "appear.H"
00010 #include "net/stream.H"
00011 #include "net/net_types.H"
00012 #include "geom/texturegl.H"
00013 #include "std/config.H"
00014 
00015 void
00016 APPEAR::get_texture(TAGformat &d)
00017 {
00018    _has_texture = 1;
00019 
00020    str_ptr texture_name;
00021    *d >> _tex_xform >> texture_name;
00022    _texture = 0;
00023    if (texture_name && texture_name != str_ptr("NO_TEXTURE")) {
00024       // XXX - taken from CLI::get_file_relative
00025       if ((**texture_name)[0] != '/' && (*texture_name)[0] != '.')
00026          texture_name = Config::JOT_ROOT() + str_ptr("/") + texture_name;
00027       _texture = new TEXTUREgl(texture_name);
00028    }
00029 }
00030 
00031 void
00032 APPEAR::put_texture(TAGformat &d) const
00033 {
00034    if (!_has_texture)
00035       return;
00036 
00037    d.id() << _tex_xform;
00038 
00039    if (_texture) {
00040       str_ptr texture_name =_texture->file();
00041       // If texture name begins with JOT_ROOT, strip it off
00042       // XXX - does not work if filename is below JOT_ROOT but the path to
00043       // the file does not start with JOT_ROOT
00044       if (strstr(**texture_name, **Config::JOT_ROOT()) == **texture_name) {
00045          cerr << texture_name << endl;
00046          char *name =  **texture_name + Config::JOT_ROOT().len() + 1;
00047          // Strip extra slashes ("/")
00048          while (name && *name == '/' && *name != '\0') name++;
00049          texture_name = str_ptr(name);
00050       }
00051       *d << texture_name;
00052    } else *d << "NO_TEXTURE";
00053 
00054    d.end_id();
00055 }

Generated on Mon Sep 18 11:39:28 2006 for jot by  doxygen 1.4.4