Sandy engine learning notes: texture textures

Source: Internet
Author: User

Q: How can I create texture maps for my created objects?

  1. P

  1. Package
  2. {
  3. Import flash. display. Sprite;
  4. Import flash. display. Bitmap;
  5. Import flash. display. bitmapdata;
  6. Import flash. Events .*;
  7. Import Sandy. Core. scene3d;
  8. Import Sandy. Core. scenegraph .*;
  9. Import Sandy. Core. Data .*;
  10. Import Sandy. Materials .*;
  11. Import Sandy. Materials. Attributes .*;
  12. Import Sandy. Primitive .*;
  13. Public class mytexture extends Sprite
  14. {
  15. Private var scenne: scene3d;
  16. Private var camera: camera3d;
  17. Private var IMG: bitmapdata = new brickwall (0, 0 );
  18. Private var bitmap: bitmap = new Bitmap (IMG );
  19. Private var plane: plane3d;
  20. Public Function mytexture ()
  21. {
  22. Camera = new camera3d (400,300 );
  23. Camera. z =-400;
  24. VaR root: Group = createscene ();
  25. Scenne = new scene3d ("scene1", this, camera, root );
  26. Addeventlistener (event. enter_frame, run );
  27. }
  28. Private function createscene (): Group
  29. {
  30. VaR G: Group = new group ();
  31. VaR material: bitmapmaterial = new bitmapmaterial (bitmap. bitmapdata );
  32. VaR ape: appearance = new appearance (material); // Add Material
  33. Plane = new plane3d ("theplane", 300,300 );
  34. Plane. Appearance = ape; // surface texture
  35. G. addchild (plane );
  36. Return g;
  37. }
  38. Private function run (Event: Event): void
  39. {
  40. Scenne. Render ();
  41. // Plane. rotatex + = 5;
  42. Plane. rotatey + = 1;
  43. // Plane. Roll + = 5;
  44. }
  45. }
  46. }

There are not many things done here. The idea is very simple. First, import the class library required by the texture.

  1. Import Sandy. Core. scene3d;
  2. Import Sandy. Core. scenegraph .*;
  3. Import Sandy. Core. Data .*;
  4. Import Sandy. Materials .*;
  5. Import Sandy. Materials. Attributes .*;
  6. Import Sandy. Primitive .*;
  7. Import Sandy. Materials .*;
  8. Import Sandy. Materials. Attributes .*;
  9. 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.

  1. Private var IMG: bitmapdata = new brickwall (0, 0 );
  2. 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

      1. VaR ape: appearance = new appearance (material); // Add Material
      1. Plane = new plane3d ("theplane", 300,300 );
      2. Plane. Appearance = ape; // surface texture
    1. After a texture is assigned to a plane, Scene Rendering is the last step to display the texture.
    2. 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.

    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.