官术网_书友最值得收藏!

Inspecting and modifying the scene

Panda3D is a great engine for quickly developing prototypes of games, because creating and modifying scenes works quick and easy. But sometimes quick is not fast enough and restarting the game to see a change taking effect is a frustrating and repetitive task. This is why Panda3D provides the scene explorer, which we will use in the following recipe.

Getting ready

The following instructions are going to modify the code created in the recipe Loading models and actors, which can be found in this chapter.

How to do it...

The following tasks will introduce you to the features of the scene explorer:

  1. Add the highlighted lines to Application.py:
    from panda3d.core import Vec3
    from pandac.PandaModules import loadPrcFileData
    
    loadPrcFileData("", "want-directtools #t")
    loadPrcFileData("", "want-tk #t")
    
    class Application(ShowBase):
        def __init__(self):
  2. Press F6 to start the application. Next to the game window, you will see the screenshot similar to this:
  3. Push the Wireframe button to enable wireframe rendering.
  4. Select the Grid tab and enable the grid:
  5. Go to the Tasks tab and push the Update button to watch all active tasks:
  6. Expand the PandaNode DIRECT node in the tree view on the left side of the window. You will see the following tree:
  7. Right-click the ModelRoot teapot.egg node and click Place to open the Placer Panel enter the values from the following screenshot:
  8. Click Placer | Print info to output your settings to Netbeans' Output pane:
  9. Close the Placer Panel.
  10. Left-click ModelRoot teapot.egg in the tree view to make it the active selection.
  11. Right-click ModelRoot teapot.egg and click Set Color.
  12. In the RGBA Panel, set the following values:
  13. Click the Print to Log button to output the color value to the Output pane of Netbeans.

How it works...

The scene explorer is enabled in the first step by setting the configuration flags want-directtools and want-tk at runtime using the loadPrcFileData() function.

Although it will never be able to replace a proper level editor, the scene explorer can come in very handy to quickly place objects, especially if you use the buttons to print your settings to the Output pane of Netbeans. These little snippets can then be copied and pasted to our code to make the changes permanent.

主站蜘蛛池模板: 沂南县| 诸城市| 富阳市| 杨浦区| 塔河县| 铅山县| 崇明县| 梁山县| 云阳县| 余姚市| 承德市| 兰溪市| 章丘市| 通海县| 宣武区| 南部县| 循化| 舟山市| 陇川县| 武城县| SHOW| 佳木斯市| 固安县| 仙桃市| 扎赉特旗| 靖江市| 邛崃市| 水富县| 巴塘县| 巴彦县| 利辛县| 江川县| 乐陵市| 巴彦淖尔市| 武夷山市| 秦皇岛市| 宝山区| 库尔勒市| 镇远县| 云和县| 兴文县|