cocos2dx box2d 连接线

cocos2d-x节点(b2EdgeShape.h)API

温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记

一个线段(边缘)形状。这些可以连接在链或者环其他边缘形状。

[cpp]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. ///cocos2d-x-3.0alpha0/external/Box2D/Collision/Shapes  
  2. // 一个线段(边缘)形状。这些可以连接在链或者环其他边缘形状。  
  3.   
  4.   
  5. #ifndef B2_EDGE_SHAPE_H  
  6. #define B2_EDGE_SHAPE_H  
  7.   
  8. #include <Box2D/Collision/Shapes/b2Shape.h>  
  9.   
  10. //  一个线段(边缘)形状。这些可以连接在链或者环其他边缘形状。  
  11. //连接信息是用来确保正确的联系法线  
  12. class b2EdgeShape : public b2Shape  
  13. {  
  14. public:  
  15.     b2EdgeShape();      //构造函数  
  16.       
  17.     // 设置独立的边缘  
  18.     //  * 参数说明: v1 : 第一个顶点  
  19.     //               v2 : 第二个顶点  
  20.     void Set(const b2Vec2& v1, const b2Vec2& v2);  
  21.       
  22.     // :用soa块分配器克隆一个具体的形状  
  23.     // * 参数说明: allocator :soa分配器对象指针  
  24.     // * 返 回 值: 形状指针  
  25.     b2Shape* Clone(b2BlockAllocator* allocator) const;  
  26.     // 获取形状的孩子元素的数量  
  27.     /// @see b2Shape::GetChildCount  
  28.     int32 GetChildCount() const;  
  29.     // 在这个形状中测试这个点的密封性,只适合用于凸的形状  
  30.     //     * 参数说明: xf : 形状的变换  
  31.     //                  p  : world坐标中的一个点  
  32.     //     * 返 回 值: true : 密封  
  33.     //                  false:敞开  
  34.     /// @see b2Shape::TestPoint  
  35.     bool TestPoint(const b2Transform& transform, const b2Vec2& p) const;  
  36.       
  37.     // :投射一束光到一个孩子形状中  
  38.     //  * 参数说明: output      :输出光线投射的结果  
  39.     //               input       :输入光线投射  
  40.     //               transform   :变换应用到此形状中  
  41.     //               childeIndex :孩子形状索引  
  42.     //  * 返 回 值: true : 成功  
  43.     //               false:失败  
  44.     bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,  
  45.                  const b2Transform& transform, int32 childIndex) const;  
  46.     // * 功能描述:给出一个变换,计算一个孩子形状的轴对齐包围盒(aabb)  
  47.     //  * 参数说明: aabb       : 孩子形状的aabb指针  
  48.     //               xf         : 一个变换的引用  
  49.     //               childIndex : 孩子的索引值  
  50.     /// @see b2Shape::ComputeAABB  
  51.     void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const;  
  52.     // 用它的大小和密度计算形状的质量  
  53.     //     * 参数说明: massData   : 计算形状的质量  
  54.     //                  density    : 密度  
  55.     /// @see b2Shape::ComputeMass  
  56.     void ComputeMass(b2MassData* massData, float32 density) const;  
  57.       
  58.     //  边缘形状的顶点  
  59.     b2Vec2 m_vertex1, m_vertex2;  
  60.       
  61.     // 可选的相邻的顶点,它们用于平滑碰撞  
  62.     b2Vec2 m_vertex0, m_vertex3;  
  63.     bool m_hasVertex0, m_hasVertex3;          //是否含有相邻顶点  
  64. };  
  65. //构造函数,用于初始化  
  66. inline b2EdgeShape::b2EdgeShape()  
  67. {  
  68.     m_type = e_edge;  
  69.     m_radius = b2_polygonRadius;  
  70.     m_vertex0.x = 0.0f;  
  71.     m_vertex0.y = 0.0f;  
  72.     m_vertex3.x = 0.0f;  
  73.     m_vertex3.y = 0.0f;  
  74.     m_hasVertex0 = false;  
  75.     m_hasVertex3 = false;  
  76. }  
  77.   
  78. #endif  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值