-
Notifications
You must be signed in to change notification settings - Fork 0
/
m2read.cpp
877 lines (656 loc) · 19.9 KB
/
m2read.cpp
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
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
#include<stdlib.h>
//#include<conio.h>
#include<stdio.h>
#include<demo.h>
#include<m2raw.h>
#include<m2camera.h>
#include<timecntr.h>
#include<m2world.h>
//#include<m2image.h>
#include<m2render.h>
#include<m2partic.h>
#include<2dlink.h>
#define framemul (1000/15)
#define xfade1 580//589
#define xfade2 1558
#define mbeamf 3069
const int ofMatrix = 1;
const int ofMesh = 2;
const int ofAbsolute = 4;
const int mfMorph = 8;
const int mfRGBPreCalc = 16; // G
const int mfBumpPreCalc = 32; // B
const int mfDistance = 64; // Z
const int numclasses = 5;
const int idMesh = 0;
const int idCamera = 1;
const int idTarget = 2;
const int idOmni = 3;
const int idDummy = 4;
struct tvmt;
struct tobject {
tvmt *vmt;
int flags;
// hierarchie-system:
tobject *owner;
tobject *next;
tobject *child;
// zustand:
float position[3];
float matrix[9];
int hidden;
};
struct tmesh {
tobject object;
CMV2PolygonObject PolygonObject;
// postrack (3):
void *postrack;
// rotationtrack (4):
void *rottrack;
// scaletrack (3):
// void *scaletrack;
// morphtrack (2*vertices*3):
void *morphtrack;
// void *nmorphtrack;
void *rgbtrack;
// hidetrack:
int *hidetrack;
int hidekey;
};
struct tcamera {
tobject object;
void *target;
// postrack (3):
void *postrack;
// FOVtrack (1):
void *FOVtrack;
float FOV;
// rolltrack (1):
void *rolltrack;
float roll;
};
struct ttarget {
tobject object;
// postrack (3):
void *postrack;
};
struct tomni {
tobject object;
// postrack (3):
void *postrack;
// coltrack (3):
void *coltrack;
float color[3];
// hidetrack:
int *hidetrack;
int hidekey;
};
struct tdummy {
tobject object;
// special effect
int special;
// position
float x[3];
// hidetrack:
int *hidetrack;
int hidekey;
int firstframe;
};
struct tmaterial {
int flag;
char *txtmap;
char *bumpmap;
};
struct tbumpomni {
// coltrack (3):
void *coltrack;
float color[3];
// multiplier track (1)
void *multtrack;
float multiplier;
// hidetrack:
int *hidetrack;
int hidekey;
int hidden;
};
//---VMT--------
struct tvmt {
int size;
void (*readdata)(tstream &, tobject *);
char *firstobj;
char *nextobj;
void (*dotracks)(void);
void (*insert)(tobject *);
};
void m_readM2(tstream &s, tobject *obj);
void c_readM2(tstream &s, tobject *obj);
void t_readM2(tstream &s, tobject *obj);
void i_readM2(tstream &s, tobject *obj);
void d_readM2(tstream &s, tobject *obj);
//from m2tracks
extern "C" {
void initframecount();
//#pragma aux initframecount "*" modify [eax]
void calcframecount(int);
//#pragma aux calcframecount "*" parm [eax] modify [eax]
void dotracks(tobject *);
//#pragma aux dotracks "*" parm [esi] modify [eax ebx ecx edx esi edi]
void calcbumpomni(tbumpomni *);
//#pragma aux calcbumpomni "*" parm [esi] modify [eax ebx ecx edx esi edi]
void doviewer(tcamera *, CMV2Camera *);
//#pragma aux doviewer "*" parm [esi] [edi] modify [eax ebx ecx edx esi edi]
void matrixmul(tobject *, CMV2Camera *, CMV2Camera *);
//#pragma aux matrixmul "*" parm [esi] [edx] [edi] modify [eax ebx ecx edx esi edi]
void m_dotracksM2(void);
void c_dotracksM2(void);
void t_dotracksM2(void);
void i_dotracksM2(void);
void d_dotracksM2(void);
};
void m_insert(tobject *);
void c_insert(tobject *);
void t_insert(tobject *);
void i_insert(tobject *);
void d_insert(tobject *);
static tvmt vmtlist[] = {
{sizeof(tmesh) ,m_readM2,NULL,NULL,m_dotracksM2, m_insert},
{sizeof(tcamera),c_readM2,NULL,NULL,c_dotracksM2, c_insert},
{sizeof(ttarget),t_readM2,NULL,NULL,t_dotracksM2, t_insert},
{sizeof(tomni) ,i_readM2,NULL,NULL,i_dotracksM2, i_insert},
{sizeof(tdummy) ,d_readM2,NULL,NULL,d_dotracksM2, d_insert}
};
//global
tmaterial *matlist;
char *txtdata;
tobject *root;
tbumpomni *bumpomni;
char *firemap;
// Moove2 {
extern tvesa *pMoove2Vesa;
extern void *coltab;
extern char *pcBackBuffer1; // 32bit
extern char *pcBackBuffer2; // 32bit
extern char *pcDestBackBuffer; // 32bit
extern char *pcFade; // 8bit
extern char *pcEye; // 32bit
extern char *pcMask; // 8bit
extern "C" void CopyBufferASM(char *pSrcScreenBuffer, tvesa *pVesa, void *);
//#pragma aux CopyBufferASM "*" parm [esi] [ebx] [edx] modify [eax ebx ecx edx esi edi]
extern void WaitVR();
extern void FromMeseCalcLightBrightnessTab(float *fRGB, float fBFactor);
extern "C" void InitZeroMem(char *pMem, long lNum);
//extern CGfxModeVesa *pVesa;
extern CGfxStrIO *pGfxStrIO;
extern CMV2World *pWorld;
extern void InitMV2();
extern CMV2Render *pRender;
extern "C" void Draw2DFadeASM(char *pBackBuffer1, char *pBackBuffer2,
char *pDestBack, char *pFade, int dwFadeFactor,
int dwNum);
extern C2DLinkEffect LinkEffect;
extern CFire Fire;
extern CMV2PBernoulli PBernoulli;
extern C2DEye EyeEffect;
extern C2DBeamFade BeamFade;
static CMV2Camera Camera;
static CMV2Camera Camera2;
// }
extern "C" int frame;
// Profiling {
extern int iAddPolys;
extern int iVSpacePolys;
extern int iToBeClipped;
extern int iDrawedPolys;
extern int iDrawPolysCounter;
extern float fDrawPolysFps;
extern "C" int iPixelCounter;
extern int iClippingCounter;
extern float fClippingFps;
// }
extern "C" void TransformToBumpmapASM(char *src, char *dest, int len);
tbumpomni *readbumpomni(tstream &s) {
tbumpomni *bumpomni;
bumpomni = (tbumpomni *) getclearmem(sizeof(tbumpomni));
//color track
bumpomni->coltrack = readtrack(s);
//multiplier track
bumpomni->multtrack = readtrack(s);
//hide track
bumpomni->hidetrack = readhtrack(s);
return bumpomni;
}
tobject *readobj(tstream &s, tobject* owner, int toread) {
tobject *next = NULL;
tvmt *vmt;
tobject *obj;
int i;
while (toread > 0) {
//id
vmt = &vmtlist[s.getint()];
obj = (tobject *) vmt->nextobj;
vmt->nextobj = &vmt->nextobj[vmt->size];
obj->vmt = vmt;
obj->owner = owner;
obj->next = next;
next = obj;
//childs
i = s.getint();
//readdata
vmt->readdata(s,obj);
//read childs
obj->child = readobj(s,obj,i);
toread--;
}
return next;
};
void m_readM2(tstream &s, tobject *obj) {
tmesh *mesh = (tmesh *) obj;
int count, z;
//flags
obj->flags = s.getint() + ofMatrix + ofMesh;
// int iShade = s.getint();
//vertices (int)
count = s.getint(); //z = vertices
mesh->PolygonObject.m_iNumDot3DPos = count;
mesh->PolygonObject.m_pDot3DPos = (CMV2Dot3DPos *) getmem(count*sizeof(CMV2Dot3DPos));//new CMV2Dot3DPos[count];
mesh->PolygonObject.m_ppDot3DPos = (CMV2Dot3DPos **) getmem(count*sizeof(CMV2Dot3DPos *));//new CMV2Dot3DPos *[count];
for (z = 0; z < count; z++)
mesh->PolygonObject.m_ppDot3DPos[z] = &mesh->PolygonObject.m_pDot3DPos[z];
if (!(obj->flags & mfMorph)) { //if not mfMorph
for (z = 0; z < count; z++)
s.read(&mesh->PolygonObject.m_pDot3DPos[z].m_Pos, 3*sizeof(float));
}
/*
for (z = 0; z < count; z++)
{
int iRGBCol = 0;
s.read(&iRGBCol, 3);
CMV2Dot3DPos *pDotPos = &mesh->PolygonObject.m_pDot3DPos[z];
pDotPos->m_fAmbientR = float((iRGBCol&0xff0000)>>8);
pDotPos->m_fAmbientG = float((iRGBCol&0x00ff00));
pDotPos->m_fAmbientB = float((iRGBCol&0x0000ff)<<8);
pDotPos->m_fAmbientR = 65535;
pDotPos->m_fAmbientG = 65535;
pDotPos->m_fAmbientB = 65535;
pDotPos->m_fR = pDotPos->m_fAmbientR;
pDotPos->m_fG = pDotPos->m_fAmbientG;
pDotPos->m_fB = pDotPos->m_fAmbientB;
}
*/
// s.read(&mesh->PolygonObject.m_pDot3DPos[z].m_iRGBCol, 3);
if (obj->flags & (mfRGBPreCalc | mfBumpPreCalc)) {
mesh->rgbtrack = readltrack(s, mesh->PolygonObject.m_iNumDot3DPos*3);
}
//faces (int) ;only for mem alloc
count = s.getint();
mesh->PolygonObject.m_pPolygons = (CMV2Polygon *) getmem(count*sizeof(CMV2Polygon));//new CMV2Polygon[count];
mesh->PolygonObject.m_ppPolygons = (CMV2Polygon **) getmem(count*sizeof(CMV2Polygon *));//new CMV2Polygon *[count];
for (z = 0; z < count; z++)
mesh->PolygonObject.m_ppPolygons[z] = &mesh->PolygonObject.m_pPolygons[z];
mesh->PolygonObject.m_pDot3D = (CMV2Dot3D *) getmem(3*count*sizeof(CMV2Dot3D));//new CMV2Dot3D[3*count];
mesh->PolygonObject.m_iNumDot3D = 3*count;
CMV2Polygon *pPolygon = mesh->PolygonObject.m_pPolygons;
CMV2Dot3D *pDot3D = mesh->PolygonObject.m_pDot3D;
CMV2Dot3DPos *pDot3DPos = mesh->PolygonObject.m_pDot3DPos;
while ((count = s.getint())) { //number of material assigns
tmaterial *mat;
mat = &matlist[s.getint()]; //material
int iJump = s.getint(); //jump table index
int iCurNumPolygon = 0;
for(z = 0; z < count; z++) {
int i;
for (i = 0; i < 3; i++)
{
pDot3D[i].m_pPos = &pDot3DPos[s.getint()];
pDot3D[i].m_fTextureU = s.getfloat();
pDot3D[i].m_fTextureV = s.getfloat();
}
pPolygon->m_pDot1 = &pDot3D[0];
pPolygon->m_pDot2 = &pDot3D[1];
pPolygon->m_pDot3 = &pDot3D[2];
pPolygon->m_pcTexture = mat->txtmap;
pPolygon->m_pcBumpmap = mat->bumpmap;
pPolygon->m_iType = iJump;
pPolygon->m_iFlag = 0;
pDot3D += 3;
pPolygon++;
}
};
mesh->PolygonObject.m_iNumPolygons = pPolygon -
mesh->PolygonObject.m_pPolygons;
int iNumPolygons = mesh->PolygonObject.m_iNumPolygons;
pPolygon = mesh->PolygonObject.m_pPolygons;
int iI;
if (obj->flags & mfDistance)
{
for (iI = 0; iI < iNumPolygons; iI++)
pPolygon[iI].m_fAddDistance = 20.0;
}
else
{
for (iI = 0; iI < iNumPolygons; iI++)
pPolygon[iI].m_fAddDistance = 0.0;
}
if (!(obj->flags & ofAbsolute)) {
//position track
mesh->postrack = readtrack(s);
//rotation track
mesh->rottrack = readtrack(s);
//scale track
// mesh->scaletrack = readtrack(s);
//morph track
// if (obj->flags & mfMorph) mesh->morphtrack = readtrack(s);
} else {
//position track
mesh->postrack = readltrack(s,3);
//morph track
if (obj->flags & mfMorph) { //vertices*3
mesh->morphtrack = readltrack(s,mesh->PolygonObject.m_iNumDot3DPos*3);
// mesh->nmorphtrack = readltrack(s,mesh->PolygonObject.m_iNumDot3DPos*3);
}
}
//hide track
mesh->hidetrack = readhtrack(s);
}
void c_readM2(tstream &s, tobject *obj) {
tcamera *cam = (tcamera *) obj;
//target
cam->target = &vmtlist[idTarget].firstobj[s.getint() * sizeof(ttarget)];
//position track
cam->postrack = readtrack(s);
//FOV track
cam->FOVtrack = readtrack(s);
//roll track
cam->rolltrack = readtrack(s);
};
void t_readM2(tstream &s, tobject *obj) {
ttarget *target = (ttarget *) obj;
//position track
target->postrack = readtrack(s);
};
void i_readM2(tstream &s, tobject *obj) {
tomni *omni = (tomni *) obj;
int z;
//position track
omni->postrack = readtrack(s);
//color track
omni->coltrack = readtrack(s);
//hide track
omni->hidetrack = readhtrack(s);
}
void d_readM2(tstream &s, tobject *obj) {
tdummy *dummy = (tdummy *) obj;
int z;
//special effect
dummy->special = s.getint();
//position
s.read(dummy->x,12);
//hide track
dummy->hidetrack = readhtrack(s);
//first visibility
dummy->firstframe = (dummy->hidetrack[0] < 2) ? 0 : dummy->hidetrack[2];
}
void readmaterials(tstream &s) {
int count, z;
tmaterial *mat;
char pal[768];
char *txtdata;
char *bumpdata;
char *map;
char *tempdata;
// char *firemap;
//texturemaps (int)
count = s.getint();
//alloc mem for texturedata (align 256k)
txtdata = (char *) getalignmem((count+1) << 18, 1 << 18);
firemap = txtdata + (count << 18);
//convert to true color
tempdata = (char *) gettempmem(65536);
map = txtdata;
for(z = 0; z < count; z++) {
int i, p;
//palette (768 chars)
s.read(&pal,768);
//bitmap (65536 chars)
s.read(tempdata,65536);
for(i = 0; i < 65536; i++) {
p = ((uint8_t *)tempdata)[i]*3;
map[i*4+2] = pal[p];
map[i*4+1] = pal[p+1];
map[i*4+0] = pal[p+2];
}
map += 1 << 18;
}
//bumpmaps (int)
count = s.getint();
//alloc mem for bumpmapdata (align 128k)
bumpdata = (char *) getalignmem(count << 17, 1 << 17);
//convert to displacement map
tempdata = (char *) gettempmem(65536);
map = bumpdata;
for(z = 0; z < count; z++) {
//bitmap (65536 chars)
s.read(tempdata,65536);
TransformToBumpmapASM(tempdata,map,65536);
map += 1 << 17;
}
// materials (int) ;number of materials
count = s.getint();
matlist = (tmaterial *) getmem(count*sizeof(tmaterial));//new tmaterial[count];
// materialdata (n materials)
s.read(matlist,count*sizeof(tmaterial));
//convert material pointers
mat = matlist;
for(z = 0; z < count; z++) {
if (!mat->flag) {
mat->txtmap = &txtdata[((int) mat->txtmap) << 18];
mat->bumpmap = ((int) mat->bumpmap != -1) ?
&bumpdata[((int) mat->bumpmap) << 17] : NULL;
} else {
mat->txtmap = firemap;
mat->bumpmap = NULL;
}
mat++;
}
}
//mesh
void m_insert(tobject *obj) {
matrixmul(obj,&Camera,&Camera2);
pRender->FromMESEAddPolygonObject(&Camera2, &((tmesh *)obj)->PolygonObject);
}
//camera
void c_insert(tobject *obj) {
}
//target
void t_insert(tobject *obj) {
}
//omni
void i_insert(tobject *obj) {
}
//dummy
void d_insert(tobject *obj) {
tdummy *dummy = (tdummy *) obj;
if (dummy->special == 0)
{
PBernoulli.m_Camera = Camera;
PBernoulli.m_Camera.m_Pos -= CVector3D(dummy->x[0],
dummy->x[1], dummy->x[2]);
PBernoulli.m_iToBeRendered = 1;
PBernoulli.m_iFrame = frame - dummy->firstframe;
}
}
void traverse(tobject *obj) {
while (obj) {
if (!obj->hidden) obj->vmt->insert(obj);
traverse(obj->child);
obj = obj->next;
};
};
void InitPlayer(tstream &s)
{
int z;
s.openfile("mainpart.mv2");
//contents
for(z = 0; z < numclasses; z++)
{
vmtlist[z].firstobj = (char *) getclearmem(s.getint() * vmtlist[z].size);
vmtlist[z].nextobj = vmtlist[z].firstobj;
};
//materials
readmaterials(s);
//bump mapping omni
bumpomni = readbumpomni(s);
//objects
root = readobj(s,NULL,s.getint());
}
void xfade(int xfstart, int xfend) {
frame = xfstart;
dotracks(root);
doviewer((tcamera *) vmtlist[idCamera].firstobj, &Camera);
pRender->Clear();
traverse(root);
pRender->DoRendering(pcBackBuffer1, pWorld->m_iXmax);
if (PBernoulli.m_iToBeRendered) {
PBernoulli.Draw(pcBackBuffer1);
}
frame = xfend;
dotracks(root);
doviewer((tcamera *) vmtlist[idCamera].firstobj, &Camera);
pRender->Clear();
traverse(root);
pRender->DoRendering(pcBackBuffer2, pWorld->m_iXmax);
while (!keypressed() && frame <= xfend) {
calcframecount(0);
Draw2DFadeASM(pcBackBuffer1, pcBackBuffer2, pcDestBackBuffer,
pcFade, -256 + (frame - xfstart)/5,
pMoove2Vesa->xres*pMoove2Vesa->yres);
CopyBufferASM(pWorld->m_pcBackBuffer, pMoove2Vesa, coltab);
}
}
void mbeam(int bstart, int brender, int bend) {
frame = bstart;
dotracks(root);
doviewer((tcamera *) vmtlist[idCamera].firstobj, &Camera);
pRender->Clear();
traverse(root);
pRender->DoRendering(pcBackBuffer1, pWorld->m_iXmax);
frame = brender;
dotracks(root);
doviewer((tcamera *) vmtlist[idCamera].firstobj, &Camera);
pRender->Clear();
traverse(root);
InitZeroMem(pcBackBuffer2, pWorld->m_iXmax*pWorld->m_iYmax*4);
pRender->DoRendering(pcBackBuffer2, pWorld->m_iXmax);
while (!keypressed() && frame <= bend) {
calcframecount(0);
BeamFade.Draw(frame - bstart, pcBackBuffer1, pcBackBuffer2,
pcDestBackBuffer);
CopyBufferASM(pcDestBackBuffer, pMoove2Vesa, coltab);
}
}
void startmoove()
{
int DirectRender;
Fire.Draw(firemap,0);
Camera = *pWorld->m_pWorldCamera;
Camera2 = *pWorld->m_pWorldCamera;
frame = 0;
dotracks(root);
doviewer((tcamera *) vmtlist[idCamera].firstobj, &Camera);
pRender->Clear();
traverse(root);
pRender->DoRendering(pcBackBuffer2, pWorld->m_iXmax);
initframecount();
while (!keypressed() && frame < 7500) {
calcframecount(0);
LinkEffect.Draw(pcBackBuffer1, pcBackBuffer2, pcDestBackBuffer, frame);
CopyBufferASM(pcDestBackBuffer, pMoove2Vesa, coltab);
}
calcframecount(7500);
// //3715
while (!keypressed() && frame < 3630*framemul) {
calcframecount(0);
if (frame >= 138*framemul && frame < 300*framemul) {
Fire.Draw(firemap,frame);
}
if (frame >= xfade1*framemul && frame < xfade1*framemul+1500) {
xfade(xfade1*framemul,xfade1*framemul+1500);
if (keypressed()) goto weg;
}
if (frame >= xfade2*framemul && frame < xfade2*framemul+1500) {
xfade(xfade2*framemul,xfade2*framemul+1500);
if (keypressed()) goto weg;
}
if (frame >= mbeamf*framemul && frame < mbeamf*framemul+2000) {
mbeam(mbeamf*framemul,(mbeamf+10)*framemul,mbeamf*framemul+2000);
if (keypressed()) goto weg;
}
dotracks(root);
calcbumpomni(bumpomni);
if (!bumpomni->hidden) FromMeseCalcLightBrightnessTab(bumpomni->color,bumpomni->multiplier);
doviewer((tcamera *) vmtlist[idCamera].firstobj, &Camera);
//InitZeroMem(pWorld->m_pcBackBuffer, pWorld->m_iXmax*pWorld->m_iYmax*4);
pWorld->m_pTimeCounter->StartTimeCounter();
pRender->Clear();
// pRender->FromMESEAddOmniLight(&Camera, &OmniLight);
traverse(root);
DirectRender = 1;
//fischauge
if (frame > 764*framemul && frame < 1037*framemul) {
pRender->DoRendering(pcBackBuffer1, pWorld->m_iXmax);
EyeEffect.Draw(pcEye, pcMask, pcBackBuffer1, pcDestBackBuffer);
DirectRender = 0;
}
if (DirectRender)
pRender->DoRendering(pcDestBackBuffer, pWorld->m_iXmax);
//partikelrauch
if (PBernoulli.m_iToBeRendered) {
PBernoulli.Draw(pWorld->m_pcBackBuffer);
}
pWorld->m_pTimeCounter->StopTimeCounter();
float fFps = pWorld->m_pTimeCounter->GetFPS();
pWorld->m_pGfxStrIO->ResetPos();
/*
char pcText[80];
sprintf(pcText, "fps, engine: %.2f, %.2f", fFps, fDrawPolysFps);
pWorld->m_pGfxStrIO->WriteStr(pcText);
sprintf(pcText, "AP, DP: %d, %d", iAddPolys, iDrawedPolys);
pWorld->m_pGfxStrIO->WriteStr(pcText);
*/
/*
sprintf(pcText, "AddPolys: %d", iAddPolys);
pWorld->m_pGfxStrIO->WriteStr(pcText);
sprintf(pcText, "VSpacePolys: %d", iVSpacePolys);
pWorld->m_pGfxStrIO->WriteStr(pcText);
sprintf(pcText, "ToBeClipped: %d", iToBeClipped);
pWorld->m_pGfxStrIO->WriteStr(pcText);
sprintf(pcText, "DrawedPolys: %d", iDrawedPolys);
pWorld->m_pGfxStrIO->WriteStr(pcText);
sprintf(pcText, "DrawedPixels: %d", iPixelCounter);
pWorld->m_pGfxStrIO->WriteStr(pcText);
sprintf(pcText, "ClippingTSC: %d", iClippingCounter);
pWorld->m_pGfxStrIO->WriteStr(pcText);
sprintf(pcText, "ClippingFps: %.2f", fClippingFps);
pWorld->m_pGfxStrIO->WriteStr(pcText);
*/
/*
float fPixelDrawedFactor = float(iPixelCounter)/
float(pWorld->m_iXmax*pWorld->m_iYmax);
sprintf(pcText, "DrawedPixelFactor: %.2f ", fPixelDrawedFactor);
int iFlag = 0;
while (fPixelDrawedFactor > 1.6)
{
if (fPixelDrawedFactor >= 2.4)
iFlag = 1;
strcat(pcText, "!");
fPixelDrawedFactor -= 0.2;
}
if (iFlag)
strcat(pcText, " Ugh...");
pWorld->m_pGfxStrIO->WriteStr(pcText);
*/
// WaitVR();
CopyBufferASM(pWorld->m_pcBackBuffer, pMoove2Vesa, coltab);
}
weg:;
}