2015-11-25 22:15:58 +00:00
|
|
|
#ifndef OPENGLVEGETATIONIMPOSTOR_H
|
|
|
|
#define OPENGLVEGETATIONIMPOSTOR_H
|
|
|
|
|
|
|
|
#include "opengl_global.h"
|
|
|
|
|
|
|
|
namespace paysages {
|
|
|
|
namespace opengl {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A tool to render an "impostor" of a vegetation layer.
|
|
|
|
*/
|
|
|
|
class OPENGLSHARED_EXPORT OpenGLVegetationImpostor {
|
|
|
|
public:
|
|
|
|
OpenGLVegetationImpostor(int partsize = 64);
|
|
|
|
~OpenGLVegetationImpostor();
|
|
|
|
|
|
|
|
inline const Texture2D *getTexture() const {
|
|
|
|
return texture;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render a single instance using this impostor.
|
|
|
|
*/
|
2015-12-14 23:14:06 +00:00
|
|
|
void render(OpenGLShaderProgram *program, const OpenGLVegetationInstance *instance, const Vector3 &camera_location);
|
2015-11-25 22:15:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepare the texture grid for a given model.
|
|
|
|
*/
|
|
|
|
void prepareTexture(const VegetationModelDefinition &model, const Scenery &environment, bool *interrupt);
|
|
|
|
|
2015-11-29 18:18:36 +00:00
|
|
|
/**
|
|
|
|
* Get the impostor grid index for an instance, to face the camera.
|
|
|
|
*/
|
|
|
|
int getIndex(const Vector3 &camera, const Vector3 &instance) const;
|
|
|
|
|
2015-11-25 22:15:58 +00:00
|
|
|
private:
|
2015-11-29 18:18:36 +00:00
|
|
|
void setVertex(int i, float u, float v);
|
2015-11-25 22:15:58 +00:00
|
|
|
|
|
|
|
private:
|
2015-12-08 00:28:15 +00:00
|
|
|
OpenGLVertexArray *vertices;
|
|
|
|
OpenGLSharedState *state;
|
2015-11-25 22:15:58 +00:00
|
|
|
int texture_size;
|
|
|
|
bool texture_changed;
|
|
|
|
Texture2D *texture;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // OPENGLVEGETATIONIMPOSTOR_H
|