(Qt 翻译) QGLAbstractScene
QGLAbstractScene Class Reference
#include <QGLAbstractScene>
This class was introduced in Qt3D 4.8.
Public Types
| enum | FormatListType { AsFilter, AsSuffix } |
Public Functions
| QGLAbstractScene ( QObject * parent = 0 ) | |
| virtual | ~QGLAbstractScene () |
| virtual void | generatePickNodes () |
| virtual QGLSceneNode * | mainNode () const = 0 |
| int | nextPickId () |
| virtual QObject * | object ( const QString & name ) const |
| virtual QStringList | objectNames () const |
| virtual QList<QObject *> | objects () const = 0 |
| QList<QGLPickNode *> | pickNodes () const |
| virtual bool | pickable () const |
| virtual void | setPickable ( bool enable ) |
Static Public Members
| QGLAbstractScene * | loadScene ( const QUrl & url, const QString & format = QString(), const QString & options = QString() ) |
| QGLAbstractScene * | loadScene ( QIODevice * device, const QUrl & url, const QString & format = QString(), const QString & options = QString() ) |
| QGLAbstractScene * | loadScene ( const QString & fileName, const QString & format = QString(), const QString &options = QString() ) |
| QStringList | supportedFormats ( FormatListType t = AsFilter ) |
详细说明
QGLAbstractScene 这个类可以表示由0或更多个 QGLSceneNode 的实例组成的3D场景.
场景一般通过3D程序包创建,然后经由 QGLSceneFormatPlugin 存入应用程序. The functions in this class provide access to major scene objects so that they can be applied or drawn whenever the application decides.
QGLAbstractScene presents a very simple model of a 3D scene. Subclasses implement the specific scene graph and object representations in a manner specific to the package's format. Subclasses may also provide functionality to create new objects at runtime, but this is not required.
The scene is defined to consist of a number of important objects of the following types:
- Camera objects define a viewing position in world-coordinates and a projection that maps 3D world co-ordinates to 2D screen co-ordinates. Camera objects should inherit from QGLCamera.
- Main objects designate the major elements of the scene besides cameras, lights, and effects. Usually they inherit from QGLSceneNode.
- Light objects define positions and parameters for lighting the scene. Light objects should inherit fromQGLLightParameters.
- Effect objects define materials, shaders, and textures for use in rendering the surface of objects. Normally effects are activated automatically when main objects are drawn. But effects can be used independently if the 3D format is acting as a library of effects.
- Mesh objects define geometry information independently of effects. Normally meshes are drawn automatically with an appropriate effect when main objects are drawn. But meshes can be used independently if the 3D format is acting as a library of meshes. Mesh objects should inherit from QGLSceneNode.
Typically, the full scene represented by an external model format is not interesting to the application. 3D modelling packages regularly insert cameras, lights, effects, and other library objects that are useful to the modelling package, but not the application. The mainNode() is usually the most interesting to applications.
QGLAbstractScene makes it easy to access the major scene elements with object(), objects(), and mainNode().
There are many other kinds of objects in the scene that may not be accessible via QGLAbstractScene because they are not considered "important" enough. For example, a file that contains the data for a skateboard object would contain many objects for the board, wheels, texturing effects, animations, and so on. The application may only be interested in the skateboard as a whole, and not its sub-components. The skateboard would be considered an important main object in this case, which can be easily accessed and incorporated into the application's logic.
Each Subclass needs to provide its own policy for deciding which objects are considered "important".
See also QGLSceneNode and QGLSceneFormatPlugin.
Member Type Documentation
enum QGLAbstractScene::FormatListType
This enum specifies the format of the list returned by the supportedFormats() function.
| Constant | Value | Description |
|---|---|---|
| QGLAbstractScene::AsFilter | 0 | Return a format list that may be used as a filter. |
| QGLAbstractScene::AsSuffix | 1 | Return a format list that is simply the filename suffixes. |
Member Function Documentation
QGLAbstractScene::QGLAbstractScene ( QObject * parent = 0 )
Constructs a 3D scene and attaches it to parent.
QGLAbstractScene::~QGLAbstractScene () [virtual]
Destroys this 3D scene.
void QGLAbstractScene::generatePickNodes () [virtual]
Generates QGLPickNode instances for important QGLSceneNode instances that are pickable. Objects that are either not important or not pickable can be omitted. The default implementation simply generates pick nodes for every top level object of type QGLSceneNode.
Sub-classes may implement different schemes for picking. When doing so parent the QGLPickNode objects onto the scene, so that they will appear in the list returned by pickNodes()
See also pickNodes() and setPickable().
QGLAbstractScene * QGLAbstractScene::loadScene ( const QUrl & url, const QString & format = QString(), const QString & options = QString() ) [static]
Loads a scene from the internet in the specified format using the registered scene format plugins. If format is an empty string, then the format will be autodetected from the filename extension of the url, which specifies the location of the data online.
The options string is passed to the underlying format loader and its meaning and format depend on the loader. For example the format string for the .3ds loader accepts the following options:
- ForceSmooth - average normals for a smooth appearance
- ForceFaceted - per face normals for a faceted appearance
- NativeIndices - map native indices for poorly smoothed models
- CorrectNormals - fix inverted normals on models with bad windings
- CorrectAcute - fix normals on models that smooth acute angles
The options may be specified globally for the whole model, or just for a particular mesh.
In this example smoothing is forced on globally, and native indices are used on just the mesh called "BattCoverMesh".
QString op = "ForceSmooth BattCoverMesh=NativeIndices";
QString url = "http://www.example.url.com/music-player.3ds";
QGLAbstractScene *scene = QGLAbstractScene::loadScene(url, QString(), op);
Returns the scene object, or null if the scene could not be loaded or the format was not supported by any of the plugins.
The scene object returned by this will contain only a single stub node at the root of the scenegraph, which will be filled out later once the asynchronous download of the scene data is complete.
See also QGLSceneFormatPlugin.
QGLAbstractScene * QGLAbstractScene::loadScene ( QIODevice * device, const QUrl & url, const QString & format = QString(), const QString & options = QString() ) [static]
Loads a scene from device in the specified format using the registered scene format plugins. If format is an empty string, then the format will be autodetected from the filename extension of device. The url specifies the location of the data in device so that relative resources can be located.
The options string is passed to the underlying format loader and its meaning and format depend on the loader. For example the format string for the .3ds loader accepts the following options:
- ForceSmooth - average normals for a smooth appearance
- ForceFaceted - per face normals for a faceted appearance
- NativeIndices - map native indices for poorly smoothed models
- CorrectNormals - fix inverted normals on models with bad windings
- CorrectAcute - fix normals on models that smooth acute angles
The options may be specified globally for the whole model, or just for a particular mesh.
In this example smoothing is forced on globally, and native indices are used on just the mesh called "BattCoverMesh".
QString op = "ForceSmooth BattCoverMesh=NativeIndices";
QString file = "music-player.3ds";
QGLAbstractScene *scene = QGLAbstractScene::loadScene(file, QString(), op);
Returns the scene object, or null if the scene could not be loaded or the format was not supported by any of the plugins.
To debug scene loading export the environment variable QT3D_DEBUG_MODEL, and (depending on backend implementation) the loader can produce useful debugging information on the console.
See also QGLSceneFormatPlugin.
QGLAbstractScene * QGLAbstractScene::loadScene ( const QString & fileName, const QString &format = QString(), const QString & options = QString() ) [static]
Loads a scene from fileName in the specified format, with the supplied options, and using the registered scene format plugins.
If format is an empty string, then the format will be autodetected from the extension of fileName.
The options string is passed to the underlying format loader and its meaning and format depend on the loader. See the doc above for loadScene() for details on the 3ds format options.
Returns the scene object, or null if the scene could not be loaded or the format was not supported by any of the plugins.
See also QGLSceneFormatPlugin.
QGLSceneNode * QGLAbstractScene::mainNode () const [pure virtual]
Returns the main mesh node in the scene, or null if the scene does not contain a main mesh node.
See also objects().
int QGLAbstractScene::nextPickId ()
Increments and returns the next available pick id for this scene.
QObject * QGLAbstractScene::object ( const QString & name ) const [virtual]
Returns the scene object that has the specified name; or null if the object was not found.
The default implementation searches objects() for an object that matches name.
See also objects().
QStringList QGLAbstractScene::objectNames () const [virtual]
Returns a list of the names of all objects in the scene which are considered important, and which have non-empty names associated with them.
The default implementation calls objects() and then compiles a list of all non-empty object names.
See also objects().
QList<QObject *> QGLAbstractScene::objects () const [pure virtual]
Returns a list of all objects in the scene which are considered important.
Important objects will typically be the main mesh object, cameras, lights, and other top-level objects. Sub-meshes and effects are normally not considered important unless the scene is acting as a library of meshes and effects.
See also objectNames(), object(), and mainNode().
QList<QGLPickNode *> QGLAbstractScene::pickNodes () const
Returns a list of the pick nodes that have been parented onto this scene.
See also generatePickNodes().
bool QGLAbstractScene::pickable () const [virtual]
Returns true if this scene is pickable.
See also setPickable().
void QGLAbstractScene::setPickable ( bool enable ) [virtual]
Sets this scene to be pickable if enable is true, otherwise picking is disabled. If the scene is set to be pickable, pick nodes are generated by calling generatePickNodes().
See also generatePickNodes() and pickable().
QStringList QGLAbstractScene::supportedFormats ( FormatListType t = AsFilter ) [static]
Returns a list of all supported formats known by currently available sceneformat plugins, in the format type t.
If t is QGLAbstractScene::AsFilter then the result may be passed to QDir::setNameFilters(), or used in other filters. This is the default.
For example to create a file dialog to load model files use this:
QString modelsDir = QDir::toNativeSeperators(QDir::homePath());
QString filter = tr("Models (%1)").arg(QAbstractScene::supportedFormats().join(" "));
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open File"), modelsDir, filter));
Otherwise (when t is QGLAbstractScene::AsSuffix) it is simply a list of file name suffixes.
Note that this function may be expensive to call since it scans for available plugins, and loads each one it finds to get an accurate report of formats supported at run-time.
(Qt 翻译) QGLAbstractScene的更多相关文章
- qt翻译和国际化的探讨。
这段时间一直都在怼qt的国际化,以前也接触过国际化,但是感觉不是那么的深刻,这次是因为一个项目要做一个国际化的版本,代码里面是不能出现中文的,所以就翻译了一下.qt用的是4.8.6 64位的,IDE( ...
- (Qt 翻译) QGLSceneNode
#include <QGLSceneNode> QGLSceneNode ( QObject * parent = 0 ) QGLSceneNode ( const QGeometryDa ...
- Qt翻译---Thread Support in Qt
Thread Support in Qt QT提供线程支持在平台独立的线程类.一个安全线程的传递事件的方式,一个信号槽的链接在线程之中.这使得开发多线程容易.多线程程序也是一个有用的范例为不冻结用户界 ...
- qt翻译--QWaitCondition
QWaitCondition Class Reference[QtCore module] 该类提供一个情况变量来同步线程. #include <QWaitCondition> 注意:该类 ...
- qt 国际化(翻译时会触发changeEvent)
1. 修改工程文件 .pro ,加入翻译源文件 hello_world.ts: TRANSLATIONS += \ Resource/translations/hello_world.t ...
- Qt 本地化(翻译)
Qt 本地化(翻译) 翻译流程大致是这样的:首先源代码产生 ts 文件,然后送给 Qt Linguist(Qt 语言家)这个 Qt 自带的小工具进行处理产生 qm 翻译文件,最后源代码里加载这个 qm ...
- Qt Installer Framework翻译(5-4)
自定义安装程序 您可以使用脚本通过以下方式来自定义安装程序: > 添加Qt Installer Framework操作,该操作由脚本提供,并由安装程序执行. > 添加新页面,该页面由您在p ...
- Qt学习之路(34): 国际化(下)
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://devbean.blog.51cto.com/448512/245063 上次 ...
- Qt多国语言QT_TR_NOOP和QT_TRANSLATE_NOOP
文章来源:http://devbean.blog.51cto.com/448512/245063/ 在代码中,我们使用tr()将需要翻译的字符串标记出来.lupdate工具就是提取出tr()函数中的相 ...
随机推荐
- Unhandled event loop exception 解决办法
网上搜索了一下.对其他人有效的办法有两种: 1. 安装了adsafe .卸载掉就可以了. 2.安装了流氓软件:百度杀毒. 卸载掉也解决问题了 我就是第三种情况.到现在还没解决的热.!. 谁还有更好的 ...
- oracle几个函数整理 DECODE() NVL NVL2 NULLIF Coalesce(转)
DECODE() decode()函数简介: 主要作用:将查询结果翻译成其他值(即以其他形式表现出来,以下举例说明): 使用方法: Select decode(columnname,值1,翻译值1,值 ...
- 在C#实现托盘效果(转)
桌面程序的开发中,经常考虑能在状态栏实现托盘快捷操作,托盘程序的实现在API时代,还是相对复杂的,首先在MSDN中可以查看其函数细节, 然后在根据其要求的参数进行复杂的设置. 在.NET时代 ...
- 从远程oracle上导入到本地同一张表中不存在的记录的方法
场景:在远程oracle上存在一张表A,在本地同样存在一张相同表结构的表B.由于本地表B中保存了业务系统操作产生的几条记录,同时原来导入了A中的部分记录,但是并没有保存A中全部的记录.A中有15条记录 ...
- Leetcode 283 Move Zeroes python
题目: Given an array nums, write a function to move all 0's to the end of it while maintaining the rel ...
- 恶补ASP.NET基础【1】枚举和结构
有时我们希望变量提取的是一个固定集合中的值,此时就可以用枚举类型, 例: enum OpenMode : byte { 新增=, 编辑=, 查看= } class Program { static v ...
- javascript 跨域汇总
什么是跨域?当两个域具有相同的协议.相同的端口.相同的host时,那么我们就可以认为它们是相同的域.比如:http://www.example.com/a.html 和 http://www.exam ...
- java设计模式--创建模式--建造者模式
对于建造者模式,小编个人理解为就是一个组装型的模式. 建造者模式 概述 将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示. 适用性 1.当创建复杂对象的算法应该独立于该对象的组 ...
- HDU1875 畅通工程再续 (并查集)
畅通工程再续 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Subm ...
- make的命令行选项
make的命令行选项 -b -m 忽略,提供其它版本make兼容性. -B --always-make 强制重建所有规则的目标,不根据规则的依赖描述决定是否重建目标文件. -C DIR --direc ...