Script code for 3D model rendering of normal textures (with source code), and 3d normal

Source: Internet
Author: User

Script code for 3D model rendering of normal textures (with source code), and 3d normal

I have studied the technology of wooyoogame over the past few days. The 3d display implementation of this website looks very simple. I have made a simple tutorial for you.

The script in it is not difficult to feel like json. It can be displayed by configuration.

First to the http://www.wooyoogame.com? Sp = 209 register an account, and click game development (install a plug-in) to write scripts.


1. Export the model (remember to adjust the unit of ratio to 1 meter). Otherwise, the model will be oversized or ultra-small.


2. Upload the exported obj model and texture image to the platform.


3. Read the model and create a model in the ide.

LoadModel("testMdl",":/tiantian/orge.obj","obj");Create({    type:"mesh";    model:"testMdl";});


The display effect is as follows:


4. Read the diff texture file of the model.

Clear (); LoadModel ("testMdl", ":/tiantian/orge. obj "," obj "); LoadImage (" bodyImg ",":/tiantian/body_dif.jpg "); LoadImage (" weaponImg ",":/tiantian/weapon_dif.jpg "); create ({type: "mesh"; model: "testMdl"; // model information Geometries: {index: 0, texture: "weaponImg "}; // sub-model 0 settings {index: 1, texture: "BodyImg"}; // sub-model 1 settings };});



Haha, now the basic effect is coming out, and the next step is to adjust more effects.

5. Read the normal texture and add more complex shader configurations.

Clear (); LoadModel ("testMdl", ":/tiantian/orge. obj "," obj "); SmoothModel (" testMdl "); LoadImage (" bodyImg ",":/tiantian/body_dif.jpg "); LoadImage (" body_nImg ",": /tiantian/body_nor.jpg "); LoadImage (" weaponImg ",":/tiantian/weapon_dif.jpg "); LoadImage (" weapon_nImg ",":/tiantian/Hangzhou "); create ({type: "mesh"; model: "testMdl"; // model information Geometries: {index: 0; shader: {type: "NormalMap"; Texture: "weaponImg"; normalMap: "weapon_nImg" ;};/// sub-model 0 settings {index: 1; shader: {type: "NormalMap"; Texture: "bodyImg "; normalMap: "body_nImg" ;};// submodel 0 settings };});



6. If there is a normal effect, we can see that the Orcs are exposed. Now we are adding some detailed settings, such as createMipmap, to generate the mipmap texture and light adjustment.

Clear (); LoadModel ("testMdl", ":/tiantian/orge. obj "," obj "); SmoothModel (" testMdl "); LoadImage (" bodyImg ",":/tiantian/body_dif.jpg "); CreateMipmap (" bodyImg ", 16 ); loadImage ("body_nImg", ":/tiantian/body_nor.jpg"); CreateMipmap ("body_nImg", 16); LoadImage ("weaponImg", ":/tiantian/snapshot "); createMipmap ("weaponImg", 16); LoadImage ("weapon_nImg", ":/tiantian/weapon_nor.jpg"); CreateMipmap ("weapon_nImg", 16); Create ({type: "mesh"; model: "testMdl"; // model information Geometries: {index: 0; shader: {type: "NormalMap"; Texture: "weaponImg"; normalMap: "weapon_nImg"; Ambient: {0.5, 0.5, 0.5}; Diffuse: {0.7, 0.7, 0.7}; Specular: {0.2, 0.2, 0.2 };};}; // set the sub-model 0 (weapon) to {index: 1; shader: {type: "NormalMap"; Texture: "bodyImg"; normalMap: "body_nImg"; Ambient: {0.5, 0.5, 0.5}; Diffuse: {0.7, 0.7, 0.7}; Specular: {0.2, 0.2, 0.2 };}; // submodel 1 (Body) settings };});



After the big job is done, you can save the script to generate a connection and view it online.

Http://www.feekood.com /? Path =:/tiantian/ShowOrge. ais


Source code download

Http://pan.baidu.com/s/1jGuxeSm

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.