Du bist nicht angemeldet.

Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!

Werbeanzeige

Anonymous

unregistriert

1

16.06.2005, 14:04

Wie kann ich in directx und c# mit der Maus auf ein objekt ?

Ich habe folgenden Code programmiert und möchte jetzt gerne auf die einzelnen Würfel per maus zugreifen können. Wie geht das ?

Quellcode

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
/* Das Programm soll einen Würfel von 5 * 5 * 5 Würfelelemente in 3D darstellen 
 * Deshalb wurde es in Directx erstellt. Um die Würfelelemente zu erstellen, 
 * wurde das Mesh " MeshBox " benutzt.
 * 
 * Wenn die Maus auf ein Würfellement der aktiven ebene Kommt, wird ein geladener 
 * Text angezeigt.
 * 
 * Wird auf ein Würfelelement mit der Maus geklickt, wird ein Frage-Antwortfenster geöffnet.
 * */

// Benutzte Verweise
using System;
using System.Windows.Forms;
using System.Drawing;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using Microsoft.DirectX.DirectInput;
using System.Threading;

// Namspace für den Würfel
namespace Wuerfel
{
    public class Form1 : Form
    {

        // Die MainMethode, Einstieg in das Programm
        static void Main() 
        { 
            Application.Run( new Form1() ); 
            Point mPos;
        
        }
        

        static Microsoft.DirectX.Direct3D.Device device = null;
        static float xAngle, yAngle, zAngle ;

        //"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
        // Deklaration der einzelen Würfelvariablen der ersten Ebene
        static Mesh meshBox1,meshBox2,meshBox3,meshBox4,meshBox5,meshBox6,meshBox7,meshBox8,meshBox9;
        static Mesh meshBox10,meshBox11,meshBox12,meshBox13,meshBox14,meshBox15,meshBox16,meshBox17;
        static Mesh meshBox18,meshBox19,meshBox20,meshBox21,meshBox22,meshBox23,meshBox24,meshBox25;
        
        // Deklaration der einzelen Würfelvariablen der zweiten Ebene
        static Mesh meshBoxb1,meshBoxb2,meshBoxb3,meshBoxb4,meshBoxb5,meshBoxb6,meshBoxb7,meshBoxb8,meshBoxb9;
        static Mesh meshBoxb10,meshBoxb11,meshBoxb12,meshBoxb13,meshBoxb14,meshBoxb15,meshBoxb16,meshBoxb17;
        static Mesh meshBoxb18,meshBoxb19,meshBoxb20,meshBoxb21,meshBoxb22,meshBoxb23,meshBoxb24,meshBoxb25;
        
        // Deklaration der einzelen Würfelvariablen der dritten Ebene
        static Mesh meshBoxc1,meshBoxc2,meshBoxc3,meshBoxc4,meshBoxc5,meshBoxc6,meshBoxc7,meshBoxc8,meshBoxc9;
        static Mesh meshBoxc10,meshBoxc11,meshBoxc12,meshBoxc13,meshBoxc14,meshBoxc15,meshBoxc16,meshBoxc17;
        static Mesh meshBoxc18,meshBoxc19,meshBoxc20,meshBoxc21,meshBoxc22,meshBoxc23,meshBoxc24,meshBoxc25;

        // Deklaration der einzelen Würfelvariablen der vierten Ebene
        static Mesh meshBoxd1,meshBoxd2,meshBoxd3,meshBoxd4,meshBoxd5,meshBoxd6,meshBoxd7,meshBoxd8,meshBoxd9;
        static Mesh meshBoxd10,meshBoxd11,meshBoxd12,meshBoxd13,meshBoxd14,meshBoxd15,meshBoxd16,meshBoxd17;
        static Mesh meshBoxd18,meshBoxd19,meshBoxd20,meshBoxd21,meshBoxd22,meshBoxd23,meshBoxd24,meshBoxd25;

        // Deklaration der einzelen Würfelvariablen der fünften Ebene
        static Mesh meshBoxe1,meshBoxe2,meshBoxe3,meshBoxe4,meshBoxe5,meshBoxe6,meshBoxe7,meshBoxe8,meshBoxe9;
        static Mesh meshBoxe10,meshBoxe11,meshBoxe12,meshBoxe13,meshBoxe14,meshBoxe15,meshBoxe16,meshBoxe17;
        static Mesh meshBoxe18,meshBoxe19,meshBoxe20,meshBoxe21,meshBoxe22,meshBoxe23,meshBoxe24,meshBoxe25;
        //""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

        //""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
        // Position der einzelnen Würfel der ersten Ebene
        //====================================================================================
        
        static Matrix mBox1     = Matrix.Translation( new Vector3( -1.6f,   -1.6f,  0.0f ) ); 
        static Matrix mBox2     = Matrix.Translation( new Vector3( -1.6f,   -0.8f,  0.0f ) );
        static Matrix mBox3     = Matrix.Translation( new Vector3( -1.6f,    0.0f,  0.0f ) );
        static Matrix mBox4     = Matrix.Translation( new Vector3( -1.6f,    0.8f,  0.0f ) );
        static Matrix mBox5     = Matrix.Translation( new Vector3( -1.6f,    1.6f,  0.0f ) );

        static Matrix mBox6     = Matrix.Translation( new Vector3( -0.8f,   -1.6f,  0.0f ) );
        static Matrix mBox7     = Matrix.Translation( new Vector3( -0.8f,   -0.8f,  0.0f ) );
        static Matrix mBox8     = Matrix.Translation( new Vector3( -0.8f,    0.0f,  0.0f ) );
        static Matrix mBox9     = Matrix.Translation( new Vector3( -0.8f,    0.8f,  0.0f ) );
        static Matrix mBox10    = Matrix.Translation( new Vector3( -0.8f,    1.6f,  0.0f ) );

