public class BlenderFactoryBase
extends java.lang.Object
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 a new blender files in a derived factory class.
Modifier and Type | Class and Description |
---|---|
protected static class |
BlenderFactoryBase.BlenderFileImplBase |
protected static class |
BlenderFactoryBase.StructDNAImage
This class provides access to the StructDNA image stored in each
data model generated by Java Blend.
|
Modifier and Type | Field and Description |
---|---|
protected BlenderFile |
blend
Blender file associated with this instance of a factory.
|
Constructor and Description |
---|
BlenderFactoryBase(BlenderFile blend)
Creates a new factory associated with the given blender file.
|
Modifier and Type | Method and 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 to
newCArrayBlock(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 to
newCArrayBlock(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 to
newCPointerBlock(Identifier, Class[], BlenderFile) . |
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> CArrayFacade<CPointer<T>> |
newCPointerBlock(Identifier blockCode,
java.lang.Class<?>[] typeList,
int count)
Factory instance method equivalent to
newCPointerBlock(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.
|
<T extends CFacade> |
newCStructBlock(Identifier blockCode,
java.lang.Class<T> facetClass)
Factory instance method equivalent to
newCStructBlock(Identifier, Class, BlenderFile) . |
static <T extends CFacade> |
newCStructBlock(Identifier blockCode,
java.lang.Class<T> facetClass,
BlenderFile blend)
Allocate a new block for one instance of a C struct.
|
<T extends CFacade> |
newCStructBlock(Identifier blockCode,
java.lang.Class<T> facetClass,
int count)
Factory instance method equivalent to
newCStructBlock(Identifier, Class, int, BlenderFile) . |
static <T extends CFacade> |
newCStructBlock(Identifier blockCode,
java.lang.Class<T> facetClass,
int count,
BlenderFile blend)
Allocate a new block for multiple instances of a C struct.
|
protected BlenderFile blend
public BlenderFactoryBase(BlenderFile blend) throws java.io.IOException
blend
- java.io.IOException
public static CPointer<java.lang.Object> getNullPointer(BlenderFile blend) throws java.io.IOException
java.io.IOException
public CPointer<java.lang.Object> getNullPointer()
public static <T extends CFacade> T newCStructBlock(Identifier blockCode, java.lang.Class<T> facetClass, BlenderFile blend) throws java.io.IOException
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);
blockCode
- facetClass
- blend
- java.io.IOException
public <T extends CFacade> T newCStructBlock(Identifier blockCode, java.lang.Class<T> facetClass) throws java.io.IOException
newCStructBlock(Identifier, Class, BlenderFile)
.java.io.IOException
public static <T extends CFacade> CArrayFacade<T> newCStructBlock(Identifier blockCode, java.lang.Class<T> facetClass, int count, BlenderFile blend) throws java.io.IOException
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);
blockCode
- facetClass
- count
- blend
- java.io.IOException
public <T extends CFacade> CArrayFacade<T> newCStructBlock(Identifier blockCode, java.lang.Class<T> facetClass, int count) throws java.io.IOException
newCStructBlock(Identifier, Class, int, BlenderFile)
.java.io.IOException
public static <T> CArrayFacade<T> newCArrayBlock(Identifier blockCode, java.lang.Class<T> componentType, int arrayLength, BlenderFile blend) throws java.io.IOException
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);
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.java.io.IOException
public <T> CArrayFacade<T> newCArrayBlock(Identifier blockCode, java.lang.Class<T> componentType, int arrayLength) throws java.io.IOException
newCArrayBlock(Identifier, Class, int, BlenderFile)
.java.io.IOException
public static <T> CArrayFacade<T> newCArrayBlock(Identifier blockCode, java.lang.Class<?>[] typeList, int[] dimensions, BlenderFile blend) throws java.io.IOException
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 CArrayFacade
and CPointer
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);
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.java.io.IOException
public <T> CArrayFacade<T> newCArrayBlock(Identifier blockCode, java.lang.Class<?>[] typeList, int[] dimensions) throws java.io.IOException
newCArrayBlock(Identifier, Class[], int[], BlenderFile)
.java.io.IOException
public static <T> CPointer<CPointer<T>> newCPointerBlock(Identifier blockCode, java.lang.Class<?>[] typeList, BlenderFile blend) throws java.io.IOException
CPointer.set(Object)
of the pointer on the pointer.blockCode
- typeList
- blend
- blender file to add block to.java.io.IOException
public <T> CPointer<CPointer<T>> newCPointerBlock(Identifier blockCode, java.lang.Class<?>[] typeList) throws java.io.IOException
newCPointerBlock(Identifier, Class[], BlenderFile)
.java.io.IOException
public static <T> CArrayFacade<CPointer<T>> newCPointerBlock(Identifier blockCode, java.lang.Class<?>[] typeList, int count, BlenderFile blend) throws java.io.IOException
CArrayFacade.set(int, Object)
of the pointer on the pointer.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.java.io.IOException
public <T> CArrayFacade<CPointer<T>> newCPointerBlock(Identifier blockCode, java.lang.Class<?>[] typeList, int count) throws java.io.IOException
newCPointerBlock(Identifier, Class[], int count, BlenderFile)
.java.io.IOException
protected static StructDNA createStructDNA(java.lang.String resourcePathTo_sdna_blend) throws java.io.IOException
resourcePathTo_sdna_blend
- "your/package/name/utils/resources/sdna.blend"java.io.IOException