c++的3D游戏笔录-基于panda3d(2)

article/2025/8/18 21:09:06

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);
}

http://chatgpt.dhexx.cn/article/7hJKJc0j.shtml

相关文章

Panda3D设置游戏背景颜色和节点颜色、透明度

Panda3D如何设置游戏背景颜色和节点颜色 ​ 在使用panda3D开发的过程中&#xff0c;遇到了很多问题&#xff0c;国内网站上的资源实在是太少&#xff0c;因此把自己遇到的比较费时间但是又很简单的问题整理了以下&#xff0c;以供后续开发者参考。 1.设置背景颜色 self.setB…

了解Panda3D引擎的配置变量

Panda3d 引擎带有一些配置变量&#xff1b; 可以通过C或python代码访问&#xff1b; 进入自带python环境&#xff1b;输入下图语句&#xff1b; cvMgr是全局实例&#xff0c;定义在ShowBase.py中&#xff1b; 然后列出了引擎的配置变量&#xff1b; 很多&#xff1b; 具体含…

如何将Blender模型导入Panda3d

两种方法&#xff0c;使用Blender插件&#xff0c;或者Blend2bam。 第一种方法&#xff1a;Blender导出插件 1.对于Blender 2.5, 2.6, 2.7版本&#xff0c;使用&#xff1a;YABEE,导出文件格式.egg 注意&#xff0c;YABEE不适用Blender2.8及以上版本 GitHub - 09th/YABEE: …

panda3d虚幻引擎--(2)

目录 前言&#xff08;阿巴阿巴&#xff09; 上帝视角 导入人物模型和动作模型 前言&#xff08;阿巴阿巴&#xff09; 前几天无意间看到了一个叫做panda3d的东西&#xff0c;觉得挺好玩&#xff0c;就翻教程&#xff0c;发现现在中文教程似乎没有那么全面成体系&#xff0…

python3的3D实战-基于panda3d(1)

Panda 3D 是一个3D游戏引擎&#xff1a;一个 3D 渲染和游戏开发库 开发维护者&#xff1a;迪士尼VR工作室和卡耐基梅隆娱乐技术中心 授权协议&#xff1a;BSD 类继承自ShowBase。这个类加载大多数其他Panda3D模块&#xff0c;并导致3D窗口出现。 run()方法包含Panda3D主循环…

python panda3d教程_panda3d学习笔记(一)Hello World

终于还是把电脑上的游戏(CS1.6和SC2)打腻了=_=,在无聊的双休,作业又写完的情况下怎么打发时间? 所以还是决定学一款游戏制作的库,我的MX250貌似带不动虚幻系列的引擎,在github上翻大佬的repo时,看到了panda3d这个3d游戏制作库,话不多说,打开官方的tutorial,开始学习…

panda3d场景的主要状态

场景的状态包括位置、方向、缩放比例、物体朝向、颜色、可见性、透明度、相机等。 最常改变的是位置和方向。 panda3d的默认坐标系&#xff1a;X向右&#xff0c;Y向前&#xff0c;Z向上。 对象方向使用欧拉角度坐标&#xff1b;由航向&#xff08;Heading|Yaw&#xf…

Panda3d如何获取到可用的模型?Maya、3D Max、OBJ等3D格式转换为egg、gltf文件

​ 使用Panda3d进行3D环境建模也有一段时间了&#xff0c;真的是被折磨的头秃。。。不过也不得不说&#xff0c;Panda3D也确实是一个比较优秀的3D游戏引擎&#xff0c;还是能满足你的大部分需要的。 ​ 如果你在深入使用Panda3d后&#xff0c;我相信有个问题那绝对是让人头大的…

Panda3D如何加载obj格式的3D模型文件

​ 在上文中&#xff0c;讲了如何将max、obj、mb、fbx等主流格式的3D模型文件转换为egg、gltf格式&#xff0c;Panda3D可以加载的格式。在上文末尾&#xff0c;博主临时看到了一种方式&#xff0c;可以让Panda3d直接加载obj格式的文件&#xff0c;因此本文来专门看下如何实现。…

Panda3D 初学者教程(一)

Panda3D 初学者教程&#xff08;一&#xff09; 原文链接 原文 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 …

