Cocos3d loads the 3Dmax model to ios

Source: Internet
Author: User

Two days ago, I suddenly saw cocos3d. I have been studying cocos2d before. After downloading the cocos3d development library, I started to try it myself and encountered many problems, let's take a look at how to use cocos3d to load the 3dmax model. Reprint please explain the source: http://fengmm521.blog.163.com/blog/static/25091358201210173463909/

First problem: Convert the 3dmax file to the pod file format.

I have been searching for this problem for a long time. The common method on the Internet is to open the 3Dmax model file with 3Dmax and save it as a text file in. dae format.

3Dmax must be in English. The Chinese version cannot output the DAE file, and the best software version is 3 Dmax 2011. I will not talk about it here.

Use the "Collada2POD" software to convert the DAE file to the pod file. Click it online. I am from the Internet.

The second problem is the loading of material and post images.

There is a pvr image loading problem on the Internet. I have never been able to load images in cocos2d or 3d, and I don't know why. It is said that the image must be long and wide at the Npower of 2. I really don't know why, so my post images are in png format. So I didn't use the pvr SDK, but there are some good tools here. For example, PVRshaman can be used to open a file in the pod format, view the model object name in the pod, and then independently call these 3D objects in cocos3d.

The format of the 3Dmax image is. how can we convert this image into png format? The problem is very simple, download a photoshop plug-in on the Internet to open the dds file and put it in the specified folder of photoshop. Open the DDS file and save it as a png file.

The third problem is the use of cocos3d.

If you have the basics of cocos2d, learn cocos3d. I will not talk about it here. Let's take a look at the tutorial below.

Detailed graphic Tutorial:

First, we need to download a 3Dmax model file from the Internet. (The dds file in the image below is the post image file of 3Dmax, And we will convert it to a png Image Using photoshop later. I converted the DAE file in the image. Ignore)

Use 3Dmax to check the effect:

Select the model you want to export and export the 3D mode you want to output to a file in DAE format:

Now, we can use notepad or other software to open the DAE file. We can see that the DAE file is actually an XML text file. Because the post image file used by 3Dmax is an image in the dds format, the image loading information in this DAE file is naturally in the dds format. All we need to do is replace the dds image name here with the png Image name we will use later. See. Find the dds image information in the DAE file and change it to png. I only changed one image. Of course you want to change all six.

 

Save the changes. Then we use the "Collada2POD" software to convert the DAE file. The GUI program is simple and intuitive.

Open Collada2POD, load the DAE file at the bottom of the pod, and set up the DAE file. I don't know how to set this item. If anyone knows it, let me know about it, I can follow the settings below for ease of use. I have not investigated how to set parameters. Point convert in the lower-right corner to start conversion. Some people have encountered many problems here, various of which I have seen before. After clicking the conversion, there is no situation, only the top two lines of the image below have no conversion of objects below, and no pod file is found. Later I found out that the problem with 3Dmax was still solved. I had to install the English version and remember that all the software that foreigners use for Chinese people was castrated with disability software. So as long as it is a foreign software, do your best to use English in English, unless you think it is okay to use Chinese. It does not affect your work. Or you will not use some advanced usage. Then there is image processing. We need to use the dds plug-in of photoshop to open the post image in 3Dmax mode. Save it as png. I have 6 images in this model, so all the images need to be saved separately.

 

Now, you can use PVRShaman to open the pod file and check the effect.

It seems that the position of the post image is incorrect, but the loading below is successful. Regardless of this, let's load the pod to cocos3d and check the effect. Because the position is incorrect when I used this to load images in png format, this PVRShaman software is designed specifically for their company's PVR image. You don't need to check this software here. Without this software, it won't affect loading 3D models to ios. Copy the converted pod and png files to the MAC system.

Create a cocos3d project:

Next, you just need to give the project a name. We just want to learn, and my name is girl:

 

Next, add the image and POD file to the project file.

 

Add and modify the code. Comment out the "hello world. Because we want to load the beauty model. Here I instantiate a CC3PODResourceNode object. After loading a model file named girlmm. pod, the image file is not required. cocos3d will automatically load the file as long as the image name and format are correct.

 

The above hello world pod Loading Code is also commented out. Otherwise, if your model is not as big as the hello world model, it will be held hold.

Then, run the program and check the effect, but it seems that there is an error.

 

 

Comment out the error and run it.

 

After the operation, it seems like there is a situation, but how does this image seem to be a bit messy, a little far away, I can't tell you, let's change the coordinates of the camera. Take a closer look at what is going on.

Change the lens coordinates from (0.0, 0.0, 6.0) to (0.0, 1.0, 2.0,). Obviously, the original two-dimensional coordinate is added with a zcoordinate of the distance. This time, we can see that there is indeed a problem with the Post graph. Let's take a look at workshop.

 

It is found that there are many identical images on this image, which may be a problem. Let's go back to Photoshop and change it. Delete unused images from the back. Open the image with Photoshop and find that the image cannot be changed. Copy a layer. For example.

 

Then we change the size of the canvas. Here we cannot change the image size. The image will be deformed. Change the width from 1024 to 512 of the same height, and then confirm to move the image at the front of the height to the position at the right of 512*512. See the following results. Then, save the image and make the same changes to all other images. The image size is either 512x512 or 256x256.

Place these images in the original image location of the girl Project under the MAC system and Replace them all directly (Click Replace ).

After the replacement, you don't need to worry about anything. Let's run the program and try again to see the effect. Haha, this time the image is normal, but a little far away, a little bit can not see the beauty of the face. Let's pull the camera closer. (In fact, it is to change the lens coordinates)

 

It seems that the light is a bit left, and the right side is too dark. Looking at the coordinates of the light, we found that the coordinates of the light are on the left-2 (-2.0, 0.0, 0.0 ), we changed the coordinates of the light to 0.0, 0.0, and 3.0 in the middle. For example, the light was in the center. Good results.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.