Skip to content

Commit 0c64763

Browse files
author
Pavel Kovalenko
committed
Add managed wrappers for post-process classes.
1 parent e039675 commit 0c64763

File tree

6 files changed

+457
-12
lines changed

6 files changed

+457
-12
lines changed

src/editors/xrManagedApi/Pch.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
#pragma once
2+
// XXX nitrocaster: move to src/Common.hpp (common engine header)
3+
#define DLL_API __declspec(dllimport)
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
#include "Pch.hpp"
2+
#include "PostProcessAnimator.hpp"
3+
#include "xrCore/xrCore.h"
4+
5+
#pragma warning(push)
6+
#pragma warning(disable:4995) // ignore deprecation warnings
7+
#include <msclr/marshal.h>
8+
#pragma warning(pop)
9+
10+
using msclr::interop::marshal_context;
11+
12+
namespace XRay
13+
{
14+
namespace ManagedApi
15+
{
16+
namespace Core
17+
{
18+
19+
PostProcessParamBase::PostProcessParamBase(::CPostProcessParam* impl) { this->impl = impl; }
20+
PostProcessParamBase::~PostProcessParamBase()
21+
{
22+
if (!dontDestroy)
23+
delete impl;
24+
impl = nullptr;
25+
}
26+
27+
PostProcessParam::PostProcessParam(::CPostProcessValue* impl) : PostProcessParamBase(impl) {}
28+
void PostProcessParam::Update(float dt) { impl->update(dt); }
29+
void PostProcessParam::Load(ReaderBase^ reader)
30+
{
31+
::IReader& readerImpl = *reader->impl;
32+
impl->load(readerImpl);
33+
}
34+
void PostProcessParam::Save(WriterBase^ writer)
35+
{
36+
::IWriter& writerImpl = *writer->impl;
37+
impl->save(writerImpl);
38+
}
39+
float PostProcessParam::Length::get() { return impl->get_length(); }
40+
int PostProcessParam::KeyCount::get() { return (int)impl->get_keys_count(); }
41+
void PostProcessParam::AddValue(float time, float value, int index) { impl->add_value(time, value, index); }
42+
void PostProcessParam::DeleteValue(float time) { impl->delete_value(time); }
43+
void PostProcessParam::UpdateValue(float time, float value, int index) { impl->update_value(time, value, index); }
44+
void PostProcessParam::GetValue(float time, [Out] float% value, int index)
45+
{
46+
float tmp;
47+
impl->get_value(time, tmp, index);
48+
value = tmp;
49+
}
50+
float PostProcessParam::GetKeyTime(int index) { return impl->get_key_time(index); }
51+
void PostProcessParam::Reset() { impl->clear_all_keys(); }
52+
53+
float PostProcessInfo::Blur::get() { return impl->blur; }
54+
void PostProcessInfo::Blur::set(float value) { impl->blur = value; }
55+
float PostProcessInfo::Gray::get() { return impl->gray; }
56+
void PostProcessInfo::Gray::set(float value) { impl->gray = value; }
57+
PostProcessInfo::Color PostProcessInfo::BaseColor::get()
58+
{ return reinterpret_cast<PostProcessInfo::Color&>(impl->color_base); }
59+
void PostProcessInfo::BaseColor::set(PostProcessInfo::Color value)
60+
{ impl->color_base = reinterpret_cast<::SPPInfo::SColor&>(value); }
61+
PostProcessInfo::Color PostProcessInfo::GrayColor::get()
62+
{ return reinterpret_cast<PostProcessInfo::Color&>(impl->color_gray); }
63+
void PostProcessInfo::GrayColor::set(PostProcessInfo::Color value)
64+
{ impl->color_gray = reinterpret_cast<::SPPInfo::SColor&>(value); }
65+
PostProcessInfo::Color PostProcessInfo::AddColor::get()
66+
{ return reinterpret_cast<PostProcessInfo::Color&>(impl->color_add); }
67+
void PostProcessInfo::AddColor::set(PostProcessInfo::Color value)
68+
{ impl->color_add = reinterpret_cast<::SPPInfo::SColor&>(value); }
69+
float PostProcessInfo::ColorMappingInfluence::get() { return impl->cm_influence; }
70+
void PostProcessInfo::ColorMappingInfluence::set(float value) { impl->cm_influence = value; }
71+
float PostProcessInfo::ColorMappingInterpolate::get() { return impl->cm_interpolate; }
72+
void PostProcessInfo::ColorMappingInterpolate::set(float value) { impl->cm_interpolate = value; }
73+
String^ PostProcessInfo::ColorMappingGradient1::get() { return gcnew String(impl->cm_tex1.c_str()); }
74+
void PostProcessInfo::ColorMappingGradient1::set(String^ value)
75+
{
76+
auto context = gcnew marshal_context();
77+
auto tmpStr = context->marshal_as<const char*>(value);
78+
impl->cm_tex1 = tmpStr;
79+
delete context;
80+
}
81+
String^ PostProcessInfo::ColorMappingGradient2::get() { return gcnew String(impl->cm_tex2.c_str()); }
82+
void PostProcessInfo::ColorMappingGradient2::set(String^ value)
83+
{
84+
auto context = gcnew marshal_context();
85+
auto tmpStr = context->marshal_as<const char*>(value);
86+
impl->cm_tex2 = tmpStr;
87+
delete context;
88+
}
89+
PostProcessInfo::PostProcessInfo(::SPPInfo* impl) { this->impl = impl; }
90+
PostProcessInfo::PostProcessInfo(::SPPInfo* impl, bool dontDestroy) : PostProcessInfo(impl)
91+
{ this->dontDestroy = dontDestroy; }
92+
PostProcessInfo::~PostProcessInfo()
93+
{
94+
if (!dontDestroy)
95+
delete impl;
96+
impl = nullptr;
97+
}
98+
PostProcessInfo% PostProcessInfo::Add(const PostProcessInfo% ppi)
99+
{
100+
impl->add(*ppi.impl);
101+
return *this;
102+
}
103+
PostProcessInfo% PostProcessInfo::Substract(const PostProcessInfo% ppi)
104+
{
105+
impl->sub(*ppi.impl);
106+
return *this;
107+
}
108+
void PostProcessInfo::Normalize() { impl->normalize(); }
109+
PostProcessInfo% PostProcessInfo::Interpolate(const PostProcessInfo% def, const PostProcessInfo% to, float factor)
110+
{
111+
impl->lerp(*def.impl, *to.impl, factor);
112+
return *this;
113+
}
114+
void PostProcessInfo::Validate(String^ str)
115+
{
116+
marshal_context context;
117+
auto tmpStr = context.marshal_as<const char*>(str);
118+
impl->validate(tmpStr);
119+
}
120+
121+
PostProcessParamProxy::PostProcessParamProxy(::CPostProcessParam* impl) : PostProcessParamBase(impl)
122+
{ dontDestroy = true; }
123+
void PostProcessParamProxy::Update(float dt) { impl->update(dt); }
124+
void PostProcessParamProxy::Load(ReaderBase^ reader) { impl->load(*reader->impl); }
125+
void PostProcessParamProxy::Save(WriterBase^ writer) { impl->save(*writer->impl); }
126+
float PostProcessParamProxy::Length::get() { return impl->get_length(); }
127+
int PostProcessParamProxy::KeyCount::get() { return impl->get_keys_count(); }
128+
void PostProcessParamProxy::AddValue(float time, float value, int index) { impl->add_value(time, value, index); }
129+
void PostProcessParamProxy::DeleteValue(float time) { impl->delete_value(time); }
130+
void PostProcessParamProxy::UpdateValue(float time, float value, int index)
131+
{ impl->update_value(time, value, index); }
132+
void PostProcessParamProxy::GetValue(float time, [Out] float% value, int index)
133+
{
134+
float tmp;
135+
impl->get_value(time, tmp, index);
136+
value = tmp;
137+
}
138+
float PostProcessParamProxy::GetKeyTime(int index) { return impl->get_key_time(index); }
139+
void PostProcessParamProxy::Reset() { impl->clear_all_keys(); }
140+
141+
BasicPostProcessAnimator::BasicPostProcessAnimator() : impl(new ::BasicPostProcessAnimator()) {}
142+
BasicPostProcessAnimator::BasicPostProcessAnimator(int id, bool cyclic) :
143+
impl(new ::BasicPostProcessAnimator(id, cyclic)) {}
144+
BasicPostProcessAnimator::~BasicPostProcessAnimator()
145+
{
146+
delete impl;
147+
impl = nullptr;
148+
}
149+
void BasicPostProcessAnimator::Clear() { impl->Clear(); }
150+
void BasicPostProcessAnimator::Load(String^ name, bool internalFs)
151+
{
152+
marshal_context context;
153+
auto tmpName = context.marshal_as<const char*>(name);
154+
impl->Load(tmpName, internalFs);
155+
}
156+
String^ BasicPostProcessAnimator::Name::get() { return gcnew String(impl->Name()); }
157+
void BasicPostProcessAnimator::Stop(float speed) { impl->Stop(speed); }
158+
void BasicPostProcessAnimator::SetDesiredFactor(float f, float sp) { impl->SetDesiredFactor(f, sp); }
159+
void BasicPostProcessAnimator::SetCurrentFactor(float f) { impl->SetCurrentFactor(f); }
160+
void BasicPostProcessAnimator::SetCyclic(bool b) { impl->SetCyclic(b); }
161+
float BasicPostProcessAnimator::Length::get() { return impl->GetLength(); }
162+
PostProcessInfo^ BasicPostProcessAnimator::PPInfo::get()
163+
{ return gcnew PostProcessInfo(&impl->PPinfo(), true); }
164+
bool BasicPostProcessAnimator::Process(float dt, PostProcessInfo^ PPInfo)
165+
{ return !!impl->Process(dt, *PPInfo->impl); }
166+
void BasicPostProcessAnimator::Create() { impl->Create(); }
167+
PostProcessParamBase^ BasicPostProcessAnimator::GetParam(PostProcessParamType param)
168+
{ return gcnew PostProcessParamProxy(impl->GetParam((pp_params)param)); }
169+
void BasicPostProcessAnimator::ResetParam(PostProcessParamType param) { impl->ResetParam((pp_params)param); }
170+
void BasicPostProcessAnimator::Save(String^ name)
171+
{
172+
marshal_context context;
173+
auto tmpName = context.marshal_as<const char*>(name);
174+
impl->Save(tmpName);
175+
}
176+
177+
}
178+
}
179+
}

0 commit comments

Comments
 (0)