c++的3D游戏笔录-基于panda3d(2)
1、panda3d使用了称为场景图(the Scene Graph)的树形数据结构,包括了所有需要渲染的对象,树根对象名为render。
2、通过window->get_render()得到render节点路径。
3、使用reparent_to()方法安装草地风景模型在场景图中。
4、 set_scale()和set_pos()调整大小和居中模型。
5、panda3d使用地理坐标系统, 比如,-28, 49, 0)表示(8, 42) 高度0.
地理坐标系(Geographic Coordinate
System),是使用三维球面来定义地球表面位置,以实现通过经纬度对地球表面点位引用的坐标系。
用 X 表示经度值并用 Y 表示纬度值
panda3d的forward改变了 Y坐标。
#include <iostream>
#include "pandaFramework.h"
#include "pandaSystem.h"using namespace std;
int main()
{PandaFramework framework;framework.open_framework();// Set the window title and open the windowframework.set_window_title("game2");WindowFramework* window = framework.open_window();// Load the environment model.NodePath scene = window->load_model(framework.get_models(), "models/environment");// Reparent the model to render.scene.reparent_to(window->get_render());// Apply scale and position transforms to the model.scene.set_scale(0.25f, 0.25f, 0.25f);scene.set_pos(-8, 42, 0);// Do the main loop, equal to run() in pythonframework.main_loop();framework.close_framework();return (0);
}
Panda3D 运行了一个任务,允许你移动摄像头使用鼠标。
通过下面命令启用它。
window->setup_trackball();
// panda3d-1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//#include <iostream>
#include "pandaFramework.h"
#include "pandaSystem.h"using namespace std;
// The global task managerPT(AsyncTaskManager) taskMgr = AsyncTaskManager::get_global_ptr();// The global clockPT(ClockObject) globalClock = ClockObject::get_global_clock();// Here's what we'll store the camera in.NodePath camera;// This is our task - a global or static function that has to return DoneStatus.// The task object is passed as argument, plus a void* pointer, containing custom data.// For more advanced usage, we can subclass AsyncTask and override the do_task method.AsyncTask::DoneStatus spinCameraTask(GenericAsyncTask* task, void* data) {// Calculate the new position and orientation (inefficient - change me!)double time = globalClock->get_real_time();double angledegrees = time * 6.0;double angleradians = angledegrees * (3.14 / 180.0);camera.set_pos(20 * sin(angleradians), -20.0 * cos(angleradians), 3);camera.set_hpr(angledegrees, 0, 0);// Tell the task manager to continue this task the next frame.return AsyncTask::DS_cont;}int main()
{PandaFramework framework;framework.open_framework();// Set the window title and open the windowframework.set_window_title("game2");WindowFramework* window = framework.open_window();// Get the camera and store it in a variable.camera = window->get_camera_group();// Load the environment model.NodePath scene = window->load_model(framework.get_models(), "models/environment");// Reparent the model to render.scene.reparent_to(window->get_render());// Apply scale and position transforms to the model.scene.set_scale(0.25f, 0.25f, 0.25f);scene.set_pos(-8, 42, 0);// Add our task.// If we specify custom data instead of NULL, it will be passed as the second argument// to the task function.taskMgr->add(new GenericAsyncTask("Spins the camera", &spinCameraTask, nullptr));// Do the main loop, equal to run() in pythonframework.main_loop();framework.close_framework();return (0);
}
c++的3D游戏笔录-基于panda3d(2)相关推荐
- c++的3D游戏笔录-基于panda3d(3)
1.taskMgr.add() 在panda3d的任务管理器在每个镜头中增加一个回调函数spinCameraTask() . 回调函数用来控制相机. AsyncTask::DoneStatus spi ...
- C++的3d游戏笔录-基于panda3d(1)
1.下载并安装panda3d https://www.panda3d.org/ 2.新建一个控件台项目. 更改主CPP文件 // panda3d-1.cpp : 此文件包含 "main&qu ...
- c++的3D游戏笔录-基于panda3d(4)
1.要创建自己的Actor类,至少完成以下工作: 加载Actor模型 加载动画 使用AnimControl或AnimControlCollection建造模型和动画 2.加载panda模型和行走动画, ...
- quake3 android,Android 3D游戏引擎研发(基于Quake3开源引擎移植)
摘要: 随着移动设备的性能提高和3D图形技术在移动设备领域的应用,在移动设备上研发3D游戏.3D场景将会成为一个新的亮点.3D游戏引擎是研发3D游戏.3D场景的核心技术.目前Android系统发展迅速 ...
- 3D游戏 java_基于Java的开源3D游戏引擎jMonkeyEngine
jMonkeyEngine简介 jMonkeyEngine是一款纯Java语言编写的游戏引擎,继承了Java应用跨平台的特性,而且是开放源代码的,遵循BSD开源协议,BSD开源协议用一句简单的话概括就 ...
- python3的3D实战-基于panda3d(1)
Panda 3D 是一个3D游戏引擎:一个 3D 渲染和游戏开发库 开发维护者:迪士尼VR工作室和卡耐基梅隆娱乐技术中心 授权协议:BSD 类继承自ShowBase.这个类加载大多数其他Panda3D ...
- 《游戏开发基础》课程论文丨基于Unity与Bolt的抗美援朝主题3D游戏设计
文章目录 摘要 关键词 一.导言 二.角色操控 2.1 隐藏鼠标 2.2 通过移动鼠标更新玩家视角 2.3 使角色跳跃 2.4 使角色移动 2.5 使角色冲刺 2.6 使角色卧倒 2.7 设置准星及切 ...
- 基于Volcano 3D游戏引擎开发一个类似魔兽世界的场景
VOLCANO MMORPG 3D游戏引擎简介 1.基本介绍:http://volcano2014.cn/ VOLCANO是一款MMORPG(大型多人在线角色扮演)3D网络游戏的开发引擎,用作支持用户 ...
- [推荐]C#快速开发3d游戏工具--Unity3d
最近有幸接触了一点Unity3d的东西,和大家分享一下. Unity3d 简介 是一款可视化的,3d游戏开发软件.可以进行手动绘制3d场景,自己添加摄像机角度,3d模型设计,事件触发,对于园子里大家很 ...
最新文章
- Flutter开发之MVC设计模式:新建文件与导入文件(八)
- Kali Linux软件更新日报20190623
- 在其他数都出现偶数次的数组中找到出现奇数次的数
- 分析各种排序算法的优劣
- python decorator_python 中的decorator
- 【Python 必会技巧】lambda 表达式(匿名函数)及其在内置函数中的应用
- geany配置python3.8_Parrot security 4.10-amd64
- 63.1拓展之box-shadow属性
- ENVI完整安装步骤
- vhdl8三种方式实现38译码器
- 硬盘“AHCI”模式和“IDE”模式的区别
- 【考研英语语法】一般将来时练习题
- 内推 | 字节跳动内推
- 分类流控qdisc之htb
- LEDE+iKuai双软路由整合
- echo 多行_【庭审现场】利用注销公司诈骗 多行不义必自毙_政务_澎湃新闻
- 老嘤学习笔记python输入输出
- vue3定位当前位置,获取当前位置的经纬度
- 微信小程序开发(十二)富文本插件wxParse的使用
- 程序员容易读错的IT专业术语词典
热门文章
- antd table 排序如何使用_antd table按表格里的日期去排序操作
- Cisco 思科计算机网络 见习总结(一)(路由器密码破解,telnet远程登陆
- 计算机如何启动及为何MBR的地址为0x7c00
- Unity Shader入门精要第七章 基础纹理 凹凸映射之在世界空间下计算
- php recursion,php5.1.6情况下,出现RECURSION。求破!!!
- 不创建临时变量交换两个数,这才是高手
- 面试中常被问到的(21)TCP/UDP如何保持可靠性
- 基于Cohesive单元的二维水力压裂(二)
- 微信小程序云开发读取数据库集合,显示到前端页面
- 我的微信小程序完整项目