        static Matrix mBox11    = Matrix.Translation( new Vector3(  0.0f,   -1.6f,  0.0f ) );
        static Matrix mBox12    = Matrix.Translation( new Vector3(  0.0f,   -0.8f,  0.0f ) );
        static Matrix mBox13    = Matrix.Translation( new Vector3(  0.0f,    0.0f,  0.0f ) );
        static Matrix mBox14    = Matrix.Translation( new Vector3(  0.0f,    0.8f,  0.0f ) );
        static Matrix mBox15    = Matrix.Translation( new Vector3(  0.0f,    1.6f,  0.0f ) );

        static Matrix mBox16    = Matrix.Translation( new Vector3(  0.8f,   -1.6f,  0.0f ) );
        static Matrix mBox17    = Matrix.Translation( new Vector3(  0.8f,   -0.8f,  0.0f ) );
        static Matrix mBox18    = Matrix.Translation( new Vector3(  0.8f,    0.0f,  0.0f ) );
        static Matrix mBox19    = Matrix.Translation( new Vector3(  0.8f,    0.8f,  0.0f ) );
        static Matrix mBox20    = Matrix.Translation( new Vector3(  0.8f,    1.6f,  0.0f ) );

        static Matrix mBox21    = Matrix.Translation( new Vector3(  1.6f,   -1.6f,  0.0f ) );
        static Matrix mBox22    = Matrix.Translation( new Vector3(  1.6f,   -0.8f,  0.0f ) );
        static Matrix mBox23    = Matrix.Translation( new Vector3(  1.6f,    0.0f,  0.0f ) );
        static Matrix mBox24    = Matrix.Translation( new Vector3(  1.6f,    0.8f,  0.0f ) );
        static Matrix mBox25    = Matrix.Translation( new Vector3(  1.6f,    1.6f,  0.0f ) );
        //====================================================================================


        // Position der einzelnen Würfel der zweiten Ebene
        //====================================================================================
        static Matrix mBoxb1    = Matrix.Translation( new Vector3( -1.6f,   -1.6f,  1.5f ) ); 
        static Matrix mBoxb2    = Matrix.Translation( new Vector3( -1.6f,   -0.8f,  1.5f ) );
        static Matrix mBoxb3    = Matrix.Translation( new Vector3( -1.6f,    0.0f,  1.5f ) );
        static Matrix mBoxb4    = Matrix.Translation( new Vector3( -1.6f,    0.8f,  1.5f ) );
        static Matrix mBoxb5    = Matrix.Translation( new Vector3( -1.6f,    1.6f,  1.5f ) );

        static Matrix mBoxb6    = Matrix.Translation( new Vector3( -0.8f,   -1.6f,  1.5f ) );
        static Matrix mBoxb7    = Matrix.Translation( new Vector3( -0.8f,   -0.8f,  1.5f ) );
        static Matrix mBoxb8    = Matrix.Translation( new Vector3( -0.8f,    0.0f,  1.5f ) );
        static Matrix mBoxb9    = Matrix.Translation( new Vector3( -0.8f,    0.8f,  1.5f ) );
        static Matrix mBoxb10   = Matrix.Translation( new Vector3( -0.8f,    1.6f,  1.5f ) );

        static Matrix mBoxb11   = Matrix.Translation( new Vector3(  0.0f,   -1.6f,  1.5f ) );
        static Matrix mBoxb12   = Matrix.Translation( new Vector3(  0.0f,   -0.8f,  1.5f ) );
        static Matrix mBoxb13   = Matrix.Translation( new Vector3(  0.0f,    0.0f,  1.5f ) );
        static Matrix mBoxb14   = Matrix.Translation( new Vector3(  0.0f,    0.8f,  1.5f ) );
        static Matrix mBoxb15   = Matrix.Translation( new Vector3(  0.0f,    1.6f,  1.5f ) );

        static Matrix mBoxb16   = Matrix.Translation( new Vector3(  0.8f,   -1.6f,  1.5f ) );
        static Matrix mBoxb17   = Matrix.Translation( new Vector3(  0.8f,   -0.8f,  1.5f ) );
        static Matrix mBoxb18   = Matrix.Translation( new Vector3(  0.8f,    0.0f,  1.5f ) );
        static Matrix mBoxb19   = Matrix.Translation( new Vector3(  0.8f,    0.8f,  1.5f ) );
        static Matrix mBoxb20   = Matrix.Translation( new Vector3(  0.8f,    1.6f,  1.5f ) );

        static Matrix mBoxb21   = Matrix.Translation( new Vector3(  1.6f,   -1.6f,  1.5f ) );
        static Matrix mBoxb22   = Matrix.Translation( new Vector3(  1.6f,   -0.8f,  1.5f ) );
        static Matrix mBoxb23   = Matrix.Translation( new Vector3(  1.6f,    0.0f,  1.5f ) );
        static Matrix mBoxb24   = Matrix.Translation( new Vector3(  1.6f,    0.8f,  1.5f ) );
        static Matrix mBoxb25   = Matrix.Translation( new Vector3(  1.6f,    1.6f,  1.5f ) );
        //====================================================================================
        
        // Position der einzelnen Würfel der dritten Ebene
        //====================================================================================
        static Matrix mBoxc1    = Matrix.Translation( new Vector3( -1.6f,   -1.6f,  2.5f ) ); 
        static Matrix mBoxc2    = Matrix.Translation( new Vector3( -1.6f,   -0.8f,  2.5f ) );
        static Matrix mBoxc3    = Matrix.Translation( new Vector3( -1.6f,    0.0f,  2.5f ) );
        static Matrix mBoxc4    = Matrix.Translation( new Vector3( -1.6f,    0.8f,  2.5f ) );
        static Matrix mBoxc5    = Matrix.Translation( new Vector3( -1.6f,    1.6f,  2.5f ) );

