New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in...

40
05.11.18 DevKitchen 2018 Cinema 4D R20 - Features API

Transcript of New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in...

Page 1: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

DevKitchen 2018 Cinema 4D R20 - Features API

Page 2: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Cinema 4D R20 Features API

Volumes

Fields

Multi-Instances

2

Page 3: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Volumes

DevKitchen 2018 – Cinema 4D R20 Features - Volumes

3

Page 4: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library.

• Volume Loader: Loads data from vdb files. • Volume Builder: Creates volume data from scene elements. • Volume Mesher: Creates a polygon mesh from volume data. • Volume Object: Stores volume data.

DevKitchen 2018 – Cinema 4D R20 Features - Volumes

4

Page 5: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Volumes in Cinema 4D R20 Classic API components in cinema.framework:

• lib_volumeobject.h: Contains the VolumeObject class. • lib_volumebuilder.h: Contains the VolumeBuilder class.

DevKitchen 2018 – Cinema 4D R20 Features - Volumes

5

Page 6: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Volumes in Cinema 4D R20 MAXON API components defined in volume.framework:

• maxon::VolumeInterface: Represents volume data. • maxon::CommandClasses: Contain volume commands. • maxon::VolumeToolsInterface: Contains functions to

handle volumes.

DevKitchen 2018 – Cinema 4D R20 Features - Volumes

6

Page 7: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Creating a VolumeBuilder object The VolumeBuilder class is defined in lib_volumebuilder.h.

• Allocate a new instance with VolumeBuilder::Alloc(); • Insert it into the BaseDocument as usual. • Use VolumeBuilder::AddSceneObject() to add objects to

the list.

DevKitchen 2018 – Cinema 4D R20 Features - Volumes

7

Page 8: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Reading Volume Data VolumeObject is defined in lib_volumeobject.h. VolumeInterface is defined in volume.h.

• Check for object type with Ovolume. • Cast into VolumeObject. • Access volume data with VolumeObject::GetVolume(). • Create a GridIteratorRef • Initialise iterator with GridIteratorInterface::Init() and

the volume.

DevKitchen 2018 – Cinema 4D R20 Features - Volumes

8

Page 9: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Reading Volume Data

• Iterate the grid with IsNotAtEnd() and StepNext(). • Access coordinates with GetCoords(). • Access value with GetValue(). • To create the world space position use the matrix provided with VolumeInterface::GetGridTransform().

DevKitchen 2018 – Cinema 4D R20 Features - Volumes

9

Page 10: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Writing Volume Data VolumeObject is defined in lib_volumeobject.h. VolumeInterface is defined in volume.h.

• Create a volume with VolumeObject::Alloc(). • insert it into the BaseDocument as usual. • Create an empty volume with VolumeToolsInterface::CreateNewFloat32Volume().

• Create a GridAccessorRef.

DevKitchen 2018 – Cinema 4D R20 Features - Volumes

10

Page 11: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Writing Volume Data

• Initialise the accessor with the empty volume using GridAccessorRef::Init().

• Write into the volume using GridAccessorRef::SetValue(). • Store the volume in the VolumeObject using

VolumeObject::SetVolume().

DevKitchen 2018 – Cinema 4D R20 Features - Volumes

11

Page 12: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Using Volume Commands VOLUMEDATA, VolumeCommandData and CommandClasses are defined in volumecommands.h

• Create a LegacyCommandDataRef context from VOLUMEDATA. • Create a VolumeCommandData object. • Set the data and store it in the context using SetLegacyData(). • Access a command from CommandClasses. • Invoke that command on the given context using Invoke().

DevKitchen 2018 – Cinema 4D R20 Features - Volumes

12

Page 13: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Using Volume Commands

• Get the result data from the context using GetLegacyData(). • Get the results from the VolumeCommandData structure.

DevKitchen 2018 – Cinema 4D R20 Features - Volumes

13

Page 15: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Volume API in Python Defined in c4d.modules.volume.

• VolumeObject and VolumeBuilder available. • Commands used with SendVolumeCommand().

DevKitchen 2018 – Cinema 4D R20 Features - Volumes

15

Page 16: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Volume API in Python Defined in maxon.frameworks.volume.

• VolumeInterface • GridAccessorInterface • VolumeToolsInterface.

DevKitchen 2018 – Cinema 4D R20 Features - Volumes

16

Page 17: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Fields

DevKitchen 2018 – Cinema 4D R20 Features - Fields

17

Page 18: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Fields System The Field system replaces the previous “Falloff” system. It allows to sample space to get a scalar value and a colour value. Fields are used in:

• MoGraph Effectors • Deformers • Volumes • Particles • ….

DevKitchen 2018 – Cinema 4D R20 Features - Fields

18

Page 19: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Fields System The system is made of these components:

• Field Objects: Objects in space that define a Field. • Field List: A list of Field layers. • Field Layer: Either references a Field object or defines a global

function.

DevKitchen 2018 – Cinema 4D R20 Features - Fields

19

Page 20: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Fields System The API is defined in cinema.framework:

• FieldObject: Represents a Field object in the scene. • FieldList/FieldLayer: The “Field” parameter type. • FieldData: Base class for custom Field objects. • FieldLayerData: Base class for custom Field layers.

DevKitchen 2018 – Cinema 4D R20 Features - Fields

20

Page 21: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Sampling a FieldObject FieldObject is defined in c4d_fielddata.h.

