heightfield.h

Go to the documentation of this file.
00001 /*
00002  * heightfield.h
00003  *
00004  * Copyright (C) 2008,2009  Thomas A. Vaughan
00005  * All rights reserved.
00006  *
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions are met:
00010  *     * Redistributions of source code must retain the above copyright
00011  *       notice, this list of conditions and the following disclaimer.
00012  *     * Redistributions in binary form must reproduce the above copyright
00013  *       notice, this list of conditions and the following disclaimer in the
00014  *       documentation and/or other materials provided with the distribution.
00015  *     * Neither the name of the <organization> nor the
00016  *       names of its contributors may be used to endorse or promote products
00017  *       derived from this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THOMAS A. VAUGHAN ''AS IS'' AND ANY
00020  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00021  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00022  * DISCLAIMED. IN NO EVENT SHALL THOMAS A. VAUGHAN BE LIABLE FOR ANY
00023  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00024  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00025  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00026  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00027  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00028  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029  *
00030  */
00031 
00032 #ifndef WAVE_GLUT_HEIGHTFIELD_H__
00033 #define WAVE_GLUT_HEIGHTFIELD_H__
00034 
00035 // includes --------------------------------------------------------------------
00036 #include "common/common.h"
00037 #include "nstream/nstream.h"
00038 #include "threadsafe/smart_ptr.h"
00039 
00040 #include <iostream>
00041 
00042 
00043 namespace hfield {
00044 
00045 ////////////////////////////////////////////////////////////////////////////////
00046 ///
00047 /// \ingroup geometric
00048 /// \defgroup hfield Wavepacket Heightfield Library
00049 ///
00050 /// \n
00051 /// This library provides basic heightfield support.  This is for modeling
00052 /// terrains logically on the client and server.
00053 ///
00054 /// \n
00055 /// \b NOTE: this library does NOT support rendering!  It is just a logical
00056 /// heightfield.  Other libraries (such as \ref terrain) know how to
00057 /// render one of these.  The purpose of this library is to be useful on
00058 /// the server (no rendering) and client.
00059 ///
00060 ////////////////////////////////////////////////////////////////////////////////
00061 
00062 /*@{*/
00063 
00064 
00065 ////////////////////////////////////////////////////////////////////////////////
00066 //
00067 //      Heightfield API
00068 //
00069 ////////////////////////////////////////////////////////////////////////////////
00070 
00071 /// A logical heightfield.
00072 class Heightfield {
00073 public:
00074         // virtual destructor --------------------------------------------------
00075         virtual ~Heightfield(void) throw();
00076 
00077         // hfield::Heightfield class interface methods -------------------------
00078         virtual void dump(IN const char * txt) const throw() = 0;
00079         virtual int getWidth(void) const throw() = 0;
00080         virtual int getLength(void) const throw() = 0;
00081         virtual float getXZScale(void) const throw() = 0;
00082         virtual float getYScale(void) const throw() = 0;
00083         virtual short getMinHeight(void) const throw() = 0;
00084         virtual short getMaxHeight(void) const throw() = 0;
00085 
00086         /// returns raw height values, NOT multipled by yScale yet
00087         virtual const short * getHeightArray(void) const throw() = 0;
00088 
00089         virtual smart_ptr<nstream::Manager> getStreamManager(void) throw() = 0;
00090         virtual const char * getHeightfieldPath(void) const throw()  = 0;
00091         virtual const char * getTexturePath(void) const throw() = 0;
00092 
00093         /// returns true height values, already multiplied by yScale
00094         virtual float getHeight(IN float x, IN float z) const throw() = 0;
00095 
00096         // static factory methods ----------------------------------------------
00097 
00098         /// Create a heightfield from a named stream.  See the Wavepacket
00099         ///   named stream library for the nstream interface and usage:
00100         ///   http://wavepacket-lib.sourceforge.net/
00101         static smart_ptr<Heightfield> create(IO nstream::Stream * stream);
00102 };
00103 
00104 
00105 
00106 };      // hfield namespace
00107 
00108 #endif  // WAVE_GLUT_HEIGHTFIELD_H__
00109