panda3d虚幻引擎--(1)

目录 前言&#xff08;阿巴阿巴&#xff09; 安装 调整窗口 导入环境 前言&#xff08;阿巴阿巴&#xff09; 前几天无意间看到了一个叫做panda3d的东西&#xff0c;觉得挺好玩&#xff0c;就翻教程&#xff0c;发现现在中文教程似乎没有那么全面成体系&#xff0c;大部分…

图解 Panda3D引擎开发入门

Panda3D 是一个 3D 渲染和游戏开发框架&#xff0c;可以在这个框架下使用 Python 和 C 。Panda3D 是开源软件&#xff0c; 它的许可证让它可以用于任何用途&#xff0c; 包括商业用途。本文使用Panda3D 1.7.0版本&#xff0c;其最新稳定版本是1.7.2。可在官网下载最新稳定版本。…

3D游戏物理开发引擎Panda3D基础

文章目录 Panda3D场景安排模型加载渲染属性任务任务链事件处理主循环 视角相机阴影环境灯方向灯 控制key-events DirectGui碰撞检测后续 Panda3D场景安排 ​ Panda3D将其对象存储在场景图中&#xff0c;从本质上讲&#xff0c;这是一个对象的层次结构&#xff0c;称为节点。 ​…

Mac 终端快捷键设置:如何给 Mac 中的 Terminal 设置 Ctrl+Alt+T 快捷键快速启动

Mac 电脑中正常是没有直接打开终端命令行的快捷键指令的&#xff0c;但可以通过 commandspace 打开聚焦搜索&#xff0c;然后输入 ter 或者 terminal 全拼打开。但习惯了 linux 的同学会觉得这个操作很别扭。于是我们希望能通过键盘按键直接打开。 操作流程如下&#xff1a; 1…

OpenCV论道:为什么我的伽马校正函数只有一行?

最近在用 OpenCV 识别棋盘棋子&#xff0c;基本的思路是这样的&#xff1a;先转灰度&#xff0c;再做高斯模糊和二值化&#xff0c;此时棋盘格上有的有棋子&#xff0c;有的无棋子&#xff1b;通过迭代腐蚀&#xff0c;消去棋子&#xff0c;再迭代膨胀回来&#xff0c;就得到了…

【TA100】图形 2.6伽马(Gamma)校正

很好的视频 https://www.bilibili.com/video/BV15t411Y7cf/?spm_id_from333.788.b_636f6d6d656e74.96&vd_source6f3a5e0ac931d869aee3d7c9bb6847e0 一、Gamma校正 1.前言&#xff1a;颜色空间 ● 一些颜色空间的举例&#xff0c;&#xff08;具体参考2.1节内容&#xff0…

Gamma Correction(伽马校正)

定义 Gamma correction, gamma nonlinearity, gamma encoding, or often simply gamma, is the name of a nonlinear operation used to code and decode luminance or tristimulus values in video or still image systems.[1] Gamma correction is, in the simplest cases, …

从0开始的技术美术之路(十)伽马校正

本篇参考B站视频 “技术美术百人计划”霜狼_may &#xff1b; 《Shader入门精要》冯乐乐女神著&#xff1b; https://www.zhihu.com/question/27467127/answer/111973548 https://www.jianshu.com/p/9a91e6ad0d38 本篇主要用于自我复习&#xff0c;如有疑问或发现有什么错误&am…

2.6 伽马校正 一、Gamma校正

一、Gamma校正 颜色空间 通用&#xff1a;sRGB 电影&#xff1a;DCI-P3 电视&#xff1a;Rec-709、PAL等 印刷&#xff1a;CMYK、Adobe RGB 传递函数 我们知道了颜色的颜色值&#xff0c;要在电子设备上显示&#xff0c;就要把它转换为视频信号&#xff0c;传递函数就是用…

【剑桥摄影协会】伽马校正(Gamma)

伽马是数字成像系统的一个重要特征&#xff0c;它定义了像素值与其实际亮度之间的关系。在标准显示器上面&#xff0c;如果没有伽马&#xff0c;数码相机拍摄到的阴影内容便会跟我们实际看到的有所差异。平时我们所说的伽马校正、伽马编码、伽马压缩&#xff0c;都是伽马曲线的…