当前位置:网站首页>Panda3D 获取鼠标位置、Panda3D任务管理器
Panda3D 获取鼠标位置、Panda3D任务管理器
2022-07-19 09:29:00 【bcbobo21cn】
看一下Panda3D Bump-Mapping示例;
运行起来是一个鼠标控制模型的例子;
它的Bump-Mapping是模型表面两种不同的效果;先不管;
它的房子模型单独用pview看一下如下;
先看一下鼠标控制相关代码;做一个小程序如下;获取鼠标位置,然后输出;
from math import pi, sin, cos
from direct.showbase.ShowBase import ShowBase
from direct.task import Task
from panda3d.core import Point3
from panda3d.core import Fog
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
md = base.win.getPointer(0)
x = md.getX()
y = md.getY()
print x
print y
app = MyApp()
app.run()
运行如下;输出了鼠标位置;但只输出了一次;
鼠标移动控制模型是如何实现的?看代码没有类似mousemove事件的东西;
根据它的手册,有一些内建的全局变量,
builtins.taskMgr (Python data, in Built-in Global Variables)
taskMgr是一个内建全局变量;taskMgr.add()指定一个被调用函数,
它的示例代码的函数是这样;
def controlCamera(self, task):
md = base.win.getPointer(0)
x = md.getX()
y = md.getY()
。。。。。。
self.last = task.time
return Task.cont
根据手册,
Task.cont
Perform the task again next frame;
重复执行任务,在下一帧;
就是每帧调用指定的函数;下回继续;
边栏推荐
- Is it safe to open an account in Shanghai Securities?
- tar. GZ file repair
- Nacos cluster setup (Reprint)
- Qt播放音视频文件报错DirectShowPlayerService::doRender: Unresolved error code 0x80040266
- C explanation of message dialog box based on MessageBox class
- A go interview question about defer understanding
- Nacos配置管理——配置共享
- 美国土安全部无授权下追踪国内外民众手机定位 花费数百万美元
- IDEA解决配置文件属性提示消失
- Druid configuration and monitoring
猜你喜欢
STM32+BH1750光敏传感器获取光照强度
Wechat applet_ 18. Communication between parent and child components
QIODevice
NoSQL-Mongodb
OpenHarmony littlefs文件系统存储结构与IO性能优化分析
Docker安装常用软件-Mysql
Stm32+bh1750 photosensitive sensor obtains light intensity
巴比特 | 元宇宙每日必读:虚拟人热度减退,有的“出道即巅峰”,围观人群都散了?...
C# 基于MessageBox类的消息对话框讲解
C explanation of message dialog box based on MessageBox class
随机推荐
线段树杂谈·普通线段数|乘法线段数|主席树
.NET 7 新增速率限制 (Rate Limiting) 功能,轻松限制请求数量
Outils de construction
Druid 配置和监控
Notepad++ software installation tutorial
一汽红旗“王炸”上市,安全、舒适一个不落
Unity实战问题-WebGL问题集锦-下篇
Find - b+ tree
Nacos集群搭建(转载)
PyG教程(8):计算更高效的稀疏矩阵形式
模板与泛型编程之退化技术
Vite 入门
php 零点定时任务,PHP Laravel定时任务Schedule【干货】
. Net 7 adds the rate limiting function to easily limit the number of requests
mysql进阶(八)排序问题方案探究
Notepad++软件安装教程
How to use swiftui to create drawing application based on coredata pencil Kit
JS method of obtaining URL address bar parameters to solve the problem of Chinese garbled code
Build tools
DolphinScheduler