        static Matrix mBoxc6    = Matrix.Translation( new Vector3( -0.8f,   -1.6f,  2.5f ) );
        static Matrix mBoxc7    = Matrix.Translation( new Vector3( -0.8f,   -0.8f,  2.5f ) );
        static Matrix mBoxc8    = Matrix.Translation( new Vector3( -0.8f,    0.0f,  2.5f ) );
        static Matrix mBoxc9    = Matrix.Translation( new Vector3( -0.8f,    0.8f,  2.5f ) );
        static Matrix mBoxc10   = Matrix.Translation( new Vector3( -0.8f,    1.6f,  2.5f ) );

        static Matrix mBoxc11   = Matrix.Translation( new Vector3(  0.0f,   -1.6f,  2.5f ) );
        static Matrix mBoxc12   = Matrix.Translation( new Vector3(  0.0f,   -0.8f,  2.5f ) );
        static Matrix mBoxc13   = Matrix.Translation( new Vector3(  0.0f,    0.0f,  2.5f ) );
        static Matrix mBoxc14   = Matrix.Translation( new Vector3(  0.0f,    0.8f,  2.5f ) );
        static Matrix mBoxc15   = Matrix.Translation( new Vector3(  0.0f,    1.6f,  2.5f ) );

        static Matrix mBoxc16   = Matrix.Translation( new Vector3(  0.8f,   -1.6f,  2.5f ) );
        static Matrix mBoxc17   = Matrix.Translation( new Vector3(  0.8f,   -0.8f,  2.5f ) );
        static Matrix mBoxc18   = Matrix.Translation( new Vector3(  0.8f,    0.0f,  2.5f ) );
        static Matrix mBoxc19   = Matrix.Translation( new Vector3(  0.8f,    0.8f,  2.5f ) );
        static Matrix mBoxc20   = Matrix.Translation( new Vector3(  0.8f,    1.6f,  2.5f ) );

        static Matrix mBoxc21   = Matrix.Translation( new Vector3(  1.6f,   -1.6f,  2.5f ) );
        static Matrix mBoxc22   = Matrix.Translation( new Vector3(  1.6f,   -0.8f,  2.5f ) );
        static Matrix mBoxc23   = Matrix.Translation( new Vector3(  1.6f,    0.0f,  2.5f ) );
        static Matrix mBoxc24   = Matrix.Translation( new Vector3(  1.6f,    0.8f,  2.5f ) );
        static Matrix mBoxc25   = Matrix.Translation( new Vector3(  1.6f,    1.6f,  2.5f ) );
        //====================================================================================

        // Positione der einzelnen Würfel der vierten Ebene
        //====================================================================================
        static Matrix mBoxd1    = Matrix.Translation( new Vector3( -1.6f,   -1.6f,  3.5f ) ); 
        static Matrix mBoxd2    = Matrix.Translation( new Vector3( -1.6f,   -0.8f,  3.5f ) );
        static Matrix mBoxd3    = Matrix.Translation( new Vector3( -1.6f,    0.0f,  3.5f ) );
        static Matrix mBoxd4    = Matrix.Translation( new Vector3( -1.6f,    0.8f,  3.5f ) );
        static Matrix mBoxd5    = Matrix.Translation( new Vector3( -1.6f,    1.6f,  3.5f ) );

        static Matrix mBoxd6    = Matrix.Translation( new Vector3( -0.8f,   -1.6f,  3.5f ) );
        static Matrix mBoxd7    = Matrix.Translation( new Vector3( -0.8f,   -0.8f,  3.5f ) );
        static Matrix mBoxd8    = Matrix.Translation( new Vector3( -0.8f,    0.0f,  3.5f ) );
        static Matrix mBoxd9    = Matrix.Translation( new Vector3( -0.8f,    0.8f,  3.5f ) );
        static Matrix mBoxd10   = Matrix.Translation( new Vector3( -0.8f,    1.6f,  3.5f ) );

        static Matrix mBoxd11   = Matrix.Translation( new Vector3(  0.0f,   -1.6f,  3.5f ) );
        static Matrix mBoxd12   = Matrix.Translation( new Vector3(  0.0f,   -0.8f,  3.5f ) );
        static Matrix mBoxd13   = Matrix.Translation( new Vector3(  0.0f,    0.0f,  3.5f ) );
        static Matrix mBoxd14   = Matrix.Translation( new Vector3(  0.0f,    0.8f,  3.5f ) );
        static Matrix mBoxd15   = Matrix.Translation( new Vector3(  0.0f,    1.6f,  3.5f ) );

        static Matrix mBoxd16   = Matrix.Translation( new Vector3(  0.8f,   -1.6f,  3.5f ) );
        static Matrix mBoxd17   = Matrix.Translation( new Vector3(  0.8f,   -0.8f,  3.5f ) );
        static Matrix mBoxd18   = Matrix.Translation( new Vector3(  0.8f,    0.0f,  3.5f ) );
        static Matrix mBoxd19   = Matrix.Translation( new Vector3(  0.8f,    0.8f,  3.5f ) );
        static Matrix mBoxd20   = Matrix.Translation( new Vector3(  0.8f,    1.6f,  3.5f ) );