• Check the object type with Ofield. • Cast into FieldObject. • Prepare position values to sample at. • Store information on the samples in a FieldInput object. • Prepare result data in a FieldOutput object. • Create a FieldInfo context object that references the FieldInput object.

DevKitchen 2018 – Cinema 4D R20 Features - Fields

21

Page 22: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Sampling a FieldObject

• Prepare sampling with InitSampling(). • Sample the FieldObject with Sample(). • Free data with FreeSampling(). • Sampling results are now stored in the FieldOutput / FieldOutputBlock structure.

DevKitchen 2018 – Cinema 4D R20 Features - Fields

22

Page 23: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Sampling a FieldList FieldList is defined in customgui_field.h. FIELDS is defined in ofalloff_panel.h.

• Access the parameter FIELDS. • Get the custom data type with GetCustomDataType(). • Data type ID is CUSTOMDATATYPE_FIELDLIST. • Cast into a FieldList object.

DevKitchen 2018 – Cinema 4D R20 Features - Fields

23

Page 24: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Sampling a FieldList

• Prepare points to sample. • Store data in FieldInput object. • Sample the list with SampleListSimple(). • The result is stored in the returned FieldOutput object.

DevKitchen 2018 – Cinema 4D R20 Features - Fields

24

Page 25: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Implementing a Custom FieldObject FieldData is defined in c4d_fieldplugin.h.

• Implement InitSampling() to store data used while sampling. • Implement FreeSampling() to free data used while sampling. • Implement Sample() to define the object’s behaviour.

DevKitchen 2018 – Cinema 4D R20 Features - Fields

25

Page 26: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Implementing a custom FieldObject

• Transformation information is stored in info._inputData._transform and the object’s world space matrix (GetMg()).

• The input positions are stored in inputs._positions. • The result values are written to outputs._value. • The plugin is registered with RegisterFieldPlugin().

DevKitchen 2018 – Cinema 4D R20 Features - Fields

26

Page 27: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Implementing a custom FieldLayer FieldLayerData is defined in c4d_fieldplugin.h.

• Implement InitSampling() to store data used while sampling. • Implement FreeSampling() to free data used while sampling. • Implement Sample() to define the layer’s behaviour.

DevKitchen 2018 – Cinema 4D R20 Features - Fields

27

Page 28: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Implementing a custom FieldLayer

• The input positions are stored in inputs._positions. • The result values are written to outputs._value. • The plugin is registered with RegisterFieldLayerPlugin(). • Set FIELDLAYER_DIRECT for layers that modify the existing

values (modifier layer).

DevKitchen 2018 – Cinema 4D R20 Features - Fields

28

Page 30: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Fields API in Python Defined in c4d.modules.mograph.

• FieldObject • FieldList

DevKitchen 2018 – Cinema 4D R20 Features - Fields

30

Page 31: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Python in Fields Python can be used to program these components:

• Python Field • Python Field Layer

DevKitchen 2018 – Cinema 4D R20 Features - Fields

31

Page 32: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Multi-Instances

DevKitchen 2018 – Cinema 4D R20 Features - Multi-Instances

32

Page 33: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Multi-Instances Multi-Instances are an extension of the existing Instance object.

• An object can be used as a position source (particles, MoGraph Matrix).

• Position data can be written into the object using the API.

DevKitchen 2018 – Cinema 4D R20 Features - Multi-Instances

33

Page 34: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Multi-Instances The InstanceObject class is defined in cinema.framework.

• lib_instanceobject.h contains the class. • oinstance.h contains parameter IDs.

DevKitchen 2018 – Cinema 4D R20 Features - Multi-Instances

34

Page 35: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Creating an InstanceObject InstanceObject is defined in lib_instanceobject.h.

• Create a new instance with InstanceObject::Alloc(). • Insert the instance into the BaseDocument. • Set the referenced object using SetReferenceObject(). • Set the parameter INSTANCEOBJECT_RENDERINSTANCE_MODE.

DevKitchen 2018 – Cinema 4D R20 Features - Multi-Instances

35

Page 36: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Creating an InstanceObject

• If using multi-instances, prepare position and colour data. • Set the positions using SetInstanceMatrices(). • Set the colours using SetInstanceColors().

DevKitchen 2018 – Cinema 4D R20 Features - Multi-Instances

36

Page 37: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

Reading Position Data from an InstanceObject

• Check the object type with Oinstance. • Cast into InstanceObject. • Get the number of instances with GetInstanceCount(). • Get the matrix for a given instance index with GetInstanceMatrix().

DevKitchen 2018 – Cinema 4D R20 Features - Multi-Instances

37

Page 38: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

InstanceObject API Documentation

• InstanceObject Manual

DevKitchen 2018 – Cinema 4D R20 Features - Multi-Instances

38

Page 39: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

InstanceObject API in Python Defined in the c4d namespace.

• InstanceObject

DevKitchen 2018 – Cinema 4D R20 Features - Multi-Instances

39

Page 40: New Dev Kitchen 2018 - Cinema 4D R20 Features release · 2018. 11. 5. · 05.11.18 Volumes in Cinema 4D R20 The volume system is based on the OpenVDB library. • Volume Loader: Loads

05.11.18

MAXON Computer GmbH Max-Planck-Straße 20 D-61381 Friedrichsdorf Germany

E [email protected] T +49 (0) 6172 5906-0 F +49 (0) 6172 5906-30

maxon.net