v2.0.2
Instance Methods | Class Methods | Properties | List of all members
CC3CAFResource Class Reference

#import <CC3CAFResource.h>

Inheritance diagram for CC3CAFResource:
Inheritance graph
[legend]

Instance Methods

(id) - initFromFile:linkedToCSFFile:
 
(void) - linkToCSFResource:
 
- Instance Methods inherited from CC3NodesResource
(void) - addNode:
 
(CC3Node *) - getNodeMatching:
 
(void) - removeNode:
 
- Instance Methods inherited from CC3Resource
(NSString *) - constructorDescription
 
(id) - initFromFile:
 
(id) - initFromResourceFile:
 
(BOOL) - loadFromFile:
 
(BOOL) - loadFromResourceFile:
 
(BOOL) - processFile:
 
(void) - remove
 
(BOOL) - saveToFile:
 
- Instance Methods inherited from CC3Identifiable
(void) - __deprecated
 
(id) - copy
 
(id) - copyAsClass:
 
(void) - copyUserDataFrom:
 
(id) - copyWithName:
 
(id) - copyWithName:asClass:
 
(id) - copyWithZone:withName:
 
(id) - copyWithZone:withName:asClass:
 
(BOOL) - deriveNameFrom:
 
(BOOL) - deriveNameFrom:usingSuffix:
 
(NSString *) - fullDescription
 
(id) - init
 
(id) - initAtIndex:fromPODResource:
 
(void) - initUserData
 
(id) - initWithName:
 
(id) - initWithTag:
 
(id) - initWithTag:withName:
 
(GLuint) - nextTag
 
(void) - populateFrom:
 

Class Methods

(BOOL) + defaultShouldSwapYZ
 
(id) + resourceFromFile:linkedToCSFFile:
 
(void) + setDefaultShouldSwapYZ:
 
- Class Methods inherited from CC3NodesResource
(BOOL) + defaultExpectsVerticallyFlippedTextures
 
(BOOL) + defaultShouldFreezeInanimateNodes
 
(id) + resourceFromFile:expectsVerticallyFlippedTextures:
 
(void) + setDefaultExpectsVerticallyFlippedTextures:
 
(void) + setDefaultShouldFreezeInanimateNodes:
 
- Class Methods inherited from CC3Resource
(void) + addResource:
 
(NSString *) + cachedResourcesDescription
 
(CC3Resource *) + getResourceNamed:
 
(BOOL) + isPreloading
 
(void) + removeAllResources
 
(void) + removeResource:
 
(void) + removeResourceNamed:
 
(id) + resource
 
(id) + resourceFromFile:
 
(id) + resourceFromResourceFile:
 
(NSString *) + resourceNameFromFilePath:
 
(void) + setIsPreloading:
 
- Class Methods inherited from CC3Identifiable
(GLint) + instanceCount
 
(void) + resetTagAllocation
 

Properties

CCTime animationDuration
 
int fileVersion
 
int flags
 
BOOL isCompressed
 
BOOL shouldSwapYZ
 
BOOL wasCSFResourceAttached
 
- Properties inherited from CC3NodesResource
BOOL expectsVerticallyFlippedTextures
 
NSArray * nodes
 
BOOL shouldFreezeInanimateNodes
 
- Properties inherited from CC3Resource
NSArray *nodes __deprecated
 
BOOL
expectsVerticallyFlippedTextures 
__deprecated
 
NSString * directory
 
BOOL isBigEndian
 
BOOL wasLoaded
 
- Properties inherited from CC3Identifiable
NSObject *sharedUserData __deprecated
 
NSString * name
 
NSString * nameSuffix
 
GLint podIndex
 
BOOL shouldIncludeInDeepCopy
 
GLuint tag
 
NSObject * userData
 
- Properties inherited from <CC3Cacheable>
NSString * name
 

Detailed Description

CC3CAFResource is a CC3NodesResource that loads animated node from a Cal3D-compatible CAF file.

After this resource has been loaded, you should populate the nodes in this resource with content extracted from a CSF resource, using the populateNodesFromCSFResource: method.

Method Documentation

+ (BOOL) defaultShouldSwapYZ

Indicates the value that the shouldSwapYZ property should be initially set to when any new instance of this class is created.

The initial value of this property is YES.

- (id) initFromFile: (NSString *)  cafFilePath
linkedToCSFFile: (NSString *)  csfFilePath 

Initializes this instance and invokes the loadFromFile: method to populate this instance from the contents of the file at the specified cafFilePath.

Once loaded, this instance is attached to the CSF resource loaded from the specified csfFilePath by invoking the linkToCSFResource method. The CSF resource is retrieved from the resource cache if it already exists, otherwise it is loaded and cached as well.

