diff --git a/inc/hgl/graph/SceneNodeAttributes.h b/inc/hgl/graph/SceneNodeAttributes.h new file mode 100644 index 00000000..e9ec53c9 --- /dev/null +++ b/inc/hgl/graph/SceneNodeAttributes.h @@ -0,0 +1,77 @@ +#pragma once +#include + +namespace hgl +{ + namespace graph + { + #pragma pack(push,1) + /** + * 场景节点变换属性
+ */ + struct SceneNodeTransformAttributes + { + uint moveable:1; ///<可移动 + uint rotatable:1; ///<可旋转 + uint scalable:1; ///<可缩放 + + //为什么要 移动、旋转、缩放 三个分开而不是一个整体 + + // 一、不可移动、不可旋转、不可缩放的通常用于Lightmap等可以完全预计算的东西 + // 二、物理引擎对于可缩放是独立支持的,所以缩放要分开 + // 三、逻辑处理对移动一般有特别响应,但旋转不一定(也有可能只处理旋转),所以移动和旋转要分开 + + // 比如RTS中的激光坦克、电磁坦克,由于是圆形范围攻击的,所以不需要关心旋转属性,只需要关心移动属性即可 + // 同理,地面雷达,因为是扇形旋转扫描敌人的,所以只关心旋转 + // 而士兵、坦克等单位,既需要移动,又需要旋转,但不会缩放 + // 再比如风车,它不能移动,但可以旋转。但我们判断是否靠近是否看到,根本不需要关心旋转属性 + }; + + /** + * 场景节点可视属性
+ */ + struct SceneNodeVisualAttributes + { + uint visible:1; ///<是否可见 + + uint cast_shadow:1; ///<投射阴影 + uint cast_static_shadow:1; ///<投射静态阴影(预计算阴景) + uint cast_dynamic_shadow:1; ///<投射动态阴影 + + uint receive_static_shadow:1; ///<接收静态阴影 + uint receive_dynamic_shadow:1; ///<接收动态阴影 + + uint receive_static_light:1; ///<接收静态光照 + uint receive_dynamic_light:1; ///<接收动态光照 + }; + + constexpr const size_t SceneNodeVisualAttributesBytes=sizeof(SceneNodeVisualAttributes); + + /** + * 场景节点裁剪属性
+ */ + struct SceneNodeCullAttribute + { + uint32 min_distance; ///<最小裁剪距离 + uint32 max_distance; ///<最大裁剪距离 + + uint32 min_volume; ///<最小裁剪体积 + uint32 max_volume; ///<最大裁剪体积 + }; + + struct SceneNodeAttributes + { + uint editor_only:1; ///<仅编辑器中使用 + uint can_tick:1; ///<可被Tick + + SceneNodeTransformAttributes transform; ///<变换属性 + SceneNodeVisualAttributes visual; ///<可视属性 + + SceneNodeCullAttribute cull; ///<裁剪属性 + }; + + constexpr const size_t SceneNodeAttributesBytes=sizeof(SceneNodeAttributes); + + #pragma pack(pop) + }//namespace graph +}//namespace hgl