Reputation: 34265
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.
Generated a .pod file by selecting File->Export->PVRGeoPOD(.pod/.h/.cpp) in Blender.
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"];
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]];
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
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?
Upvotes: 2
Views: 1897
Reputation: 34265
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.
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.
Upvotes: 2