        static Matrix mBoxd21   = Matrix.Translation( new Vector3(  1.6f,   -1.6f,  3.5f ) );
        static Matrix mBoxd22   = Matrix.Translation( new Vector3(  1.6f,   -0.8f,  3.5f ) );
        static Matrix mBoxd23   = Matrix.Translation( new Vector3(  1.6f,    0.0f,  3.5f ) );
        static Matrix mBoxd24   = Matrix.Translation( new Vector3(  1.6f,    0.8f,  3.5f ) );
        static Matrix mBoxd25   = Matrix.Translation( new Vector3(  1.6f,    1.6f,  3.5f ) );

        //====================================================================================

        // Positionen der einzelnen Würfel der fünften Ebene
        //====================================================================================
        static Matrix mBoxe1    = Matrix.Translation( new Vector3( -1.6f,   -1.6f,  4.5f ) ); 
        static Matrix mBoxe2    = Matrix.Translation( new Vector3( -1.6f,   -0.8f,  4.5f ) );
        static Matrix mBoxe3    = Matrix.Translation( new Vector3( -1.6f,    0.0f,  4.5f ) );
        static Matrix mBoxe4    = Matrix.Translation( new Vector3( -1.6f,    0.8f,  4.5f ) );
        static Matrix mBoxe5    = Matrix.Translation( new Vector3( -1.6f,    1.6f,  4.5f ) );

        static Matrix mBoxe6    = Matrix.Translation( new Vector3( -0.8f,   -1.6f,  4.5f ) );
        static Matrix mBoxe7    = Matrix.Translation( new Vector3( -0.8f,   -0.8f,  4.5f ) );
        static Matrix mBoxe8    = Matrix.Translation( new Vector3( -0.8f,    0.0f,  4.5f ) );
        static Matrix mBoxe9    = Matrix.Translation( new Vector3( -0.8f,    0.8f,  4.5f ) );
        static Matrix mBoxe10   = Matrix.Translation( new Vector3( -0.8f,    1.6f,  4.5f ) );

        static Matrix mBoxe11   = Matrix.Translation( new Vector3(  0.0f,   -1.6f,  4.5f ) );
        static Matrix mBoxe12   = Matrix.Translation( new Vector3(  0.0f,   -0.8f,  4.5f ) );
        static Matrix mBoxe13   = Matrix.Translation( new Vector3(  0.0f,    0.0f,  4.5f ) );
        static Matrix mBoxe14   = Matrix.Translation( new Vector3(  0.0f,    0.8f,  4.5f ) );
        static Matrix mBoxe15   = Matrix.Translation( new Vector3(  0.0f,    1.6f,  4.5f ) );

        static Matrix mBoxe16   = Matrix.Translation( new Vector3(  0.8f,   -1.6f,  4.5f ) );
        static Matrix mBoxe17   = Matrix.Translation( new Vector3(  0.8f,   -0.8f,  4.5f ) );
        static Matrix mBoxe18   = Matrix.Translation( new Vector3(  0.8f,    0.0f,  4.5f ) );
        static Matrix mBoxe19   = Matrix.Translation( new Vector3(  0.8f,    0.8f,  4.5f ) );
        static Matrix mBoxe20   = Matrix.Translation( new Vector3(  0.8f,    1.6f,  4.5f ) );

        static Matrix mBoxe21   = Matrix.Translation( new Vector3(  1.6f,   -1.6f,  0.0f ) );
        static Matrix mBoxe22   = Matrix.Translation( new Vector3(  1.6f,   -0.8f,  0.0f ) );
        static Matrix mBoxe23   = Matrix.Translation( new Vector3(  1.6f,    0.0f,  0.0f ) );
        static Matrix mBoxe24   = Matrix.Translation( new Vector3(  1.6f,    0.8f,  0.0f ) );
        static Matrix mBoxe25   = Matrix.Translation( new Vector3(  1.6f,    1.6f,  0.0f ) );

        //====================================================================================
        //----------------------------------------------------------------------------------------------------

        PresentParameters presentParams;
        System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer ();
        
        
        
        //----------------------------------------------------------------------------------------------------
        //""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

        //""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
        public Form1()
        {
            Text = "KDE Würfel ";
            myTimer.Tick += new EventHandler( OnTimer );
            myTimer.Interval = 2;
            ClientSize = new Size( 800, 600 ); 
        }
        //""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

        protected override void OnResize( System.EventArgs e )
            
