PuzzleSDK
DrawNode3D.h
浏览该文件的文档.
1/****************************************************************************
2 Copyright (c) 2014-2016 Chukong Technologies Inc.
3 Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
4
5 http://www.cocos2d-x.org
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
16
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 THE SOFTWARE.
24 ****************************************************************************/
25
26#ifndef __DRAW_NODE_3D_H__
27#define __DRAW_NODE_3D_H__
28
29#include "cocos2d.h"
30
31NS_CC_BEGIN
32
36class DrawNode3D: public cocos2d::Node
37{
38public:
40 static cocos2d::DrawNode3D* create();
41
45 void drawLine(const cocos2d::Vec3 &from, const cocos2d::Vec3 &to, const Color4F &color);
46
60 void drawCube(cocos2d::Vec3* vertices, const Color4F &color);
61
63 void clear();
64
69 const BlendFunc& getBlendFunc() const;
70
78 void setBlendFunc(const BlendFunc &blendFunc);
79
80 void updateCommand(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t flags);
81
82 // Overrides
83 virtual void draw(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t flags) override;
84
85CC_CONSTRUCTOR_ACCESS:
86 DrawNode3D();
87 virtual ~DrawNode3D();
88 virtual bool init() override;
89
90protected:
91
92 void onBeforeDraw();
93 void onAfterDraw();
94
95 struct V3F_C4B
96 {
97 cocos2d::Vec3 vertices;
98 Color4B colors;
99 };
100 void ensureCapacity(int count);
101
102
103 BlendFunc _blendFunc;
104 cocos2d::CustomCommand _customCommand;
105 backend::ProgramState* _programStateLine = nullptr;
106 backend::DepthStencilDescriptor *_depthstencilDescriptor = nullptr;
107 backend::UniformLocation _locMVPMatrix;
108 std::vector<V3F_C4B> _bufferLines;
109
110
111private:
113
114 bool _isDirty = true;
116};
117
118NS_CC_END
119
120#endif // __DRAW_NODE_3D_H__
void clear()
Definition: DrawNode3D.cpp:193
std::vector< V3F_C4B > _bufferLines
Definition: DrawNode3D.h:108
cocos2d::CustomCommand _customCommand
Definition: DrawNode3D.h:104
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override
Definition: DrawNode3D.cpp:122
backend::ProgramState * _programStateLine
Definition: DrawNode3D.h:105
void onAfterDraw()
Definition: DrawNode3D.cpp:217
void onBeforeDraw()
Definition: DrawNode3D.cpp:210
CC_DISALLOW_COPY_AND_ASSIGN(DrawNode3D)
bool _rendererDepthTestEnabled
Definition: DrawNode3D.h:115
virtual ~DrawNode3D()
Definition: DrawNode3D.cpp:36
BlendFunc _blendFunc
Definition: DrawNode3D.h:103
void ensureCapacity(int count)
Definition: DrawNode3D.cpp:57
const BlendFunc & getBlendFunc() const
Definition: DrawNode3D.cpp:199
backend::DepthStencilDescriptor * _depthstencilDescriptor
Definition: DrawNode3D.h:106
bool _isDirty
Definition: DrawNode3D.h:114
void setBlendFunc(const BlendFunc &blendFunc)
Definition: DrawNode3D.cpp:204
void drawCube(cocos2d::Vec3 *vertices, const Color4F &color)
Definition: DrawNode3D.cpp:172
void updateCommand(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags)
Definition: DrawNode3D.cpp:141
backend::UniformLocation _locMVPMatrix
Definition: DrawNode3D.h:107
static cocos2d::DrawNode3D * create()
Definition: DrawNode3D.cpp:42
void drawLine(const cocos2d::Vec3 &from, const cocos2d::Vec3 &to, const Color4F &color)
Definition: DrawNode3D.cpp:157
virtual bool init() override
Definition: DrawNode3D.cpp:72
cocos2d::Vec3 vertices
Definition: DrawNode3D.h:97