Panda3D 初学者教程(一)

原文链接

原文

Lesson 1

Hello World

In which we learn how to make and run a Panda3D instance, and how to load and manipulate models.

At it’s most basic, running a Panda3D program is quite simple: create a “ShowBase” object, and tell it to run.

Specifically, it can be convenient to make our main “game-class” a sub-class of ShowBase: this unifies our game-class with the ShowBase that we’ll run, and even gives us a globally-accessible variable, named “base”, that points to our game.

from direct.showbase.ShowBase import ShowBaseclass Game(ShowBase):def __init__(self):ShowBase.__init__(self)game = Game()
game.run()

If you run the code above, a window should open titled “Panda”, and showing an empty grey view:

By default, Panda3D opens an 800x600 window, which can be somewhat small. So, let’s make it a little bigger.

There are a few ways of doing this, but one simple method is to “request window properties”. In short, we create a “WindowProperties” object, set the properties that we want in that object, and then pass it back to Panda, requesting that it apply them.

I’ve chosen a window-size of 1000x750; modify this to suit your screen and preference.

from direct.showbase.ShowBase import ShowBase
from panda3d.core import WindowPropertiesclass Game(ShowBase):def __init__(self):ShowBase.__init__(self)properties = WindowProperties()properties.setSize(1000, 750)self.win.requestProperties(properties)game = Game()
game.run()

Panda3D by default uses a particular mouse-based camera-control. We probably don’t want to use that, so we disable that control, allowing us to (later) control the camera ourselves:

self.disableMouse()

Next, let’s consider adding some models to the scene…

翻译:

在其中,我们学习如何创建和运行Panda3D实例,以及如何加载和操作模型。
最基本的是,运行Panda3D程序非常简单:创建一个“ShowBase”对象,并告诉它运行。
具体来说,可以方便地将我们的主“游戏类”设置为ShowBase的子类:这将我们的游戏类与我们要运行的ShowBase统一起来,甚至为我们提供了一个全局可访问的变量,名为“base”,它指向我们的游戏。

from direct.showbase.ShowBase import ShowBaseclass Game(ShowBase):def __init__(self):ShowBase.__init__(self)game = Game()
game.run()

如果运行上述代码,将打开一个标题为“Panda”的窗口,并显示一个空的灰色视图:

默认情况下,Panda3D会打开一个800x600窗口,该窗口可能有些小。所以,让我们把它放大一点。
有几种方法可以做到这一点,但一种简单的方法是“请求窗口属性”。简而言之,我们创建一个“WindowProperties”对象,设置该对象中需要的属性,然后将其传递回Panda,请求它应用这些属性。
我选择了尺寸为1000x750的窗口;修改此选项以适合您的屏幕和偏好。

from direct.showbase.ShowBase import ShowBase
from panda3d.core import WindowPropertiesclass Game(ShowBase):def __init__(self):ShowBase.__init__(self)properties = WindowProperties()properties.setSize(1000, 750)self.win.requestProperties(properties)game = Game()
game.run()

默认情况下,Panda3D使用特定的基于鼠标的摄影机控件。我们可能不想使用它,所以我们禁用该控件,允许我们(稍后)自己控制相机:

self.disableMouse()

接下来,让我们考虑在场景中添加一些模型…

