Sandy engine learning notes: multi-dimensional textures

Source: Internet
Author: User

 

In the sandy engine, we can map multiple dimensions. The box class is a typical example. It can perform multi-faceted textures and different Paster effects on the six faces. The procedure is very simple. You can select different surfaces only when presenting the surface, give different surfaces such a simple effect.

 

There is a getface method in the box class, which can return the primitiveface type. This type contains an appearance attribute. Using this attribute, we can assign different methods.

  Appearance: appearance
Getface (p_nface: uint): primitiveface returns a primitiveface object (an array of polygons) Defining the specified face. simple process: Embed several images in flash and process bitmap as links. Here we only use the image for demonstration and change it to face1 --- face5 for different faces, first, we need to do some simple processing. Prepare multiple textures as follows: Private var skin1: bitmapdata = new face1 (); var Material1: bitmapmaterial = new bitmapmaterial (skin1); var app1: appearance = new appearance (Material1); // create a material surface box for the object. getface (0 ). appearance = app1 ;// Specify the material surface ...... the method is the same. In this way, we can create different textures for the box at http://blog.5d.cn/user45/hero82748274/category/148744.htmlcode labels: Package <br/> {<br/> Import flash. display. sprite; <br/> Import flash. events. *; <br/> Import Sandy. core. scene3d; <br/> Import Sandy. core. scenegraph. *; <br/> Import Sandy. primitive. *; <br/> Import Sandy. core. data. *; <br/> Import Sandy. materials. *; <br/> Import Sandy. materials. attributes. *; <br/> Import Sandy. core. scenegraph. mode7. *; <br/> Import flash. UI. keyboard; </P> <p> Import flash. display. bitmap; <br/> Import flash. display. bitmapdata; <br/> public class my3d2 extends sprite <br/>{< br/> private var scenne: scene3d; <br/> private var camera: cameramode7; <br/> private var rAny: Number = 0.5; <br/> private var box: box; <br/> private var skin1: bitmapdata = new face1 ); <br/> private var skin2: bitmapdata = new face2 (0, 0); <br/> private var skin3: bitmapdata = new face3 (0, 0); <br/> private var skin4: bitmapdata = new face4 (0, 0); <br/> private var skin5: bitmapdata = new face5 (0, 0); <br/> private var skin6: bitmapdata = new face6 (0, 0 ); </P> <p> private VaR _ leftpush: Number = 0; <br/> private VaR _ rightpush: Number = 0; <br/> private VaR _ uppush: int = 0; <br/> private VaR _ downpush: Int = 0; <br/> Public Function my3d2 () <br/> {<br/> camera = new cameramode7 (400,400); // set the camera size and position <br/> camera. X = 0; <br/> camera. y = 100; <br/> camera. z =-200; <br/> camera. tilt = 20; </P> <p> var root: Group = createscene (); </P> <p> scenne = new scene3d ("scene1", this, camera, root); // create a scenario with a camera <br/> addeventlistener (event. enter_frame, run); <br/>}< br/> private function createscene (): group <br/>{< br/> var G: Group = new group (); <br/> box = new box ("box", 100,100,100); </P> <p> var Material1: bitmapmaterial = new bitmapmaterial (skin1 ); <br/> var material: bitmapmaterial = new bitmapmaterial (skin2); <br/> var materi_3: bitmapmaterial = new bitmapmaterial (skin3); <br/> var material4: new bitmapmaterial (skin4); <br/> var material5: bitmapmaterial = new bitmapmaterial (skin5); <br/> var material6: bitmapmaterial = new bitmapmaterial (skin6 ); <br/> material1.lightingenable = true; <br/> material2.lightingenable = true; <br/> enabled = true; <br/> material4.lightingenable = true; <br/> material5.lightingenable = true; <br/> material6.lightingenable = true; <br/> var app1: appearance = new appearance (Material1); // create a material surface for an object <br/> var app2: appearance = new appearance (material); // create a material surface for the object <br/> var app3: appearance = new appearance (materi_3 ); // create a material surface for the object <br/> var app4: appearance = new appearance (material4); // create a material surface for the object <br/> var app5: appearance = new appearance (material5); // create a material surface for the object <br/> var app6: appearance = new appearance (material6 ); // create a material surface for the object <br/> box. rotatex = 10; <br/> box. rotatey = 0; <br/> box. getface (0 ). appearance = app1; // specify the material surface <br/> box. getface (1 ). appearance = app2; // specify the material surface <br/> box. getface (2 ). appearance = app3; // specify the material surface <br/> box. getface (3 ). appearance = app4; // specify the material surface <br/> box. getface (4 ). appearance = app5; // specify the material surface <br/> box. getface (5 ). appearance = app6; // specify the material surface </P> <p> camera. lookat (box. x, box. y, box. z); <br/> G. addchild (box); <br/> return g; </P> <p >}< br/> private function run (Event: Event ): void <br/> {<br/> scenne. render (); <br/> box. rotatex + = 1; // Let the cube rotate on the X axis <br/> box. rotatey + = 1; // Let the cube rotate on the Y axis <br/> // keypress (); <br/>}</P> <p >}< br/>}

 

 

 

 

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.