1 | /**************************************************************************************** |
2 | |
3 | Copyright (C) 2015 Autodesk, Inc. |
4 | All rights reserved. |
5 | |
6 | Use of this software is subject to the terms of the Autodesk license agreement |
7 | provided at the time of installation or download, or which otherwise accompanies |
8 | this software in either electronic or hard copy form. |
9 | |
10 | ****************************************************************************************/ |
11 | |
12 | //! \file fbxline.h |
13 | #ifndef _FBXSDK_SCENE_GEOMETRY_LINE_H_ |
14 | #define _FBXSDK_SCENE_GEOMETRY_LINE_H_ |
15 | |
16 | #include <fbxsdk/fbxsdk_def.h> |
17 | |
18 | #include <fbxsdk/core/base/fbxarray.h> |
19 | #include <fbxsdk/scene/geometry/fbxgeometry.h> |
20 | |
21 | #include <fbxsdk/fbxsdk_nsbegin.h> |
22 | |
23 | /** A line is a geometry made of points. To be different from curves(nurbs, etc), line is linear. |
24 | * The class can define a line with as many points as needed. The line can also represent line segments, which means there will be gaps among points. |
25 | * To denote line segments and these gaps, certain points could be marked as end points. That's why we supply an index array(mPointArray) and an end point array(mEndPointArray). |
26 | * To mark a point as end point, we add its index(of mPointArray) to mEndPointArray. |
27 | * \nosubgrouping |
28 | * Methods to initialize, set and access control points are provided in the FbxGeometryBase class. |
29 | * To initialize control point count, please use FbxLine::InitControlPoints(int pCount). |
30 | * To set a control point, please use FbxLine::SetControlPointAt(const FbxVector4 &pCtrlPoint , int pIndex). |
31 | * To get control point count, please use FbxLine::GetControlPointsCount(). |
32 | * To get a control point, please use FbxLine::GetControlPointAt(int pIndex). The pIndex could be returned by GetPointIndexAt(i). |
33 | */ |
34 | class FBXSDK_DLL FbxLine : public FbxGeometry |
35 | { |
36 | FBXSDK_OBJECT_DECLARE(FbxLine, FbxGeometry); |
37 | |
38 | public: |
39 | /** Return the type of node attribute. |
40 | * \return Return the type of this node attribute which is \e EType::eLine. |
41 | */ |
42 | virtual FbxNodeAttribute::EType GetAttributeType() const; |
43 | |
44 | /** Reset the line to default values. |
45 | * Frees and set to \c NULL all layers and clear the control point array, the index array and end points array. |
46 | */ |
47 | void Reset(); |
48 | |
49 | /** Sets the size of index array(mPointArray). |
50 | * \param pCount Specify the size of mPointArray. |
51 | */ |
52 | void SetIndexArraySize(int pCount); |
53 | |
54 | /** Return the size of index array(mPointArray). |
55 | * \return The number of points defined for this line. |
56 | */ |
57 | int GetIndexArraySize() const; |
58 | |
59 | /** Get the pointer to the index array. |
60 | * \return the pointer to the index array(mPointArray). |
61 | */ |
62 | inline FbxArray<int>* GetIndexArray() { return &mPointArray;} |
63 | |
64 | /** Sets index array(mPointArray) at a specified index. |
65 | * \param pValue An index to a control point. Its range is from 0 to count of control point. |
66 | * \param pIndex The specified index to mPointArray. Its range is from 0 to size of mPointArray. |
67 | * \param pAsEndPoint Mark current point as end point or not. If pAsEndPoint is true, pIndex will be automatically added to mEndPointArray. |
68 | * \return True on success, false on failure if pIndex is out of range. |
69 | */ |
70 | bool SetPointIndexAt(int pValue, int pIndex, bool pAsEndPoint = false); |
71 | |
72 | /** Gets the point index(i.e: an index to a control point) at the specified index. |
73 | * \param pIndex The specified index to the point index array(mPointArray). Its range is from 0 to size of mPointArray. |
74 | * \return Return the index to the table of the control points. If pIndex is out of range, it will return -1. |
75 | */ |
76 | int GetPointIndexAt(int pIndex) const; |
77 | |
78 | /** Adds a point to the index array (mPointArray). |
79 | * \param pValue The index to a control point. Its range is from 0 to count of control point. |
80 | * \param pAsEndPoint Mark current point as end point or not. If pAsEndPoint is true, current point index will be automatically added to mEndPointArray. |
81 | * \return True on success, false on failure if pValue is out of range. |
82 | */ |
83 | bool AddPointIndex(int pValue, bool pAsEndPoint = false); |
84 | |
85 | /** Get the pointer to the end point array. |
86 | * \return the pointer to the end points array(mEndPointArray). |
87 | */ |
88 | inline FbxArray<int>* GetEndPointArray() { return &mEndPointArray;} |
89 | |
90 | /** Adds a point index to the end point array (mEndPointArray). |
91 | * To mark it as end point, its index to mPointArray will be added to mEndPointArray. |
92 | * \param pPointIndex The specified index to the point index array(mPointArray). Its range is from 0 to size of mPointArray. |
93 | * \return True on success, false on failure if pPointIndex is out of range. |
94 | * \remarks The point index in mEndPointArray should be incremental, otherwise, it will return false. |
95 | * To add pPointIndex, mEndPointArray will be automatically appended and resized. You never have to set count or resize for mEndPointArray. |
96 | * Below is the code sample: |
97 | * \code |
98 | * int lIndexCount = lLine->GetIndexArraySize(); |
99 | * for(int i = 0; i < lIndexCount; i++) |
100 | * { |
101 | * if(i%2 == 1) |
102 | * { |
103 | * lLine->AddEndPoint(i); |
104 | * } |
105 | * } |
106 | * \endcode |
107 | */ |
108 | bool AddEndPoint(int pPointIndex); |
109 | |
110 | /** Gets the point index(an index to the point index array) at the specified index. |
111 | * \param pEndPointIndex The specified index to the end points array(mEndPointArray). Its range is from 0 to size of mEndPointArray. |
112 | * \return Return the index to the point index array(mPointArray). If pEndPointIndex is out of range, it will return -1. |
113 | * \remarks Below is the code sample: |
114 | * \code |
115 | * int lEndPointsCount = lLine->GetEndPointCount(); |
116 | * for (int j = 0; j < lEndPointsCount; j++) |
117 | * { |
118 | * //Get the index to the index array. |
119 | * int lEndIndex = lLine->GetEndPointAt(j); |
120 | * // to get the control point index of the end point |
121 | * int lControlPointIndex = lLine->GetPointIndexAt(lEndIndex); |
122 | * } |
123 | * \endcode |
124 | */ |
125 | int GetEndPointAt(int pEndPointIndex) const; |
126 | |
127 | /** Query the number of end points. |
128 | * \return Return the size of end point array(mEndPointArray). |
129 | */ |
130 | int GetEndPointCount() const; |
131 | |
132 | /** This property decide whether this line is renderable in 3DSMax. |
133 | * Lines from Maya are not renderable by default. |
134 | */ |
135 | FbxPropertyT<FbxBool> Renderable; |
136 | |
137 | /***************************************************************************************************************************** |
138 | ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! ** |
139 | *****************************************************************************************************************************/ |
140 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
141 | virtual FbxObject& Copy(const FbxObject& pObject); |
142 | |
143 | protected: |
144 | virtual void Construct(const FbxObject* pFrom); |
145 | virtual void ConstructProperties(bool pForceSet); |
146 | virtual void Destruct(bool pRecursive); |
147 | |
148 | private: |
149 | FbxArray<int> mPointArray; |
150 | FbxArray<int> mEndPointArray; |
151 | #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/ |
152 | }; |
153 | |
154 | #include <fbxsdk/fbxsdk_nsend.h> |
155 | |
156 | #endif /* _FBXSDK_SCENE_GEOMETRY_LINE_H_ */ |
157 | |