Q: How can I create texture maps for my created objects?
- P
- Package
- {
- Import flash. display. Sprite;
- Import flash. display. Bitmap;
- Import flash. display. bitmapdata;
- Import flash. Events .*;
- Import Sandy. Core. scene3d;
- Import Sandy. Core. scenegraph .*;
- Import Sandy. Core. Data .*;
- Import Sandy. Materials .*;
- Import Sandy. Materials. Attributes .*;
- Import Sandy. Primitive .*;
- Public class mytexture extends Sprite
- {
- Private var scenne: scene3d;
- Private var camera: camera3d;
- Private var IMG: bitmapdata = new brickwall (0, 0 );
- Private var bitmap: bitmap = new Bitmap (IMG );
- Private var plane: plane3d;
- Public Function mytexture ()
- {
- Camera = new camera3d (400,300 );
- Camera. z =-400;
- VaR root: Group = createscene ();
- Scenne = new scene3d ("scene1", this, camera, root );
- Addeventlistener (event. enter_frame, run );
- }
- Private function createscene (): Group
- {
- VaR G: Group = new group ();
- VaR material: bitmapmaterial = new bitmapmaterial (bitmap. bitmapdata );
- VaR ape: appearance = new appearance (material); // Add Material
- Plane = new plane3d ("theplane", 300,300 );
- Plane. Appearance = ape; // surface texture
- G. addchild (plane );
- Return g;
- }
- Private function run (Event: Event): void
- {
- Scenne. Render ();
- // Plane. rotatex + = 5;
- Plane. rotatey + = 1;
- // Plane. Roll + = 5;
- }
- }
- }
There are not many things done here. The idea is very simple. First, import the class library required by the texture.
- Import Sandy. Core. scene3d;
- Import Sandy. Core. scenegraph .*;
- Import Sandy. Core. Data .*;
- Import Sandy. Materials .*;
- Import Sandy. Materials. Attributes .*;
- Import Sandy. Primitive .*;
- Import Sandy. Materials .*;
- Import Sandy. Materials. Attributes .*;
- Is responsible for material work. We need to pay attention to the methods in this package to facilitate our call.
Production ideas:
The old idea is to create a camera, a scene, and a plane for us to map.
- Private var IMG: bitmapdata = new brickwall (0, 0 );
- Private var bitmap: bitmap = new Bitmap (IMG );
See here
To make the material change and display it to the created object, use the following statements:
VaR material: bitmapmaterial = new bitmapmaterial (bitmap. bitmapdata); // display the material to the object
- VaR ape: appearance = new appearance (material); // Add Material
- Plane = new plane3d ("theplane", 300,300 );
- Plane. Appearance = ape; // surface texture
- After a texture is assigned to a plane, Scene Rendering is the last step to display the texture.
- Scenne. Render ();
Summary process:
Create a camera, create a scene with a camera, and render the scene for the scene object (you can also add some simple effects to the object.