Created
May 2, 2017 14:22
FoliageComponent Header
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by Victor Holt on 5/1/2017. | |
// | |
#pragma once | |
#include <gs-common/PreCompiledHeadersUrho.h> | |
#include <gs-common/helpers/SimplePerlin.h> | |
#include <gs-common/helpers/Array2D.h> | |
#include <gs-graphics/CustomMesh.h> | |
using namespace Urho3D; | |
gs_nsstart | |
#define MAX_FOLIAGE_NODES 10000 | |
class GridCell; | |
class SenchaThread; | |
class FoliageComponent : public Component | |
{ | |
URHO3D_OBJECT(FoliageComponent, Component); | |
public: | |
//! Constructor. | |
//! \param context | |
FoliageComponent(Context* context); | |
/// Register object factory and attributes. | |
static void RegisterObject(Context* context); | |
//! Handles the Urho3D Update Event. | |
//! \param eventType | |
//! \param eventData | |
void HandleUpdateEvent(StringHash eventType, VariantMap& eventData); | |
//! Initializes the foliage component. | |
//! \param gridCell | |
//! \param name | |
//! \param model | |
//! \param maxFoliageNodes | |
void Initialize(GridCell* gridCell, const String& name, Model* model = nullptr, uint32_t maxFoliageNodes = MAX_FOLIAGE_NODES); | |
protected: | |
//! Saves the foliage to disk. | |
void Save(VectorBuffer& data); | |
//! Loads the foliage from disk. | |
void Load(); | |
//! Unloads the foliage. | |
void Unload(); | |
protected: | |
/// Base foliage node. | |
Node* foliageNode_; | |
/// Foilage model group. | |
StaticModelGroup* modelGroup_; | |
/// Model for building the foliage mesh. | |
Model* baseModel_; | |
/// Basic mesh for building grass. | |
CustomMesh* foliageMesh_; | |
/// Grid cell for the foliage. | |
GridCell* gridCell_; | |
/// Bounding box for the foliage. | |
BoundingBox boundingBox_; | |
/// Name used for saving the foliage. | |
String name_; | |
/// File path for the foliage. | |
String filePath_; | |
/// Checks if the foliage is loaded. | |
bool isLoaded_ = false; | |
/// Whether or not the foliage is in view. | |
bool isInView_ = false; | |
/// Whether or not the foliage is processing. | |
bool isProcessing_ = false; | |
/// Max foliage nodes that can be created. | |
uint32_t maxFoliageNodes_ = MAX_FOLIAGE_NODES; | |
/// Render distance of the foliage. | |
float maxRenderDistance_; | |
/// List of instanced nodes. | |
PODVector<Node*> instancedNodes_; | |
/// Mutex for loading foliage. | |
Mutex foliageLock_; | |
/// Loading thread. | |
SenchaThread* loadThread_; | |
/// Unloading thread. | |
SenchaThread* unloadThread_; | |
}; | |
gs_nsend |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment