mirror of https://github.com/axmolengine/axmol.git
DrawNode V2 (#2124)
* DrawNodeV2 ready4merge * Update README.md * Lua stuff * Update DrawNode.h * Update DrawNode.cpp * Update DrawNode.cpp * Update DrawNode.cpp * Add the cocos2dx test again, add some improvements * Some improvements * Remove CandyMix from Android devices * Update DrawNodeTest.cpp * Clean tester code
This commit is contained in:
parent
7b377d6351
commit
4ae3792164
|
@ -35,7 +35,6 @@
|
|||
- AX_ENABLE_EXT_EFFEKSEER: the effekseer extension, default: `FALSE`
|
||||
- AX_ENABLE_EXT_JSONDEFAULT: the UserDefault based on json, default: `FALSE`
|
||||
- AX_ENABLE_EXT_LUA: the lua extension, default: `TRUE`
|
||||
- AX_ENABLE_EXT_DRAWNODEEX: the DrawNodeEx extension, default: `TRUE`
|
||||
- AX_WITH_XXX: usually user don't need care it
|
||||
- AX_USE_COMPAT_GL: whether use compat gl as renderer backend, default: win32: `TRUE`, others: `FALSE`
|
||||
- win32: whether use ANGLE GLES backend
|
||||
|
|
1629
core/2d/DrawNode.cpp
1629
core/2d/DrawNode.cpp
File diff suppressed because it is too large
Load Diff
|
@ -30,8 +30,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef __CCDRAWNODES_CCDRAW_NODE_H__
|
||||
#define __CCDRAWNODES_CCDRAW_NODE_H__
|
||||
#ifndef __DRAW_NODE_H__
|
||||
#define __DRAW_NODE_H__
|
||||
|
||||
#include "2d/Node.h"
|
||||
#include "base/Types.h"
|
||||
|
@ -45,6 +45,7 @@ namespace ax
|
|||
static const int DEFAULT_LINE_WIDTH = 2;
|
||||
|
||||
class PointArray;
|
||||
|
||||
/**
|
||||
* @addtogroup _2d
|
||||
* @{
|
||||
|
@ -58,7 +59,6 @@ class PointArray;
|
|||
class AX_DLL DrawNode : public Node
|
||||
{
|
||||
public:
|
||||
|
||||
/** Different draw modus types.
|
||||
*
|
||||
*.
|
||||
|
@ -71,11 +71,26 @@ public:
|
|||
Semi,
|
||||
};
|
||||
|
||||
enum PointType
|
||||
{
|
||||
Circle,
|
||||
Rect,
|
||||
};
|
||||
|
||||
// See also example on https://www.angusj.com/clipper2/Docs/Units/Clipper/Types/EndType.htm
|
||||
enum EndType
|
||||
{
|
||||
Square,
|
||||
Round,
|
||||
Butt,
|
||||
};
|
||||
|
||||
/** creates and initialize a DrawNode node.
|
||||
*
|
||||
* @return Return an autorelease object.
|
||||
*/
|
||||
static DrawNode* create(float defaultLineWidth = DEFAULT_LINE_WIDTH);
|
||||
// DrawNode();
|
||||
|
||||
/** Draw a point.
|
||||
*
|
||||
|
@ -84,7 +99,10 @@ public:
|
|||
* @param color The point color.
|
||||
* @js NA
|
||||
*/
|
||||
void drawPoint(const Vec2& point, const float pointSize, const Color4B& color);
|
||||
void drawPoint(const Vec2& point,
|
||||
const float pointSize,
|
||||
const Color4B& color,
|
||||
DrawNode::PointType pointType = DrawNode::PointType::Rect);
|
||||
|
||||
/** Draw a group point.
|
||||
*
|
||||
|
@ -93,7 +111,10 @@ public:
|
|||
* @param color The point color.
|
||||
* @js NA
|
||||
*/
|
||||
void drawPoints(const Vec2* position, unsigned int numberOfPoints, const Color4B& color);
|
||||
void drawPoints(const Vec2* position,
|
||||
unsigned int numberOfPoints,
|
||||
const Color4B& color,
|
||||
DrawNode::PointType pointType = DrawNode::PointType::Rect);
|
||||
|
||||
/** Draw a group point.
|
||||
*
|
||||
|
@ -103,7 +124,11 @@ public:
|
|||
* @param color The point color.
|
||||
* @js NA
|
||||
*/
|
||||
void drawPoints(const Vec2* position, unsigned int numberOfPoints, const float pointSize, const Color4B& color);
|
||||
void drawPoints(const Vec2* position,
|
||||
unsigned int numberOfPoints,
|
||||
const float pointSize,
|
||||
const Color4B& color,
|
||||
DrawNode::PointType pointType = DrawNode::PointType::Rect);
|
||||
|
||||
/** Draw an line from origin to destination with color.
|
||||
*
|
||||
|
@ -112,7 +137,12 @@ public:
|
|||
* @param color The line color.
|
||||
* @js NA
|
||||
*/
|
||||
void drawLine(const Vec2& origin, const Vec2& destination, const Color4B& color);
|
||||
void drawLine(const Vec2& origin,
|
||||
const Vec2& destination,
|
||||
const Color4B& color,
|
||||
float thickness = 1.0f,
|
||||
DrawNode::EndType etStart = DrawNode::EndType::Round,
|
||||
DrawNode::EndType etEnd = DrawNode::EndType::Round);
|
||||
|
||||
/** Draws a rectangle given the origin and destination point measured in points.
|
||||
* The origin and the destination can not have the same x and y coordinate.
|
||||
|
@ -121,7 +151,7 @@ public:
|
|||
* @param destination The rectangle destination.
|
||||
* @param color The rectangle color.
|
||||
*/
|
||||
void drawRect(const Vec2& origin, const Vec2& destination, const Color4B& color);
|
||||
void drawRect(const Vec2& origin, const Vec2& destination, const Color4B& color, float thickness = 1.0f);
|
||||
|
||||
/** Draws a polygon given a pointer to point coordinates and the number of vertices measured in points.
|
||||
* The polygon can be closed or open.
|
||||
|
@ -131,7 +161,11 @@ public:
|
|||
* @param closePolygon The polygon can be closed or open.
|
||||
* @param color The polygon color.
|
||||
*/
|
||||
void drawPoly(const Vec2* poli, unsigned int numberOfPoints, bool closePolygon, const Color4B& color);
|
||||
void drawPoly(const Vec2* poli,
|
||||
unsigned int numberOfPoints,
|
||||
bool closedPolygon,
|
||||
const Color4B& color,
|
||||
float thickness = 1.0f);
|
||||
|
||||
/** Draws a circle given the center, radius and number of segments.
|
||||
*
|
||||
|
@ -143,7 +177,7 @@ public:
|
|||
* @param scaleX The scale value in x.
|
||||
* @param scaleY The scale value in y.
|
||||
* @param color Set the circle color.
|
||||
* @param threshold (optional) Set the threshold which will be draws a better rendered polygon.
|
||||
* @param thickness (default 1.0f)
|
||||
*/
|
||||
void drawCircle(const Vec2& center,
|
||||
float radius,
|
||||
|
@ -153,7 +187,7 @@ public:
|
|||
float scaleX,
|
||||
float scaleY,
|
||||
const Color4B& color,
|
||||
float threshold = 500); // 500 should "simulate/save" the backwards compatibility
|
||||
float thickness = 1.0f);
|
||||
|
||||
/** Draws a circle given the center, radius and number of segments.
|
||||
*
|
||||
|
@ -163,7 +197,7 @@ public:
|
|||
* @param segments The number of segments.
|
||||
* @param drawLineToCenter Whether or not draw the line from the origin to center.
|
||||
* @param color Set the circle color.
|
||||
* @param threshold (optional) Set the threshold which will be draws a better rendered polygon.
|
||||
* @param thickness (default 1.0f)
|
||||
*/
|
||||
void drawCircle(const Vec2& center,
|
||||
float radius,
|
||||
|
@ -171,7 +205,40 @@ public:
|
|||
unsigned int segments,
|
||||
bool drawLineToCenter,
|
||||
const Color4B& color,
|
||||
float threshold = 500); // 500 should "simulate/save" the backwards compatibility
|
||||
float thickness = 1.0f);
|
||||
|
||||
/** Draws a star given the center, radiusI, radiusO and number of segments.
|
||||
*
|
||||
* @param center The circle center point.
|
||||
* @param radiusI The inner radius.
|
||||
* @param radiusO The outer radius.
|
||||
* @param segments The number of segments.
|
||||
* @param color Set the star color.
|
||||
* @param thickness (default = 1.0f)
|
||||
*/
|
||||
void drawStar(const Vec2& center,
|
||||
float radiusI,
|
||||
float radiusO,
|
||||
unsigned int segments,
|
||||
const Color4B& color,
|
||||
float thickness = 1.0f);
|
||||
|
||||
/** Draws a solid star given the center, radiusI, radiusO and number of segments.
|
||||
*
|
||||
* @param center The circle center point.
|
||||
* @param radiusI The inner radius.
|
||||
* @param radiusO The outer radius.
|
||||
* @param segments The number of segments.
|
||||
* @param color Set the star color.
|
||||
* @param thickness (default = 1.0f)
|
||||
*/
|
||||
void drawSolidStar(const Vec2& center,
|
||||
float radiusI,
|
||||
float radiusO,
|
||||
unsigned int segments,
|
||||
const Color4B& color,
|
||||
const Color4B& filledColor,
|
||||
float thickness = 1.0f);
|
||||
|
||||
/** Draws a quad bezier path.
|
||||
*
|
||||
|
@ -185,7 +252,8 @@ public:
|
|||
const Vec2& control,
|
||||
const Vec2& destination,
|
||||
unsigned int segments,
|
||||
const Color4B& color);
|
||||
const Color4B& color,
|
||||
float thickness = 1.0f);
|
||||
|
||||
/** Draw a cubic bezier curve with color and number of segments
|
||||
*
|
||||
|
@ -201,7 +269,8 @@ public:
|
|||
const Vec2& control2,
|
||||
const Vec2& destination,
|
||||
unsigned int segments,
|
||||
const Color4B& color);
|
||||
const Color4B& color,
|
||||
float thickness = 1.0f);
|
||||
|
||||
/** Draws a Cardinal Spline path.
|
||||
*
|
||||
|
@ -210,7 +279,11 @@ public:
|
|||
* @param segments The number of segments.
|
||||
* @param color Set the Spline color.
|
||||
*/
|
||||
void drawCardinalSpline(PointArray* config, float tension, unsigned int segments, const Color4B& color);
|
||||
void drawCardinalSpline(PointArray* config,
|
||||
float tension,
|
||||
unsigned int segments,
|
||||
const Color4B& color,
|
||||
float thickness = 1.0f);
|
||||
|
||||
/** Draws a Catmull Rom path.
|
||||
*
|
||||
|
@ -218,7 +291,7 @@ public:
|
|||
* @param segments The number of segments.
|
||||
* @param color The Catmull Rom color.
|
||||
*/
|
||||
void drawCatmullRom(PointArray* points, unsigned int segments, const Color4B& color);
|
||||
void drawCatmullRom(PointArray* points, unsigned int segments, const Color4B& color, float thickness = 1.0f);
|
||||
|
||||
/** draw a dot at a position, with a given radius and color.
|
||||
*
|
||||
|
@ -236,7 +309,12 @@ public:
|
|||
* @param p4 The rectangle vertex point.
|
||||
* @param color The rectangle color.
|
||||
*/
|
||||
void drawRect(const Vec2& p1, const Vec2& p2, const Vec2& p3, const Vec2& p4, const Color4B& color);
|
||||
void drawRect(const Vec2& p1,
|
||||
const Vec2& p2,
|
||||
const Vec2& p3,
|
||||
const Vec2& p4,
|
||||
const Color4B& color,
|
||||
float thickness = 1.0f);
|
||||
|
||||
/** Draws a solid rectangle given the origin and destination point measured in points.
|
||||
* The origin and the destination can not have the same x and y coordinate.
|
||||
|
@ -246,7 +324,11 @@ public:
|
|||
* @param color The rectangle color.
|
||||
* @js NA
|
||||
*/
|
||||
void drawSolidRect(const Vec2& origin, const Vec2& destination, const Color4B& color);
|
||||
void drawSolidRect(const Vec2& origin,
|
||||
const Vec2& destination,
|
||||
const Color4B& color,
|
||||
float thickness = 0,
|
||||
const Color4B& borderColor = Color4B(0, 0, 0, 0));
|
||||
|
||||
/** Draws a solid polygon given a pointer to CGPoint coordinates, the number of vertices measured in points, and a
|
||||
* color.
|
||||
|
@ -256,7 +338,12 @@ public:
|
|||
* @param color The solid polygon color.
|
||||
* @js NA
|
||||
*/
|
||||
void drawSolidPoly(const Vec2* poli, unsigned int numberOfPoints, const Color4B& color);
|
||||
void drawSolidPoly(const Vec2* poli,
|
||||
unsigned int numberOfPoints,
|
||||
const Color4B& color,
|
||||
float thickness = 0,
|
||||
const Color4B& borderColor = Color4B(0, 0, 0, 0),
|
||||
bool isconvex = false);
|
||||
|
||||
/** Draws a solid circle given the center, radius and number of segments.
|
||||
* @param center The circle center point.
|
||||
|
@ -266,7 +353,7 @@ public:
|
|||
* @param scaleX The scale value in x.
|
||||
* @param scaleY The scale value in y.
|
||||
* @param fillColor The color will fill in polygon.
|
||||
* @param borderWidth The border of line width.
|
||||
* @param thickness The border of line width.
|
||||
* @param borderColor The border of line color.
|
||||
* @js NA
|
||||
*/
|
||||
|
@ -277,7 +364,7 @@ public:
|
|||
float scaleX,
|
||||
float scaleY,
|
||||
const Color4B& fillColor,
|
||||
float borderWidth,
|
||||
float thickness,
|
||||
const Color4B& borderColor);
|
||||
|
||||
/** Draws a solid circle given the center, radius and number of segments.
|
||||
|
@ -306,13 +393,35 @@ public:
|
|||
* @param color The solid circle color.
|
||||
* @js NA
|
||||
*/
|
||||
void drawSolidCircle(const Vec2& center,
|
||||
float radius,
|
||||
float angle,
|
||||
unsigned int segments,
|
||||
const Color4B& color);
|
||||
void drawSolidCircle(const Vec2& center, float radius, float angle, unsigned int segments, const Color4B& color);
|
||||
|
||||
/** Draws a pie given the center, radius, angle, start angle, end angle and number of segments.
|
||||
/** Draws a pie given the center, radius, angle, start angle, end angle and number of segments.
|
||||
* @param center The circle center point.
|
||||
* @param radius The circle rotate of radius.
|
||||
* @param angle The circle angle.
|
||||
* @param startAngle The start angle.
|
||||
* @param endAngle The end angle.
|
||||
* @param scaleX The scale value in x.
|
||||
* @param scaleY The scale value in y.
|
||||
* @param fillColor The solid circle color.
|
||||
* @param borderColor The borderColor.
|
||||
* @param DrawMode The draw mode
|
||||
* @js NA
|
||||
*/
|
||||
void drawPie(const Vec2& center,
|
||||
float radius,
|
||||
float rotation,
|
||||
int startAngle,
|
||||
int endAngle,
|
||||
float scaleX,
|
||||
float scaleY,
|
||||
const Color4B& fillColor,
|
||||
const Color4B& borderColor,
|
||||
DrawMode drawMode = DrawMode::Outline,
|
||||
float thickness = 1.0f);
|
||||
|
||||
// Cocos2dx/Axmol 1.0 API backwards compatibhility
|
||||
/** Draws a pie given the center, radius, angle, start angle, end angle and number of segments.
|
||||
* @param center The circle center point.
|
||||
* @param radius The circle rotate of radius.
|
||||
* @param angle The circle angle.
|
||||
|
@ -332,16 +441,27 @@ public:
|
|||
float scaleX,
|
||||
float scaleY,
|
||||
const Color4B& color,
|
||||
DrawMode drawMode);
|
||||
DrawMode drawMode = DrawMode::Outline);
|
||||
|
||||
/** draw a segment with a radius and color.
|
||||
void setIsConvex(bool isConvex)
|
||||
{
|
||||
AXLOGW("'setIsConvex()' No longer supported. Use the new drawPolygon API.");
|
||||
};
|
||||
|
||||
|
||||
/** draw a segment with a radius and color.
|
||||
*
|
||||
* @param from The segment origin.
|
||||
* @param to The segment destination.
|
||||
* @param radius The segment radius.
|
||||
* @param color The segment color.
|
||||
*/
|
||||
void drawSegment(const Vec2& from, const Vec2& to, float radius, const Color4B& color);
|
||||
void drawSegment(const Vec2& from,
|
||||
const Vec2& to,
|
||||
float radius,
|
||||
const Color4B& color,
|
||||
DrawNode::EndType etStart = DrawNode::EndType::Round,
|
||||
DrawNode::EndType etEnd = DrawNode::EndType::Round);
|
||||
|
||||
/** draw a polygon with a fill color and line color
|
||||
* @code
|
||||
|
@ -352,15 +472,25 @@ public:
|
|||
* @param verts A pointer to point coordinates.
|
||||
* @param count The number of verts measured in points.
|
||||
* @param fillColor The color will fill in polygon.
|
||||
* @param borderWidth The border of line width.
|
||||
* @param thickness The border of line width.
|
||||
* @param borderColor The border of line color.
|
||||
* @js NA
|
||||
*/
|
||||
void drawPolygon(const Vec2* verts,
|
||||
void drawPolygon(Vec2* verts,
|
||||
int count,
|
||||
const Color4B& fillColor,
|
||||
float borderWidth,
|
||||
const Color4B& borderColor);
|
||||
float thickness,
|
||||
const Color4B& borderColor,
|
||||
bool isconvex = false);
|
||||
|
||||
void drawPolygon(Vec2* verts, int count, float thickness, const Color4B& borderColor, bool isconvex = false);
|
||||
|
||||
void drawSolidPolygon(Vec2* verts,
|
||||
int count,
|
||||
const Color4B& fillColor,
|
||||
float thickness,
|
||||
const Color4B& borderColor,
|
||||
bool isconvex = false);
|
||||
|
||||
/** draw a triangle with color.
|
||||
*
|
||||
|
@ -371,7 +501,21 @@ public:
|
|||
* @js NA
|
||||
*/
|
||||
|
||||
void drawTriangle(const Vec2& p1, const Vec2& p2, const Vec2& p3, const Color4B& color);
|
||||
void drawTriangle(const Vec2* vertices3, const Color4B& color, float thickness = 1.0f);
|
||||
|
||||
void drawTriangle(const Vec2& p1, const Vec2& p2, const Vec2& p3, const Color4B& color, float thickness = 1.0f);
|
||||
|
||||
void drawSolidTriangle(const Vec2* vertices3,
|
||||
const Color4B& fillColor,
|
||||
const Color4B& borderColor,
|
||||
float thickness = 1.0f);
|
||||
|
||||
void drawSolidTriangle(const Vec2& p1,
|
||||
const Vec2& p2,
|
||||
const Vec2& p3,
|
||||
const Color4B& fillColor,
|
||||
const Color4B& borderColor,
|
||||
float thickness = 1.0f);
|
||||
|
||||
/** Clear the geometry in the node's buffer. */
|
||||
void clear();
|
||||
|
@ -394,12 +538,9 @@ public:
|
|||
virtual void visit(Renderer* renderer, const Mat4& parentTransform, uint32_t parentFlags) override;
|
||||
|
||||
void setLineWidth(float lineWidth);
|
||||
|
||||
// Get CocosStudio guide lines width.
|
||||
float getLineWidth();
|
||||
|
||||
void setIsConvex(bool isConvex) { _isConvex = isConvex; }; // Set backwards compatible with axmol 2.0
|
||||
|
||||
/**
|
||||
* When isolated is set, the position of the node is no longer affected by parent nodes.
|
||||
* Which means it will be drawn just like a root node.
|
||||
|
@ -413,9 +554,9 @@ public:
|
|||
virtual bool init() override;
|
||||
|
||||
protected:
|
||||
void ensureCapacity(int count);
|
||||
void ensureCapacityGLPoint(int count);
|
||||
void ensureCapacityGLLine(int count);
|
||||
void ensureCapacityTriangle(int count);
|
||||
void ensureCapacityPoint(int count);
|
||||
void ensureCapacityLine(int count);
|
||||
|
||||
void updateShader();
|
||||
void updateShaderInternal(CustomCommand& cmd,
|
||||
|
@ -432,38 +573,249 @@ protected:
|
|||
int _bufferCapacityTriangle = 0;
|
||||
int _bufferCountTriangle = 0;
|
||||
V2F_C4B_T2F* _bufferTriangle = nullptr;
|
||||
CustomCommand _customCommandTriangle;
|
||||
bool _dirtyTriangle = false;
|
||||
|
||||
int _bufferCapacityPoint = 0;
|
||||
int _bufferCountPoint = 0;
|
||||
V2F_C4B_T2F* _bufferPoint = nullptr;
|
||||
Color4F _pointColor;
|
||||
Color4B _pointColor;
|
||||
int _pointSize = 0;
|
||||
|
||||
int _bufferCapacityLine = 0;
|
||||
int _bufferCountLine = 0;
|
||||
V2F_C4B_T2F* _bufferLine = nullptr;
|
||||
|
||||
BlendFunc _blendFunc;
|
||||
|
||||
CustomCommand _customCommandTriangle;
|
||||
CustomCommand _customCommandPoint;
|
||||
CustomCommand _customCommandLine;
|
||||
bool _dirtyPoint = false;
|
||||
bool _dirtyLine = false;
|
||||
|
||||
BlendFunc _blendFunc;
|
||||
|
||||
bool _dirtyTriangle = false;
|
||||
bool _dirtyPoint = false;
|
||||
bool _dirtyLine = false;
|
||||
bool _isolated = false;
|
||||
float _lineWidth = 0.0f;
|
||||
float _defaultLineWidth = 0.0f;
|
||||
float _lineWidth = 1.0f;
|
||||
float _defaultLineWidth = 1.0f;
|
||||
|
||||
ax::any_buffer _abuf;
|
||||
any_buffer _abuf;
|
||||
|
||||
bool _isConvex = true;
|
||||
private:
|
||||
// Internal function _drawPoint
|
||||
void _drawPoint(const Vec2& position,
|
||||
const float pointSize,
|
||||
const Color4B& color,
|
||||
const DrawNode::PointType pointType);
|
||||
|
||||
// Internal function _drawPoints
|
||||
void _drawPoints(const Vec2* position,
|
||||
unsigned int numberOfPoints,
|
||||
const float pointSize,
|
||||
const Color4B& color,
|
||||
const DrawNode::PointType pointType);
|
||||
|
||||
// Internal function _drawDot
|
||||
void _drawDot(const Vec2& pos, float radius, const Color4B& color);
|
||||
|
||||
// Internal function _drawTriangle
|
||||
void _drawTriangle(const Vec2* vertices3,
|
||||
const Color4B& borderColor,
|
||||
const Color4B& fillColor,
|
||||
bool solid = true,
|
||||
float thickness = 0.0f);
|
||||
|
||||
// Internal function _drawAStar
|
||||
void _drawAStar(const Vec2& center,
|
||||
float radiusI,
|
||||
float radiusO,
|
||||
unsigned int segments,
|
||||
const Color4B& color,
|
||||
const Color4B& filledColor,
|
||||
float thickness = 1.0f,
|
||||
bool solid = false);
|
||||
|
||||
// Internal function _drawPoly
|
||||
void _drawPoly(const Vec2* poli,
|
||||
unsigned int numberOfPoints,
|
||||
bool closedPolygon,
|
||||
const Color4B& color,
|
||||
float thickness = 1.0f,
|
||||
bool isconvex = true);
|
||||
|
||||
// Internal function _drawPolygon
|
||||
void _drawPolygon(const Vec2* verts,
|
||||
unsigned int count,
|
||||
const Color4B& fillColor,
|
||||
const Color4B& borderColor,
|
||||
bool closedPolygon = true,
|
||||
float thickness = 1.0f,
|
||||
bool isconvex = true);
|
||||
|
||||
// Internal function _drawSegment
|
||||
void _drawSegment(const Vec2& origin,
|
||||
const Vec2& destination,
|
||||
const Color4B& color,
|
||||
float thickness = 1.0f,
|
||||
DrawNode::EndType etStart = DrawNode::EndType::Square,
|
||||
DrawNode::EndType etEnd = DrawNode::EndType::Square);
|
||||
|
||||
// Internal function _drawCircle
|
||||
void _drawCircle(const Vec2& center,
|
||||
float radius,
|
||||
float angle,
|
||||
unsigned int segments,
|
||||
bool drawLineToCenter,
|
||||
float scaleX,
|
||||
float scaleY,
|
||||
const Color4B& borderColor,
|
||||
const Color4B& fillColor,
|
||||
bool solid,
|
||||
float thickness = 1.0f);
|
||||
|
||||
// Internal function _drawPie
|
||||
void _drawPie(const Vec2& center,
|
||||
float radius,
|
||||
float rotation,
|
||||
int startAngle,
|
||||
int endAngle,
|
||||
float scaleX,
|
||||
float scaleY,
|
||||
const Color4B& fillColor,
|
||||
const Color4B& borderColor,
|
||||
DrawMode drawMode,
|
||||
float thickness = 1.0f);
|
||||
|
||||
/* Internal function _transform
|
||||
* @param vertices A Vec2 vertices list.
|
||||
* @param count The number of vertices.
|
||||
* @param closedPolygon The closedPolygon flag.
|
||||
* @js NA
|
||||
*/
|
||||
Vec2* _transform(const Vec2* vertices, unsigned int& count, bool closedPolygon = false);
|
||||
|
||||
private:
|
||||
AX_DISALLOW_COPY_AND_ASSIGN(DrawNode);
|
||||
};
|
||||
/** @} */
|
||||
}
|
||||
|
||||
#endif // __CCDRAWNODES_CCDRAW_NODE_H__
|
||||
public:
|
||||
class Properties
|
||||
{
|
||||
public:
|
||||
float factor = 0.5f; /// set the lineWidth like Axmol 1.0
|
||||
|
||||
// transforming stuff
|
||||
Vec2 scale;
|
||||
Vec2 center;
|
||||
float rotation;
|
||||
Vec2 position;
|
||||
|
||||
// Thickness stuff
|
||||
float lineWidth;
|
||||
float defaultLineWidth = 1.0f;
|
||||
|
||||
// Drawing flags
|
||||
bool transform = true;
|
||||
bool drawOrder = false;
|
||||
|
||||
/** Set the DrawNode drawOrder
|
||||
*
|
||||
* @param drawOrder. true/false = On/Off
|
||||
* Its for performance there
|
||||
* false = cocos2dx behaviour => faster but works only on 1.0f thickness
|
||||
|
||||
* @js NA
|
||||
*/
|
||||
void setDrawOrder(bool dO) { drawOrder = dO; };
|
||||
|
||||
/** Get the DrawNode drawOrder
|
||||
*
|
||||
* @js NA
|
||||
*/
|
||||
bool getDrawOrder(void) { return drawOrder; };
|
||||
|
||||
/** Set the DrawNode transform
|
||||
*
|
||||
* @param transform. true/false = On/Off
|
||||
*
|
||||
* @js NA
|
||||
*/
|
||||
void setTransform(bool t) { transform = t; };
|
||||
|
||||
/** Get the DrawNode transform
|
||||
*
|
||||
* @js NA
|
||||
*/
|
||||
bool getTransform(void) { return transform; };
|
||||
|
||||
/** Set the DrawNode scale for each drawing primitive after this.
|
||||
|
||||
* @js NA
|
||||
*/
|
||||
void setScale(Vec2 s) { scale = s; };
|
||||
|
||||
/** Set the DrawNode rotation for each drawing primitive after this.
|
||||
|
||||
* @js NA
|
||||
*/
|
||||
void setRotation(float r) { rotation = r; };
|
||||
|
||||
/** Get the DrawNode rotation for each drawing primitive after this.
|
||||
|
||||
* @js NA
|
||||
*/
|
||||
float getRotation() { return rotation; };
|
||||
|
||||
/** Set the DrawNode center of rotation for each drawing primitive after this.
|
||||
|
||||
* @js NA
|
||||
*/
|
||||
void setCenter(Vec2 c) { center = c; };
|
||||
|
||||
/** Get the DrawNode center of rotation for each drawing primitive after this.
|
||||
|
||||
* @js NA
|
||||
*/
|
||||
Vec2 getCenter() { return center; };
|
||||
|
||||
/** Set the DrawNode position for each drawing primitive after this.
|
||||
|
||||
* @js NA
|
||||
*/
|
||||
void setPosition(Vec2 p) { position = p; };
|
||||
|
||||
/** Get the DrawNode position for drawing primitive.
|
||||
|
||||
* @js NA
|
||||
*/
|
||||
Vec2 getPosition() { return position; };
|
||||
|
||||
/** Set the DrawNode line width for each drawing primitive after this.
|
||||
|
||||
* @js NA
|
||||
*/
|
||||
void setLineWidth(float lw) { lineWidth = lw; };
|
||||
|
||||
/** Get the DrawNode line width for each drawing primitive after this.
|
||||
|
||||
* @js NA
|
||||
*/
|
||||
float getLineWidth() { return lineWidth; };
|
||||
|
||||
/** Set all default DrawNode properties.
|
||||
|
||||
* @js NA
|
||||
*/
|
||||
void setDefaultValues()
|
||||
{
|
||||
scale = Vec2(1.0f, 1.0f);
|
||||
center = Vec2(0.0f, 0.0f);
|
||||
rotation = 0.0f;
|
||||
position = Vec2(0.0f, 0.0f);
|
||||
lineWidth = 1.0f;
|
||||
drawOrder = false;
|
||||
};
|
||||
} properties;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
} // namespace ax
|
||||
|
||||
#endif // __DRAW_NODE_EX_H__
|
||||
|
|
|
@ -139,8 +139,6 @@ cmake_dependent_option(AX_ENABLE_EXT_SDFGEN "Build extension SDFGen" ${AX_EXT_HI
|
|||
|
||||
option(AX_ENABLE_EXT_JSONDEFAULT "Build extension JSONDefault" ${AX_EXT_HINT})
|
||||
|
||||
option(AX_ENABLE_EXT_DRAWNODEEX "Build extension DrawNodeEx" ${AX_EXT_HINT})
|
||||
|
||||
set(_AX_THIRDPARTY_NAME "3rdparty" CACHE INTERNAL "" )
|
||||
|
||||
if (WIN32)
|
||||
|
|
|
@ -127,8 +127,4 @@ if(AX_ENABLE_EXT_JSONDEFAULT)
|
|||
add_subdirectory(JSONDefault)
|
||||
endif()
|
||||
|
||||
if(AX_ENABLE_EXT_DRAWNODEEX)
|
||||
add_subdirectory(DrawNodeEx)
|
||||
endif()
|
||||
|
||||
message(STATUS "Enabled ${_AX_CORE_LIB} extensions:${_AX_EXTENSION_LIBS}")
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
set(target_name DrawNodeEx)
|
||||
|
||||
FILE(GLOB_RECURSE DRAWNODEEX_SOURCES *.h;*.cpp;./**/*.h;./**/*.cpp)
|
||||
|
||||
add_library(${target_name} ${DRAWNODEEX_SOURCES})
|
||||
target_include_directories(${target_name} PUBLIC src)
|
||||
|
||||
setup_ax_extension_config(${target_name})
|
|
@ -5,11 +5,6 @@
|
|||
- Version: 4.5
|
||||
- License: MIT
|
||||
|
||||
## DrawNodeEx => DrawNodeV2
|
||||
- Upstream: https://github.com/axmolengine/axmol
|
||||
- Version: 0.95.1
|
||||
- License: MIT
|
||||
|
||||
## Effekseer (OFF default)
|
||||
- [![Upstream](https://img.shields.io/github/v/release/effekseer/Effekseer?label=Upstream)](https://github.com/effekseer/EffekseerForCocos2d-x)
|
||||
- https://github.com/effekseer/EffekseerForCocos2d-x
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -189,6 +189,8 @@ list(APPEND GAME_HEADER
|
|||
Source/ExtensionsTest/TableViewTest/TableViewTestScene.h
|
||||
Source/MeshRendererTest/MeshRendererTest.h
|
||||
Source/MeshRendererTest/DrawNode3D.h
|
||||
Source/DrawNodeTest/DrawNodeTest.h
|
||||
Source/DrawPrimitivesTest/DrawPrimitivesTest.h
|
||||
Source/BaseTest.h
|
||||
Source/SceneTest/SceneTest.h
|
||||
Source/ReleasePoolTest/ReleasePoolTest.h
|
||||
|
@ -221,7 +223,6 @@ list(APPEND GAME_HEADER
|
|||
Source/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h
|
||||
Source/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.h
|
||||
Source/UITest/CocoStudioGUITest/UITextTest/UITextTest.h
|
||||
Source/DrawPrimitivesTest/DrawPrimitivesTest.h
|
||||
Source/BillBoardTest/BillBoardTest.h
|
||||
Source/SpriteFrameCacheTest/SpriteFrameCacheTest.h
|
||||
Source/EffectsAdvancedTest/EffectsAdvancedTest.h
|
||||
|
@ -286,7 +287,6 @@ list(APPEND GAME_SOURCE
|
|||
Source/NetworkTest/DownloaderTest/DownloaderTest.cpp
|
||||
Source/NetworkTest/HttpClientTest/HttpClientTest.cpp
|
||||
Source/NetworkTest/WebSocketTest/WebSocketTest.cpp
|
||||
Source/DrawPrimitivesTest/DrawPrimitivesTest.cpp
|
||||
Source/EffectsAdvancedTest/EffectsAdvancedTest.cpp
|
||||
Source/EffectsTest/EffectsTest.cpp
|
||||
Source/ExtensionsTest/AssetsManagerExTest/AssetsManagerExTest.cpp
|
||||
|
@ -323,6 +323,8 @@ list(APPEND GAME_SOURCE
|
|||
Source/SpineTest/SpineTest.cpp
|
||||
# Source/Scene3DTest/Scene3DTest.cpp
|
||||
Source/MeshRendererTest/DrawNode3D.cpp
|
||||
Source/DrawNodeTest/DrawNodeTest.cpp
|
||||
Source/DrawPrimitivesTest/DrawPrimitivesTest.cpp
|
||||
Source/MeshRendererTest/MeshRendererTest.cpp
|
||||
Source/SpritePolygonTest/SpritePolygonTest.cpp
|
||||
Source/SpriteTest/SpriteTest.cpp
|
||||
|
@ -536,12 +538,6 @@ if (AX_ENABLE_EXT_EFFEKSEER)
|
|||
list(APPEND GAME_SOURCE Source/EffekseerTest/EffekseerTest.cpp)
|
||||
endif()
|
||||
|
||||
if (AX_ENABLE_EXT_DRAWNODEEX)
|
||||
list(APPEND GAME_HEADER Source/DrawNodeExTest/DrawNodeExTest.h)
|
||||
list(APPEND GAME_SOURCE Source/DrawNodeExTest/DrawNodeExTest.cpp)
|
||||
endif()
|
||||
|
||||
|
||||
list(APPEND GAME_SOURCE
|
||||
Source/UITest/CocoStudioGUITest/UIEditBoxTest.cpp
|
||||
)
|
||||
|
@ -571,9 +567,6 @@ if (AX_ENABLE_EXT_EFFEKSEER)
|
|||
target_compile_definitions(${APP_NAME} PRIVATE AX_ENABLE_EXT_EFFEKSEER=1)
|
||||
endif()
|
||||
|
||||
if (AX_ENABLE_EXT_DRAWNODEEX)
|
||||
target_compile_definitions(${APP_NAME} PRIVATE AX_ENABLE_EXT_DRAWNODE=1)
|
||||
endif()
|
||||
|
||||
# mark app resources
|
||||
ax_setup_app_config(${APP_NAME})
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,438 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md).
|
||||
|
||||
https://axmol.dev/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "axmol.h"
|
||||
#include "ui/CocosGUI.h"
|
||||
#include "../BaseTest.h"
|
||||
#include "2d/DrawNode.h"
|
||||
|
||||
DEFINE_TEST_SUITE(DrawNodeTests);
|
||||
|
||||
class DrawNodeBaseTest : public TestCase
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
enum sliderType
|
||||
{
|
||||
AngleStart = 0,
|
||||
AngleEnd,
|
||||
Rotation,
|
||||
Thickness,
|
||||
sliderTypeLast
|
||||
};
|
||||
enum drawMethodes
|
||||
{
|
||||
Line = 0,
|
||||
Rect,
|
||||
Circle,
|
||||
QuadBezier,
|
||||
CubicBezier,
|
||||
CardinalSpline,
|
||||
CatmullRom,
|
||||
Poly,
|
||||
Polygon,
|
||||
Dot,
|
||||
Point,
|
||||
Points,
|
||||
Triangle,
|
||||
Segment,
|
||||
SolidCircle,
|
||||
SolidPoly,
|
||||
SolidRect,
|
||||
Star,
|
||||
SolidStar,
|
||||
LAST
|
||||
};
|
||||
|
||||
std::string drawMethods[drawMethodes::LAST] = { "drawLine",
|
||||
"drawRect",
|
||||
"drawCircle",
|
||||
"drawQuadBezier",
|
||||
"drawCubicBezier",
|
||||
"drawCardinalSpline",
|
||||
"drawCatmullRom",
|
||||
"drawPoly",
|
||||
"drawPolygon",
|
||||
"drawDot",
|
||||
"drawPoint",
|
||||
"drawPoints",
|
||||
"drawTriangle",
|
||||
"drawSegment",
|
||||
"drawSolidCircle",
|
||||
"drawSolidPoly",
|
||||
"drawSolidRect",
|
||||
"drawStar",
|
||||
"drawSolidStar", };
|
||||
|
||||
public:
|
||||
|
||||
DrawNodeBaseTest();
|
||||
|
||||
void onChangedRadioButtonSelect(ax::ui::RadioButton* radioButton, ax::ui::RadioButton::EventType type);
|
||||
void listviewCallback(ax::Object* sender, ax::ui::ListView::EventType type);
|
||||
void setDrawOrder(Object* sender);
|
||||
void setTransform(Object* sender);
|
||||
|
||||
void update(float dt);
|
||||
|
||||
virtual std::string title() const override;
|
||||
void drawDirection(const ax::Vec2* vec, const int size, ax::Vec2 offset);
|
||||
|
||||
void initSliders();
|
||||
|
||||
void changeStartAngle(ax::Object* pSender, ax::ui::Slider::EventType type);
|
||||
void changeEndAngle(ax::Object* pSender, ax::ui::Slider::EventType type);
|
||||
void changeRotation(ax::Object* pSender, ax::ui::Slider::EventType type);
|
||||
void changeThickness(ax::Object* pSender, ax::ui::Slider::EventType type);
|
||||
|
||||
// using from https://github.com/intmainreturn00/AwesomeNode/
|
||||
void generateDataPoints();
|
||||
|
||||
ax::PointArray *pts = nullptr;
|
||||
ax::PointArray *pts2 = nullptr;
|
||||
float defY, defY2, dev;
|
||||
const int n = 50;
|
||||
const int grid = 10;
|
||||
const int margin = 20;
|
||||
ax::Size screen;
|
||||
ax::Vec2 sixth;
|
||||
|
||||
protected:
|
||||
|
||||
int _currentSeletedItemIndex = 0;
|
||||
|
||||
//UI stuff
|
||||
ax::ui::Slider* slider[sliderType::sliderTypeLast];
|
||||
ax::Label* sliderLabel[sliderType::sliderTypeLast];
|
||||
float sliderValue[sliderType::sliderTypeLast];
|
||||
|
||||
|
||||
ax::ui::RadioButtonGroup* _radioButtonGroup;
|
||||
ax::Layer* _uiLayer;
|
||||
ax::ui::Layout* _widget;
|
||||
int selectedRadioButton;
|
||||
|
||||
ax::MenuItemFont* menuItemDrawOrder;
|
||||
ax::MenuItemFont* menuItemTransform;
|
||||
|
||||
// DrawNode stuff
|
||||
ax::DrawNode* drawNode = nullptr;
|
||||
ax::DrawNode* drawNodeArray[10];
|
||||
|
||||
|
||||
// Window stuff
|
||||
ax::Vec2 origin;
|
||||
ax::Vec2 size;
|
||||
ax::Vec2 center;
|
||||
};
|
||||
|
||||
class DrawNodePictureTest : public DrawNodeBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(DrawNodePictureTest);
|
||||
|
||||
DrawNodePictureTest();
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
void update(float dt) override;
|
||||
|
||||
private:
|
||||
ax::any_buffer _abuf;
|
||||
};
|
||||
|
||||
class DrawNodeMorphTest_SolidPolygon : public DrawNodeBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(DrawNodeMorphTest_SolidPolygon);
|
||||
|
||||
DrawNodeMorphTest_SolidPolygon();
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
void update(float dt);
|
||||
void onEnter();
|
||||
|
||||
private:
|
||||
ax::Vec2* verticesObj1[10];
|
||||
ax::Vec2* verticesObj2[10];
|
||||
ax::Vec2* verticesObjMorph[10];
|
||||
ax::Color4F color[10];
|
||||
float rad[10];
|
||||
bool state[10];
|
||||
|
||||
int segments = 40;
|
||||
};
|
||||
|
||||
class DrawNodeMorphTest_Polygon : public DrawNodeBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(DrawNodeMorphTest_Polygon);
|
||||
|
||||
DrawNodeMorphTest_Polygon();
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
void update(float dt);
|
||||
void onEnter();
|
||||
|
||||
private:
|
||||
ax::Vec2* verticesObj1[10];
|
||||
ax::Vec2* verticesObj2[10];
|
||||
ax::Vec2* verticesObjMorph[10];
|
||||
ax::Color4F color[10];
|
||||
float rad[10];
|
||||
bool state[10];
|
||||
|
||||
int segments = 40;
|
||||
};
|
||||
|
||||
class DrawNodeThicknessTest : public DrawNodeBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(DrawNodeThicknessTest);
|
||||
|
||||
DrawNodeThicknessTest();
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
void update(float dt);
|
||||
void onEnter();
|
||||
|
||||
private:
|
||||
// ax::Label* _lineWidthLabel;
|
||||
// float lineWidth = 0;
|
||||
ax::Label* _thicknessLabel;
|
||||
float thickness = 1.0f;
|
||||
};
|
||||
|
||||
class DrawNodeVersionsTest : public DrawNodeBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(DrawNodeVersionsTest);
|
||||
|
||||
DrawNodeVersionsTest();
|
||||
void drawDirection(const ax::Vec2* vec, const int size, ax::Vec2 offset);
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
void update(float dt) override;
|
||||
|
||||
private:
|
||||
ax::Vec2 center;
|
||||
};
|
||||
|
||||
class DrawNodeFilledPolygonTest : public DrawNodeBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(DrawNodeFilledPolygonTest);
|
||||
|
||||
DrawNodeFilledPolygonTest();
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
||||
class DrawNodePieTest : public DrawNodeBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(DrawNodePieTest);
|
||||
|
||||
DrawNodePieTest();
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
void update(float dt);
|
||||
void onEnter();
|
||||
|
||||
};
|
||||
|
||||
class DrawNodeMethodsTest : public DrawNodeBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(DrawNodeMethodsTest);
|
||||
|
||||
DrawNodeMethodsTest();
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
void update(float dt);
|
||||
void onEnter();
|
||||
|
||||
void drawAll();
|
||||
|
||||
private:
|
||||
ax::ui::ListView* createListView();
|
||||
|
||||
ax::Vec2* verticess;
|
||||
|
||||
int count = 1;
|
||||
|
||||
ax::Label* labelRound;
|
||||
ax::Label* labelSquare;
|
||||
ax::Label* labelButt;
|
||||
|
||||
ax::ui::RadioButtonGroup* _radioButtonGroup;
|
||||
int selectedRadioButton;
|
||||
};
|
||||
|
||||
|
||||
class DrawNodeDrawInWrongOrder_Issue1888 : public DrawNodeBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(DrawNodeDrawInWrongOrder_Issue1888);
|
||||
|
||||
DrawNodeDrawInWrongOrder_Issue1888();
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
void update(float dt) override;
|
||||
|
||||
private:
|
||||
ax::Vec2* heart;
|
||||
const int totalFrames = 240;
|
||||
ax::any_buffer _abuf;
|
||||
};
|
||||
|
||||
class DrawNodeAxmolTest2 : public DrawNodeBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(DrawNodeAxmolTest2);
|
||||
|
||||
DrawNodeAxmolTest2();
|
||||
void onChangedRadioButtonSelect(ax::ui::RadioButton* radioButton, ax::ui::RadioButton::EventType type);
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
void update(float dt);
|
||||
void drawAllv2(ax::DrawNode* drawNode, bool drawOrder);
|
||||
void drawAllv1(ax::DrawNode* drawNode);
|
||||
|
||||
private:
|
||||
ax::Vec2 s;
|
||||
|
||||
ax::ui::RadioButtonGroup* _radioButtonGroup;
|
||||
int selectedRadioButton;
|
||||
};
|
||||
|
||||
class DrawNodeIssueTester : public DrawNodeBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(DrawNodeIssueTester);
|
||||
|
||||
DrawNodeIssueTester();
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
void update(float dt);
|
||||
void onEnter();
|
||||
|
||||
void changeThreshold(Object* pSender, ax::ui::Slider::EventType type);
|
||||
void changeLineWidth(Object* pSender, ax::ui::Slider::EventType type);
|
||||
|
||||
private:
|
||||
ax::Label* _lineWidthLabel;
|
||||
float lineWidth = 0;
|
||||
ax::Label* _thresholdLabel;
|
||||
float threshold = 0;
|
||||
};
|
||||
|
||||
|
||||
class DrawNodeThicknessStressTest : public DrawNodeBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(DrawNodeThicknessStressTest);
|
||||
|
||||
DrawNodeThicknessStressTest();
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
void update(float dt);
|
||||
void onEnter();
|
||||
|
||||
void changeThreshold(Object* pSender, ax::ui::Slider::EventType type);
|
||||
void changeLineWidth(Object* pSender, ax::ui::Slider::EventType type);
|
||||
|
||||
private:
|
||||
ax::Label* _lineWidthLabel;
|
||||
float lineWidth = 0;
|
||||
ax::Label* _thresholdLabel;
|
||||
float threshold = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class DrawNodeSpLinesTest : public DrawNodeBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(DrawNodeSpLinesTest);
|
||||
|
||||
DrawNodeSpLinesTest();
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
void onTouchesEnded(const std::vector<ax::Touch*>& touches, ax::Event* event);
|
||||
void addNewControlPoint(ax::Vec2 p);
|
||||
void update(float dt);
|
||||
|
||||
private:
|
||||
ax::DrawNode* drawNodeCP = nullptr;
|
||||
std::vector<ax::Vec2> points;
|
||||
ax::PointArray* array;
|
||||
};
|
||||
|
||||
#if defined(AX_PLATFORM_PC)
|
||||
class CandyMixEeffect : public DrawNodeBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(CandyMixEeffect);
|
||||
|
||||
CandyMixEeffect();
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
void update(float dt);
|
||||
void renderLine(float x1, float x2, float y, ax::Color4F color, float angle);
|
||||
|
||||
private:
|
||||
std::vector<ax::Vec2> points;
|
||||
ax::PointArray* array;
|
||||
|
||||
ax::ui::RadioButtonGroup* _radioButtonGroup;
|
||||
int selectedRadioButton;
|
||||
};
|
||||
#endif
|
|
@ -234,6 +234,7 @@ DrawNodeBackwardsAPITest::DrawNodeBackwardsAPITest()
|
|||
Vec2 vertices[4];
|
||||
drawNode1->setScale(0.5);
|
||||
Color4F color;
|
||||
bool setIsConvex = false;
|
||||
for (int iy = 0; iy < 5; iy++)
|
||||
{
|
||||
x = 0;
|
||||
|
@ -247,14 +248,16 @@ DrawNodeBackwardsAPITest::DrawNodeBackwardsAPITest()
|
|||
if (AXRANDOM_0_1() > 0.5f)
|
||||
{
|
||||
drawNode1->setIsConvex(true);
|
||||
setIsConvex = true;
|
||||
color = Color4F::YELLOW;
|
||||
}
|
||||
else
|
||||
{
|
||||
drawNode1->setIsConvex(false); // default value!
|
||||
setIsConvex = false;
|
||||
color = Color4F::ORANGE;
|
||||
}
|
||||
drawNode1->drawPolygon(vertices, 4, Color4F(0.7f, 0.7f, 0.7f, 0.5f), 1, color);
|
||||
drawNode1->drawPolygon(vertices, 4, Color4F(0.7f, 0.7f, 0.7f, 0.5f), 1, color, setIsConvex);
|
||||
x += 70;
|
||||
}
|
||||
y += 80;
|
||||
|
|
|
@ -46,10 +46,6 @@ public:
|
|||
# pragma message("The optional extension Effekseer is enabled.")
|
||||
addTest("Effekseer", []() { return new EffekseerTests(); });
|
||||
#endif
|
||||
#if defined(AX_ENABLE_EXT_DRAWNODE)
|
||||
# pragma message("The optional extension DrawNodeEx is enabled.")
|
||||
addTest("DrawNodeEx", []() { return new DrawNodeExTests(); });
|
||||
#endif
|
||||
// addTest("Node: Scene3D", [](){return new Scene3DTests(); });
|
||||
#if defined(AX_PLATFORM_PC) || (AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID) || defined(__EMSCRIPTEN__)
|
||||
addTest("ImGui", []() { return new ImGuiTests(); });
|
||||
|
@ -92,7 +88,8 @@ public:
|
|||
addTest("Node: BillBoard Test", []() { return new BillBoardTests(); });
|
||||
addTest("Node: Camera3D Test", []() { return new Camera3DTests(); });
|
||||
addTest("Node: Clipping", []() { return new ClippingNodeTests(); });
|
||||
addTest("Node: Draw", []() { return new DrawPrimitivesTests(); });
|
||||
addTest("Node: Draw", []() { return new DrawNodeTests(); });
|
||||
addTest("Node: Draw (cocos2dx)", []() { return new DrawPrimitivesTests(); });
|
||||
addTest("Node: Label - New API", []() { return new NewLabelTests(); });
|
||||
addTest("Node: Layer", []() { return new LayerTests(); });
|
||||
addTest("Node: Light", []() { return new LightTests(); });
|
||||
|
|
|
@ -72,12 +72,8 @@
|
|||
#include "CurrentLanguageTest/CurrentLanguageTest.h"
|
||||
#include "DataVisitorTest/DataVisitorTest.h"
|
||||
#include "NetworkTest/NetworkTest.h"
|
||||
#include "DrawNodeTest/DrawNodeTest.h"
|
||||
#include "DrawPrimitivesTest/DrawPrimitivesTest.h"
|
||||
|
||||
#if defined(AX_ENABLE_EXT_DRAWNODE)
|
||||
#include "DrawNodeExTest/DrawNodeExTest.h"
|
||||
#endif
|
||||
|
||||
#include "EffectsAdvancedTest/EffectsAdvancedTest.h"
|
||||
#include "EffectsTest/EffectsTest.h"
|
||||
#include "ExtensionsTest/ExtensionsTest.h"
|
||||
|
|
|
@ -170,10 +170,6 @@ if (AX_ENABLE_EXT_EFFEKSEER)
|
|||
target_compile_definitions(${APP_NAME} PRIVATE AX_ENABLE_EXT_EFFEKSEER=1)
|
||||
endif()
|
||||
|
||||
if (AX_ENABLE_EXT_DRAWNODEEX)
|
||||
target_compile_definitions(${APP_NAME} PRIVATE AX_ENABLE_EXT_DRAWNODE=1)
|
||||
endif()
|
||||
|
||||
# mark app resources
|
||||
ax_setup_app_config(${APP_NAME} CONSOLE)
|
||||
|
||||
|
|
Loading…
Reference in New Issue