「利用者:Ansimionescu/Notes/2」の版間の差分
(→Pointers) |
細 (1版 をインポートしました) |
(相違点なし)
|
2018年6月29日 (金) 05:49時点における最新版
Data API: RNA
The data API is a layer over the DNA structs, abstracting how the data is actually stored, and providing information about structs and their properties.
Where to find the important files:
blender-svn/blender/source/blender/makesrna/
RNA_types.h: The important RNA data structures are defined here.
RNA_access.h: API for accessing structs and properties at runtime.
RNA_define.h: API for defining structs and properties.
All Blender data is presented as structs, each being a collection of properties. These properties are all of one of these types:
- boolean
- string
- integer
- float
- enum
- pointer to a struct
- collection of pointers to structs
- fixed-length array of booleans/integers/floats
Next to a type a subtype is also defined (e.g. file path, color, etc.).
Some less obvious Blender data structures:
- C chars and shorts representing numbers map to ints, they simply have different min/max.
- The vertices of a mesh are represented as a collection.
- Nested structs may be represented as pointers to structs that are not editable.
- Tristate values as used for texture mapping are represented as enum with 3 choices (disabled, enabled, enabled inverted).
- Colors are represented as float arrays with length 3 or 4 and subtype color, and matrices are represented as float arrays with length 9 (3x3) or 16 (4x4) and subtype matrix.
Pointers
There are three types of pointers.
/* Pointer
*
* These functions will fill in RNA pointers, this can be done in three ways:
* - a pointer Main is created by just passing the data pointer
* - a pointer to a datablock can be created with the type and id data pointer
* - a pointer to data contained in a datablock can be created with the id type
* and id data pointer, and the data type and pointer to the struct itself.
*
* There is also a way to get a pointer with the information about all structs.
*/
void RNA_main_pointer_create(struct Main *main, PointerRNA *r_ptr);
void RNA_id_pointer_create(struct ID *id, PointerRNA *r_ptr);
void RNA_pointer_create(struct ID *id, StructRNA *type, void *data, PointerRNA *r_ptr);
Home:
[0] http://wiki.blender.org/index.php/User:Ansimionescu
Reference:
[1] RNA: http://wiki.blender.org/index.php/Dev:2.5/Source/Architecture/RNA
[2] Code examples: http://wiki.blender.org/index.php/Dev:2.5/Source/Architecture/RNA/ExampleCode
[3] Data API (design document): http://wiki.blender.org/index.php/Dev:2.5/Source/Architecture/DataAPI