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.1C++sceneobject.h

SceneObject.h

SDK Source File: SceneObject.h

Source / SDK 6.1 / 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 //Inplace setters
24 SceneObject* SetColor(uint32_t v) { this->Color.Set(v); return this;}
25 SceneObject* SetA(uint8_t a) {this->Color.SetA(a); return this;}
26 SceneObject* SetAf(float a) {this->Color.SetAf(a); return this;}
27 SceneObject* SetAfSafe(float a) {this->Color.SetAfSafe(a); return this;}
28 SceneObject* SetR(uint8_t r) {this->Color.SetR(r); return this;}
29 SceneObject* SetG(uint8_t g) {this->Color.SetG(g); return this;}
30 SceneObject* SetB(uint8_t b) {this->Color.SetB(b); return this;}
31
32 SceneObject* SetVisible(bool v) {this->Visible = v; return this;}
33
34 SceneObject* SetTransform(const Math::Transform& t) {this->Transform = t; return this;}
35 SceneObject* SetPosition(const Math::Vec2& p) {this->Transform.Position=p; return this;}
36 SceneObject* SetPosition(float x, float y) {this->Transform.Position.X = x; this->Transform.Position.Y = y; return this;}
37 SceneObject* SetRotation(int r) {this->Transform.Rotation = (360+r%360)%360; return this;}
38 SceneObject* SetMirroring(unsigned int m) {this->Transform.Mirroring = m; return this;}
39 SceneObject* SetScale(unsigned int s) {this->Transform.ScaleX = s; this->Transform.ScaleY = s; return this;}
40 SceneObject* SetScale(unsigned int sx, unsigned int sy) {this->Transform.ScaleX = sx; this->Transform.ScaleY = sy; return this;}
41 SceneObject* SetXScale(unsigned int s) {this->Transform.ScaleX = s; return this;}
42 SceneObject* SetYScale(unsigned int s) {this->Transform.ScaleY = s; return this;}
43
44 const Math::Vec2 ScreenPosition()
45 {
46 Math::Vec2 pos = this->Transform.Position;
47
48 if(this->Parent==nullptr) return pos;
49
50 switch(ScreenAngle)
51 {
52 case 0:
53 case 360:
54 pos.Set(this->Transform.Position.X,this->Transform.Position.Y);
55 break;
56 case 90:
57 pos.Set(240-this->Transform.Position.Y,this->Transform.Position.X);
58 break;
59 case 180:
60 pos.Set(240-this->Transform.Position.X,240-this->Transform.Position.Y);
61 break;
62 case 270:
63 pos.Set(this->Transform.Position.Y,240-this->Transform.Position.X);
64 break;
65 default:
66 break;
67 }
68
69 return pos;
70 }
71
72 SceneObject* Move(const Math::Vec2& v) { return this->Move(v.X, v.Y); }
73 SceneObject* Move(float dx, float dy)
74 {
75 if(this->Parent==nullptr) return this;
76
77 if(!this->InBegin)
78 {
79 LOG_w("SceneObject: Move() can only be called within Begin/End block!\n");
80 return this;
81 }
82
83 switch(ScreenAngle)
84 {
85 case 0:
86 case 360:
87 {
88 this->Transform.Position.X+=dx;
89 this->Transform.Position.Y+=dy;
90 }
91 break;
92
93 case 90:
94 {
95 this->Transform.Position.X-=dy;
96 this->Transform.Position.Y+=dx;
97 }
98 break;
99
100 case 180:
101 {
102 this->Transform.Position.X-=dx;
103 this->Transform.Position.Y-=dy;
104 }
105 break;
106
107 case 270:
108 {
109 this->Transform.Position.X+=dy;
110 this->Transform.Position.Y-=dx;
111 }
112 break;
113
114 default:
115 break;
116 }
117
118 return this;
119 }
120public:
121 Math::Transform Transform;
122 Math::Color Color;
123
124 uint32_t ScreenAngle;
125 bool Visible;
126
127 Screen* Parent;
128 bool InBegin;
129};
130
131}
132#endif /* WASMLIBS_CPP_SCENEOBJECT_H_ */
133
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.
Context Rail

Related nodes

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