3ds Max Plugins

Functions

DataBlock::ParamType type(const DataBlock::Param &p)
class DataBlock
#include <datablk.h>

DataBlock class for reading and writing hierarchically structured data.

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”.

Public Types

enum class ParamType

Values:

enumerator TYPE_NONE
enumerator TYPE_STRING

Text string.

enumerator TYPE_INT

Integer.

enumerator TYPE_REAL

real (float).

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_MATRIX

TMatrix.

using Param = std::variant<std::string, int, real, Point2, Point3, Point4, IPoint2, IPoint3, bool, E3DCOLOR, TMatrix>

Public Functions

DataBlock(std::shared_ptr<NameMap> nameMap)
~DataBlock() = default
DataBlock(const DataBlock&) = delete
DataBlock &operator=(const DataBlock&) = delete
void clearData()

Delete all sub-blocks.

void reset()

Reset DataBlock object (clear all data & names).

bool loadText(const 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.

bool loadFromStream(std::ifstream &is, const char *fname = NULL)

Load DataBlock tree from arbitrary stream Data may be presented like text, binary or stream data created by function beginTaggedBlock(_MAKE4C(‘blk’)) fname uses if loading from text file to right parse include directives

bool load(const std::filesystem::path &fname)

Load DataBlock tree from a text file.

bool saveToTextFile(const std::filesystem::path &filename) const

Save this DataBlock (and its sub-tree) to the specified file (text form)

int getNameId(const char *name) const

Returns name id from NameMap, or -1 if there’s no such name in the NameMap.

const char *getName(int name_id) const

Returns name by name id, uses NameMap. Returns NULL if name id is not valid.

inline int getBlockNameId() const

Returns name id of this DataBlock.

inline const char *getBlockName() const

Returns name of this DataBlock.

inline int blockCount() const

Returns number of sub-blocks in this DataBlock. Use for enumeration.

DataBlock *getBlock(int block_number) const

Returns pointer to i-th sub-block.

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 int paramCount() const

Returns number of parameters in this DataBlock. Use for enumeration.

ParamType getParamType(int param_number) const

Returns type of i-th parameter. See ParamType enum.

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(const char *name, int start_after = -1) const

Returns true if there is parameter with specified name in this DataBlock.

std::optional<std::reference_wrapper<const Param>> getParam(int param_number) const
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
real getReal(int param_number, real def = 0.f) const
Point3 getPoint3(int param_number, const Point3 &def = Point3(0, 0, 0)) const
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
real getReal(const char *name, real def) const
Point3 getPoint3(const char *name, const Point3 &def) const
int setStr(const char *name, const char *value)
int setBool(const char *name, bool value)
int setInt(const char *name, int value)
int setReal(const char *name, real value)
int setPoint3(const char *name, const Point3 &value)
int addStr(const char *name, const char *value)
int addBool(const char *name, bool value)
int addInt(const char *name, int value)
int addReal(const char *name, real value)
int addPoint3(const char *name, const Point3 &value)

Public Static Functions

static ParamType deserialize_param_type(std::string_view s)

Protected Functions

void setBlockName(const char *name)
int addBlock(std::unique_ptr<DataBlock>)
int addParam(const char *name, ParamType type, const char *value, int line, const char *filename)
void saveText(std::ofstream &os, int level = 0) const

Save this DataBlock (and its sub-tree) in the text form. level is used for text indentation.

Protected Attributes

std::shared_ptr<NameMap> nameMap
int nameId
std::vector<std::unique_ptr<DataBlock>> blocks
std::vector<Param> params
std::vector<int> nameIds

Friends

friend class DataBlockParser

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

NameMap() = default
NameMap(const NameMap&) = delete
NameMap &operator=(const NameMap&) = delete
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.

Private Members

std::unordered_map<std::string, int, CaseInsensitiveHash, CaseInsensitiveEqual> s2i
std::vector<const char*> names

Warning

doxygenfile: Cannot find file “str.H