mirror of
https://github.com/whoahq/whoa.git
synced 2026-03-18 05:31:07 +03:00
Compare commits
15 Commits
bf0bea41c5
...
1347f509d4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1347f509d4 | ||
|
|
06186d1251 | ||
|
|
e5cc9de486 | ||
|
|
7682dba2c9 | ||
|
|
c6e18336de | ||
|
|
e7bd5968cf | ||
|
|
a51e9ba082 | ||
|
|
8935c520c0 | ||
|
|
7cf7127810 | ||
|
|
8fb51991e0 | ||
|
|
7fdd22545f | ||
|
|
15eafe92d7 | ||
|
|
1ad3679f90 | ||
|
|
81970958a8 | ||
|
|
a9cad5238d |
@ -1 +1 @@
|
||||
Subproject commit 4ba7e0a6c3836254daf97bab159807fae6cab039
|
||||
Subproject commit 1e5366bbc6935e3363abf5921f0be12f902e790a
|
||||
@ -32,6 +32,8 @@ if(WHOA_SYSTEM_MAC)
|
||||
"-framework AppKit"
|
||||
"-framework Carbon"
|
||||
"-framework IOKit"
|
||||
"-framework Metal"
|
||||
"-framework QuartzCore"
|
||||
)
|
||||
|
||||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mac/MainMenu.nib DESTINATION "bin")
|
||||
|
||||
9
src/app/mac/EngineMTLLayerView.h
Normal file
9
src/app/mac/EngineMTLLayerView.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef APP_MAC_ENGINE_MTL_LAYER_VIEW_H
|
||||
#define APP_MAC_ENGINE_MTL_LAYER_VIEW_H
|
||||
|
||||
#include "app/mac/EngineGLLayerView.h"
|
||||
|
||||
@interface EngineMTLLayerView : EngineGLLayerView
|
||||
@end
|
||||
|
||||
#endif
|
||||
36
src/app/mac/EngineMTLLayerView.mm
Normal file
36
src/app/mac/EngineMTLLayerView.mm
Normal file
@ -0,0 +1,36 @@
|
||||
#include "app/mac/EngineMTLLayerView.h"
|
||||
#import <QuartzCore/CAMetalLayer.h>
|
||||
|
||||
@implementation EngineMTLLayerView
|
||||
|
||||
- (CALayer*)makeBackingLayer {
|
||||
return [CAMetalLayer layer];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(NSRect)frame glWindow:(GLWindow*)window {
|
||||
self = [super initWithFrame:frame glWindow:window];
|
||||
|
||||
if (self) {
|
||||
[self setWantsLayer:YES];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)drawRect:(NSRect)dirtyRect {
|
||||
// Rendering is driven by CGxDeviceMTL.
|
||||
}
|
||||
|
||||
- (void)update {
|
||||
[super update];
|
||||
|
||||
if (![self.layer isKindOfClass:[CAMetalLayer class]]) {
|
||||
return;
|
||||
}
|
||||
|
||||
CAMetalLayer* layer = (CAMetalLayer*)self.layer;
|
||||
CGSize size = [self convertSizeToBacking:self.bounds.size];
|
||||
layer.drawableSize = size;
|
||||
}
|
||||
|
||||
@end
|
||||
@ -1,7 +1,9 @@
|
||||
#include "app/mac/View.h"
|
||||
#include "app/mac/EngineGLLayerView.h"
|
||||
#include "app/mac/EngineMTLLayerView.h"
|
||||
#include "app/mac/WindowCallbacks.h"
|
||||
#include "gx/gll/GLWindow.h"
|
||||
#include "gx/Device.hpp"
|
||||
|
||||
GLWindowCallbacks EngineViewCallbacks = {
|
||||
&MacOnResized,
|
||||
@ -23,5 +25,9 @@ void AssignEngineViewCallbacks(GLWindowCallbacks* callbacks) {
|
||||
}
|
||||
|
||||
Class GetEngineViewClass() {
|
||||
if (GxDevApi() == GxApi_Metal) {
|
||||
return [EngineMTLLayerView class];
|
||||
}
|
||||
|
||||
return [EngineGLLayerView class];
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#include "app/mac/MacClient.h"
|
||||
#include "event/Input.hpp"
|
||||
#include "gx/gll/CGxDeviceGLL.hpp"
|
||||
#include "gx/mtl/CGxDeviceMTL.hpp"
|
||||
#include "gx/Device.hpp"
|
||||
#include "gx/Window.hpp"
|
||||
#include <bc/Debug.hpp>
|
||||
@ -171,7 +172,11 @@ void MacOnResized(int32_t width, int32_t height, bool a3) {
|
||||
return;
|
||||
}
|
||||
|
||||
static_cast<CGxDeviceGLL*>(g_theGxDevicePtr)->Resize(width, height);
|
||||
if (GxDevApi() == GxApi_GLL) {
|
||||
static_cast<CGxDeviceGLL*>(g_theGxDevicePtr)->Resize(width, height);
|
||||
} else if (GxDevApi() == GxApi_Metal) {
|
||||
static_cast<CGxDeviceMTL*>(g_theGxDevicePtr)->Resize(width, height);
|
||||
}
|
||||
|
||||
OsQueuePut(OS_INPUT_SIZE, width, height, 0, 0);
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
#include "gx/Adapter.hpp"
|
||||
#include "gx/Device.hpp"
|
||||
#include <storm/Array.hpp>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
static CGxDevice* s_device;
|
||||
@ -417,6 +418,13 @@ void ConsoleDeviceInitialize(const char* title) {
|
||||
api = GxApi_GLL;
|
||||
#endif
|
||||
|
||||
#if defined(WHOA_SYSTEM_MAC)
|
||||
const char* apiOverride = getenv("WHOA_GX_API");
|
||||
if (apiOverride && !strcmp(apiOverride, "metal")) {
|
||||
api = GxApi_Metal;
|
||||
}
|
||||
#endif
|
||||
|
||||
s_device = GxDevCreate(api, OsWindowProc, format);
|
||||
|
||||
// TODO
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
|
||||
#if defined(WHOA_SYSTEM_MAC)
|
||||
#include "gx/gll/CGxDeviceGLL.hpp"
|
||||
#include "gx/mtl/CGxDeviceMTL.hpp"
|
||||
#include "gx/mac/Display.hpp"
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#include <OpenGL/OpenGL.h>
|
||||
@ -117,6 +118,8 @@ int32_t CGxDevice::AdapterFormats(EGxApi api, TSGrowableArray<CGxFormat>& adapte
|
||||
CGxDevice::OpenGlAdapterFormats(adapterFormats);
|
||||
} else if (api == GxApi_GLL) {
|
||||
CGxDevice::GLLAdapterFormats(adapterFormats);
|
||||
} else if (api == GxApi_Metal) {
|
||||
CGxDevice::OpenGlAdapterFormats(adapterFormats);
|
||||
}
|
||||
|
||||
#elif defined(WHOA_SYSTEM_LINUX)
|
||||
@ -228,6 +231,11 @@ CGxDevice* CGxDevice::NewGLL() {
|
||||
auto m = SMemAlloc(sizeof(CGxDeviceGLL), __FILE__, __LINE__, 0x0);
|
||||
return new (m) CGxDeviceGLL();
|
||||
}
|
||||
|
||||
CGxDevice* CGxDevice::NewMTL() {
|
||||
auto m = SMemAlloc(sizeof(CGxDeviceMTL), __FILE__, __LINE__, 0x0);
|
||||
return new (m) CGxDeviceMTL();
|
||||
}
|
||||
#endif
|
||||
|
||||
CGxDevice* CGxDevice::NewOpenGl() {
|
||||
@ -924,6 +932,10 @@ CGxPool* CGxDevice::PoolCreate(EGxPoolTarget target, EGxPoolUsage usage, uint32_
|
||||
return pool;
|
||||
}
|
||||
|
||||
void CGxDevice::RenderTargetGet(EGxBuffer buffer, CGxTex*& gxTex) {
|
||||
gxTex = this->m_textureTarget[buffer].m_texture;
|
||||
}
|
||||
|
||||
void CGxDevice::RsGet(EGxRenderState which, int32_t& value) {
|
||||
value = static_cast<int32_t>(this->m_appRenderStates[which].m_value);
|
||||
}
|
||||
|
||||
@ -77,6 +77,7 @@ class CGxDevice {
|
||||
#endif
|
||||
#if defined(WHOA_SYSTEM_MAC)
|
||||
static CGxDevice* NewGLL();
|
||||
static CGxDevice* NewMTL();
|
||||
#endif
|
||||
static CGxDevice* NewOpenGl();
|
||||
static void OpenGlAdapterFormats(TSGrowableArray<CGxFormat>& adapterFormats);
|
||||
@ -108,12 +109,12 @@ class CGxDevice {
|
||||
uint32_t m_appMasterEnables = 0;
|
||||
uint32_t m_hwMasterEnables = 0;
|
||||
TSList<CGxPool, TSGetLink<CGxPool>> m_poolList;
|
||||
CGxBuf* m_bufLocked[GxPoolTargets_Last];
|
||||
CGxBuf* m_bufLocked[GxPoolTargets_Last] = {};
|
||||
CGxPool* m_vertexPool = nullptr;
|
||||
CGxPool* m_indexPool = nullptr;
|
||||
CGxBuf* m_streamBufs[GxPoolTargets_Last];
|
||||
CGxBuf* m_streamBufs[GxPoolTargets_Last] = {};
|
||||
CGxVertexAttrib m_primVertexFormatAttrib[GxVertexBufferFormats_Last];
|
||||
CGxBuf* m_primVertexFormatBuf[GxVertexBufferFormats_Last];
|
||||
CGxBuf* m_primVertexFormatBuf[GxVertexBufferFormats_Last] = {};
|
||||
uint32_t m_primVertexMask = 0;
|
||||
uint32_t m_primVertexDirty = 0;
|
||||
EGxVertexBufferFormat m_primVertexFormat = GxVertexBufferFormats_Last;
|
||||
@ -124,7 +125,7 @@ class CGxDevice {
|
||||
TSFixedArray<CGxAppRenderState> m_appRenderStates;
|
||||
TSFixedArray<CGxStateBom> m_hwRenderStates;
|
||||
// TODO
|
||||
TextureTarget m_textureTarget[GxBuffers_Last];
|
||||
TextureTarget m_textureTarget[GxBuffers_Last] = {};
|
||||
// TODO
|
||||
uint32_t m_baseMipLevel = 0; // TODO placeholder
|
||||
|
||||
@ -183,6 +184,7 @@ class CGxDevice {
|
||||
void PrimVertexFormat(CGxBuf*, CGxVertexAttrib*, uint32_t);
|
||||
void PrimVertexMask(uint32_t);
|
||||
void PrimVertexPtr(CGxBuf*, EGxVertexBufferFormat);
|
||||
void RenderTargetGet(EGxBuffer buffer, CGxTex*& gxTex);
|
||||
void RsGet(EGxRenderState, int32_t&);
|
||||
void RsSet(EGxRenderState, int32_t);
|
||||
void RsSet(EGxRenderState, void*);
|
||||
|
||||
@ -20,6 +20,7 @@ if(WHOA_SYSTEM_MAC)
|
||||
file(GLOB MAC_SOURCES
|
||||
"gll/*.cpp"
|
||||
"gll/*.mm"
|
||||
"mtl/*.mm"
|
||||
"mac/*.cpp"
|
||||
)
|
||||
|
||||
|
||||
@ -24,6 +24,8 @@ CGxDevice* GxDevCreate(EGxApi api, int32_t (*windowProc)(void* window, uint32_t
|
||||
device = CGxDevice::NewOpenGl();
|
||||
} else if (api == GxApi_GLL) {
|
||||
device = CGxDevice::NewGLL();
|
||||
} else if (api == GxApi_Metal) {
|
||||
device = CGxDevice::NewMTL();
|
||||
} else {
|
||||
// Error
|
||||
}
|
||||
|
||||
6
src/gx/RenderTarget.cpp
Normal file
6
src/gx/RenderTarget.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "gx/RenderTarget.hpp"
|
||||
#include "gx/Device.hpp"
|
||||
|
||||
void GxRenderTargetGet(EGxBuffer buffer, CGxTex*& gxTex) {
|
||||
g_theGxDevicePtr->RenderTargetGet(buffer, gxTex);
|
||||
}
|
||||
10
src/gx/RenderTarget.hpp
Normal file
10
src/gx/RenderTarget.hpp
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef GX_RENDER_TARGET_HPP
|
||||
#define GX_RENDER_TARGET_HPP
|
||||
|
||||
#include "gx/Types.hpp"
|
||||
|
||||
class CGxTex;
|
||||
|
||||
void GxRenderTargetGet(EGxBuffer buffer, CGxTex*& gxTex);
|
||||
|
||||
#endif
|
||||
@ -35,7 +35,8 @@ enum EGxApi {
|
||||
GxApi_D3d10 = 3,
|
||||
GxApi_D3d11 = 4,
|
||||
GxApi_GLL = 5,
|
||||
GxApis_Last = 6
|
||||
GxApi_Metal = 6,
|
||||
GxApis_Last = 7
|
||||
};
|
||||
|
||||
enum EGxBlend {
|
||||
|
||||
81
src/gx/mtl/CGxDeviceMTL.hpp
Normal file
81
src/gx/mtl/CGxDeviceMTL.hpp
Normal file
@ -0,0 +1,81 @@
|
||||
#ifndef GX_MTL_C_GX_DEVICE_MTL_HPP
|
||||
#define GX_MTL_C_GX_DEVICE_MTL_HPP
|
||||
|
||||
#include "gx/CGxDevice.hpp"
|
||||
#include "gx/gll/GLWindow.h"
|
||||
|
||||
class CGxBatch;
|
||||
class CGxShader;
|
||||
|
||||
class CGxDeviceMTL : public CGxDevice {
|
||||
public:
|
||||
// Member variables
|
||||
GLWindow m_window;
|
||||
|
||||
// Virtual member functions
|
||||
void ITexMarkAsUpdated(CGxTex*) override;
|
||||
void IRsSendToHw(EGxRenderState) override;
|
||||
int32_t DeviceCreate(int32_t (*windowProc)(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam), const CGxFormat&) override;
|
||||
int32_t DeviceSetFormat(const CGxFormat&) override;
|
||||
void* DeviceWindow() override;
|
||||
void DeviceWM(EGxWM wm, uintptr_t param1, uintptr_t param2) override {};
|
||||
void CapsWindowSize(CRect&) override;
|
||||
void CapsWindowSizeInScreenCoords(CRect& dst) override;
|
||||
void ScenePresent() override;
|
||||
void SceneClear(uint32_t, CImVector) override;
|
||||
void Draw(CGxBatch* batch, int32_t indexed) override;
|
||||
void PoolSizeSet(CGxPool*, uint32_t) override;
|
||||
char* BufLock(CGxBuf*) override;
|
||||
int32_t BufUnlock(CGxBuf*, uint32_t) override;
|
||||
void BufData(CGxBuf* buf, const void* data, size_t size, uintptr_t offset) override;
|
||||
void TexDestroy(CGxTex* texId) override;
|
||||
void IShaderCreate(CGxShader*) override;
|
||||
void ShaderCreate(CGxShader*[], EGxShTarget, const char*, const char*, int32_t) override;
|
||||
int32_t StereoEnabled(void) override;
|
||||
void XformSetProjection(const C44Matrix& matrix) override;
|
||||
|
||||
// Member functions
|
||||
CGxDeviceMTL();
|
||||
void Resize(uint32_t width, uint32_t height);
|
||||
|
||||
private:
|
||||
void ISetCaps(const CGxFormat& format);
|
||||
void EnsureLibrary();
|
||||
void BeginFrame();
|
||||
void* GetPipeline(EGxVertexBufferFormat format, bool useColor, bool useSkin, bool useTex, int32_t blendMode);
|
||||
void* GetPoolBuffer(CGxPool* pool);
|
||||
void ITexCreate(CGxTex* texId);
|
||||
void ITexUpload(CGxTex* texId);
|
||||
void* GetTexture(CGxTex* texId);
|
||||
void* GetSampler(CGxTex* texId);
|
||||
void EnsureFallbackTexture();
|
||||
void EnsureDepthTexture(uint32_t width, uint32_t height);
|
||||
void* GetDepthState(bool depthTest, bool depthWrite, uint32_t depthFunc);
|
||||
void* m_device = nullptr;
|
||||
void* m_commandQueue = nullptr;
|
||||
void* m_layer = nullptr;
|
||||
void* m_shaderLibrary = nullptr;
|
||||
void* m_pipelineColor[GxVertexBufferFormats_Last][GxBlends_Last] = {};
|
||||
void* m_pipelineSolid[GxVertexBufferFormats_Last][GxBlends_Last] = {};
|
||||
void* m_pipelineSkin[GxVertexBufferFormats_Last][GxBlends_Last] = {};
|
||||
void* m_pipelineColorTex[GxVertexBufferFormats_Last][GxBlends_Last] = {};
|
||||
void* m_pipelineSolidTex[GxVertexBufferFormats_Last][GxBlends_Last] = {};
|
||||
void* m_pipelineSkinTex[GxVertexBufferFormats_Last][GxBlends_Last] = {};
|
||||
void* m_pipelineColorTex2[GxVertexBufferFormats_Last][GxBlends_Last] = {};
|
||||
void* m_pipelineSolidTex2[GxVertexBufferFormats_Last][GxBlends_Last] = {};
|
||||
void* m_pipelineSkinTex2[GxVertexBufferFormats_Last][GxBlends_Last] = {};
|
||||
void* m_frameCommandBuffer = nullptr;
|
||||
void* m_frameEncoder = nullptr;
|
||||
void* m_frameDrawable = nullptr;
|
||||
uint32_t m_frameHasDraw = 0;
|
||||
uint32_t m_clearMask = 0;
|
||||
uint32_t m_clearColor = 0;
|
||||
void* m_fallbackTexture = nullptr;
|
||||
void* m_fallbackSampler = nullptr;
|
||||
void* m_depthTexture = nullptr;
|
||||
uint32_t m_depthWidth = 0;
|
||||
uint32_t m_depthHeight = 0;
|
||||
void* m_depthStates[2][2][4] = {};
|
||||
};
|
||||
|
||||
#endif
|
||||
1855
src/gx/mtl/CGxDeviceMTL.mm
Normal file
1855
src/gx/mtl/CGxDeviceMTL.mm
Normal file
File diff suppressed because it is too large
Load Diff
97
src/ui/game/CGCamera.cpp
Normal file
97
src/ui/game/CGCamera.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
#include "ui/game/CGCamera.hpp"
|
||||
#include "ui/game/Types.hpp"
|
||||
#include "console/CVar.hpp"
|
||||
#include "world/World.hpp"
|
||||
#include <storm/String.hpp>
|
||||
#include <tempest/Math.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
static CVar* s_cameraView;
|
||||
|
||||
CGCamera::CameraViewData CGCamera::s_cameraViewDataDefault[MAX_CAMERA_VIEWS] = {
|
||||
{ "0.0", "0.0", "0.0" }, // VIEW_FIRST_PERSON
|
||||
{ "0.0", "0.0", "0.0" }, // VIEW_THIRD_PERSON_A
|
||||
{ "5.55", "10.0", "0.0" }, // VIEW_THIRD_PERSON_B
|
||||
{ "5.55", "20.0", "0.0" }, // VIEW_THIRD_PERSON_C
|
||||
{ "13.88", "30.0", "0.0" }, // VIEW_THIRD_PERSON_D
|
||||
{ "13.88", "10.0", "0.0" }, // VIEW_THIRD_PERSON_E
|
||||
{ "0.0", "0.0", "0.0" }, // VIEW_COMMENTATOR
|
||||
{ "5.0", "10.0", "0.0" }, // VIEW_BARBER_SHOP
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
bool ValidateCameraView(CVar* var, const char* oldValue, const char* value, void* arg) {
|
||||
auto view = SStrToFloat(value);
|
||||
auto min = static_cast<float>(VIEW_FIRST_PERSON);
|
||||
auto max = static_cast<float>(VIEW_BARBER_SHOP);
|
||||
|
||||
if (view >= min && view <= max) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO ConsoleWriteA("Value out of range (%f - %f)\n", DEFAULT_COLOR, min, max);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CGCamera::CGCamera() : CSimpleCamera(CWorld::GetNearClip(), CWorld::GetFarClip(), 90.0f * CMath::DEG2RAD) {
|
||||
this->m_relativeTo = 0;
|
||||
|
||||
this->m_view = s_cameraView->GetInt();
|
||||
|
||||
this->m_distance = SStrToFloat(CGCamera::s_cameraViewDataDefault[this->m_view].m_distance);
|
||||
this->m_yaw = 0.0f;
|
||||
this->m_pitch = SStrToFloat(CGCamera::s_cameraViewDataDefault[this->m_view].m_pitch);
|
||||
this->m_roll = 0.0f;
|
||||
|
||||
this->m_fovOffset = 0.0f;
|
||||
}
|
||||
|
||||
float CGCamera::FOV() const {
|
||||
// Clamp offset-adjusted FOV between 0pi and 1pi
|
||||
return std::min(std::max(this->m_fov + this->m_fovOffset, 0.0f), CMath::PI);
|
||||
}
|
||||
|
||||
C3Vector CGCamera::Forward() const {
|
||||
if (this->m_relativeTo) {
|
||||
return this->CSimpleCamera::Forward() * this->ParentToWorld();
|
||||
}
|
||||
|
||||
return this->CSimpleCamera::Forward();
|
||||
}
|
||||
|
||||
C33Matrix CGCamera::ParentToWorld() const {
|
||||
// TODO
|
||||
return {};
|
||||
}
|
||||
|
||||
C3Vector CGCamera::Right() const {
|
||||
if (this->m_relativeTo) {
|
||||
return this->CSimpleCamera::Right() * this->ParentToWorld();
|
||||
}
|
||||
|
||||
return this->CSimpleCamera::Right();
|
||||
}
|
||||
|
||||
void CGCamera::SetupWorldProjection(const CRect& projRect) {
|
||||
this->SetGxProjectionAndView(projRect);
|
||||
}
|
||||
|
||||
C3Vector CGCamera::Up() const {
|
||||
if (this->m_relativeTo) {
|
||||
return this->CSimpleCamera::Up() * this->ParentToWorld();
|
||||
}
|
||||
|
||||
return this->CSimpleCamera::Up();
|
||||
}
|
||||
|
||||
void CameraRegisterCVars() {
|
||||
// TODO
|
||||
|
||||
s_cameraView = CVar::Register("cameraView", nullptr, 0x10, "2", &ValidateCameraView, DEFAULT);
|
||||
|
||||
// TODO
|
||||
}
|
||||
48
src/ui/game/CGCamera.hpp
Normal file
48
src/ui/game/CGCamera.hpp
Normal file
@ -0,0 +1,48 @@
|
||||
#ifndef UI_GAME_C_G_CAMERA_HPP
|
||||
#define UI_GAME_C_G_CAMERA_HPP
|
||||
|
||||
#include "ui/simple/CSimpleCamera.hpp"
|
||||
#include "util/GUID.hpp"
|
||||
|
||||
class CGCamera : public CSimpleCamera {
|
||||
public:
|
||||
// Public structs
|
||||
struct CameraViewData {
|
||||
const char* m_distance;
|
||||
const char* m_pitch;
|
||||
const char* m_yaw;
|
||||
};
|
||||
|
||||
// Public static variables
|
||||
static CameraViewData s_cameraViewDataDefault[];
|
||||
|
||||
// Virtual public member functions
|
||||
virtual ~CGCamera() = default;
|
||||
virtual float FOV() const;
|
||||
virtual C3Vector Forward() const;
|
||||
virtual C3Vector Right() const;
|
||||
virtual C3Vector Up() const;
|
||||
|
||||
// Public member functions
|
||||
CGCamera();
|
||||
C33Matrix ParentToWorld() const;
|
||||
void SetupWorldProjection(const CRect& projRect);
|
||||
|
||||
private:
|
||||
// Private member variables
|
||||
// TODO
|
||||
WOWGUID m_relativeTo;
|
||||
// TODO
|
||||
int32_t m_view;
|
||||
// TODO
|
||||
float m_distance;
|
||||
float m_yaw;
|
||||
float m_pitch;
|
||||
float m_roll;
|
||||
// TODO
|
||||
float m_fovOffset;
|
||||
};
|
||||
|
||||
void CameraRegisterCVars();
|
||||
|
||||
#endif
|
||||
@ -8,6 +8,7 @@
|
||||
#include "ui/game/ActionBarScript.hpp"
|
||||
#include "ui/game/BattlefieldInfoScript.hpp"
|
||||
#include "ui/game/BattlenetUI.hpp"
|
||||
#include "ui/game/CGCamera.hpp"
|
||||
#include "ui/game/CGCharacterModelBase.hpp"
|
||||
#include "ui/game/CGCooldown.hpp"
|
||||
#include "ui/game/CGDressUpModelFrame.hpp"
|
||||
@ -284,4 +285,8 @@ void CGGameUI::RegisterGameCVars() {
|
||||
CVar::Register("fullSizeFocusFrame", "Increases the size of the focus frame to that of the target frame", 0x20, "0", nullptr, GAME);
|
||||
|
||||
// TODO
|
||||
|
||||
CameraRegisterCVars();
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#include "ui/game/CGWorldFrame.hpp"
|
||||
#include "gx/Coordinate.hpp"
|
||||
#include "gx/Shader.hpp"
|
||||
#include "gx/Transform.hpp"
|
||||
#include "ui/game/CGCamera.hpp"
|
||||
#include "ui/game/PlayerName.hpp"
|
||||
#include <storm/Memory.hpp>
|
||||
#include <tempest/Matrix.hpp>
|
||||
@ -46,6 +48,10 @@ CGWorldFrame::CGWorldFrame(CSimpleFrame* parent) : CSimpleFrame(parent) {
|
||||
this->EnableEvent(SIMPLE_EVENT_MOUSEWHEEL, -1);
|
||||
|
||||
// TODO
|
||||
|
||||
this->m_camera = STORM_NEW(CGCamera);
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CGWorldFrame::OnFrameRender(CRenderBatch* batch, uint32_t layer) {
|
||||
@ -56,10 +62,37 @@ void CGWorldFrame::OnFrameRender(CRenderBatch* batch, uint32_t layer) {
|
||||
}
|
||||
}
|
||||
|
||||
void CGWorldFrame::OnFrameSizeChanged(const CRect& rect) {
|
||||
this->CSimpleFrame::OnFrameSizeChanged(rect);
|
||||
|
||||
// Screen rect (DDC)
|
||||
this->m_screenRect.minX = std::max(this->m_rect.minX, 0.0f);
|
||||
this->m_screenRect.minY = std::max(this->m_rect.minY, 0.0f);
|
||||
this->m_screenRect.maxX = std::min(this->m_rect.maxX, NDCToDDCWidth(1.0f));
|
||||
this->m_screenRect.maxY = std::min(this->m_rect.maxY, NDCToDDCHeight(1.0f));
|
||||
|
||||
// Camera aspect ratio
|
||||
if (this->m_camera) {
|
||||
this->m_camera->SetScreenAspect(this->m_screenRect);
|
||||
}
|
||||
|
||||
// Viewport (NDC)
|
||||
DDCToNDC(this->m_rect.minX, this->m_rect.minY, &this->m_viewport.minX, &this->m_viewport.minY);
|
||||
DDCToNDC(this->m_rect.maxX, this->m_rect.maxY, &this->m_viewport.maxX, &this->m_viewport.maxY);
|
||||
this->m_viewport.minX = std::max(this->m_viewport.minX, 0.0f);
|
||||
this->m_viewport.minY = std::max(this->m_viewport.minY, 0.0f);
|
||||
this->m_viewport.maxX = std::min(this->m_viewport.maxX, 1.0f);
|
||||
this->m_viewport.maxY = std::min(this->m_viewport.maxY, 1.0f);
|
||||
}
|
||||
|
||||
void CGWorldFrame::OnWorldRender() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CGWorldFrame::OnWorldUpdate() {
|
||||
// TODO
|
||||
|
||||
this->m_camera->SetupWorldProjection(this->m_screenRect);
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
#include "ui/simple/CSimpleFrame.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
class CGCamera;
|
||||
|
||||
class CGWorldFrame : public CSimpleFrame {
|
||||
public:
|
||||
// Static variables
|
||||
@ -15,11 +17,22 @@ class CGWorldFrame : public CSimpleFrame {
|
||||
|
||||
// Virtual member functions
|
||||
virtual void OnFrameRender(CRenderBatch* batch, uint32_t layer);
|
||||
// TODO
|
||||
virtual void OnFrameSizeChanged(const CRect& rect);
|
||||
|
||||
// Member functions
|
||||
CGWorldFrame(CSimpleFrame* parent);
|
||||
void OnWorldRender();
|
||||
void OnWorldUpdate();
|
||||
|
||||
private:
|
||||
// Private member variables
|
||||
// TODO
|
||||
CRect m_screenRect;
|
||||
CRect m_viewport;
|
||||
// TODO
|
||||
CGCamera* m_camera;
|
||||
// TODO
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -13,4 +13,16 @@ enum SCRIPTEVENT {
|
||||
// TODO
|
||||
};
|
||||
|
||||
enum CAMERA_VIEW {
|
||||
VIEW_FIRST_PERSON = 0,
|
||||
VIEW_THIRD_PERSON_A = 1,
|
||||
VIEW_THIRD_PERSON_B = 2,
|
||||
VIEW_THIRD_PERSON_C = 3,
|
||||
VIEW_THIRD_PERSON_D = 4,
|
||||
VIEW_THIRD_PERSON_E = 5,
|
||||
VIEW_COMMENTATOR = 6,
|
||||
VIEW_BARBER_SHOP = 7,
|
||||
MAX_CAMERA_VIEWS,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -104,10 +104,6 @@ void CSimpleCamera::SetFieldOfView(float fov) {
|
||||
this->m_fov = fov;
|
||||
}
|
||||
|
||||
void CSimpleCamera::SetNearZ(float nearZ) {
|
||||
this->m_nearZ = nearZ;
|
||||
}
|
||||
|
||||
void CSimpleCamera::SetGxProjectionAndView(const CRect& projRect) {
|
||||
// Projection
|
||||
|
||||
@ -127,6 +123,14 @@ void CSimpleCamera::SetGxProjectionAndView(const CRect& projRect) {
|
||||
GxXformSetView(viewMat);
|
||||
}
|
||||
|
||||
void CSimpleCamera::SetNearZ(float nearZ) {
|
||||
this->m_nearZ = nearZ;
|
||||
}
|
||||
|
||||
void CSimpleCamera::SetScreenAspect(const CRect& screenRect) {
|
||||
this->m_aspect = (screenRect.maxX - screenRect.minX) / (screenRect.maxY - screenRect.minY);
|
||||
}
|
||||
|
||||
C3Vector CSimpleCamera::Up() const {
|
||||
return { this->m_facing.c0, this->m_facing.c1, this->m_facing.c2 };
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@ class CSimpleCamera {
|
||||
void SetFieldOfView(float fov);
|
||||
void SetGxProjectionAndView(const CRect& projRect);
|
||||
void SetNearZ(float nearZ);
|
||||
void SetScreenAspect(const CRect& screenRect);
|
||||
|
||||
protected:
|
||||
// Protected member variables
|
||||
|
||||
@ -23,6 +23,8 @@ if(WHOA_SYSTEM_MAC)
|
||||
"-framework AppKit"
|
||||
"-framework Carbon"
|
||||
"-framework IOKit"
|
||||
"-framework Metal"
|
||||
"-framework QuartzCore"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user