Class BlenderFactoryBase
- java.lang.Object
-
- org.cakelab.blender.utils.BlenderFactoryBase
-
- Direct Known Subclasses:
BlenderFactory
public class BlenderFactoryBase extends java.lang.Object
This is the base class for generated factory classes of a specific blender version.Factory classes are part of the utils package and optional. This base class contains the public factory methods to create blocks for facades, arrays and pointers. It also contains utilities to create new blender files in a derived factory class.
- Author:
- homac
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
BlenderFactoryBase.BlenderFileImplBase
base class to be used by a derived factory class to create new blender files.protected static class
BlenderFactoryBase.StructDNAImage
This class provides access to the StructDNA image stored in each data model generated by Java Blend.
-
Field Summary
Fields Modifier and Type Field Description protected BlenderFile
blend
Blender file associated with this instance of a factory.
-
Constructor Summary
Constructors Constructor Description BlenderFactoryBase(BlenderFile blend)
Creates a new factory associated with the given blender file.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static StructDNA
createStructDNA(java.lang.String resourcePathTo_sdna_blend)
This method provides the StructDNA from a given sdna.blend image resource path.CPointer<java.lang.Object>
getNullPointer()
Returns a null pointer object associated with the blender file of this factory.static CPointer<java.lang.Object>
getNullPointer(BlenderFile blend)
Create a null pointer object associated with the given blender file.<T> CArrayFacade<T>
newCArrayBlock(Identifier blockCode, java.lang.Class<?>[] typeList, int[] dimensions)
Factory instance method equivalent tonewCArrayBlock(Identifier, Class[], int[], BlenderFile)
.static <T> CArrayFacade<T>
newCArrayBlock(Identifier blockCode, java.lang.Class<?>[] typeList, int[] dimensions, BlenderFile blend)
Allocate a new block for one instance of a multi-dimensional array of any component type supported by blender.<T> CArrayFacade<T>
newCArrayBlock(Identifier blockCode, java.lang.Class<T> componentType, int arrayLength)
Factory instance method equivalent tonewCArrayBlock(Identifier, Class, int, BlenderFile)
.static <T> CArrayFacade<T>
newCArrayBlock(Identifier blockCode, java.lang.Class<T> componentType, int arrayLength, BlenderFile blend)
Allocate a new block for one instance of a one-dimensional array of any non-pointer component type which is either a scalar or a DNA struct.<T> CPointer<CPointer<T>>
newCPointerBlock(Identifier blockCode, java.lang.Class<?>[] typeList)
Factory instance method equivalent tonewCPointerBlock(Identifier, Class[], BlenderFile)
.<T> CArrayFacade<CPointer<T>>
newCPointerBlock(Identifier blockCode, java.lang.Class<?>[] typeList, int count)
Factory instance method equivalent tonewCPointerBlock(Identifier, Class[], int count, BlenderFile)
.static <T> CArrayFacade<CPointer<T>>
newCPointerBlock(Identifier blockCode, java.lang.Class<?>[] typeList, int count, BlenderFile blend)
This method creates a block with a set of pointers and returns an array facet to access them.static <T> CPointer<CPointer<T>>
newCPointerBlock(Identifier blockCode, java.lang.Class<?>[] typeList, BlenderFile blend)
This method creates a block with a single pointer in it.<T extends CFacade>
TnewCStructBlock(Identifier blockCode, java.lang.Class<T> facetClass)
Factory instance method equivalent tonewCStructBlock(Identifier, Class, BlenderFile)
.<T extends CFacade>
CArrayFacade<T>newCStructBlock(Identifier blockCode, java.lang.Class<T> facetClass, int count)
Factory instance method equivalent tonewCStructBlock(Identifier, Class, int, BlenderFile)
.static <T extends CFacade>
CArrayFacade<T>newCStructBlock(Identifier blockCode, java.lang.Class<T> facetClass, int count, BlenderFile blend)
Allocate a new block for multiple instances of a C struct.static <T extends CFacade>
TnewCStructBlock(Identifier blockCode, java.lang.Class<T> facetClass, BlenderFile blend)
Allocate a new block for one instance of a C struct.
-
-
-
Field Detail
-
blend
protected BlenderFile blend
Blender file associated with this instance of a factory.
-
-
Constructor Detail
-
BlenderFactoryBase
public BlenderFactoryBase(BlenderFile blend) throws java.io.IOException
Creates a new factory associated with the given blender file. All blocks instantiated by this factory will be allocated in the given blender file.- Parameters:
blend
-- Throws:
java.io.IOException
-
-
Method Detail
-
getNullPointer
public static CPointer<java.lang.Object> getNullPointer(BlenderFile blend) throws java.io.IOException
Create a null pointer object associated with the given blender file. Since pointers have architecture specific properties, they have to be associated with a blender file (which defines the encoding).- Returns:
- Null pointer object.
- Throws:
java.io.IOException
-
getNullPointer
public CPointer<java.lang.Object> getNullPointer()
Returns a null pointer object associated with the blender file of this factory. Since pointers have architecture specific properties, they have to be associated with a blender file (which defines the encoding).- Returns:
- Null pointer object.
-
newCStructBlock
public static <T extends CFacade> T newCStructBlock(Identifier blockCode, java.lang.Class<T> facetClass, BlenderFile blend) throws java.io.IOException
Allocate a new block for one instance of a C struct.This method allocates a new block in the given blender file and assigns it to a facet of the given class (facetClass).
Example:BlenderFile blend = BlenderFactory.newBlenderFile(new File("my.blend")); Scene scene = BlenderFactory.newDNAStructBlock(BlockCodes.CODE_SCE, Scene.class, blend);
- Throws:
java.io.IOException
-
newCStructBlock
public <T extends CFacade> T newCStructBlock(Identifier blockCode, java.lang.Class<T> facetClass) throws java.io.IOException
Factory instance method equivalent tonewCStructBlock(Identifier, Class, BlenderFile)
.- Throws:
java.io.IOException
-
newCStructBlock
public static <T extends CFacade> CArrayFacade<T> newCStructBlock(Identifier blockCode, java.lang.Class<T> facetClass, int count, BlenderFile blend) throws java.io.IOException
Allocate a new block for multiple instances of a C struct.This method allocates a new block of apropriate size to fit 'count' instances of the given C struct in the given blender file and assigns it to an array facet of the given class type (facetClass).
Example:BlenderFile blend = BlenderFactory.newBlenderFile(new File("my.blend")); CArrayFacade<Scene> scene = BlenderFactory.newDNAStructBlock(BlockCodes.CODE_SCE, Scene.class, 2, blend);
- Throws:
java.io.IOException
-
newCStructBlock
public <T extends CFacade> CArrayFacade<T> newCStructBlock(Identifier blockCode, java.lang.Class<T> facetClass, int count) throws java.io.IOException
Factory instance method equivalent tonewCStructBlock(Identifier, Class, int, BlenderFile)
.- Throws:
java.io.IOException
-
newCArrayBlock
public static <T> CArrayFacade<T> newCArrayBlock(Identifier blockCode, java.lang.Class<T> componentType, int arrayLength, BlenderFile blend) throws java.io.IOException
Allocate a new block for one instance of a one-dimensional array of any non-pointer component type which is either a scalar or a DNA struct.This method allocates a new block of appropriate size to fit an array of the given arrayLength and the given componentType in the given blender file and assigns it to an array facet.
Example:// 1-dim float array with 4 elems CArrayFacade<Float> rgba = BlenderFactory.newDNAArrayBlock(BlockCodes.CODE_DATA, Float.class, 4, blend);
- Parameters:
blockCode
- Code of the new block. Frequently ID_DATA for arrays.componentType
- Component type of the array.arrayLength
- length of the arrayblend
- blender file to add block to.- Returns:
- CArrayFacade facet to access array data in the new block.
- Throws:
java.io.IOException
-
newCArrayBlock
public <T> CArrayFacade<T> newCArrayBlock(Identifier blockCode, java.lang.Class<T> componentType, int arrayLength) throws java.io.IOException
Factory instance method equivalent tonewCArrayBlock(Identifier, Class, int, BlenderFile)
.- Throws:
java.io.IOException
-
newCArrayBlock
public static <T> CArrayFacade<T> newCArrayBlock(Identifier blockCode, java.lang.Class<?>[] typeList, int[] dimensions, BlenderFile blend) throws java.io.IOException
Allocate a new block for one instance of a multi-dimensional array of any component type supported by blender.This method allocates a new block of appropriate size to fit an array of the given arrayLength and the given component type specification (typeList) and the given lengths for each dimension, in the given blender file and assigns it to an array facade. Refer to
Example:CArrayFacade
andCPointer
to understand the concept of type specifications by type lists.// 2-dim 4x4 float array Class<?>[] typeList = new Class[]{CArrayFacade.class, Float.class}; int[] dimensions = new int[]{4,4}; CArrayFacade<CArrayFacade<Float>> mv_mat4x4 = BlenderFactory.newDNAArrayBlock(BlockCodes.CODE_DATA, typeList, dimensions, blend); // 1-dim array of pointers on bytes (e.g. strings) typeList = new Class[]{CArrayFacade.class, CPointer.class, Byte.class}; dimensions = new int[]{4}; CArrayFacade<CPointer<Byte>> fileList = BlenderFactory.newDNAArrayBlock(BlockCodes.CODE_DATA, typeList, dimensions, blend);
- Parameters:
blockCode
- Code of the new block. Frequently ID_DATA for arrays.typeList
- type specification for all referenced typesdimensions
- length of each array dimensionblend
- blender file to add block to.- Throws:
java.io.IOException
-
newCArrayBlock
public <T> CArrayFacade<T> newCArrayBlock(Identifier blockCode, java.lang.Class<?>[] typeList, int[] dimensions) throws java.io.IOException
Factory instance method equivalent tonewCArrayBlock(Identifier, Class[], int[], BlenderFile)
.- Throws:
java.io.IOException
-
newCPointerBlock
public static <T> CPointer<CPointer<T>> newCPointerBlock(Identifier blockCode, java.lang.Class<?>[] typeList, BlenderFile blend) throws java.io.IOException
This method creates a block with a single pointer in it. The returned pointer is a pointer on this created pointer. To change the value of that pointer use the methodCPointer.set(Object)
of the pointer on the pointer.- Parameters:
blockCode
-typeList
-blend
- blender file to add block to.- Returns:
- a pointer on the pointer stored in the block.
- Throws:
java.io.IOException
-
newCPointerBlock
public <T> CPointer<CPointer<T>> newCPointerBlock(Identifier blockCode, java.lang.Class<?>[] typeList) throws java.io.IOException
Factory instance method equivalent tonewCPointerBlock(Identifier, Class[], BlenderFile)
.- Throws:
java.io.IOException
-
newCPointerBlock
public static <T> CArrayFacade<CPointer<T>> newCPointerBlock(Identifier blockCode, java.lang.Class<?>[] typeList, int count, BlenderFile blend) throws java.io.IOException
This method creates a block with a set of pointers and returns an array facet to access them. To change the value of the pointers use for example the methodCArrayFacade.set(int, Object)
of the pointer on the pointer.- Parameters:
blockCode
- Usually ID_DATA for lists of pointers.typeList
- type specification of the pointer.count
- number of pointers to fit in block.blend
- blender file to add block to.- Throws:
java.io.IOException
-
newCPointerBlock
public <T> CArrayFacade<CPointer<T>> newCPointerBlock(Identifier blockCode, java.lang.Class<?>[] typeList, int count) throws java.io.IOException
Factory instance method equivalent tonewCPointerBlock(Identifier, Class[], int count, BlenderFile)
.- Throws:
java.io.IOException
-
createStructDNA
protected static StructDNA createStructDNA(java.lang.String resourcePathTo_sdna_blend) throws java.io.IOException
This method provides the StructDNA from a given sdna.blend image resource path. Every generated Java Blend data model has such an sdnaImage resource (to be found in "your/package/name/utils/resources/sdna.blend") which contains just the sdna meta data of the blender version the model was generated from.- Parameters:
resourcePathTo_sdna_blend
- "your/package/name/utils/resources/sdna.blend"- Throws:
java.io.IOException
-
-