Sandy engine learning notes: Create a cube

Source: Internet
Author: User

Q: How can I use Sandy's class library to create a cube?

First, we need to first understand the structure of the sandy class library.

 

 

We can see the class library table released on the official website above, which is easy to understand, such as Sandy. events and flash. event Events are similar. If we want to create a cube, we use Sandy. the primitive class package contains a box class, which mainly creates some simple models. This time we only need to use box

 

VaR mybox: box = new box ("thebox", 50,100,150, primitivemode. TRI, 2 );

This is a process of creation. Is it very simple? In fact, official documents are not well written. Fortunately, the official website provides code training and explanations. Good nonsense novels. The above creation is just a box class, mainly to create some cube and rectangular model. Ignore the last two parameters.

VaR mybox: box = new box ("thebox", 50,100,150 );

 

The first name, the second name, the third name, and the fourth name respectively indicate the length, width, and height.

 

 

  1. Package {
  2. Import flash. display. Sprite;
  3. Import flash. Events .*;
  4. Import Sandy. Core. scene3d;
  5. Import Sandy. Core. scenegraph .*;
  6. Import Sandy. Primitive .*;
  7. Import Sandy. Core. Data .*;
  8. Import Sandy. Materials .*;
  9. Import Sandy. Materials. Attributes .*;
  10. Public class my3d extends Sprite
  11. {
  12. Private var scenne: scene3d;
  13. Private var camera: camera3d;
  14. Private var rAny: Number = 0.5;
  15. Private var box: box;
  16. Public Function my3d ()
  17. {
  18. Camera = new camera3d (300,300 );
  19. Camera. z =-400;
  20. VaR root: Group = createscene ();
  21. Scenne = new scene3d ("scene1", this, camera, root );
  22. Addeventlistener (event. enter_frame, run );
  23. }
  24. Private function createscene (): Group
  25. {
  26. VaR G: Group = new group ();
  27. Box = new box ("box", 100,100,100 );
  28. Box. rotatex = 30;
  29. Box. rotatey = 30;
  30. G. addchild (box );
  31. Return g;
  32. }
  33. Private function run (Event: Event): void
  34. {
  35. Scenne. Render ();
  36. Box. rotatex = mousex;
  37. Box. rotatey = Mousey;
  38. }
  39. }
  40. }

 

You do not need to read the code for the moment. First, we understand the creation process. We create a scenario, a camera, a box, and a stage. Let's assume that this is the right creation process, and a photographic machine is placed in the scene according to our ideas. Locate in a position and watch at a position, which is the cube we want to observe.

It will be rendered in the scene before it can be displayed on the stage ..

It is such a process.

 

 

 

Note:

Import Sandy. Core. scene3d; // scenario

Import Sandy. Core. scenegraph. *; // responsible for graphics

Import Sandy. Primitive. *; // Simple Model

 

This time, we mainly used three packages of the sandy engine. Its creation process is like shooting by a director. Create a scenario, create a role, and render a scenario.

 

Well, next time we will learn about the camera, scene and texture maps, and advanced 3DS Model import.

 

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.