raSystem  1.0 bata
raBasics.cpp
Go to the documentation of this file.
1 #include "..\include\raMain.h"
2 
3 namespace System
4 {
7  raEntity(dx, new raMaterial(dx.get(),
8  "raEffects\\MyEngine.fx", "RenderWithColor"))
9  {
10  m_nVertices = 3;
11  m_nIndices = 0; //unbenutzt
12  }
13 
15  {
17 
18  m_pVertices[0].position.x = -1.0f;
19  m_pVertices[0].position.y = 0.0f;
20  m_pVertices[0].position.z = 0.0f;
21 
22  m_pVertices[0].color[0] = 1.0f;
23  m_pVertices[0].color[1] = 0.0f;
24  m_pVertices[0].color[2] = 0.0f;
25 
26  m_pVertices[1].position.x = 0.0f;
27  m_pVertices[1].position.y = 1.0f;
28  m_pVertices[1].position.z = 0.0f;
29 
30  m_pVertices[1].color[0] = 0.0f;
31  m_pVertices[1].color[1] = 1.0f;
32  m_pVertices[1].color[2] = 0.0f;
33 
34  m_pVertices[2].position.x = 1.0f;
35  m_pVertices[2].position.y = 0.0f;
36  m_pVertices[2].position.z = 0.0f;
37 
38  m_pVertices[2].color[0] = 0.0f;
39  m_pVertices[2].color[1] = 0.0f;
40  m_pVertices[2].color[2] = 1.0f;
41  }
43  raEntity(dx, new raMaterial(dx.get(),
44  "raEffects\\MyEngine.fx", "RenderWithColor"))
45  {
46  m_nVertices = 4;
47  m_nIndices = 6;
48  }
49 
51  raEntity(dx, praMaterial)
52  {
53  m_nVertices = 4;
54  m_nIndices = 6;
55  }
56 
58  {
60 
61  m_pVertices[0].position.x = -1.0f;
62  m_pVertices[0].position.y = -1.0f;
63  m_pVertices[0].position.z = 0.0f;
64 
65  m_pVertices[0].color[0] = 1.0f;
66  m_pVertices[0].color[1] = 0.0f;
67  m_pVertices[0].color[2] = 0.0f;
68 
69  m_pVertices[1].position.x = -1.0f;
70  m_pVertices[1].position.y = 1.0f;
71  m_pVertices[1].position.z = 0.0f;
72 
73  m_pVertices[1].color[0] = 0.0f;
74  m_pVertices[1].color[1] = 1.0f;
75  m_pVertices[1].color[2] = 0.0f;
76 
77  m_pVertices[2].position.x = 1.0f;
78  m_pVertices[2].position.y = -1.0f;
79  m_pVertices[2].position.z = 0.0f;
80 
81  m_pVertices[2].color[0] = 0.0f;
82  m_pVertices[2].color[1] = 0.0f;
83  m_pVertices[2].color[2] = 1.0f;
84 
85  m_pVertices[3].position.x = 1.0f;
86  m_pVertices[3].position.y = 1.0f;
87  m_pVertices[3].position.z = 0.0f;
88 
89  m_pVertices[3].color[0] = 0.0f;
90  m_pVertices[3].color[1] = 0.0f;
91  m_pVertices[3].color[2] = 0.0f;
92  }
93 
95  {
97 
98  m_pIndices[0] = 0;
99  m_pIndices[1] = 1;
100  m_pIndices[2] = 2;
101  m_pIndices[3] = 1;
102  m_pIndices[4] = 3;
103  m_pIndices[5] = 2;
104 
105  m_pSubsets[0].IndexStart = 0;
107  }
108 
110  raEntity(dx, new raMaterial(dx.get(),
111  "raEffects\\MyEngine.fx", "RenderWithColor"))
112  {
113  m_nVertices = 8;
114  m_nIndices = 36;
115  }
116 
118  {
120 
121  m_pVertices[0].position.x = -1.0f;
122  m_pVertices[0].position.y = -1.0f;
123  m_pVertices[0].position.z = -1.0f;
124 
125  m_pVertices[0].color[0] = 0.0f;
126  m_pVertices[0].color[1] = 0.0f;
127  m_pVertices[0].color[2] = 0.0f;
128 
129  m_pVertices[1].position.x = -1.0f;
130  m_pVertices[1].position.y = 1.0f;
131  m_pVertices[1].position.z = -1.0f;
132 
133  m_pVertices[1].color[0] = 0.0f;
134  m_pVertices[1].color[1] = 0.0f;
135  m_pVertices[1].color[2] = 1.0f;
136 
137  m_pVertices[2].position.x = 1.0f;
138  m_pVertices[2].position.y = -1.0f;
139  m_pVertices[2].position.z = -1.0f;
140 
141  m_pVertices[2].color[0] = 0.0f;
142  m_pVertices[2].color[1] = 1.0f;
143  m_pVertices[2].color[2] = 0.0f;
144 
145  m_pVertices[3].position.x = 1.0f;
146  m_pVertices[3].position.y = 1.0f;
147  m_pVertices[3].position.z = -1.0f;
148 
149  m_pVertices[3].color[0] = 0.0f;
150  m_pVertices[3].color[1] = 1.0f;
151  m_pVertices[3].color[2] = 1.0f;
152 
153  m_pVertices[4].position.x = -1.0f;
154  m_pVertices[4].position.y = -1.0f;
155  m_pVertices[4].position.z = 1.0f;
156 
157  m_pVertices[4].color[0] = 1.0f;
158  m_pVertices[4].color[1] = 0.0f;
159  m_pVertices[4].color[2] = 0.0f;
160 
161  m_pVertices[5].position.x = -1.0f;
162  m_pVertices[5].position.y = 1.0f;
163  m_pVertices[5].position.z = 1.0f;
164 
165  m_pVertices[5].color[0] = 1.0f;
166  m_pVertices[5].color[1] = 0.0f;
167  m_pVertices[5].color[2] = 1.0f;
168 
169  m_pVertices[6].position.x = 1.0f;
170  m_pVertices[6].position.y = -1.0f;
171  m_pVertices[6].position.z = 1.0f;
172 
173  m_pVertices[6].color[0] = 1.0f;
174  m_pVertices[6].color[1] = 1.0f;
175  m_pVertices[6].color[2] = 0.0f;
176 
177  m_pVertices[7].position.x = 1.0f;
178  m_pVertices[7].position.y = 1.0f;
179  m_pVertices[7].position.z = 1.0f;
180 
181  m_pVertices[7].color[0] = 1.0f;
182  m_pVertices[7].color[1] = 1.0f;
183  m_pVertices[7].color[2] = 1.0f;
184  }
185 
187  {
189 
190  //vorn
191  m_pIndices[0] = 0;
192  m_pIndices[1] = 1;
193  m_pIndices[2] = 2;
194  m_pIndices[3] = 1;
195  m_pIndices[4] = 3;
196  m_pIndices[5] = 2;
197 
198  //hinten
199  m_pIndices[6] = 4;
200  m_pIndices[7] = 6;
201  m_pIndices[8] = 5;
202  m_pIndices[9] = 5;
203  m_pIndices[10] = 6;
204  m_pIndices[11] = 7;
205 
206  //links
207  m_pIndices[12] = 4;
208  m_pIndices[13] = 5;
209  m_pIndices[14] = 1;
210  m_pIndices[15] = 4;
211  m_pIndices[16] = 1;
212  m_pIndices[17] = 0;
213 
214  //rechts
215  m_pIndices[18] = 2;
216  m_pIndices[19] = 3;
217  m_pIndices[20] = 7;
218  m_pIndices[21] = 2;
219  m_pIndices[22] = 7;
220  m_pIndices[23] = 6;
221 
222  //unten
223  m_pIndices[24] = 0;
224  m_pIndices[25] = 6;
225  m_pIndices[26] = 4;
226  m_pIndices[27] = 0;
227  m_pIndices[28] = 2;
228  m_pIndices[29] = 6;
229 
230  //oben
231  m_pIndices[30] = 1;
232  m_pIndices[31] = 5;
233  m_pIndices[32] = 7;
234  m_pIndices[33] = 1;
235  m_pIndices[34] = 7;
236  m_pIndices[35] = 3;
237 
238  m_pSubsets[0].IndexStart = 0;
240  }
241 
243  float radius, raMaterial* praMaterial):
244  raEntity(dx, praMaterial ? praMaterial :
245  new raTexturedMaterial(dx,
246  "raEffects\\MyEngine.fx", "RenderScene",
247  "raGrafik\\earth.bmp"))
248  {
249  m_r = radius;
250  m_width = width;
251  m_height = height;
252 
253  m_nVertices = m_width * m_height;
254  m_nIndices = 6 * (m_width - 1) * (m_height - 1);
255  }
256 
258  {
259  m_pVertices =
261 
262  int n = 0;
263 
264  for (int y = 0; y < m_height; y++)
265  {
266  float theta;
267  //Polkappen öffnen
268  if(y == 0)
269  theta = PI * (0.5f / ((float)m_height - 1));
270  else if(y == m_height - 1)
271  theta = PI * ((m_height - 1.5f) / ((float)m_height - 1));
272  else
273  theta = PI * (y / ((float)m_height - 1));
274  float rsintheta = m_r * sin(theta);
275  float rcostheta = m_r * cos(theta);
276  for (int x = 0; x < m_width; x++)
277  {
278  float phi = 2 * PI * x / ((float)m_width - 1);
279  m_pVertices[n].position.x = rsintheta * cos(phi);
280  m_pVertices[n].position.y = rcostheta;
281  m_pVertices[n].position.z = rsintheta * sin(phi);
282 
283  m_pVertices[n].texcoord.x = x / ((float)m_width - 1);
284  m_pVertices[n].texcoord.y = y / ((float)m_height - 1);
286  n++;
287  }
288  }
289  }
290 
292  {
294  int n = 0;
295  for(int y = 0; y < m_height - 1; y++)
296  {
297  for(int x = 0; x < m_width - 1; x++)
298  {
299  //Winding Order umgekehrt
300  m_pIndices[n + 0] = (UINT16) (y * m_width + x);
301  m_pIndices[n + 2] = (UINT16) ((y + 1) * m_width + x);
302  m_pIndices[n + 1] = (UINT16) (y * m_width + (x + 1));
303  m_pIndices[n + 3] = (UINT16) ((y + 1) * m_width + x);
304  m_pIndices[n + 5] = (UINT16) ((y + 1) * m_width + (x + 1));
305  m_pIndices[n + 4] = (UINT16) (y * m_width + (x + 1));
306 
307  n+=6;
308  }
309  }
310 
311  m_pSubsets[0].IndexStart = 0;
313  }
314 
316  : raEntity(dx, new raMaterial(dx.get(),
317  "raEffects\\MyEngine.fx", "RenderWithColor"))
318  {
319  m_height = height;
320  m_nSlices = 36;
321 
322  m_nVertices = m_nSlices * m_height;
323  m_nIndices = 6 * m_nSlices * (m_height - 1);// nicht m_nSlices - 1, weil die Naht geschlossen wird
324  }
325 
327  {
328  m_pVertices =
330 
331  int n = 0;
332  for(int y = 0; y < m_height; y++)
333  {
334  for(int phi = 0; phi < m_nSlices; phi++)
335  {
336  float r0 = r(y);
337  float phi0 = 2 * PI * phi / (m_nSlices-1);
338  m_pVertices[n].position.x = (float) r0 * sin(phi0);
339  m_pVertices[n].position.y = (float) y;
340  m_pVertices[n].position.z = (float) r0 * cos(phi0);
341 
342  m_pVertices[n].color[0] = (float) rand() / RAND_MAX; //1.0f;
343  m_pVertices[n].color[1] = (float) rand() / RAND_MAX; //1.0f;
344  m_pVertices[n].color[2] = (float) rand() / RAND_MAX; //1.0f;
345  n+=1;
346  }
347  }
348  }
349 
351  {
353 
354  int n = 0;
355  for(int y = 0; y < m_height - 1; y++)
356  {
357  for(int phi = 0; phi < m_nSlices; phi++)
358  {
359  m_pIndices[n + 0] = (UINT16)(y * m_nSlices + phi);
360  m_pIndices[n + 1] = (UINT16)(y * m_nSlices + (phi + 1)%m_nSlices);
361  m_pIndices[n + 2] = (UINT16)((y+1) * m_nSlices + phi);
362  m_pIndices[n + 3] = (UINT16)((y+1) * m_nSlices + phi);
363  m_pIndices[n + 4] = (UINT16)(y * m_nSlices + (phi + 1)%m_nSlices);
364  m_pIndices[n + 5] = (UINT16)((y+1) * m_nSlices + (phi + 1)%m_nSlices);
365 
366  n+=6;
367  }
368  }
369 
370  m_pSubsets[0].IndexStart = 0;
372  }
373 
375  raEntity(dx, new raMaterial(dx.get(),
376  "raEffects\\MyEngine.fx", "RenderWithColor"))
377  {
378  m_level = level;
379  m_nVertices = 0;
380  for(int i = 1; i < level + 3; i++)
381  m_nVertices += (UINT16) pow(2.0, i);
382  m_nIndices = 0; //unbenutzt
383  }
384 
385  void raLineList::makeChildren(VERTEXPOSITIONCOLOR* m_pVertices, D3DXVECTOR3 v0, D3DXVECTOR3 d, int& n, int level)
386  {
387  float r = (float) rand() / RAND_MAX;
388  float b = (float) rand() / RAND_MAX;
389 
390  //Anfangs- und Endpunkt hinzufügen
391  m_pVertices[n].position.x = v0.x;
392  m_pVertices[n].position.y = v0.y;
393  m_pVertices[n].position.z = v0.z;
394  m_pVertices[n].color[0] = r;
395  m_pVertices[n].color[1] = 1.0f;
396  m_pVertices[n].color[2] = b;
397  n += 1;
398 
399  m_pVertices[n].position.x = v0.x + d.x;
400  m_pVertices[n].position.y = v0.y + d.y;
401  m_pVertices[n].position.z = v0.z + d.z;
402  m_pVertices[n].color[0] = r;
403  m_pVertices[n].color[1] = 1.0f;
404  m_pVertices[n].color[2] = b;
405  n += 1;
406 
407  //Zwei Kinder
408  if(level >= 0)
409  {
410  D3DXVECTOR4 v2, v3;
411 
412  D3DXMATRIX matLeftRot;
413  D3DXMatrixRotationZ(&matLeftRot, PI / 16.0f);
414  D3DXVec3Transform(&v2, &d, &matLeftRot);
415  makeChildren(m_pVertices, v0 + d, 0.9f * (D3DXVECTOR3) v2, n, level - 1);
416 
417  D3DXMATRIX matRightRot;
418  D3DXMatrixRotationZ(&matRightRot, -PI / 16.0f);
419  D3DXVec3Transform(&v3, &d, &matRightRot);
420  makeChildren(m_pVertices, v0 + d, 0.9f * (D3DXVECTOR3) v3, n, level - 1);
421  }
422  }
424  {
425  m_pVertices =
427 
428  int n = 0;
429  D3DXVECTOR3 v0(0, 0, 0);
430  D3DXVECTOR3 v1(0, 1, 0);
431  makeChildren((VERTEXPOSITIONCOLOR*)m_pVertices, v0, v1, n, m_level);
432  }
433 
434  void raLineList::RenderMesh(ID3D11DeviceContext* pd3dImmediateContext,ID3DX11EffectTechnique* pTechnique)
435  {
436  }
437 
439  bool bAlpha) : raEntity(dx, praMaterial, bAlpha)
440  {
441  m_nVertices = 4;
442  m_nIndices = 6;
443  // m_DrawOrder = 3;
444  m_bDepthDisable = true;
445  }
446 
448  {
449  m_pVertices =
451 
452  m_pVertices[0].position.x = -1.0f;
453  m_pVertices[0].position.y = -1.0f;
454  m_pVertices[0].position.z = 0.0f;
455 
456  m_pVertices[1].position.x = -1.0f;
457  m_pVertices[1].position.y = 1.0f;
458  m_pVertices[1].position.z = 0.0f;
459 
460  m_pVertices[2].position.x = 1.0f;
461  m_pVertices[2].position.y = -1.0f;
462  m_pVertices[2].position.z = 0.0f;
463 
464  m_pVertices[3].position.x = 1.0f;
465  m_pVertices[3].position.y = 1.0f;
466  m_pVertices[3].position.z = 0.0f;
467 
468  for(int i = 0; i < 4; i++)
469  {
470  m_pVertices[i].texcoord.x = 0.5f * (float)m_pVertices[i].position.x + 0.5f;
471  m_pVertices[i].texcoord.y = - 0.5f * (float)m_pVertices[i].position.y - 0.5f;
472  }
473  }
474 
476  {
478 
479  m_pIndices[0] = 0;
480  m_pIndices[1] = 1;
481  m_pIndices[2] = 2;
482  m_pIndices[3] = 1;
483  m_pIndices[4] = 3;
484  m_pIndices[5] = 2;
485 
486  m_pSubsets[0].IndexStart = 0;
488  }
489 
491  raEntity(dx, new raMaterial(dx,
492  "raEffects\\MyEngine.fx", "RenderWithColor"))
493  {
494  m_nVertices = 6 + 3 * 20;
495  m_nIndices = 0; //unbenutzt
496  m_pSubsets[0].PrimitiveType = D3D11_PRIMITIVE_TOPOLOGY_LINELIST;
497  }
498 
500  {
501  m_pVertices =
503 
504  m_nVertices = 0;
505  for (int axis = 0; axis < 3; axis++)
506  {
507  for (int n = 0; n <= 1; n++)
508  {
509  m_pVertices[m_nVertices].position.x = (float) (axis == 0? n: 0);
510  m_pVertices[m_nVertices].position.y = (float) (axis == 1? n: 0);
511  m_pVertices[m_nVertices].position.z = (float) (axis == 2? n: 0);
512 
513  m_pVertices[m_nVertices].color[axis] = 1;
514  m_pVertices[m_nVertices].color[(axis + 1) % 3] = 0;
515  m_pVertices[m_nVertices].color[(axis + 2) % 3] = 0;
516  m_nVertices++;
517  }
518 
519  //Ticks zeichnen
520  for (int i = 0; i < 10; i++)
521  {
522  for (int j = -1; j <= 1; j+=2)
523  {
524  m_pVertices[m_nVertices].position.x =
525  (axis == 0? 0.1f * i : (axis == 1? 0.01f * j : 0));
526  m_pVertices[m_nVertices].position.y =
527  (axis == 1? 0.1f * i : 0.01f * j);
528  m_pVertices[m_nVertices].position.z =
529  (axis == 2? 0.1f * i : 0);
530 
531  m_pVertices[m_nVertices].color[axis] = 1;
532  m_pVertices[m_nVertices].color[(axis + 1) % 3] = 0;
533  m_pVertices[m_nVertices].color[(axis + 2) % 3] = 0;
534  m_nVertices++;
535  }
536  }
537  }
538  }
539 };
raFloat y
Definition: raVector3.h:13
virtual void SetupVertices()
Definition: raBasics.cpp:257
raTriangle(raSmartPointer< raDirectX > dx)
Definition: raBasics.cpp:5
raSphere(raSmartPointer< raDirectX >, int width, int height, float radius=1.0f, raMaterial *pMaterial=NULL)
Definition: raBasics.cpp:242
raFloat x
Definition: raVector3.h:12
virtual void SetupVertices()
Definition: raBasics.cpp:326
virtual void SetupVertices()
Definition: raBasics.cpp:57
raFloat x
Definition: raVector2.h:10
raCube(raSmartPointer< raDirectX > dx)
Definition: raBasics.cpp:109
unsigned short UINT16
Definition: d3dx11dbg.h:35
VERTEXPOSITIONCOLOR * m_pVertices
Definition: raEntity.h:39
UINT64 IndexCount
Definition: raSDKmesh.h:142
interface ID3DX11EffectTechnique ID3DX11EffectTechnique
raLineList(raSmartPointer< raDirectX >, int level)
Definition: raBasics.cpp:374
virtual void SetupIndices()
Definition: raBasics.cpp:350
virtual void SetupVertices()
Definition: raBasics.cpp:447
raFloat z
Definition: raVector3.h:14
raTexturedQuad(raSmartPointer< raDirectX > dx, raMaterial *pMaterial, bool bAlpha=false)
Definition: raBasics.cpp:438
virtual void RenderMesh(ID3D11DeviceContext *pd3dImmediateContext, ID3DX11EffectTechnique *pTechnique)
Definition: raBasics.cpp:434
virtual void SetupVertices()
Definition: raBasics.cpp:117
virtual void SetupVertices()
Definition: raBasics.cpp:14
SDKMESH_SUBSET * m_pSubsets
Definition: raVisual.h:121
virtual void SetupIndices()
Definition: raBasics.cpp:94
raAchsenkreuz(raSmartPointer< raDirectX > dx)
Definition: raBasics.cpp:490
UINT64 IndexStart
Definition: raSDKmesh.h:141
virtual void SetupVertices()
Definition: raBasics.cpp:423
raFloat y
Definition: raVector2.h:11
virtual void SetupIndices()
Definition: raBasics.cpp:186
virtual void SetupIndices()
Definition: raBasics.cpp:291
virtual void SetupIndices()
Definition: raBasics.cpp:475
bool m_bDepthDisable
Definition: raVisual.h:114
UINT PrimitiveType
Definition: raSDKmesh.h:140
#define PI
Definition: raMain.h:129
raRotationskoerper(raSmartPointer< raDirectX >, int height)
Definition: raBasics.cpp:315
raQuad(raSmartPointer< raDirectX > dx)
Definition: raBasics.cpp:42
virtual void SetupVertices()
Definition: raBasics.cpp:499