Normally, you should use the resourceFromFile:linkedToCSFFile: method to reuse the cached instance instead of creating and initializing a new instance. The resourceFromFile:linkedToCSFFile: method automatically invokes this method if an instance does not exist in the resource cache, in order to create and load the resource from the file, and after doing so, places the newly loaded instance into the cache.

However, by invoking the alloc method and then invoking this method directly, the application can load the resource without first checking the resource cache. The resource can then be placed in the cache using the addResource: method. If you load two separate resources from the same file, be sure to set a distinct name for each before adding both resources to the cache. By default, the name of the resource is the file name.

If you need to set additional configuration info, such as the directory property, prior to loading the resource, consider using the init or resource methods and then invoking the loadFromFile: method instead.

The specified file path may be either an absolute path, or a path relative to the application resource directory. If the file is located directly in the application resources directory, the specified file path can simply be the name of the file.

This method will return nil if the file could not be loaded.

- (void) linkToCSFResource: (CC3CSFResource *)  csfRez

Populates the content of the nodes in this resource with some of the contents of the nodes in the specified CSF resource.

The CAF and CSF files are exported from the 3D editor as part of a single, self-consistent export. The specified CSF resource must be from the same export as this CAF resource. Typically, the export package will include a single CSF file and multiple CAF files.

The CAF file format contains only the calIndex value of each node, and a single track of animation content. The CSF file format contains node names, locations, rotations, and hierarchical structure.

For each node in this CAF resource, this method uses its calIndex property to retrieve the corresponding node contained in the specified CSF resource. Once retrieved, the following content is copied from the node in the CSF resource to the node in this CAF resource:

  • node name

After the CSF content has been extracted, the wasCSFResourceAttached property of this CAF resource will be set to YES, but the CSF resource is not retained by this CAF resource.

This method should be invoked once after this CAF resource has been loaded. Invoking this method prior to loading this resource will result in nothing happening. It is safe to invoke this method more than once, but subsequent invocations will have no effect.

+ (id) resourceFromFile: (NSString *)  cafFilePath
linkedToCSFFile: (NSString *)  csfFilePath 

Returns a resource instance loaded from the specified cafFilePath.

Once loaded, the instance is attached to the CSF resource loaded from the specified csfFilePath by invoking the linkToCSFResource method. The CSF resource is retrieved from the resource cache if it already exists, otherwise it is loaded and cached as well.

Resources loaded through this method are cached. If the resource was already loaded and is in the cache, it is retrieved and returned. If the resource has not in the cache, it is loaded from the specified file, placed into the cache, and returned. It is therefore safe to invoke this method any time the resource is needed, without having to worry that the resource will be repeatedly loaded from file.

To clear a resource instance from the cache, use the removeResource: method.

To load the file directly, bypassing the cache, use the alloc and initFromFile: methods. This technique can be used to load the same resource twice, perhaps to configure each separately. Each distinct resource can then be given its own name, and added to the cache separately. However, when choosing to do so, be aware that resources often consume significant memory. Consider copying resource components instead of loading the entire resource, if you need to create multiple instances of a few resource components.

If you need to set additional configuration info, such as the directory property, prior to loading the resource, consider using the resource method and then invoking the loadFromFile: method to load the file, and the addResource: method to add that instance to the cache.

The specified file path may be either an absolute path, or a path relative to the application resource directory. If the file is located directly in the application resources directory, the specified file path can simply be the name of the file.

This method will return nil if the file is not in the cache and could not be loaded.

+ (void) setDefaultShouldSwapYZ: (BOOL)  shouldSwap

Indicates the value that the shouldSwapYZ property should be initially set to when any new instance of this class is created.

The initial value of this property is YES.

Property Documentation

- (CCTime) animationDuration
readnonatomicassign

Returns the animation duration in seconds.

- (int) fileVersion
readnonatomicassign

Returns the file format version, extracted from the file.

- (int) flags
readnonatomicassign

Returns file content format flags.

- (BOOL) isCompressed
readnonatomicassign

Returns whether the file contains compressed animation content.

- (BOOL) shouldSwapYZ
readwritenonatomicassign

Indicates whether the Y & Z elements of animated locations and quaternions loaded by this resource should be swapped during loading.

When swapped, the new Z value is also negated.

If set to YES, for each location and quaternion in the animation content, the Z value will be set from the negated Y value of the loaded quaternion, and the Y value will be set from the Z value.

This setting can be used to correct possible coordinate system orientation discrepancies between the CAF exporters and Cocos3D.

The initial value of this property is set from the value of the class-side defaultShouldSwapYZ property.

- (BOOL) wasCSFResourceAttached
readnonatomicassign

Returns whether this resource has been populated from its corresponding CSF resource.

The initial value of this property is NO. It is changed to YES once the linkToCSFResource: method has been invoked.


The documentation for this class was generated from the following file: