spAttachment* _spAtlasAttachmentLoader_newAttachment (spAttachmentLoader* loader, spSkin* skin, spAttachmentType type, const char* name) { spAtlasAttachmentLoader* self = SUB_CAST(spAtlasAttachmentLoader, loader); switch (type) { case ATTACHMENT_REGION: { spRegionAttachment* attachment; spAtlasRegion* region = spAtlas_findRegion(self->atlas, name); if (!region) { _spAttachmentLoader_setError(loader, "Region not found: ", name); return 0; } attachment = spRegionAttachment_create(name); attachment->rendererObject = region; spRegionAttachment_setUVs(attachment, region->u, region->v, region->u2, region->v2, region->rotate); attachment->regionOffsetX = region->offsetX; attachment->regionOffsetY = region->offsetY; attachment->regionWidth = region->width; attachment->regionHeight = region->height; attachment->regionOriginalWidth = region->originalWidth; attachment->regionOriginalHeight = region->originalHeight; return SUPER(attachment); } case ATTACHMENT_BOUNDING_BOX: return SUPER(spBoundingBoxAttachment_create(name)); default: _spAttachmentLoader_setUnknownTypeError(loader, type); return 0; } }
spAttachment* _spAtlasAttachmentLoader_createAttachment (spAttachmentLoader* loader, spSkin* skin, spAttachmentType type, const char* name, const char* path) { spAtlasAttachmentLoader* self = SUB_CAST(spAtlasAttachmentLoader, loader); switch (type) { case SP_ATTACHMENT_REGION: { spRegionAttachment* attachment; spAtlasRegion* region = spAtlas_findRegion(self->atlas, path); if (!region) { _spAttachmentLoader_setError(loader, "Region not found: ", path); return 0; } attachment = spRegionAttachment_create(name); attachment->rendererObject = region; spRegionAttachment_setUVs(attachment, region->u, region->v, region->u2, region->v2, region->rotate); attachment->regionOffsetX = region->offsetX; attachment->regionOffsetY = region->offsetY; attachment->regionWidth = region->width; attachment->regionHeight = region->height; attachment->regionOriginalWidth = region->originalWidth; attachment->regionOriginalHeight = region->originalHeight; return SUPER(attachment); } case SP_ATTACHMENT_MESH: case SP_ATTACHMENT_LINKED_MESH: { spMeshAttachment* attachment; spAtlasRegion* region = spAtlas_findRegion(self->atlas, path); if (!region) { _spAttachmentLoader_setError(loader, "Region not found: ", path); return 0; } attachment = spMeshAttachment_create(name); attachment->rendererObject = region; attachment->regionU = region->u; attachment->regionV = region->v; attachment->regionU2 = region->u2; attachment->regionV2 = region->v2; attachment->regionRotate = region->rotate; attachment->regionOffsetX = region->offsetX; attachment->regionOffsetY = region->offsetY; attachment->regionWidth = region->width; attachment->regionHeight = region->height; attachment->regionOriginalWidth = region->originalWidth; attachment->regionOriginalHeight = region->originalHeight; return SUPER(SUPER(attachment)); } case SP_ATTACHMENT_BOUNDING_BOX: return SUPER(SUPER(spBoundingBoxAttachment_create(name))); case SP_ATTACHMENT_PATH: return SUPER(SUPER(spPathAttachment_create(name))); case SP_ATTACHMENT_POINT: return SUPER(SUPER(spPointAttachment_create(name))); case SP_ATTACHMENT_CLIPPING: return SUPER(SUPER(spClippingAttachment_create(name))); default: _spAttachmentLoader_setUnknownTypeError(loader, type); return 0; } UNUSED(skin); }