类和组件概述
When you first open your project based on the VR Sample and see a lot of different classes you might get confused a bit. But let's take a quick look at each of them and see what they actually do and how they are related to each other.当您第一次基于VR Sample打开项目并看到很多不同的类时,您可能会感到困惑。但是,让我们快速浏览一下它们,看看它们的实际作用以及它们之间的关系。
VRInteractable ClassVRInteractable类#
This is a base class for all objects, that you can interact with. It defines a basic set of interactions, in other words: here you define what can a user do with your object. You can add your own type of interaction here.这是可以与之交互的所有对象的基类。它定义了一组基本的交互,即:在此定义用户可以对对象执行的操作。您可以在此处添加自己的互动类型。
The following component classes are inherited from the VRInteractable:以下组件类是从VRInteractable继承的:
ObjMovable | This component type can be used for all objects, that can be grabbed, held and thrown (it can be a ball, a pistol, whatever you can take, carry and drop).此组件类型可用于所有可抓取,保持和抛出的物体(可以是球,手枪,无论是可以携带,携带还是放下的物体)。 |
---|---|
ObjHandle | This component type can be used for all objects, that can be turned or moved while being held (various handles, levers, valves, etc.).此组件类型可用于所有在握住时可以旋转或移动的对象(各种手柄,杠杆,阀门等)。 |
ObjSwitch | This component type can be used for all objects, that can be switched by grabbing (all sorts of buttons and on-off switches, including rotary ones).此组件类型可用于所有对象,可通过抓取进行切换(各种按钮和开关,包括旋转开关)。 |
ObjButton | This component type demonstrates animated text, when grabbed, and can be used in combination with the ObjSwitch component to provide additional effects.这种组件类型在被抓取时会演示动画文本,并且可以与ObjSwitch组件结合使用以提供其他效果。 |
ObjLaserPointer | This component enables casting a laser ray by the object. The laser pointer object in the VR Sample world has ObjMovable and ObjLaserPointer components attached.The laser pointer object in the VR Sample world has ObjMovable and ObjLaserPointer components attached. The laser pointer object in the VR Sample world has ObjMovable and ObjLaserPointer components attached. VR Sample世界中的激光指示器对象具有附加的ObjMovable和ObjLaserPointer组件。 |
VRPlayer ClassVRPlayer类别#
This is a base class for all players. It contains declaration of baseline controls, common basic player operations, callback management etc.这是所有玩家的基础类。它包含基线控件的声明,常见的基本播放器操作,回调管理等。
The following component classes are inherited from the VRPlayer:以下组件类是从VRPlayer继承的:
VRPlayerSpawner ClassVRPlayerSpawner类别#
This class registers all VRPlayer components in the Component System, checks which VR plugin is loaded and creates a player of the corresponding type (VRPlayerOcculus or VRPlayerVive). It also enables and shows necessary controllers.此类在组件系统中注册所有VRPlayer组件,检查加载了哪个VR插件,并创建相应类型(VRPlayerOcculus或VRPlayerVive)的播放器。它还启用并显示必要的控制器。
AppOculusProxy and AppViveProxy ClassesAppOculusProxy和AppViveProxy类#
Both plugins implementing HMD support (AppOculus and AppVive) have UnigineScript interface. So, in order to use them in our C++ project we need a proxy class (sort of API "translator") for each of them, wrapping UnigineScript methods in C++.两个实现HMD支持的插件( AppOculus 和 AppVive )都具有UnigineScript接口。因此,为了在我们的C ++项目中使用它们,我们需要为它们每个使用一个代理类(某种API“翻译器”),将UnigineScript方法包装在C++中。
GuiSample ClassGuiSample类#
This component type is used to create various graphic user interfaces (GUI). Here you can add widgets (labels, buttons, etc.) and implement event handlers for them.此组件类型用于创建各种图形用户界面(GUI)。在这里,您可以添加小部件(标签,按钮等)并为其实现事件处理程序。
Framework构架#
Framework includes the Component System which implements the core functionality of components and a set of utility classes and functions used for playing sounds, auxiliary math and 3d math functions, callback system implementation .框架包括实现组件核心功能的 Component System 和一组用于播放声音,辅助数学和3d数学函数,回调系统实现的实用程序类和函数。
Triggers ClassTriggers类#
Triggers is a framework class used to mark room obstacles for the VR Player (e.g. room walls, objects, etc.) and give a warning if there is an obstacle on the way (as the player gets closer to an obstacle, controllers' vibration becomes more intense). Triggers是一个框架类,用于标记VR播放器的房间障碍物(例如,房间墙壁,物体等),并在途中有障碍物时发出警告(随着播放器靠近障碍物,控制器'振动会变得更加强烈。)
You can simply create primitives for walls and objects in your room and add them as children to the node dummy named Obstacles, which is a child of the VR dummy node (see the hierarchy in the Editor below).您可以简单地为房间中的墙壁和对象创建图元,并将它们作为子级添加到名为Obstacles的节点虚拟对象中,该虚拟节点是VR dummy node的子级(请参见下面的编辑器中的层次结构)。
All children of the Obstacles node will be automatically switched to invisible mode and will be used only to inform the player and prevent collisions with objects in the real room. Obstacles节点的所有子代将自动切换到不可见模式,并且仅用于通知玩家并防止与真实房间中的对象发生碰撞。