// ----------------------------------------------------------------------------
// Blitz-Irrlicht 1.8.3 Wrapper by Ed Musolino 2015
// Based off of Frank Dodd's Irrlicht 1.7 Freebasic Wrapper (2006-2010)
// ----------------------------------------------------------------------------

//  This software is provided 'as-is', without any express Or implied
//  warranty.  In no event will the authors be held liable For any damages
//  arising from the use of this software.

//  Permission is granted To anyone To use this software For any purpose,
//  including commercial applications, And To alter it And redistribute it
//  freely, subject To the following restrictions:

//  1. The Origin of this software must Not be misrepresented; you must not
//     claim that you wrote the original software. If you use this software
//     in a product, an acknowledgement in the product documentation would be
//     appreciated but is Not required.
//  2. Altered source versions must be clearly marked as such, And must Not be
//     misrepresented as being the original software.
//  3. This notice may Not be removed Or altered from any source distribution.
//
// /////////////////////////////////////////////////////////////////////////////

// Copyright (C) 2008 Frank Dodd
// This file is part of the "IrrlichtWrapper" distributed under the Irrlicht licence
// For conditions of distribution and use, see copyright notice in irrlicht.h

#ifndef __C_ZONE_SCENE_NODE_H_INCLUDED__
#define __C_ZONE_SCENE_NODE_H_INCLUDED__

#include "ISceneNode.h"
#include "SMeshBuffer.h"
#include "CTerrainTileSceneNode.h"

#define ZONE_IDLE							0
#define ZONE_READ_COLOR						1
#define ZONE_READ_DETAIL					2
#define ZONE_WRITING_TERRAIN_STRUCTURE		3
#define ZONE_WRITING_TERRAIN_TRANSFORMATION	4
#define ZONE_WRITING_TERRAIN_PATCHES		5
#define ZONE_RUNNING						6

namespace irr
{
namespace scene
{

class CZoneSceneNode : public ISceneNode
{
	public:
		CZoneSceneNode( f32 initialNearDistance, f32 initialFarDistance,
                        ISceneNode* root, ISceneManager* smgr, s32 id);
		virtual void OnRegisterSceneNode();
		virtual void render();
		virtual const core::aabbox3d<f32>& getBoundingBox() const{ return boundingBox; }
		virtual void SetDrawProperties( f32 newNearDistance, f32 newFarDrawDistance, bool accumulateChildBoxes );
		virtual void SetBoundingBox( f32 x, f32 y, f32 z, f32 w, f32 h, f32 d );
		virtual void addChild (ISceneNode *child);
		virtual void attachTerrain ( CTerrainTileSceneNode * terrainSource,
									char * structureMap,
									char * colorMap,
									char * detailMap,
									core::position2d<s32> dataPositionSource,
									s32 sliceSize );

	private:
        bool accumulateBoundingBoxes ;
        bool firstChild;
		f32 farDrawDistance;
		f32 nearDrawDistance;
		core::aabbox3d<f32> boundingBox;

		// terrain management
		CTerrainTileSceneNode * terrain;
		s32 terrainRow;
		s32 terrainSliceSize;
		char * imageName;
		char * colorName;
		char * detailName;
		video::IImage* image;
		video::ITexture* textureColor;
		video::ITexture* textureDetail;
		core::position2d<s32> dataPosition;
		s32 zoneState;
};


}
}

#endif