        {
            myTimer.Stop();
            try
            {   
                presentParams = new PresentParameters();
                presentParams.Windowed = true;                 
                presentParams.SwapEffect = SwapEffect.Discard; 
                presentParams.EnableAutoDepthStencil = true;   
                presentParams.AutoDepthStencilFormat = DepthFormat.D16; 
                if ( device != null ) device.Dispose();
                device = new Microsoft.DirectX.Direct3D.Device( 0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, this,
                    CreateFlags.SoftwareVertexProcessing, presentParams );
                //----------------------------------------------------------------------------------------------------

                // erste Ebene
                if ( meshBox1   != null ) meshBox1.Dispose(); 
                if ( meshBox2   != null ) meshBox2.Dispose(); 
                if ( meshBox3   != null ) meshBox3.Dispose(); 
                if ( meshBox4   != null ) meshBox4.Dispose();
                if ( meshBox5   != null ) meshBox5.Dispose(); 
                if ( meshBox6   != null ) meshBox6.Dispose(); 
                if ( meshBox7   != null ) meshBox7.Dispose(); 
                if ( meshBox8   != null ) meshBox8.Dispose(); 
                if ( meshBox9   != null ) meshBox9.Dispose(); 
                if ( meshBox10  != null ) meshBox10.Dispose();
                if ( meshBox11  != null ) meshBox11.Dispose();
                if ( meshBox12  != null ) meshBox12.Dispose();
                if ( meshBox13  != null ) meshBox13.Dispose();
                if ( meshBox14  != null ) meshBox14.Dispose();
                if ( meshBox15  != null ) meshBox15.Dispose();
                if ( meshBox16  != null ) meshBox16.Dispose();
                if ( meshBox17  != null ) meshBox17.Dispose();
                if ( meshBox18  != null ) meshBox18.Dispose();
                if ( meshBox19  != null ) meshBox19.Dispose();
                if ( meshBox20  != null ) meshBox20.Dispose();
                if ( meshBox21  != null ) meshBox21.Dispose();
                if ( meshBox22  != null ) meshBox22.Dispose();
                if ( meshBox23  != null ) meshBox23.Dispose();
                if ( meshBox24  != null ) meshBox24.Dispose();
                if ( meshBox25  != null ) meshBox25.Dispose();
    
                // zweite Ebene
                if ( meshBoxb1  != null ) meshBoxb1.Dispose(); 
                if ( meshBoxb2  != null ) meshBoxb2.Dispose(); 
                if ( meshBoxb3  != null ) meshBoxb3.Dispose(); 
                if ( meshBoxb4  != null ) meshBoxb4.Dispose();
                if ( meshBoxb5  != null ) meshBoxb5.Dispose(); 
                if ( meshBoxb6  != null ) meshBoxb6.Dispose(); 
                if ( meshBoxb7  != null ) meshBoxb7.Dispose(); 
                if ( meshBoxb8  != null ) meshBoxb8.Dispose(); 
                if ( meshBoxb9  != null ) meshBoxb9.Dispose(); 
                if ( meshBoxb10 != null ) meshBoxb10.Dispose();
                if ( meshBoxb11 != null ) meshBoxb11.Dispose();
                if ( meshBoxb12 != null ) meshBoxb12.Dispose();
                if ( meshBoxb13 != null ) meshBoxb13.Dispose();
                if ( meshBoxb14 != null ) meshBoxb14.Dispose();
                if ( meshBoxb15 != null ) meshBoxb15.Dispose();
                if ( meshBoxb16 != null ) meshBoxb16.Dispose();
                if ( meshBoxb17 != null ) meshBoxb17.Dispose();
                if ( meshBoxb18 != null ) meshBoxb18.Dispose();
                if ( meshBoxb19 != null ) meshBoxb19.Dispose();
                if ( meshBoxb20 != null ) meshBoxb20.Dispose();
                if ( meshBoxb21 != null ) meshBoxb21.Dispose();
                if ( meshBoxb22 != null ) meshBoxb22.Dispose();
                if ( meshBoxb23 != null ) meshBoxb23.Dispose();
                if ( meshBoxb24 != null ) meshBoxb24.Dispose();
                if ( meshBoxb25 != null ) meshBoxb25.Dispose();
                
                // zweite Ebene
                if ( meshBoxc1  != null ) meshBoxc1.Dispose(); 
                if ( meshBoxc2  != null ) meshBoxc2.Dispose(); 
                if ( meshBoxc3  != null ) meshBoxc3.Dispose(); 
                if ( meshBoxc4  != null ) meshBoxc4.Dispose();
                if ( meshBoxc5  != null ) meshBoxc5.Dispose(); 
                if ( meshBoxc6  != null ) meshBoxc6.Dispose(); 
                if ( meshBoxc7  != null ) meshBoxc7.Dispose(); 
                if ( meshBoxc8  != null ) meshBoxc8.Dispose(); 
                if ( meshBoxc9  != null ) meshBoxc9.Dispose(); 
                if ( meshBoxc10 != null ) meshBoxc10.Dispose();
                if ( meshBoxc11 != null ) meshBoxc11.Dispose();
                if ( meshBoxc12 != null ) meshBoxc12.Dispose();
                if ( meshBoxc13 != null ) meshBoxc13.Dispose();
                if ( meshBoxc14 != null ) meshBoxc14.Dispose();
                if ( meshBoxc15 != null ) meshBoxc15.Dispose();
                if ( meshBoxc16 != null ) meshBoxc16.Dispose();
                if ( meshBoxc17 != null ) meshBoxc17.Dispose();
                if ( meshBoxc18 != null ) meshBoxc18.Dispose();
                if ( meshBoxc19 != null ) meshBoxc19.Dispose();
                if ( meshBoxc20 != null ) meshBoxc20.Dispose();
                if ( meshBoxc21 != null ) meshBoxc21.Dispose();
                if ( meshBoxc22 != null ) meshBoxc22.Dispose();
                if ( meshBoxc23 != null ) meshBoxc23.Dispose();
                if ( meshBoxc24 != null ) meshBoxc24.Dispose();
                if ( meshBoxc25 != null ) meshBoxc25.Dispose();

                // vierte Ebene
                if ( meshBoxd1  != null ) meshBoxd1.Dispose(); 
                if ( meshBoxd2  != null ) meshBoxd2.Dispose(); 
                if ( meshBoxd3  != null ) meshBoxd3.Dispose(); 
                if ( meshBoxd4  != null ) meshBoxd4.Dispose();
                if ( meshBoxd5  != null ) meshBoxd5.Dispose(); 
                if ( meshBoxd6  != null ) meshBoxd6.Dispose(); 
                if ( meshBoxd7  != null ) meshBoxd7.Dispose(); 
                if ( meshBoxd8  != null ) meshBoxd8.Dispose(); 
                if ( meshBoxd9  != null ) meshBoxd9.Dispose(); 
                if ( meshBoxd10 != null ) meshBoxd10.Dispose();
                if ( meshBoxd11 != null ) meshBoxd11.Dispose();
                if ( meshBoxd12 != null ) meshBoxd12.Dispose();
                if ( meshBoxd13 != null ) meshBoxd13.Dispose();
                if ( meshBoxd14 != null ) meshBoxd14.Dispose();
                if ( meshBoxd15 != null ) meshBoxd15.Dispose();
                if ( meshBoxd16 != null ) meshBoxd16.Dispose();
                if ( meshBoxd17 != null ) meshBoxd17.Dispose();
                if ( meshBoxd18 != null ) meshBoxd18.Dispose();
                if ( meshBoxd19 != null ) meshBoxd19.Dispose();
                if ( meshBoxd20 != null ) meshBoxd20.Dispose();
                if ( meshBoxd21 != null ) meshBoxd21.Dispose();
                if ( meshBoxd22 != null ) meshBoxd22.Dispose();
                if ( meshBoxd23 != null ) meshBoxd23.Dispose();
                if ( meshBoxd24 != null ) meshBoxd24.Dispose();
                if ( meshBoxd25 != null ) meshBoxd25.Dispose();

                // fünfte Ebene
                if ( meshBoxe1  != null ) meshBoxe1.Dispose(); 
                if ( meshBoxe2  != null ) meshBoxe2.Dispose(); 
                if ( meshBoxe3  != null ) meshBoxe3.Dispose(); 
                if ( meshBoxe4  != null ) meshBoxe4.Dispose();
                if ( meshBoxe5  != null ) meshBoxe5.Dispose(); 
                if ( meshBoxe6  != null ) meshBoxe6.Dispose(); 
                if ( meshBoxe7  != null ) meshBoxe7.Dispose(); 
                if ( meshBoxe8  != null ) meshBoxe8.Dispose(); 
                if ( meshBoxe9  != null ) meshBoxe9.Dispose(); 
                if ( meshBoxe10 != null ) meshBoxe10.Dispose();
                if ( meshBoxe11 != null ) meshBoxe11.Dispose();
                if ( meshBoxe12 != null ) meshBoxe12.Dispose();
                if ( meshBoxe13 != null ) meshBoxe13.Dispose();
                if ( meshBoxe14 != null ) meshBoxe14.Dispose();
                if ( meshBoxe15 != null ) meshBoxe15.Dispose();
                if ( meshBoxe16 != null ) meshBoxe16.Dispose();
                if ( meshBoxe17 != null ) meshBoxe17.Dispose();
                if ( meshBoxe18 != null ) meshBoxe18.Dispose();
                if ( meshBoxe19 != null ) meshBoxe19.Dispose();
                if ( meshBoxe20 != null ) meshBoxe20.Dispose();
                if ( meshBoxe21 != null ) meshBoxe21.Dispose();
                if ( meshBoxe22 != null ) meshBoxe22.Dispose();
                if ( meshBoxe23 != null ) meshBoxe23.Dispose();
                if ( meshBoxe24 != null ) meshBoxe24.Dispose();
                if ( meshBoxe25 != null ) meshBoxe25.Dispose();
                //----------------------------------------------------------------------------------------------------

                //Die Form vom Würfel (x , y , z) für Ebene eins
                meshBox1    = Mesh.Box ( device, 0.5f, 0.5f, 0.5f ); 
                meshBox2    = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox3    = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox4    = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox5    = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox6    = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox7    = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox8    = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox9    = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox10   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox11   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox12   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox13   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox14   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox15   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox16   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox17   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox18   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox19   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox20   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox21   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox22   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox23   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox24   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBox25   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );

                //Die Form vom Würfel (x , y , z)für Ebene zwei
                meshBoxb1   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f ); 
                meshBoxb2   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb3   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb4   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb5   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb6   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb7   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb8   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb9   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb10  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb11  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb12  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb13  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb14  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb15  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb16  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb17  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb18  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb19  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb20  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb21  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb22  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb23  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb24  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxb25  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );

