2
votes

Requirement

I have a 3d model created in Blender - a cube with numbers 1 to 6 on each faces. I have added a UV texture on each face to represent the number. The numbers are showing fine when I render it on Blender.

I am trying to export this model to iPhone using Cocos3D.

Specifications

  • iOS 6.1 and Xcode 4.6.2
  • cocos3d 0.7.0
  • Blender 2.67b

What I have done

  1. I added the PVRGeoPOD Converter plugin to Blender as per this official doc.
  2. Created the 3D model in blender. Used the default blender cube and added UV texture on all 6 faces.
  3. Generated a .pod file by selecting File->Export->PVRGeoPOD(.pod/.h/.cpp) in Blender.

  4. Added the pod file to the Cocos3D default template project. Change the code to use my numbered cube file instead of the default "Hello world" text.

    [self addContentFromPODFile: @"numbered_cube.pod"];
    
  5. Added a 3 axis rotation so that I can see all 6 faces.

    CC3MeshNode* helloTxt = (CC3MeshNode*)[self getNodeNamed: @"Cube"];
    CCActionInterval* partialRot = [CC3RotateBy actionWithDuration: 1.0 
                                       rotateBy: cc3v(40.0, 30.0, 30.0)];
    [helloTxt runAction: [CCRepeatForever actionWithAction: partialRot]];
    

The Problem

Well, the cube is showing, and it is rotating. But there is no texture on the cube. In the log, I can see this

Building CC3PODResource from file numbered_cube.pod containing 3 nodes (1 mesh nodes), 1 meshes, 1 cameras, 1 lights, 1 materials, 0 textures, 0 frames, ambient light

Further research

I did some search and come across this SO thread. It tells about Collada (.dae) file, kind of intermediate file between .blend and .pod. When I tried to convert, I only got the .pod file. I then used File->Export->Collada(.dae) to create a .dae file manullay. Then I tried to convert this .dae file to .pod using PVRGeoPODGUI standalone tool. The file is successfully opening, but the export button is always disabled.

So simply, my problem is how can I show the textures in the 3D model I created in Blender in iPhone using Cocos3D. Any idea?

1

1 Answers

2
votes

Okay, I got it working. I will explain in detail.

For starters, my mistake was I hadn't added the texture image to the XCode project bundle. I was having a misconception that once the texture is added in blender, it automatically gets exported along with the .pod file. But it is not the case. When you export textured models from Blender, don't forget to add the texture to the XCode project bundle.

One other things I noticed when trying to fix this error, which also results in your texture not getting showed when running in iPhone.

  1. When you export .blend to .pod in two steps (.blend -> .dae -> .pod), there are some configuration you need to do before the first conversion (.blend -> .dae). That is when you save the .dae file, you need to tick all fields under "Texture Options". Then only texture data gets exported.

    enter image description here