Project: omgwheel
Code Location: http://omgwheel.googlecode.com/svn/trunk//trunk
Browse
/
Download File
HeightMap.h
#ifndef HEIGHTMAP_H
#define HEIGHTMAP_H

#include "Nxf.h"

class NxActor;
class NxVec3;

namespace Ogre {
    class ManualObject;
	class Vector3;
};

/**
  * HeightMap is a class which loads a bitmap that, based on
  * greyscale value, determines height of some tile edge in a tile
  * grid.
  *
  * HeightMap will generate an Ogre manual object which can then be
  * attached to the scene.
  *
  * It is possible to fetch height based on requested coordinates.
  *
  * @author ivucica
  */

class HeightMap {
public:
    HeightMap();
    ~HeightMap();

   /**
     * \brief Get the height at position specified by x and y coordinates.
     */
    float getHeight(float x, float y) const { return 0; } // TODO (ivucica#2#): stub
   /**
     * \brief Get the Ogre "manual object" containing 3d heightmap data
     */
    Ogre::ManualObject* getGeometry();

private:
    /**
     * \brief Creates manual object containing 3d heightmap data
     */
    void createGeometry();
	/**
	 * \brief Gets the normal of a face specified by its bottom-left coordinate
	 */
	Ogre::Vector3 getFaceNormal(Ogre::Image& img, int x, int y);
	/**
	 * \brief Gets the normal of a vertex calculated from the face normals of surrounding faces
	 */
	Ogre::Vector3 getVertexNormal(Ogre::Image& img, int x, int y);
	/**
	 * \brief Adds a single vertex to the heightmap, along with texcoords and normals
	 */
	void putElement(Ogre::Image& img, int tile1, int tile2, int x, int y, Ogre::ManualObject* geometry, int ox, int oy);
	/**
	 * \brief Stores the geometry
	 */
    Ogre::ManualObject* mGeometry;
	


	NxActor* CreateHeightfield(const NxVec3& pos, int index, NxReal step);
	void RenderHeightfield();

};

#endif