                //Die Form vom Würfel (x , y , z)für Ebene drei
                meshBoxc1   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f ); 
                meshBoxc2   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc3   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc4   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc5   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc6   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc7   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc8   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc9   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc10  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc11  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc12  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc13  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc14  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc15  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc16  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc17  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc18  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc19  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc20  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc21  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc22  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc23  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc24  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxc25  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );

                //Die Form vom Würfel (x , y , z)für Ebene vier
                meshBoxd1   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f ); 
                meshBoxd2   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd3   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd4   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd5   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd6   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd7   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd8   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd9   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd10  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd11  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd12  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd13  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd14  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd15  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd16  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd17  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd18  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd19  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd20  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd21  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd22  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd23  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd24  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxd25  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );

                //Die Form vom Würfel (x , y , z)für Ebene fünf
                meshBoxe1   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f ); 
                meshBoxe2   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe3   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe4   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe5   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe6   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe7   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe8   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe9   = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe10  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe11  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe12  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe13  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe14  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe15  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe16  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe17  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe18  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe19  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe20  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe21  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe22  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe23  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe24  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                meshBoxe25  = Mesh.Box ( device, 0.5f, 0.5f, 0.5f );
                //----------------------------------------------------------------------------------------------------


                //set up material with diffuse and ambient white color
                Material myMaterial = new Material();
                myMaterial.Diffuse = myMaterial.Ambient = Color.Gold;
                device.Material = myMaterial;
            
                //turn on some blue directional light coaxial to the camera
                device.Lights[0].Type = LightType.Spot;
                device.Lights[0].Diffuse = Color.Green;
                device.Lights[0].Direction = new Vector3( 0, 0, 7 );
                device.Lights[0].Enabled = true;
                
                device.Transform.View = Matrix.LookAtLH(
                    new Vector3( 0f, 0f, -6.0f ),   //Augenpunkt 5.0 vor dem canvas
                    new Vector3( 0f, 0f,  -1f ),   //Kammera sieht auf 0,0,0
                    new Vector3( 0f, 1.0f,  0f ) ); //world's up direction is the y-axis
                
                device.Transform.Projection = Matrix.PerspectiveFovLH( (float)Math.PI/4, 1f, 1f, 100f );
                device.RenderState.CullMode = Cull.None;
                device.RenderState.Lighting = true;
                xAngle = yAngle = zAngle = 1; //start angles
                myTimer.Start(); //start the timer again
            }
            catch (DirectXException) { MessageBox.Show("Could not initialize Direct3D." ); return; }
        }
        //""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

        //""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
        protected static void OnTimer( Object myObject, EventArgs myEventArgs )
        {
            if (device == null) return;
            //throw the old image away
            device.Clear( ClearFlags.Target | ClearFlags.ZBuffer, Color.Honeydew, 5f, 0 );
            //rotate with 3 angular velocities
            Matrix m = Matrix.RotationYawPitchRoll( xAngle += 0.05f, yAngle += 0.05f, zAngle += 0.05f );
            //draw on the canvas
            
            //----------------------------------------------------------------------------------------------------
            device.BeginScene();
            // Erste Ebene
            device.Transform.World  = m * mBox1;  meshBox1      .DrawSubset( 0 );
            device.Transform.World  = m * mBox2;  meshBox2      .DrawSubset( 0 );
            device.Transform.World  = m * mBox3;  meshBox3      .DrawSubset( 0 );
            device.Transform.World  = m * mBox4;  meshBox4      .DrawSubset( 0 );
            device.Transform.World  = m * mBox5;  meshBox5      .DrawSubset( 0 );

            device.Transform.World  = m * mBox6;  meshBox6      .DrawSubset( 0 );
            device.Transform.World  = m * mBox7;  meshBox7      .DrawSubset( 0 );
            device.Transform.World  = m * mBox8;  meshBox8      .DrawSubset( 0 );
            device.Transform.World  = m * mBox9;  meshBox9      .DrawSubset( 0 );
            device.Transform.World  = m * mBox10; meshBox10     .DrawSubset( 0 );
            
            device.Transform.World  = m * mBox11; meshBox11     .DrawSubset( 0 );
            device.Transform.World  = m * mBox12; meshBox12     .DrawSubset( 0 );
            device.Transform.World  = m * mBox13; meshBox13     .DrawSubset( 0 );
            device.Transform.World  = m * mBox14; meshBox14     .DrawSubset( 0 );
            device.Transform.World  = m * mBox15; meshBox15     .DrawSubset( 0 );
            
            device.Transform.World  = m * mBox16; meshBox16     .DrawSubset( 0 );
            device.Transform.World  = m * mBox17; meshBox17     .DrawSubset( 0 );
            device.Transform.World  = m * mBox18; meshBox18     .DrawSubset( 0 );
            device.Transform.World  = m * mBox19; meshBox19     .DrawSubset( 0 );
            device.Transform.World  = m * mBox20; meshBox20     .DrawSubset( 0 );
            
            device.Transform.World  = m * mBox21; meshBox21     .DrawSubset( 0 );
            device.Transform.World  = m * mBox22; meshBox22     .DrawSubset( 0 );
            device.Transform.World  = m * mBox23; meshBox23     .DrawSubset( 0 );
            device.Transform.World  = m * mBox24; meshBox24     .DrawSubset( 0 );
            device.Transform.World  = m * mBox25; meshBox25     .DrawSubset( 0 );

            // zweite Ebene
            device.Transform.World  = m * mBoxb1;  meshBoxb1        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb2;  meshBoxb2        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb3;  meshBoxb3        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb4;  meshBoxb4        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb5;  meshBoxb5        .DrawSubset( 0 );
            
            device.Transform.World  = m * mBoxb6;  meshBoxb6        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb7;  meshBoxb7        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb8;  meshBoxb8        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb9;  meshBoxb9        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb10; meshBoxb10       .DrawSubset( 0 );
            
            device.Transform.World  = m * mBoxb11; meshBoxb11       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb12; meshBoxb12       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb13; meshBoxb13       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb14; meshBoxb14       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb15; meshBoxb15       .DrawSubset( 0 );
            
            device.Transform.World  = m * mBoxb16; meshBoxb16       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb17; meshBoxb17       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb18; meshBoxb18       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb19; meshBoxb19       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb20; meshBoxb20       .DrawSubset( 0 );
            
            device.Transform.World  = m * mBoxb21; meshBoxb21       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb22; meshBoxb22       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb23; meshBoxb23       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb24; meshBoxb24       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxb25; meshBoxb25       .DrawSubset( 0 );

            // dritte Ebene
            device.Transform.World  = m * mBoxc1 ; meshBoxc1        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc2 ; meshBoxc2        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc3 ; meshBoxc3        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc4 ; meshBoxc4        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc5 ; meshBoxc5        .DrawSubset( 0 );
            
            device.Transform.World  = m * mBoxc6 ; meshBoxc6        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc7 ; meshBoxc7        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc8 ; meshBoxc8        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc9 ; meshBoxc9        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc10; meshBoxc10       .DrawSubset( 0 );
            
            device.Transform.World  = m * mBoxc11; meshBoxc11       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc12; meshBoxc12       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc13; meshBoxc13       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc14; meshBoxc14       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc15; meshBoxc15       .DrawSubset( 0 );
            
            device.Transform.World  = m * mBoxc16; meshBoxc16       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc17; meshBoxc17       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc18; meshBoxc18       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc19; meshBoxc19       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc20; meshBoxc20       .DrawSubset( 0 );
            
            device.Transform.World  = m * mBoxc21; meshBoxc21       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc22; meshBoxc22       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc23; meshBoxc23       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc24; meshBoxc24       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxc25; meshBoxc25       .DrawSubset( 0 );

            // vierte Ebene
            device.Transform.World  = m * mBoxd1;  meshBoxd1        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd2;  meshBoxd2        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd3;  meshBoxd3        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd4;  meshBoxd4        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd5;  meshBoxd5        .DrawSubset( 0 );
            
            device.Transform.World  = m * mBoxd6;  meshBoxd6        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd7;  meshBoxd7        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd8;  meshBoxd8        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd9;  meshBoxd9        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd10; meshBoxd10       .DrawSubset( 0 );
            
            device.Transform.World  = m * mBoxd11; meshBoxd11       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd12; meshBoxd12       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd13; meshBoxd13       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd14; meshBoxd14       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd15; meshBoxd15       .DrawSubset( 0 );
            
            device.Transform.World  = m * mBoxd16; meshBoxd16       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd17; meshBoxd17       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd18; meshBoxd18       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd19; meshBoxd19       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd20; meshBoxd20       .DrawSubset( 0 );
            
            device.Transform.World  = m * mBoxd21; meshBoxd21       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd22; meshBoxd22       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd23; meshBoxd23       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd24; meshBoxd24       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxd25; meshBoxd25       .DrawSubset( 0 );

            // fünfte Ebene
            device.Transform.World  = m * mBoxe1;  meshBoxe1        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe2;  meshBoxe2        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe3;  meshBoxe3        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe4;  meshBoxe4        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe5;  meshBoxe5        .DrawSubset( 0 );
            
            device.Transform.World  = m * mBoxe6;  meshBoxe6        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe7;  meshBoxe7        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe8;  meshBoxe8        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe9;  meshBoxe9        .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe10; meshBoxe10       .DrawSubset( 0 );
            
            device.Transform.World  = m * mBoxe11; meshBoxe11       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe12; meshBoxe12       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe13; meshBoxe13       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe14; meshBoxe14       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe15; meshBoxe15       .DrawSubset( 0 );
            
            device.Transform.World  = m * mBoxe16; meshBoxe16       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe17; meshBoxe17       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe18; meshBoxe18       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe19; meshBoxe19       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe20; meshBoxe20       .DrawSubset( 0 );
            
            device.Transform.World  = m * mBoxe21; meshBoxe21       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe22; meshBoxe22       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe23; meshBoxe23       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe24; meshBoxe24       .DrawSubset( 0 );
            device.Transform.World  = m * mBoxe25; meshBoxe25       .DrawSubset( 0 );

            device.EndScene();
            device.Present(); //show the canvas
            //----------------------------------------------------------------------------------------------------
        

            
        }
