Added NzDynaTerrain (basis) + simplex3d 4d for nznoise
This commit is contained in:
38
include/Nazara/DynaTerrain/Config.hpp
Normal file
38
include/Nazara/DynaTerrain/Config.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Nazara Engine
|
||||
|
||||
Copyright (C) 2012 AUTHORS (EMAIL)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_CONFIG_MODULENAME_HPP
|
||||
#define NAZARA_CONFIG_MODULENAME_HPP
|
||||
|
||||
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
|
||||
|
||||
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
|
||||
#define NAZARA_MODULENAME_MEMORYLEAKTRACKER 0
|
||||
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_MODULENAME_SAFE 1
|
||||
|
||||
#endif // NAZARA_CONFIG_MODULENAME_HPP
|
||||
11
include/Nazara/DynaTerrain/Debug.hpp
Normal file
11
include/Nazara/DynaTerrain/Debug.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
// Copyright (C) 2012 AUTHORS
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/ModuleName/Config.hpp>
|
||||
#if NAZARA_MODULENAME_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG)
|
||||
#include <Nazara/Core/Debug/MemoryLeakTracker.hpp>
|
||||
|
||||
#define delete NzMemoryManager::NextFree(__FILE__, __LINE__), delete
|
||||
#define new new(__FILE__, __LINE__)
|
||||
#endif
|
||||
8
include/Nazara/DynaTerrain/DebugOff.hpp
Normal file
8
include/Nazara/DynaTerrain/DebugOff.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// Copyright (C) 2012 AUTHORS
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#if NAZARA_MODULENAME_MEMORYLEAKTRACKER || defined(NAZARA_DEBUG)
|
||||
#undef delete
|
||||
#undef new
|
||||
#endif
|
||||
27
include/Nazara/DynaTerrain/DynaTerrain.hpp
Normal file
27
include/Nazara/DynaTerrain/DynaTerrain.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2012 AUTHORS
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_MODULENAME_HPP
|
||||
#define NAZARA_MODULENAME_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
class NAZARA_API NzModuleName
|
||||
{
|
||||
public:
|
||||
NzModuleName();
|
||||
~NzModuleName();
|
||||
|
||||
bool Initialize();
|
||||
void Uninitialize();
|
||||
|
||||
static bool IsInitialized();
|
||||
|
||||
private:
|
||||
static bool s_initialized;
|
||||
};
|
||||
|
||||
#endif // NAZARA_MODULENAME_HPP
|
||||
71
include/Nazara/DynaTerrain/Node.hpp
Normal file
71
include/Nazara/DynaTerrain/Node.hpp
Normal file
@@ -0,0 +1,71 @@
|
||||
// Copyright (C) 2012 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NODE_H
|
||||
#define NODE_H
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include "Patch.hpp"
|
||||
class NzQuadTree;
|
||||
|
||||
|
||||
//SUPPRIMER LES NODES FILS OU SEULEMENT LES PATCHS CONTENUS ? POUR L'INSTANT SUPPRESSION DES PATCHS
|
||||
|
||||
class NzNode
|
||||
{
|
||||
public:
|
||||
enum nzDirection
|
||||
{
|
||||
TOP,
|
||||
BOTTOM,
|
||||
LEFT,
|
||||
RIGHT,
|
||||
TOPLEFT,
|
||||
TOPRIGHT,
|
||||
BOTTOMLEFT,
|
||||
BOTTOMRIGHT,
|
||||
CENTER
|
||||
};
|
||||
|
||||
NzNode(NzQuadTree* quad, NzNode* parent, const NzVector2f& center, const NzVector2f& size, nzDirection dir = CENTER);
|
||||
~NzNode();
|
||||
|
||||
void Subdivide();
|
||||
void Refine(bool eraseMemory);
|
||||
|
||||
void CreatePatch(const NzVector2f& center, const NzVector2f& size);
|
||||
void DeletePatch();
|
||||
|
||||
unsigned short int GetLevel() const;
|
||||
|
||||
bool IsLeaf() const;
|
||||
bool IsRoot() const;
|
||||
|
||||
//Retourne le voisin le plus proche dans la direction indiqué, de niveau de profondeur inférieur ou égal
|
||||
bool LocateNeighbor(nzDirection dir, NzNode* neighbor);
|
||||
|
||||
|
||||
private:
|
||||
NzQuadTree* m_associatedQuadTree;
|
||||
NzNode* m_parent;
|
||||
NzNode* m_topLeftLeaf;
|
||||
NzNode* m_topRightLeaf;
|
||||
NzNode* m_bottomLeftLeaf;
|
||||
NzNode* m_bottomRightLeaf;
|
||||
bool m_isLeaf;
|
||||
bool m_isRoot;
|
||||
bool m_patchMemoryAllocated;
|
||||
unsigned short int m_level;
|
||||
|
||||
NzPatch* m_patch;
|
||||
NzVector2f m_center;
|
||||
NzVector2f m_size;
|
||||
nzDirection m_direction;
|
||||
};
|
||||
|
||||
#endif // NODE_H
|
||||
35
include/Nazara/DynaTerrain/Patch.hpp
Normal file
35
include/Nazara/DynaTerrain/Patch.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2012 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef PATCH_H
|
||||
#define PATCH_H
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
|
||||
class NzPatch
|
||||
{
|
||||
public:
|
||||
NzPatch(NzVector2f center, NzVector2f size);
|
||||
~NzPatch();
|
||||
|
||||
NzVector2f GetCenter() const;
|
||||
NzVector2f GetSize() const;
|
||||
|
||||
bool IntersectsCircle(const NzVector2f& center, double radius);
|
||||
bool IsContainedByCircle(const NzVector2f& center, double radius);
|
||||
|
||||
NzPatch* LocatePatch(const NzVector2f& position);
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
NzVector2f m_center;
|
||||
NzVector2f m_size;
|
||||
};
|
||||
|
||||
#endif // PATCH_H
|
||||
30
include/Nazara/DynaTerrain/QuadTree.hpp
Normal file
30
include/Nazara/DynaTerrain/QuadTree.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2012 Rémi Bèges
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef QUADTREE_H
|
||||
#define QUADTREE_H
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
#include <list>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include "Node.hpp"
|
||||
|
||||
class NzQuadTree
|
||||
{
|
||||
public:
|
||||
NzQuadTree(const NzVector2f& terrainCenter, const NzVector2f& terrainSize);
|
||||
void RegisterLeaf(NzNode* node);
|
||||
bool UnRegisterLeaf(NzNode* node);
|
||||
NzNode* GetRootPtr();
|
||||
~NzQuadTree();
|
||||
private:
|
||||
NzNode* root;
|
||||
//N'a pas la charge des objets en mémoire
|
||||
std::list<NzNode*> leaves;
|
||||
};
|
||||
|
||||
#endif // QUADTREE_H
|
||||
Reference in New Issue
Block a user