增加Axis,BlendMode,Light,Material等定义
This commit is contained in:
parent
8ea38d734d
commit
d1322a9f97
23
inc/hgl/graph/Axis.h
Normal file
23
inc/hgl/graph/Axis.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef HGL_GRAPH_AXIS_INCLUDE
|
||||||
|
#define HGL_GRAPH_AXIS_INCLUDE
|
||||||
|
namespace hgl
|
||||||
|
{
|
||||||
|
namespace graph
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 轴枚举
|
||||||
|
*/
|
||||||
|
enum Axis
|
||||||
|
{
|
||||||
|
HGL_AXIS_NONE=0,
|
||||||
|
|
||||||
|
HGL_AXIS_X,
|
||||||
|
HGL_AXIS_Y,
|
||||||
|
HGL_AXIS_Z,
|
||||||
|
|
||||||
|
HGL_AXIS_END
|
||||||
|
|
||||||
|
};//enum Axis
|
||||||
|
}//namespace graph
|
||||||
|
}//namespace hgl
|
||||||
|
#endif//HGL_GRAPH_AXIS_INCLUDE
|
21
inc/hgl/graph/BlendMode.h
Normal file
21
inc/hgl/graph/BlendMode.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef HGL_GRAPH_BLEND_MODE_INCLUDE
|
||||||
|
#define HGL_GRAPH_BLEND_MODE_INCLUDE
|
||||||
|
|
||||||
|
namespace hgl
|
||||||
|
{
|
||||||
|
namespace graph
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 混合模式数据结构
|
||||||
|
*/
|
||||||
|
struct BlendMode ///混合模式
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned int src,dst; ///<混合因子
|
||||||
|
unsigned int func; ///<混合方式
|
||||||
|
}rgb,alpha;
|
||||||
|
};//struct BlendMode
|
||||||
|
//namespace graph
|
||||||
|
}//namespace hgl
|
||||||
|
#endif//HGL_GRAPH_BLEND_MODE_INCLUDE
|
106
inc/hgl/graph/Light.h
Normal file
106
inc/hgl/graph/Light.h
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
#ifndef HGL_GRAPH_LIGHT_INCLUDE
|
||||||
|
#define HGL_GRAPH_LIGHT_INCLUDE
|
||||||
|
|
||||||
|
#include<hgl/math/Math.h>
|
||||||
|
namespace hgl
|
||||||
|
{
|
||||||
|
namespace graph
|
||||||
|
{
|
||||||
|
enum LightMode
|
||||||
|
{
|
||||||
|
lmNone = 0,
|
||||||
|
|
||||||
|
lmVertex,
|
||||||
|
lmPixel,
|
||||||
|
|
||||||
|
lmEnd
|
||||||
|
};//enum LightMode
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 光源类型
|
||||||
|
*/
|
||||||
|
enum LightType
|
||||||
|
{
|
||||||
|
ltNone=0, ///<起始定义,无意义
|
||||||
|
|
||||||
|
ltSunLight, ///<太阳光
|
||||||
|
|
||||||
|
ltPoint, ///<点光源
|
||||||
|
ltDirection, ///<方向光
|
||||||
|
ltSpot, ///<聚光灯
|
||||||
|
ltInfiniteSpotLight,///<无尽聚光灯
|
||||||
|
|
||||||
|
ltAreaQuad, ///<四边形面光源
|
||||||
|
|
||||||
|
ltEnd ///<结束定义,无意义
|
||||||
|
};//enum LightType
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 灯光
|
||||||
|
*/
|
||||||
|
struct Light
|
||||||
|
{
|
||||||
|
LightType type; ///<光源类型
|
||||||
|
|
||||||
|
bool enabled; ///<是否开启
|
||||||
|
|
||||||
|
Color4f ambient; ///<环境光
|
||||||
|
Color4f specular; ///<镜面光
|
||||||
|
Color4f diffuse; ///<漫反射
|
||||||
|
};//struct Light
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 太阳光
|
||||||
|
*/
|
||||||
|
struct SunLight :public Light
|
||||||
|
{
|
||||||
|
Vector3f direction;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 方向光
|
||||||
|
*/
|
||||||
|
struct DirectionLight:public Light
|
||||||
|
{
|
||||||
|
Vector3f direction; ///<方向
|
||||||
|
|
||||||
|
float nDotVP; ///<normal . light direction
|
||||||
|
float nDotHV; ///<normal . half vector
|
||||||
|
};//struct DirectionLight
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点光源
|
||||||
|
*/
|
||||||
|
struct PointLight:public Light
|
||||||
|
{
|
||||||
|
Vector3f position; ///<光源位置
|
||||||
|
|
||||||
|
Vector3f attenuation; ///<constant,linear,quadratic
|
||||||
|
};//struct PointLight
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 聚光灯
|
||||||
|
*/
|
||||||
|
struct SpotLight:public Light
|
||||||
|
{
|
||||||
|
Vector3f position; ///<位置
|
||||||
|
Vector3f direction; ///<方向
|
||||||
|
Vector3f attenuation; ///<constant,linear,quadratic
|
||||||
|
|
||||||
|
float coscutoff;
|
||||||
|
float exponent;
|
||||||
|
};//struct SpotLight
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 无尽聚光灯
|
||||||
|
*/
|
||||||
|
struct InfiniteSpotLight:public Light
|
||||||
|
{
|
||||||
|
Vector3f position;
|
||||||
|
Vector3f direction;
|
||||||
|
Vector3f exponent;
|
||||||
|
};//struct InfiniteSpotLight
|
||||||
|
}//namespace graph
|
||||||
|
}//namespace hgl
|
||||||
|
#endif//HGL_GRAPH_LIGHT_INCLUDE
|
52
inc/hgl/graph/Material.h
Normal file
52
inc/hgl/graph/Material.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#ifndef HGL_GRAPH_MATERIAL_INCLUDE
|
||||||
|
#define HGL_GRAPH_MATERIAL_INCLUDE
|
||||||
|
|
||||||
|
#include<hgl/type/Color4f.h>
|
||||||
|
#include<hgl/graph/Shader.h>
|
||||||
|
#include<hgl/graph/Axis.h>
|
||||||
|
#include<hgl/graph/BlendMode.h>
|
||||||
|
namespace hgl
|
||||||
|
{
|
||||||
|
namespace graph
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 渲染材质
|
||||||
|
*/
|
||||||
|
class Material
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
Shader *shader;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Color4f Color; ///<颜色
|
||||||
|
//
|
||||||
|
// uint draw_face; ///<绘制的面
|
||||||
|
// uint fill_mode; ///<填充方式
|
||||||
|
//
|
||||||
|
// uint cull_face; ///<裁剪面,0:不裁(双面材质),FACE_FRONT:正面,FACE_BACK:背面
|
||||||
|
//
|
||||||
|
// bool depth_test; ///<深度测试
|
||||||
|
// uint depth_func; ///<深度处理方式
|
||||||
|
// bool depth_mask; ///<深度遮罩
|
||||||
|
//
|
||||||
|
// float alpha_test; ///<alpha测试值,0:全部不显示,1:全部显示
|
||||||
|
//
|
||||||
|
// bool outside_discard; ///<贴图出界放弃
|
||||||
|
//
|
||||||
|
// bool smooth; ///<是否平滑(未用)
|
||||||
|
//
|
||||||
|
// bool color_material; ///<是否使用颜色追踪材质
|
||||||
|
//
|
||||||
|
// bool blend; ///<是否开启混合
|
||||||
|
//
|
||||||
|
// BlendMode blend_mode; ///<混合模式
|
||||||
|
//
|
||||||
|
// Axis up_axis; ///<高度图向上轴
|
||||||
|
|
||||||
|
public:
|
||||||
|
};//class Material
|
||||||
|
}//namespace graph
|
||||||
|
}//namespace hgl
|
||||||
|
#endif//HGL_GRAPH_MATERIAL_INCLUDE
|
21
inc/hgl/graph/Renderable.h
Normal file
21
inc/hgl/graph/Renderable.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef HGL_GRAPH_RENDERABLE_INCLUDE
|
||||||
|
#define HGL_GRAPH_RENDERABLE_INCLUDE
|
||||||
|
|
||||||
|
#include<hgl/graph/Shader.h>
|
||||||
|
namespace hgl
|
||||||
|
{
|
||||||
|
namespace graph
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 可渲染对象
|
||||||
|
*/
|
||||||
|
class Renderable
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
VertexArray *va;
|
||||||
|
Material *mtl;
|
||||||
|
};//class Renderable
|
||||||
|
}//namespace graph
|
||||||
|
}//namespace hgl
|
||||||
|
#endif//HGL_GRAPH_RENDERABLE_INCLUDE
|
Loading…
x
Reference in New Issue
Block a user