//""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""        
    }


}

Steven77

Alter Hase

Beiträge: 515

Wohnort: Münster - Gievenbeach

Beruf: Wissenschaftlicher Mitarbeiter

  • Private Nachricht senden

2

16.06.2005, 16:45

Hehehe, hast Du schonmal sowas gesehen?

C-/C++-Quelltext

1
2
3
4
for (int i = 0; i < cnt; i++)
{
    // Schubidu...

}

PS: Sollte kein Lösungsvorschlag für Dein eigentliches Problem sein. Lohnt sich aber zu kennen ;)

Steven77

Alter Hase

Beiträge: 515

Wohnort: Münster - Gievenbeach

Beruf: Wissenschaftlicher Mitarbeiter

  • Private Nachricht senden

3

16.06.2005, 16:50

Jetzt ein Lösungsvorschlag:
Transformiere die Mausposition in World-Koordinaten. Aus der x- und y-Position erhältst Du dann die transformierten Positionen in der World. Für die z-Komponente nimmst Du eine Gerade und testest, ob diese Gerade einen der entsprechenden Würfel schneidet. Wenn ja, dann ist das der Kandidat.
Ich hoffe, das war nicht zu oberflächlich und kann Dir helfen...?

DarioFrodo

Treue Seele

Beiträge: 349

