Cocoa Dev
Cocoa Dev

Reputation: 9541

How do I create new models and textures on a Cocos2D game for iOS

The previous developer quit and I inherited his project. No documentation and it's my first game project. The game is completed but we can't use the previous artwork because some of the images infringe on another companies art. So I need to create new art (models, textures).

The game has .h files which appear to be vertices for the 3d objects. The models are in 3ds which can't be opened by Blender but can be opened by Cheetah

There is a 3DAtlas.pvrtc file which I assume contains textures for the .h files but I can't view it.

How can I view the pvrtc file or create a new one?

I need to create some more models so how do I go from model to the .h file? What do I do about textures?

Upvotes: 0

Views: 872

Answers (1)

Nick Lockwood
Nick Lockwood

Reputation: 40995

pvrtc is a special texture format used by iOS graphics chips. You can't easily view a pvrtc on a desktop computer unless you find some specialist graphics program to open it, but you can create a new pvrtc image easily enough by taking a regular png file and then running it through apple's texture tool command line program that comes with Xcode.

Here are some instructions I prepared earlier:

Generating PVR image files

Apple includes a command-line PVT texture generation application called texturetool with the Xcode developer tools. This can usually be found at:

/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool

The texturetool application is fairly limited, and can only be used to create 4bpp (bits-per-pixel) and 2bpp compressed images, which are extremely low quality and look a bit like highly compressed jpegs. These are probably not good enough for still images - especially images containing transparency - but may be appropriate for video frames or textures for 3D models.

NOTE: In addition to needing power-of-two dimensions, PVR images must also be perfectly square, i.e. the width and height must be equal. Valid sizes are 2x2, 4x4, 8x8, 16x16, 32x32, 64x64, 128x128, 256x256, etc. Remember to crop or scale your images to a valid size before converting them.

The typical texturetool settings you will want to use are one of the following:

/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool -e PVRTC --channel-weighting-perceptual --bits-per-pixel-4 -f PVR -o {output_file_name}.pvr {input_file_name}.png

This generates a 4 bpp compressed PVR image.

/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool -e PVRTC --channel-weighting-perceptual --bits-per-pixel-2 -f PVR -o {output_file_name}.pvr {input_file_name}.png

This generates a 2 bpp compressed PVR image.

As stated previously, these files will appear like heavily compressed JPEG images, and will not be appropriate for user interface components or images with fine detail. It is also possible to create PVR images in a variety of higher qualities, but for this you will need to use a different tool. One such app is TexturePacker (http://www.texturepacker.com/), which is not free, but provides a handy command line tool for generating additional PVR formats.

The typical TexturePacker settings you will want to use are one of the following:

TexturePacker --disable-rotation --no-trim --opt RGBA8888 {input_file_name}.png --sheet {output_file_name}.pvr

This creates a 32-bit maximum-quality PVR image with alpha transparency.

TexturePacker --disable-rotation --no-trim --dither-fs-alpha --opt RGBA4444 {input_file_name}.png --sheet {output_file_name}.pvr

This creates a 16-bit dithered PVR image with alpha transparency.

TexturePacker --disable-rotation --no-trim --dither-fs --opt RGB565 {input_file_name}.png --sheet {output_file_name}.pvr

This creates an opaque 16-bit dithered PVR image without alpha transparency.

Upvotes: 4

Related Questions