2001-11-27 18:50:04 -07:00
|
|
|
// lodspheremesh.h
|
2018-03-11 07:12:58 -06:00
|
|
|
//
|
2010-02-05 13:05:18 -07:00
|
|
|
// Copyright (C) 2001-2010, Celestia Development Team
|
|
|
|
// Original version by Chris Laurel <claurel@gmail.com>
|
2001-11-27 18:50:04 -07:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 2
|
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
|
2003-03-28 11:39:23 -07:00
|
|
|
#ifndef CELENGINE_LODSPHEREMESH_H_
|
|
|
|
#define CELENGINE_LODSPHEREMESH_H_
|
2001-11-27 18:50:04 -07:00
|
|
|
|
2002-02-25 13:29:32 -07:00
|
|
|
#include <celengine/texture.h>
|
2018-07-31 14:41:26 -06:00
|
|
|
#include <Eigen/Geometry>
|
2010-02-05 13:05:18 -07:00
|
|
|
#include <celmath/frustum.h>
|
2002-02-25 13:29:32 -07:00
|
|
|
|
2001-11-27 18:50:04 -07:00
|
|
|
|
2007-05-15 07:14:34 -06:00
|
|
|
#define MAX_SPHERE_MESH_TEXTURES 6
|
2004-02-24 03:16:48 -07:00
|
|
|
#define NUM_SPHERE_VERTEX_BUFFERS 2
|
2002-08-20 03:09:35 -06:00
|
|
|
|
2002-02-08 14:52:59 -07:00
|
|
|
class LODSphereMesh
|
2001-11-27 18:50:04 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
LODSphereMesh();
|
|
|
|
~LODSphereMesh();
|
|
|
|
|
2019-05-16 15:51:11 -06:00
|
|
|
void render(unsigned int attributes, const celmath::Frustum&, float pixWidth,
|
2002-08-20 03:09:35 -06:00
|
|
|
Texture** tex, int nTextures);
|
2019-05-16 15:51:11 -06:00
|
|
|
void render(unsigned int attributes, const celmath::Frustum&, float pixWidth,
|
2018-09-22 07:13:49 -06:00
|
|
|
Texture* tex0 = nullptr, Texture* tex1 = nullptr,
|
|
|
|
Texture* tex2 = nullptr, Texture* tex3 = nullptr);
|
2019-05-16 15:51:11 -06:00
|
|
|
void render(const celmath::Frustum&, float pixWidth,
|
2002-08-20 03:09:35 -06:00
|
|
|
Texture** tex, int nTextures);
|
2001-11-27 18:50:04 -07:00
|
|
|
|
2020-05-05 09:02:53 -06:00
|
|
|
enum
|
|
|
|
{
|
2004-02-17 02:58:52 -07:00
|
|
|
Normals = 0x01,
|
|
|
|
Tangents = 0x02,
|
|
|
|
};
|
|
|
|
|
2001-11-27 18:50:04 -07:00
|
|
|
private:
|
2003-07-30 11:07:46 -06:00
|
|
|
struct RenderInfo
|
|
|
|
{
|
2004-02-24 04:43:28 -07:00
|
|
|
RenderInfo(int _step,
|
|
|
|
unsigned int _attr,
|
2019-05-16 15:51:11 -06:00
|
|
|
const celmath::Frustum& _frustum) :
|
2004-02-24 04:43:28 -07:00
|
|
|
step(_step),
|
|
|
|
attributes(_attr),
|
2018-12-05 10:09:22 -07:00
|
|
|
frustum(_frustum)
|
2003-07-30 11:07:46 -06:00
|
|
|
{};
|
|
|
|
|
2018-03-11 07:12:58 -06:00
|
|
|
int step;
|
2003-07-30 11:07:46 -06:00
|
|
|
unsigned int attributes; // vertex attributes
|
2019-05-16 15:51:11 -06:00
|
|
|
const celmath::Frustum& frustum; // frustum, for culling
|
2018-07-31 14:41:26 -06:00
|
|
|
Eigen::Vector3f fp[8]; // frustum points, for culling
|
2003-07-30 11:07:46 -06:00
|
|
|
int texLOD[MAX_SPHERE_MESH_TEXTURES];
|
|
|
|
};
|
|
|
|
|
2020-05-05 09:02:53 -06:00
|
|
|
void renderPatches(int phi0, int theta0,
|
|
|
|
int extent,
|
|
|
|
int level,
|
|
|
|
const RenderInfo&);
|
2002-02-07 21:08:57 -07:00
|
|
|
|
2003-07-30 11:07:46 -06:00
|
|
|
void renderSection(int phi0, int theta0, int extent, const RenderInfo&);
|
2001-11-27 18:50:04 -07:00
|
|
|
|
2018-09-22 07:13:49 -06:00
|
|
|
float* vertices{ nullptr };
|
2004-02-24 03:16:48 -07:00
|
|
|
|
2018-10-30 12:57:10 -06:00
|
|
|
int maxVertices{ 0 };
|
|
|
|
int vertexSize{ 0 };
|
2004-02-24 03:16:48 -07:00
|
|
|
|
2018-10-30 12:57:10 -06:00
|
|
|
int nIndices{ 0 };
|
|
|
|
unsigned short* indices{ nullptr };
|
2002-02-25 13:29:32 -07:00
|
|
|
|
2018-10-30 12:57:10 -06:00
|
|
|
int nTexturesUsed{ 0 };
|
|
|
|
Texture* textures[MAX_SPHERE_MESH_TEXTURES]{};
|
2018-09-22 07:13:49 -06:00
|
|
|
unsigned int subtextures[MAX_SPHERE_MESH_TEXTURES]{};
|
2004-02-24 03:16:48 -07:00
|
|
|
|
2018-09-22 07:13:49 -06:00
|
|
|
bool vertexBuffersInitialized{ false };
|
2020-05-05 09:02:53 -06:00
|
|
|
GLuint currentVB{ 0 };
|
|
|
|
GLuint vertexBuffers[NUM_SPHERE_VERTEX_BUFFERS];
|
2018-10-30 12:57:10 -06:00
|
|
|
GLuint indexBuffer{ 0 };
|
2001-11-27 18:50:04 -07:00
|
|
|
};
|
|
|
|
|
2003-03-28 11:39:23 -07:00
|
|
|
#endif // CELENGINE_LODSPHEREMESH_H_
|