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