3ds Max Plugins
DataBlock class for reading and writing hierarchically structured data.
Defines
-
INLINE
Typedefs
-
typedef float real
-
class DataBlock
- #include <datablk.h>
Class for reading and writing hierarchically structured data.
DataBlock itself is a node of the tree that has a name and hosts typified named parameters and named sub-nodes.
For clarity, names are restricted to C indentifier rules.
Actual names are stored in NameMap that is shared by all DataBlocks in the tree. Blocks and parameters use integer ids to address names in the NameMap, so there are methods that take name ids and those that take character strings. You can use name ids when you look for blocks or parameters for performance gain.
DataBlock tree contents can be serialized in text form.
Text files of this format usually have extension “.blk”.
Loading
-
bool loadText(char *text, int text_length, const char *filename = NULL)
Load DataBlock tree from specified text. Filename is for error output only.
-
bool loadText(std::string &text, const char *filename = NULL)
Load DataBlock tree from specified text. Filename is for error output only.
Note
This method will modify text when including files.
Saving
Names
Block Name
Sub-blocks
-
DataBlock *getBlockByName(int name_id, int start_after = -1) const
Returns pointer to sub-block with specified name id, or NULL if not found.
-
inline DataBlock *getBlockByName(const char *name, int start_after = -1) const
Returns pointer to sub-block with specified name, or NULL if not found.
-
inline DataBlock *getBlockByNameEx(const char *name, DataBlock *def_blk) const
Get sub-block by name, returns def_blk, if not found.
-
inline DataBlock *getBlockByNameEx(const char *name) const
Get block by name, returns (always valid) emptyBlock, if not found.
-
DataBlock *addBlock(const char *name)
Add block or get existing one. See also addNewBlock() and getBlockByNameEx(const char *name) const.
-
DataBlock *addNewBlock(const char *name)
Add new block. See also addBlock().
-
void setParamsFrom(const DataBlock *copy_from)
Copies all parameters (not sub-blocks!) from specified DataBlock.
-
DataBlock *addNewBlock(const DataBlock *copy_from, const char *as_name = NULL)
Create new block as a copy of specified DataBlock, with copy of all its sub-tree.
-
bool removeBlock(const char *name)
Remove all sub-blocks with specified name. Returns false if no sub-blocks were removed.
-
inline DataBlock *setBlock(const DataBlock *blk, const char *as_name = NULL)
Similar to addNewBlock(const DataBlock *copy_from, const char *as_name), but removes existing sub-blocks with the same name first.
Parameters - Getting and Enumeration
-
int getParamNameId(int param_number) const
Returns i-th parameter name id. See getNameId().
-
inline const char *getParamName(int param_number) const
Returns i-th parameter name. Uses getName().
-
int findParam(int name_id, int start_after = -1) const
Find parameter by name id. Returns parameter index or -1 if not found.
-
inline int findParam(const char *name, int start_after = -1) const
Find parameter by name. Uses getNameId(). Returns parameter index or -1 if not found.
-
inline bool paramExists(int name_id, int start_after = -1) const
Returns true if there is parameter with specified name id in this DataBlock.
Parameters - Getting by Index
These methods get parameter value by parameter index in the block, the index number is from 0 to paramCount() -1.
On parameter type mismatch, zero-like value is returned.
Use them for enumerating parameters together with DataBlock::getParamNameId() / DataBlock::getParamName() and DataBlock::getParamType().
-
const char *getStr(int param_number, const char *def = "") const
-
bool getBool(int param_number, bool def = false) const
-
int getInt(int param_number, int def = 0) const
-
Point2 getPoint2(int param_number, const Point2 &def = Point2(0, 0)) const
-
Point3 getPoint3(int param_number, const Point3 &def = Point3(0, 0, 0)) const
-
Point4 getPoint4(int param_number, const Point4 &def = Point4(0, 0, 0, 0)) const
-
IPoint2 getIPoint2(int param_number, const IPoint2 &def = IPoint2(0, 0)) const
-
IPoint3 getIPoint3(int param_number, const IPoint3 &def = IPoint3(0, 0, 0)) const
-
E3DCOLOR getE3dcolor(int param_number, const E3DCOLOR &def = E3DCOLOR(0, 0, 0, 0)) const
Parameters - Getting by Name
These methods get parameter value by parameter name.
If there is no parameter with specified name in this DataBlock, or it has different type, default value is returned.
If there is more than one matching parameter, value of the first one is returned.
-
const char *getStr(const char *name, const char *def) const
-
bool getBool(const char *name, bool def) const
-
int getInt(const char *name, int def) const
-
Point2 getPoint2(const char *name, const Point2 &def) const
-
Point3 getPoint3(const char *name, const Point3 &def) const
-
Point4 getPoint4(const char *name, const Point4 &def) const
-
IPoint2 getIPoint2(const char *name, const IPoint2 &def) const
-
IPoint3 getIPoint3(const char *name, const IPoint3 &def) const
-
E3DCOLOR getE3dcolor(const char *name, const E3DCOLOR &def) const
Parameters - Setting
These methods set value of the parameter with the specified name.
If parameter of requested type doesn’t exist, it’s added, otherwise its value is set to the specified one.
-
int setStr(const char *name, const char *value)
-
int setBool(const char *name, bool value)
-
int setInt(const char *name, int value)
-
int setPoint2(const char *name, const Point2 &value)
-
int setPoint3(const char *name, const Point3 &value)
-
int setPoint4(const char *name, const Point4 &value)
-
int setIPoint2(const char *name, const IPoint2 &value)
-
int setIPoint3(const char *name, const IPoint3 &value)
-
int setE3dcolor(const char *name, const E3DCOLOR value)
Parameters - Adding
These methods add new parameter with the specified name.
It’s possible to add multiple parameters with the same name and type.
If you want just to add / set single parameter value, use set* methods.
-
int addStr(const char *name, const char *value)
-
int addBool(const char *name, bool value)
-
int addInt(const char *name, int value)
-
int addPoint2(const char *name, const Point2 &value)
-
int addPoint3(const char *name, const Point3 &value)
-
int addPoint4(const char *name, const Point4 &value)
-
int addIPoint2(const char *name, const IPoint2 &value)
-
int addIPoint3(const char *name, const IPoint3 &value)
-
int addE3dcolor(const char *name, const E3DCOLOR value)
Parameters - Removing
-
bool removeParam(const char *name)
Remove all parameters with the specified name. Returns false if no parameters were removed.
Public Types
-
enum class ParamType
Parameter types enum.
Values:
-
enumerator TYPE_NONE
-
enumerator TYPE_STRING
Text string.
-
enumerator TYPE_INT
Integer.
-
enumerator TYPE_POINT2
Point2.
-
enumerator TYPE_POINT3
Point3.
-
enumerator TYPE_POINT4
Point4.
-
enumerator TYPE_IPOINT2
IPoint2.
-
enumerator TYPE_IPOINT3
IPoint3.
-
enumerator TYPE_BOOL
Boolean.
-
enumerator TYPE_E3DCOLOR
E3DCOLOR.
-
enumerator TYPE_NONE
Private Functions
-
struct Param
- #include <datablk.h>
Public Functions
-
Param(int id, const std::string &s)
-
Param(int id, int i)
-
Param(int id, const Point2 &p2)
-
Param(int id, const Point3 &p3)
-
Param(int id, const Point4 &p4)
-
Param(int id, const IPoint2 &ip2)
-
Param(int id, const IPoint3 &ip3)
-
Param(int id, bool b)
-
Param(int id, const E3DCOLOR &c)
-
~Param()
-
const char *as_c_str() const
-
int as_int() const
-
const Point2 &as_pt2() const
-
const Point3 &as_pt3() const
-
const Point4 &as_pt4() const
-
const IPoint2 &as_ipt2() const
-
const IPoint3 &as_ipt3() const
-
bool as_bool() const
-
const E3DCOLOR &as_color() const
-
void set_str(const std::string &s)
-
void set_int(int i)
-
void set_pt2(const Point2 &p2)
-
void set_pt3(const Point3 &p3)
-
void set_pt4(const Point4 &p4)
-
void set_ipt2(const IPoint2 &ip2)
-
void set_ipt3(const IPoint3 &ip3)
-
void set_bool(bool b)
-
void set_color(const E3DCOLOR &c)
-
Param(int id, const std::string &s)
-
bool loadText(char *text, int text_length, const char *filename = NULL)
Warning
doxygenfile: Cannot find file “e3DCOLOR.H
common classes and functions for 2D, 3D and 4D math
-
class Matrix33
- #include <math3d.h>
-
class TMatrix
- #include <math3d.h>
4x3 transformation matrix. last column (3rd, counting from zero) is translation
See also
Matrix3 TMatrix4 Point3 Point2 Point4
-
class BBox2
- #include <math3d.h>
-
class BBox3
- #include <math3d.h>
-
class StaticMeshRayTracer
- #include <math3d.h>
Subclassed by StaticMeshRTracer
-
class NameMap
- #include <namemap.h>
Public Functions
-
inline NameMap()
-
inline ~NameMap()
-
void clear()
Clear name list.
-
inline int nameCount() const
Number of names in list. You can get them all by iterating from 0 to nameCount()-1.
-
const char *getName(int i) const
Returns NULL when name_id is invalid.
-
int getNameId(const char *name) const
Returns -1 if not found.
-
int addNameId(const char *name)
Returns -1 if NULL. Adds name to the list if not found.
-
inline NameMap()
Warning
doxygenfile: Cannot find file “str.H