Silverlight C # Game Development: L2 custom Model import

Source: Internet
Author: User

The Geometries of Balder provides many existing models, such as cubes and columns. However, when developing games, we usually use 3D design tools to create custom 3D models, this article describes how to import and display a custom 3D model.

First, let's look at the built-in Geometries model. You can view it in the object browser or Geometries.

The Heightmap in it will be introduced later. This time we will mainly introduce Mesh (Mesh object) and use it to import custom models.

Then, prepare a 3D design tool, 3Dmax, Maya, Lightwave, or ......, Well, let's simply use the popular 3 DMax to open the Max software, pull a pot from the Object, select File-> export, and select the ASE file format.

Save the name as teapot. the ase file is added to our project. This project can be modified from L1. See or download Silverlight C # Game Development: L1 3D world construction.

Change the file compilation method to Resource, that is, Resource mode. Set the Silverlight Control name to Lesson02 and add the following code to the constructor:

// L1
Game game = new Game () {Width = 600, Height = 400 };
Game. Camera = new Camera ();
Game. Camera. Position = new Coordinate (100,150,100 );
Game. Camera. Target = new Coordinate (0, 0, 0 );
Game. Children. Add (new OmniLight () {Position = new Coordinate (0, 0, 0 )});

// L2
// A new Mesh object Mesh
Mesh Teapot = new Mesh ();
// Set coordinates
Teapot. Position = new Coordinate (0, 0, 0 );
// Enable interaction (you can use the mouse to rotate)
Teapot. InteractionEnabled = true;
// Read the file name. Currently, the file format of ase is supported.
Teapot. AssetName = new Uri ("/Balder_Studio; component/Res/teapot. ase", UriKind. Relative );
// Add the teapot to the Game
Game. Children. Add (Teapot );

LayoutRoot. Children. Add (game );

 

Please note that the directory of the Uri assigned by AssetName must be the same as the location you added to. If this is not too clear, please refer to the project that comes with it and download the source code.

In this case, you may find some errors because the namecontrol reference is not added and the namespace Using is added to the file header:

Using Balder. Execution;
Using Balder. Lighting;
Using Balder. View;
Using Balder. Math;
Using Balder. Objects. Geometries;

Well, don't forget to add the control in MainPage to Lesson02. Run it and check the effect. The following is the Silverlight program:


If you think it is too small, you can modify the camera coordinates to adjust the observed range. We will introduce the camera and light in the next chapter.

Source code: Click here to download the project

If Balder. dll is missing in the project, download it quickly here: SL4_Balder.rar

We recommend the Silverlight game development blog:Dark blue right hand 

 

 

Related Article

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.