Panda3D 初学者教程(一)相关推荐

  1. panda3d python教程_panda3d 入门.docx

    panda3d 入门 PANDA3D入门----------古道天马前言这个是我自学的总结.因为刚开始看PANDA3D的教程,发现在看天书,静下心来学后,感觉其实是教程不够深入浅出,没有照顾我们这些一 ...

  2. SAP UI5 初学者教程之十九 - SAP UI5 数据类型和复杂的数据绑定

    一套适合 SAP UI5 初学者循序渐进的学习教程 教程目录 SAP UI5 本地开发环境的搭建 SAP UI5 初学者教程之一:Hello World SAP UI5 初学者教程之二:SAP UI5 ...

  3. SAP UI5 初学者教程之二十八 - SAP UI5 应用的集成测试工具 OPA 介绍试读版

    一套适合 SAP UI5 初学者循序渐进的学习教程 教程目录 SAP UI5 本地开发环境的搭建 SAP UI5 初学者教程之一:Hello World SAP UI5 初学者教程之二:SAP UI5 ...

  4. SAP UI5 初学者教程之二十七 - SAP UI5 应用的单元测试工具 QUnit 介绍试读版

    一套适合 SAP UI5 初学者循序渐进的学习教程 教程目录 SAP UI5 本地开发环境的搭建 SAP UI5 初学者教程之一:Hello World SAP UI5 初学者教程之二:SAP UI5 ...

  5. SAP UI5 初学者教程之二十六 - OData 服务配合 Mock 服务器的使用步骤详解试读版

    一套适合 SAP UI5 初学者循序渐进的学习教程 教程目录 SAP UI5 本地开发环境的搭建 SAP UI5 初学者教程之一:Hello World SAP UI5 初学者教程之二:SAP UI5 ...

  6. SAP UI5 初学者教程之二十五 - 使用代理服务器解决 SAP UI5 应用访问远端 OData 服务的跨域问题试读版

    一套适合 SAP UI5 初学者循序渐进的学习教程 教程目录 SAP UI5 本地开发环境的搭建 SAP UI5 初学者教程之一:Hello World SAP UI5 初学者教程之二:SAP UI5 ...

  7. SAP UI5 初学者教程之二十四 - 如何使用 OData 数据模型试读版

    一套适合 SAP UI5 初学者循序渐进的学习教程 教程目录 SAP UI5 本地开发环境的搭建 SAP UI5 初学者教程之一:Hello World SAP UI5 初学者教程之二:SAP UI5 ...

  8. SAP UI5 初学者教程之二十三 - 列表控件的排序 Sort 和分组 Group 试读版

    一套适合 SAP UI5 初学者循序渐进的学习教程 教程目录 SAP UI5 本地开发环境的搭建 SAP UI5 初学者教程之一:Hello World SAP UI5 初学者教程之二:SAP UI5 ...

  9. SAP UI5 初学者教程之应用开发 - 过滤器 filter 的开发和使用

    通过本教程前一步骤SAP UI5 初学者教程之二十一 - SAP UI5 的自定义格式器 Custom Formatter的学习,我们已经得到了一张发票列表: 本步骤我们更进一步,给这个列表添加一个搜 ...

最新文章

  1. 深度学习之后会是啥?
  2. 怎么将零件整合到一起_Fraunhofer ILT用于大型零件3D打印的“边飞行边加工”的LPBF概念...
  3. c# 在DataTable的第一列(指定列)的前面添加一列
  4. 在maven引入一个maven仓库中不存在的jar,安装本地底仓库
  5. confirm的意思中文翻译_confirm的中文意思
  6. 微博html怎么编辑器,类似新浪微博的编辑器 输入@就出现可选的下拉框 是怎么实现的...
  7. leanote 支持php,Leanote source leanote源码导读
  8. 国际电联秘书长特别代表杨晓雅:2020年全球将接入500亿物联网终端
  9. 麦克纳姆轮速度分解再分析
  10. 对多线程程序,单核cpu与多核cpu如何工作相关的探讨
  11. 远程连接ubuntu的MongoDB遇到的坑
  12. 2020-09-10 保证软件开发过程遵循ISO 26262标准的十个主要进阶步骤
  13. 课题申报书范文_高等学校教改课题申报书范文
  14. 1024 科学计数法(C语言详解)
  15. 什么是Csrss.exe进程?此进程有何作用?
  16. Java多线程编程核心技术 (pdf完整版)
  17. Spring Cloud 系列之 Netflix Eureka 注册中心
  18. 计算机硬盘启动设置方法,如何在BIOS中设置硬盘启动
  19. HDU 5745 La Vie en rose(水~)
  20. 如何成为前端开发工程师

热门文章

  1. Android自定义view-电子签名画板
  2. uniapp使用canvas完成手写电子签名
  3. ggridges包—峰峦图详细介绍
  4. 2020机修钳工(中级)考试及机修钳工(中级)复审模拟考试
  5. 安卓手机调试微信网页, 真机调试模式开启
  6. osgEarth示例分析——osgearth_srstest
  7. paraview热流图(1):添加glyphs
  8. 用户分析体系,该如何搭建
  9. 一般哪些原因会造成硬盘损坏呢
  10. 淘宝/天猫/1688拍立淘API接口(以图搜商品API接口,图片搜索API接口,图片搜索商品API接口)代码对接教程