WOWCube Docs logo
WOWCube Docs
Mission Control
Section Shortcuts
APIExamplesSourceWOWConnectChangelog
Filters
SDK and language defaults persist in cookies.
SDK version
Navigation Tree
Collapsed by default, focused on the active path.
Made byMcKay Seamons
GitHub
  1. Home
  2. Docs
  3. Source
  4. Screen.cpp
Mission NodeSDK 6.2C++screen.cpp

Screen.cpp

SDK Source File: Screen.cpp

Source / SDK 6.2 / C++ / Core

Screen.cpp

Screen.cpp
CPP
1/* Copyright Statement:
2 *
3 * (C) 2021-2024 Cubios Inc. All rights reserved.
4 */
5
6#include "Screen.h"
7#include "native.h"
8
9namespace Cubios {
10
11Screen::Screen(uint8_t id)
12: displayId(id),
13 orientationMode(ORIENTATION_MODE_MENU),
14 inBegin(false),
15 enableAR(false)
16{
17 SetOrientation(orientationMode);
18}
19
20void Screen::SetOrientation(TOPOLOGY_orientation_mode_t mode)
21{
22 orientationMode = mode;
23 angle = TOPOLOGY_getAngle(cubeN, displayId, orientationMode);
24 TOPOLOGY_getPlace(cubeN, displayId, orientationMode, &place);
25}
26
27uint8_t Screen::Position() const
28{
29 return place.position;
30}
31
32TOPOLOGY_orientation_t Screen::Direction() const
33{
34 TOPOLOGY_orientation_t result = (TOPOLOGY_orientation_t)TOPOLOGY_getFaceletOrientation(cubeN, displayId);
35 return result;
36}
37
38uint8_t Screen::OppositeFace() const
39{
40 TOPOLOGY_orientation_t orientation = this->Direction();
41 uint8_t result = 0;
42 if (orientation == ORIENTATION_UP){
43 result = TOPOLOGY_getFace(ORIENTATION_DOWN);
44 } else if (orientation == ORIENTATION_DOWN) {
45 result = TOPOLOGY_getFace(ORIENTATION_UP);
46 } else if (orientation == ORIENTATION_FRONT) {
47 result = TOPOLOGY_getFace(ORIENTATION_BACK);
48 } else if (orientation == ORIENTATION_BACK) {
49 result = TOPOLOGY_getFace(ORIENTATION_FRONT);
50 } else if (orientation == ORIENTATION_LEFT) {
51 result = TOPOLOGY_getFace(ORIENTATION_RIGHT);
52 } else if (orientation == ORIENTATION_RIGHT) {
53 result = TOPOLOGY_getFace(ORIENTATION_LEFT);
54 }
55 return result;
56}
57
58uint8_t Screen::Face() const
59{
60 return place.face;
61}
62
63SceneObject* Screen::Add(SceneObject* obj)
64{
65 if(!this->inBegin)
66 {
67 LOG_w("Screen:Scene objects can only be added withing Begin/End block!\n");
68 obj->Parent = nullptr;
69 return obj;
70 }
71 if(!obj->Visible) return obj;
72
73 obj->Parent = this;
74 obj->InBegin = this->inBegin;
75
76 if(this->enableAR) obj->ScreenAngle = angle; else obj->ScreenAngle = 0;
77
78 this->objects.push_back(obj);
79
80 return obj;
81}
82
83SceneObject* Screen::AddCopy(SceneObject* obj)
84{
85 SceneObject* object = this->Add(obj);
86
87 if(object!=nullptr)
88 {
89 this->copies.push_back(object);
90 }
91
92 return object;
93}
94
95void Screen::Begin(TOPOLOGY_orientation_mode_t mode, bool autorotation)
96{
97 this->inBegin = true;
98 this->enableAR = autorotation;
99
100 this->orientationMode = mode;
101
102 angle = TOPOLOGY_getAngle(cubeN, displayId, orientationMode);
103 TOPOLOGY_getPlace(cubeN, displayId, orientationMode, &place);
104
105 this->objects.clear();
106}
107
108void Screen::End()
109{
110 this->inBegin = false;
111 this->present();
112
113 for(size_t i=0;i<this->copies.size();i++)
114 {
115 delete this->copies[i];
116 }
117 this->copies.clear();
118}
119
120void Screen::present()
121{
122 if (objects.empty()) return;
123
124 GFX_setRenderTarget(displayId);
125 for(auto obj: objects)
126 {
127 obj->Render();
128 obj->InBegin = this->inBegin;
129 }
130 GFX_render();
131}
132
133
134}
135
136
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.
Context Rail

Related nodes

AppManager.cpp
Source / SDK 6.2 / C++ / Core
AppManager.h
Source / SDK 6.2 / C++ / Core
Gfx.h
Source / SDK 6.2 / C++ / Core
native access.h
Source / SDK 6.2 / C++ / Core
Previous Node
Scramble.h
Source / SDK 6.2 / C++ / Core
Next Node
Screen.h
Source / SDK 6.2 / C++ / Core