CC3Resource is a wrapper class around a resource structure loaded from a data file containing 3D resources. More...
#import <CC3Resource.h>
Public Member Functions | |
(id) | - initFromFile: |
(id) | - initFromResourceFile: |
(BOOL) | - loadFromFile: |
(BOOL) | - loadFromResourceFile: |
Static Public Member Functions | |
(id) | + resource |
(id) | + resourceFromFile: |
(id) | + resourceFromResourceFile: |
Properties | |
NSString * | directory |
CCArray * | nodes |
BOOL | wasLoaded |
CC3Resource is a wrapper class around a resource structure loaded from a data file containing 3D resources.
It handles loading object data from files, and creating CC3Nodes from that data.
This is an abstract class. Specific subclasses will load files of specific types.
Of the methods defined in this class, subclasses must override the primitive template method loadFromFile:. Other methods defined by this class have been implemented using this primitive method. As a result, subclasses do not need to override any of the other methods defined by this class.
Access to 3D data objects loaded from the file is through the nodes property, which contains the root nodes of a structural 3D node assembly constructed from the 3D data loaded from the file. Subclasses should ensure that the nodes array property is fully populated upon successful completion of the loadFromFile: method.
- (id) initFromFile: | (NSString *) | aFilePath |
Initializes this instance and populates the internal data structures from the file at the specified path, which must be an absolute path, and extracts the nodes from the data.
This method invokes the loadFromFile: template method to perform the actual file loading.
This method will return nil if the file could not be loaded.
- (id) initFromResourceFile: | (NSString *) | aRezPath |
Initializes this instance and populates the internal data structures from the file at the specified resource path, and extracts the nodes from the data.
The specified file path is a path relative to the resource directory. Typically this means that the specified path can just be the name of the file, with no path information.
This method invokes the loadFromFile: template method to perform the actual file loading.
This method will return nil if the file could not be loaded.
- (BOOL) loadFromFile: | (NSString *) | aFilePath |
This template method is the primary method for loading this resource.
Populates the internal data structures from the file at the specified path, which must be an absolute path, extracts the nodes from the data, and returns whether the loading was successful.
This is a template method. This implementation performs the following:
Subclasses must override this method to perform the actual file loading, parsing, and node extraction, but should be sure to invoke this superclass implementation to ensure the above tasks are performed.
Once this method has been successfully invoked, the application may immediately access the nodes property to retrieve the node assemblies contained in this resource.
- (BOOL) loadFromResourceFile: | (NSString *) | aRezPath |
Populates the internal data structures from the file at the specified resource path, extracts the nodes from the data, and returns whether the loading was successful.
This method invokes the loadFromFile: template method to perform the actual file loading.
The specified file path is a path relative to the resource directory. Typically this means that the specified path can just be the name of the file, with no path information.
+ (id) resource |
Allocates and initializes an autoreleased instance, without loading a file.
The file can be loaded later using the loadFromFile: method.
Use this method if you want to perform initialization activities prior to file loading.
+ (id) resourceFromFile: | (NSString *) | aFilePath |
Allocates and initializes an autoreleased instance, and populates the internal data structures from the file at the specified path, which must be an absolute path, and extracts the nodes from the data.
This method invokes the loadFromFile: template method to perform the actual file loading.
This method will return nil if the file could not be loaded.
+ (id) resourceFromResourceFile: | (NSString *) | aRezPath |
Allocates and initializes an autoreleased instance, populates the internal data structures from the file at the specified resource path, and extracts the nodes from the data.
The specified file path is a path relative to the resource directory. Typically this means that the specified path can just be the name of the file, with no path information.
This method invokes the loadFromFile: template method to perform the actual file loading.
This method will return nil if the file could not be loaded.
- (NSString *) directory [read, write, retain] |
The directory where additional resources (typically textures) can be found.
By default, this property will be set to the directory where the resource file is located, as indicated by the file path provided when the loadFromFile: method is invoked.
The application may set this property to a different directory if appropriate, but must do so before the loadFromFile: method is invoked.
- (CCArray *) nodes [read, assign] |
A collection of the root nodes of the node assembly extracted from the file.
Each of these nodes will usually contain child nodes.
- (BOOL) wasLoaded [read, assign] |
Indicates whether the resource has been successfully loaded.
The initial value of this property is NO, but will change to YES if the loadFromFile: method successfully loads the resource.