Wohnort: Kerkau, 100km nördlich von Magdeburg

Beruf: Selbstständig

  • Private Nachricht senden

4

07.08.2006, 11:51

Und wie kann man die Mauskoordinaten in 3D transformieren? Ich habe ein ähnliches Problem, ich weiß aber nicht, wie ich die 2D-Mauskoordinaten nach 3D Welt Koordinaten bekomme. Meine Mauskoordinaten liegen etweder zwischen 1 und 0 (0/0 obere linke Ecke, 1/1 untere Rechte Ecke) oder in Screensize (0/0 und z.B. 800/600 bei einer Auflösung von 800*600).

Muss ich die Mauskoor. mit der Projekctionsmatrix multiplizieren oder transformieren und/oder mit der CameraMatrix??

Es wäre echt nett, wenn mir jemand helfen könnte.
Erst wenn der letzte Fluss vergiftet,
der letzte Baum gefällt,
der letzte Fisch gefangen,
dann werdet ihr merken, dass man Geld nicht essen kann

Man verkauft die Erde nicht, auf der die Menschen wandeln.

- Indianerweisheiten

Ich bin auch ein einhornimmond ;)

DarioFrodo

Treue Seele

Beiträge: 349

Wohnort: Kerkau, 100km nördlich von Magdeburg

Beruf: Selbstständig

  • Private Nachricht senden

5

07.08.2006, 11:54

Noch ne Frage

Und wie kann man 2D Koordinaten transfromieren?
Erst wenn der letzte Fluss vergiftet,
der letzte Baum gefällt,
der letzte Fisch gefangen,
dann werdet ihr merken, dass man Geld nicht essen kann

Man verkauft die Erde nicht, auf der die Menschen wandeln.

- Indianerweisheiten

Ich bin auch ein einhornimmond ;)

Werbeanzeige