-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathengine.cpp
More file actions
719 lines (539 loc) · 17.5 KB
/
Copy pathengine.cpp
File metadata and controls
719 lines (539 loc) · 17.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
#include "Common.h"
#include "Engine.h"
#include "Console.h"
#include <stdio.h>
#include <string.h>
#include "camera.h"
#include "platform.h"
#include "gcgamut.h"
#include "landscape.h"
#include "maptex.h"
#include "eventmanager.h"
#include "water.h"
#include "map.h"
#include "atmospherics.h"
#include "shadows.h"
#include "renderinfo.h"
#include "screenfx.h"
#include "GameInterface.h"
#include "shadows.h"
#include "world.h"
#include "THING.h"
#include "tree.h"
#include "ResourceAccumulator.h"
#include "chunker.h"
#include "meshrenderer.h"
#include "trees.h"
#if TARGET==PS2
#include "PS2Pinmapper.h"
#include "PS2ClutData.h"
#include "PS2MipmapData.h"
#include "PS2Display.h"
#else
#include "state.h"
#endif
//******************************************************************************************
CEngine::CEngine()
{
mNearZ = DEFAULT_Z_NEAR;
mFarZ = DEFAULT_Z_FAR;
mGamut = NULL;
mRenderLandscape=TRUE;
mDrawPolyBuckets=FALSE;
mMapTexs = NULL;
mKempyCube=NULL;
mWater=NULL;
mLights=NULL;
mSky=NULL;
mHudAditive = TRUE;
mLandscape = NULL;
mHilightTexture=NULL;
mHitEffectTexture=NULL;
mCloakTexture=NULL;
mCurrentViewpoint = 0;
for (int i=0;i<VIEWPOINTS;i++)
{
mCamera[i] = NULL;
}
}
//******************************************************************************************
void CEngine::Shutdown()
{
SCREENFX.Shutdown();
SHADOWS.ShutDown();
TREES.Shutdown();
SAFE_DELETE(mGamut);
mLandscape->ShutDown();
SAFE_DELETE(mLandscape);
for (int i=0;i<VIEWPOINTS;i++)
{
SAFE_DELETE(mCamera[i]);
}
SAFE_DELETE(mLights);
SAFE_DELETE(mWater);
SAFE_DELETE_ARRAY(mMapTexs);
SAFE_DELETE(mKempyCube);
SAFE_RELEASE(mHilightTexture);
SAFE_RELEASE(mHitEffectTexture);
SAFE_RELEASE(mCloakTexture);
#ifdef _DIRECTX
// The dynamic vbuffers can piss off.
CVBufTexture::ClearOut();
#endif
}
//******************************************************************************************
BOOL CEngine::Init()
{
int i;
mLandscape=NULL;
for (i=0;i<VIEWPOINTS;i++)
{
mCamera[i] = NULL;
}
// Set the default hit effect factor
mHitEffectFactorR=200;
mHitEffectFactorG=150;
mHitEffectFactorB=150;
CONSOLE.RegisterVariable("cg_hiteffectfactorr","The red factor for the hit effect (/100)",CVar_int,&mHitEffectFactorR);
CONSOLE.RegisterVariable("cg_hiteffectfactorg","The green factor for the hit effect (/100)",CVar_int,&mHitEffectFactorG);
CONSOLE.RegisterVariable("cg_hiteffectfactorb","The blue factor for the hit effect (/100)",CVar_int,&mHitEffectFactorB);
// Landscape rendering
CONSOLE.RegisterVariable("cg_renderlandscape","Should the landscape be rendered",CVar_bool,&mRenderLandscape);
// Debug rendering
CONSOLE.RegisterVariable("cg_drawpolybuckets","Should polybucket volumes be rendered",CVar_bool,&mDrawPolyBuckets);
// Create the gamut
mGamut = new( MEMTYPE_GAMUT ) C3DGamut(32);
// Map textures
if((mMapTexs = new( MEMTYPE_MAPTEX ) CMapTex[N_MAPMIPS])==NULL) return FALSE;
// Water
if((mWater = new( MEMTYPE_WATER ) CWATER)==NULL) return FALSE;
// Landscape
if((mLandscape = new( MEMTYPE_LANDSCAPE ) CLANDSCAPE)==NULL)
return FALSE;
#if TARGET == XBOX
// we DO NOT init the landscape here. We init it after the FMV playing,
// so that we can use the megabyte of texture RAM used only temporarily
// by the FMV
#else
// the old, more sensible method.
if(!mLandscape->Init(mMapTexs))
return FALSE;
#endif
// Skycube
mKempyCube = NULL;
if((mKempyCube = new( MEMTYPE_KEMPYCUBE ) CKEMPYCUBE)==NULL) return FALSE;
// Light manager
mLights = NULL;
if((mLights = new( MEMTYPE_LIGHT ) CLightManager)==NULL) return FALSE;
if(!mLights->Init()) return FALSE;
// Initialise screen FX
SCREENFX.Init();
// Shadows
#ifndef EDITORBUILD2
SHADOWS.Init();
#endif
TREES.Init();
mCurrentViewpoint = 0;
//mDebugNoParticles = FALSE;
return TRUE;
}
//******************************************************************************************
void CEngine::InitResources()
{
// Initialise screen FX
SCREENFX.InitResources();
SHADOWS.InitResources();
mHilightTexture=CTEXTURE::GetTextureByName("hilight.tga");
mHitEffectTexture=CTEXTURE::GetTextureByName("hiteffect.tga",TEXFMT_UNKNOWN,TEX_NORMAL,1);
mCloakTexture=CTEXTURE::GetTextureByName("cloak.tga",TEXFMT_UNKNOWN,TEX_NORMAL,1);
mLandscape->InitResources();
}
//******************************************************************************************
#ifdef RESBUILDER
void CEngine::AccumulateResources(CResourceAccumulator *accumulator)
{
#if TARGET==PC
// mHilightTexture->AccumulateResources(accumulator,RES_BASESET);
mHilightTexture->AccumulateResources(accumulator);
mLandscape->AccumulateResources(accumulator);
SHADOWS.AccumulateResources(accumulator);
// "Random" engine stuff that the PS2 needs that we can't easily accumulate elsewhere
CTexture *tex=CTEXTURE::GetTextureByName("landscapelight.tga");
tex->AccumulateResources(accumulator,RES_NOTONXBOX);
mHitEffectTexture->AccumulateResources(accumulator,0);
mCloakTexture->AccumulateResources(accumulator,0);
#endif
}
#endif
//******************************************************************************************
void CEngine::LoadAllNamedMeshes( CMEMBUFFER &dataFile )
{
// Make sure we restart from 0
ResetNamedMeshes();
CONSOLE.Status("Loading named meshes");
SINT num_named_meshes;
dataFile.Read( &num_named_meshes, sizeof(SINT) ) ;
for (int i=0;i < num_named_meshes; i++)
{
// Load names
unsigned char stringLength;
dataFile.Read( &stringLength, sizeof(stringLength) );
char MeshName[255];
dataFile.Read( MeshName, sizeof(char) * stringLength );
MeshName[stringLength]=0;
ENGINE.AddNewGlobalNamedMesh(MeshName) ;
}
CONSOLE.StatusDone("Loading named meshes");
}
//******************************************************************************************
void CEngine::ResetNamedMeshes()
{
mNumGlobalMeshes=0;
}
//******************************************************************************************
SINT CEngine::AddNewGlobalNamedMesh(char *name)
{
// do we have this already
SINT c0;
for (c0 = 0; c0 < mNumGlobalMeshes; c0 ++)
{
if (mGlobalMeshes[c0])
if (!(stricmp(name, mGlobalMeshes[c0]->mName)))
return c0;
}
// nope - need to create a new resource
if (mNumGlobalMeshes == MAX_GLOBAL_MESHES - 1)
{
return -1;
}
mGlobalMeshes[mNumGlobalMeshes] = CMESH::GetMesh(name);
if (!mGlobalMeshes[mNumGlobalMeshes])
{
return -1;
}
mNumGlobalMeshes ++;
return mNumGlobalMeshes -1 ;
}
//=============================================-===--==---=---- --- -- -
void CEngine::GetViewMatrixFromCamera(CCamera *cam, FMatrix *matview)
{
FMatrix pitch ;
pitch.MakeRotationPitchF(1.570796f) ;
FMatrix ori = cam->GetOrientation();
ori.TransposeInPlace() ;
*matview = pitch * ori;
}
//=============================================-===--==---=---- --- -- -
void CEngine::SetViewpoint(int viewpoint,CCamera *camera,CViewport *viewport,CPlayer *player)
{
memcpy(&mViewport[viewpoint],viewport,sizeof(mViewport[viewpoint]));
mPlayer[viewpoint]=player;
if (mCamera[viewpoint])
delete mCamera[viewpoint];
mCamera[viewpoint] = new( MEMTYPE_CAMERA ) CInterpolatedCamera(camera);
}
//=============================================-===--==---=---- --- -- -
float CEngine::GetRenderTime()
{
return EVENT_MANAGER.GetTime();
}
//=============================================-===--==---=---- --- -- -
void CEngine::SetNumViewpoints(int n)
{
mViewpoints=n;
}
//=============================================-===--==---=---- --- -- -
void CEngine::SelectViewpoint(int n)
{
ASSERT(n<mViewpoints);
ASSERT(n>=0);
mCurrentViewpoint=n;
memcpy(&mCurrentViewport,&mViewport[mCurrentViewpoint],sizeof(mCurrentViewport));
PLATFORM.SetViewport(&mCurrentViewport);
}
//=============================================-===--==---=---- --- -- -
void CEngine::ResetPos(int x, int y)
{
ASSERT(mCurrentViewpoint!=-1);
mLandscape->ResetPos(x, y);
}
//=============================================-===--==---=---- --- -- -
void CEngine::InitDamageSystem()
{
mLandscape->ResetDamage();
// stick in tree shadows with damage markers
CThing* boj;
ListIterator <CThing> iterator(&WORLD.GetThingNB());
for (boj=iterator.First(); boj; boj=iterator.Next())
{
if (boj->IsA(THING_TYPE_TREE))
{
AddDamage(boj->GetPos().X+TREE_SHADOW_XOFF, boj->GetPos().Y+TREE_SHADOW_YOFF, ((CTree*)boj)->GetShadowSize());
}
}
ENGINE.LockCurrentDamage();
}
void CEngine::BuildLevelSpecifics()
{
#if TARGET != XBOX
// everyone else inits the damage right now.
InitDamageSystem();
#endif
mLandscape->BuildLevelSpecifics();
#if TARGET == PS2
DWORD lFogCol = MAP.GetFog();
PS2DISPLAY.SetClearColour( lFogCol );
#endif
}
//=============================================-===--==---=---- --- -- -
void CEngine::UpdatePos(CCamera* cam)
{
if (!mRenderLandscape)
return;
ASSERT(mCurrentViewpoint!=-1);
mLandscape->UpdatePos(cam,mCurrentViewpoint);
}
//=============================================-===--==---=---- --- -- -
void CEngine::LoadMixers(int set)
{
mMapTexs[0].LoadAll(set,MT_NUMTEX,256);
mMapTexs[1].LoadAllFromMapTex(&mMapTexs[0]); // 128
mMapTexs[2].LoadAllFromMapTex(&mMapTexs[1]); // 64
mMapTexs[3].LoadAllFromMapTex(&mMapTexs[2]); // 32
mMapTexs[4].LoadAllFromMapTex(&mMapTexs[3]); // 16
mMapTexs[5].LoadAllFromMapTex(&mMapTexs[4]); // 8
mMapTexs[6].LoadAllFromMapTex(&mMapTexs[5]); // 4
#if TARGET==PS2
// Upload textures to IOP
PINMAPPER.UploadMixTextures();
// Reinitialise pinmapper
PINMAPPER.InvalidateLevelData();
#endif
}
//=============================================-===--==---=---- --- -- -
void CEngine::SetKempyCube(UBYTE number)
{
mKempyCube->Change(number);
}
//=============================================-===--==---=---- --- -- -
void CEngine::SetWater(UBYTE number)
{
mWater->Change(number);
}
//=============================================-===--==---=---- --- -- -
void CEngine::SetupLights()
{
// D3D lighting
const SHeightFieldProperties &hfp=MAP.GetHFProperties();
FVector sunlight(hfp.SunPosX,hfp.SunPosY,hfp.SunPosZ);
sunlight.X=-sunlight.X;
sunlight.Y=-sunlight.Y;
sunlight.Z=-sunlight.Z;
sunlight.Normalise();
CAtmospherics::AlterLightDir(&sunlight);
SHADOWS.MakeView(sunlight);//shadowlight); // the light the shadows use
ENGINE.EnableLighting();
CLight light;
float r,g,b;
DWORD col;
#ifdef OLD_LIGHTING
DWORD a=MAP.GetAmbient();
RENDERINFO.SetAmbient(a);
col=MAP.GetSun() - MAP.GetAmbient();
CAtmospherics::AlterLightCol(&col);
r=((float)((col&0xff0000)>>16))*(1.0f/256);
g=((float)((col&0xff00)>>8))*(1.0f/256);
b=((float)(col&0xff))*(1.0f/256);
light.Init( LIGHT_DIRECTIONAL, sunlight, r,g,b);
RENDERINFO.SetLight( 0, &light );
RENDERINFO.SetLightEnable( 0, TRUE );
#else
#if TARGET == PS2
DWORD lSunCol = MAP.GetSun();
DWORD lAntiSunCol = MAP.GetAntiSun();
UINT lSunColR = (lSunCol&0xff0000)>>16;
UINT lSunColG = (lSunCol&0xff00)>>8;
UINT lSunColB = (lSunCol&0xff);
/*char buf[256];
sprintf(buf,"Sun = %d,%d,%d\n",lSunColR,lSunColG,lSunColB);
TRACE(buf);*/
UINT lAntiSunColR = (lAntiSunCol&0xff0000)>>16;
UINT lAntiSunColG = (lAntiSunCol&0xff00)>>8;
UINT lAntiSunColB = (lAntiSunCol&0xff);
//sprintf(buf,"AntiSun = %d,%d,%d\n",lAntiSunColR,lAntiSunColG,lAntiSunColB);
//TRACE(buf);
// Don't allow the antisun to be brighter than the sun
if (lSunColR<lAntiSunColR)
lAntiSunColR=lSunColR;
if (lSunColG<lAntiSunColG)
lAntiSunColG=lSunColG;
if (lSunColB<lAntiSunColB)
lAntiSunColB=lSunColB;
lSunColR = (( lSunColR - lAntiSunColR )/2);
lSunColG = (( lSunColG - lAntiSunColG )/2);
lSunColB = (( lSunColB - lAntiSunColB )/2);
DWORD lAmbient = ((lAntiSunColR+lSunColR)<<16) | ((lAntiSunColG+lSunColG)<<8) | (lAntiSunColB+lSunColB);
//printf( "Ambient: %x\n", lAmbient );
RENDERINFO.SetAmbient( lAmbient );
r=((float)(lSunColR))*(1.0f/256);
g=((float)(lSunColG))*(1.0f/256);
b=((float)(lSunColB))*(1.0f/256);
//sprintf(buf,"Sunout = %f,%f,%f\n",r,g,b);
//TRACE(buf);
//asm("break");
light.Init( LIGHT_DIRECTIONAL, sunlight, r, g, b );
RENDERINFO.SetLight( 0, &light );
RENDERINFO.SetLightEnable( 0, TRUE );
#else
RENDERINFO.SetAmbient(MAP.GetAmbient()); // no real ambient
col = MAP.GetSun();
r=((float)((col&0xff0000)>>16))*(1.0f/256);
g=((float)((col&0xff00)>>8))*(1.0f/256);
b=((float)(col&0xff))*(1.0f/256);
light.Init( LIGHT_DIRECTIONAL, sunlight, r, g, b);
RENDERINFO.SetLight( 0, &light );
RENDERINFO.SetLightEnable( 0, TRUE );
FVector alight;
alight.X = -sunlight.X;
alight.Y = -sunlight.Y;
alight.Z = -sunlight.Z;
// alight.Normalise();
col = MAP.GetAntiSun();
r=((float)((col&0xff0000)>>16))*(1.0f/256);
g=((float)((col&0xff00)>>8))*(1.0f/256);
b=((float)(col&0xff))*(1.0f/256);
light.Init( LIGHT_DIRECTIONAL, alight, r, g, b);
RENDERINFO.SetLight( 1, &light );
RENDERINFO.SetLightEnable( 1, TRUE );
#endif
#endif
RENDERINFO.SetLightEnable( 2, FALSE );
RENDERINFO.SetLightEnable( 3, FALSE );
RENDERINFO.SetLightEnable( 4, FALSE );
RENDERINFO.SetLightEnable( 5, FALSE );
RENDERINFO.SetLightEnable( 6, FALSE );
RENDERINFO.SetLightEnable( 7, FALSE );
}
//=============================================-===--==---=---- --- -- -
void CEngine::LogLight(const FVector &inPos, eLightType lt, float inRadius)
{
mLights->AddReq(inPos, mGamut, lt,inRadius);
}
//=============================================-===--==---=---- --- -- -
void CEngine::SwitchAllLights(BOOL onoff)
{
mLights->SwitchAll(onoff);
}
//=============================================-===--==---=---- --- -- -
//******************************************************************************************
void CEngine::EnableAlpha()
{
RENDERINFO.SRS( RS_ALPHABLENDENABLE, TRUE );
RENDERINFO.SRS( RS_SRCBLEND, BLEND_SRCALPHA );
RENDERINFO.SRS( RS_DESTBLEND, BLEND_INVSRCALPHA);
RENDERINFO.SRS( RS_ZWRITEENABLE , FALSE );
}
//******************************************************************************************
void CEngine::EnableAdditiveAlpha()
{
RENDERINFO.SRS( RS_ALPHABLENDENABLE, TRUE );
RENDERINFO.SRS( RS_SRCBLEND, BLEND_ONE );
RENDERINFO.SRS( RS_DESTBLEND, BLEND_ONE );
RENDERINFO.SRS( RS_ZWRITEENABLE , FALSE );
}
//******************************************************************************************
void CEngine::DisableAlpha()
{
RENDERINFO.SRS( RS_ALPHABLENDENABLE, FALSE );
RENDERINFO.SRS( RS_ZWRITEENABLE , TRUE );
}
//=============================================-===--==---=---- --- -- -
void CEngine::SetTreeAlphaMode( const bool aSet )
{
if( aSet )
{
// RENDERINFO.SRS(RS_ALPHABLENDENABLE,TRUE);
// RENDERINFO.SRS(RS_ALPHATESTENABLE,TRUE);
// RENDERINFO.SRS(RS_ALPHAREF,0x08);
}
else
{
// RENDERINFO.SRS(RS_ALPHABLENDENABLE,TRUE);
// RENDERINFO.SRS(RS_ALPHAREF,0x08);
}
}
//=============================================-===--==---=---- --- -- -
void CEngine::DisableLighting()
{
RENDERINFO.SRS(RS_LIGHTING,FALSE) ;
}
//=============================================-===--==---=---- --- -- -
void CEngine::EnableLighting()
{
// RENDERINFO.SRS(RS_LIGHTING,TRUE) ;
RENDERINFO.SetLightingEnabled(TRUE);
}
//=============================================-===--==---=---- --- -- -
void CEngine::SetSky(UBYTE number)
{
}
//=============================================-===--==---=---- --- -- -
void CEngine::UpdateArea(SINT inStartX, SINT inStartY, SINT inFinishX, SINT inFinishY, BOOL updategeometryinstead)
{
// mLandscape->ResetPos(0,0);
mLandscape->UpdateArea(inStartX, inStartY, inFinishX, inFinishY, updategeometryinstead);
}
//=============================================-===--==---=---- --- -- -
#ifdef RESBUILDER
void CEngine::Serialize(class CChunker *c,CResourceAccumulator *ra)
{
c->Start(MKID("ENGN"));
int nmaptex=N_MAPMIPS;
c->Write(&nmaptex,sizeof(nmaptex),1);
for (int i=0;i<nmaptex;i++)
{
mMapTexs[i].Serialize(c,ra);
}
MAP.Serialize(c,ra);
c->End();
}
#endif
//=============================================-===--==---=---- --- -- -
void CEngine::Deserialize(class CChunkReader *c)
{
if (c->GetNext()!=MKID("ENGN"))
{
SASSERT(0,"Engine deserialize format failure!");
}
int nmaptex;
c->Read(&nmaptex,sizeof(nmaptex),1);
SASSERT(nmaptex==N_MAPMIPS,"Deserialize format failure in engine! (wrong number of mixer textures)");
for (int i=0;i<nmaptex;i++)
{
mMapTexs[i].Deserialize(c,i);
}
MAP.Deserialize(c);
#if TARGET==PS2
// Upload textures to IOP
PINMAPPER.UploadMixTextures();
// Reinitialise pinmapper
PINMAPPER.InvalidateLevelData();
#endif
}
//=============================================-===--==---=---- --- -- -
#ifdef EDITORBUILD2
FVector CEngine::GetCursorOffsetMatrix(float x,float y)
{
float sx=(float)PLATFORM.GetScreenWidth();
float sy=(float)PLATFORM.GetScreenHeight();
if (x < 0) x = 0;
if (y < 0) y = 0;
if (x > sx - 1) x = sx - 1;
if (y > sy - 1) y = sy - 1;
x-=sx/2;
y-=sy/2;
FVector vector(x/(sx/2),1.0f,y/(sx/2));
vector.Normalise();
return vector;
}
#endif