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. SceneObject.h
Mission NodeSDK 6.2C++sceneobject.h

SceneObject.h

SDK Source File: SceneObject.h

Source / SDK 6.2 / C++ / Core

SceneObject.h

SceneObject.h
CPP
1/* Copyright Statement:
2 *
3 * (C) 2021-2024 Cubios Inc. All rights reserved.
4 */
5
6#ifndef WASMLIBS_CPP_SCENEOBJECT_H_
7#define WASMLIBS_CPP_SCENEOBJECT_H_
8
9#include "Math/Transform.h"
10#include "Math/Color.h"
11#include "Object.h"
12
13namespace Cubios
14{
15class Screen;
16class SceneObject: public Object
17{
18public:
19 SceneObject():Parent(nullptr),ScreenAngle(0),Visible(true),InBegin(false){}
20 virtual ~SceneObject(){}
21 virtual void Render() = 0;
22
23 virtual SceneObject* operator[](uint16_t) {return this;}
24
25 //Inplace setters
26 SceneObject* SetColor(uint32_t v) { this->Color.Set(v); return this;}
27 SceneObject* SetA(uint8_t a) {this->Color.SetA(a); return this;}
28 SceneObject* SetAf(float a) {this->Color.SetAf(a); return this;}
29 SceneObject* SetAfSafe(float a) {this->Color.SetAfSafe(a); return this;}
30 SceneObject* SetR(uint8_t r) {this->Color.SetR(r); return this;}
31 SceneObject* SetG(uint8_t g) {this->Color.SetG(g); return this;}
32 SceneObject* SetB(uint8_t b) {this->Color.SetB(b); return this;}
33
34 SceneObject* SetVisible(bool v) {this->Visible = v; return this;}
35
36 SceneObject* SetTransform(const Math::Transform& t) {this->Transform = t; return this;}
37 SceneObject* SetPosition(const Math::Vec2& p) {this->Transform.Position=p; return this;}
38 SceneObject* SetPosition(float x, float y) {this->Transform.Position.X = x; this->Transform.Position.Y = y; return this;}
39 SceneObject* SetRotation(int r) {this->Transform.Rotation = (360+r%360)%360; return this;}
40 SceneObject* SetMirroring(unsigned int m) {this->Transform.Mirroring = m; return this;}
41 SceneObject* SetScale(unsigned int s) {this->Transform.ScaleX = s; this->Transform.ScaleY = s; return this;}
42 SceneObject* SetScale(unsigned int sx, unsigned int sy) {this->Transform.ScaleX = sx; this->Transform.ScaleY = sy; return this;}
43 SceneObject* SetXScale(unsigned int s) {this->Transform.ScaleX = s; return this;}
44 SceneObject* SetYScale(unsigned int s) {this->Transform.ScaleY = s; return this;}
45
46 const Math::Vec2 ScreenPosition()
47 {
48 Math::Vec2 pos = this->Transform.Position;
49
50 if(this->Parent==nullptr) return pos;
51
52 switch(ScreenAngle)
53 {
54 case 0:
55 case 360:
56 pos.Set(this->Transform.Position.X,this->Transform.Position.Y);
57 break;
58 case 90:
59 pos.Set(240-this->Transform.Position.Y,this->Transform.Position.X);
60 break;
61 case 180:
62 pos.Set(240-this->Transform.Position.X,240-this->Transform.Position.Y);
63 break;
64 case 270:
65 pos.Set(this->Transform.Position.Y,240-this->Transform.Position.X);
66 break;
67 default:
68 break;
69 }
70
71 return pos;
72 }
73
74 SceneObject* Move(const Math::Vec2& v) { return this->Move(v.X, v.Y); }
75 SceneObject* Move(float dx, float dy)
76 {
77 if(this->Parent==nullptr) return this;
78
79 if(!this->InBegin)
80 {
81 LOG_w("SceneObject: Move() can only be called within Begin/End block!\n");
82 return this;
83 }
84
85 switch(ScreenAngle)
86 {
87 case 0:
88 case 360:
89 {
90 this->Transform.Position.X+=dx;
91 this->Transform.Position.Y+=dy;
92 }
93 break;
94
95 case 90:
96 {
97 this->Transform.Position.X-=dy;
98 this->Transform.Position.Y+=dx;
99 }
100 break;
101
102 case 180:
103 {
104 this->Transform.Position.X-=dx;
105 this->Transform.Position.Y-=dy;
106 }
107 break;
108
109 case 270:
110 {
111 this->Transform.Position.X+=dy;
112 this->Transform.Position.Y-=dx;
113 }
114 break;
115
116 default:
117 break;
118 }
119
120 return this;
121 }
122public:
123 Math::Transform Transform;
124 Math::Color Color;
125
126 uint32_t ScreenAngle;
127 bool Visible;
128
129 Screen* Parent;
130 bool InBegin;
131};
132
133}
134#endif /* WASMLIBS_CPP_SCENEOBJECT_H_ */
135
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
Scene.h
Source / SDK 6.2 / C++ / Core
Next Node
Scramble.cpp
Source / SDK 6.2 / C++ / Core