Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/GraphicCover.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations) (download) (as text)
Tue Nov 23 14:34:03 2010 UTC (13 years, 5 months ago) by okadu
File MIME type: text/x-chdr
File size: 3651 byte(s)
[okadu] Version 2.13
1 #ifndef GRAPHICCOVER_H_INCLUDED
2 #define GRAPHICCOVER_H_INCLUDED
3
4 class CLineDumpL;
5
6 void NormalizeMatrix(MTX4 *);
7 bool LineLineNearest(VEC3 *, VEC3 *, VEC3 *, VEC3 *, VEC3 *, VEC3 *);
8 float LineLineDistance(VEC3 *, VEC3 *, VEC3 *, VEC3 *);
9 void LinePointPosition(VEC3 *, VEC3 *, VEC3 *, VEC3 *, VEC3 *, float);
10
11 void InitGrid();
12 void DrawGrid(VEC3);
13 void DrawTangent(VEC3, VEC3, D3DCOLOR, CLineDumpL *);
14 void DrawFocus(VEC3);
15 void Draw3DLineWithShadow(VEC3, VEC3, D3DCOLOR, D3DCOLOR c2 = 0);
16 void Draw3DPointAs2DRect(VEC3, D3DCOLOR, int);
17
18 void InitShadow();
19 void CastShadow(CObject *);
20 void RenderShadow();
21
22 /*
23 * 角度正規化 (0〜2PI におさめる)
24 */
25 inline float NormAngle(double a){
26 return (float)(a-2.0f*D3DX_PI*ceil(a/(2.0*D3DX_PI)));
27 }
28
29 /*
30 * 視界前方水平ベクトル
31 */
32 inline VEC3 GetVFow(){
33 VEC3 fow = GetVDir();
34 fow.y = 0.0f;
35 V3Norm(&fow, &fow);
36 return fow;
37 }
38
39 /*
40 * ベクトル正規直交化 (dir → up → right の順で保存)
41 */
42 inline void V3NormAxis(VEC3 *r, VEC3 *u, VEC3 *d){
43 V3Norm(r, V3Cross(r, u, V3Norm(d, d)));
44 V3Norm(u, V3Cross(u, d, r));
45 }
46
47 /*
48 * ベクトルをローカル系に変換
49 */
50 inline VEC3 V3WorldToLocal(VEC3 *v, VEC3 *r, VEC3 *u, VEC3 *d){
51 return VEC3(V3Dot(v, r), V3Dot(v, u), V3Dot(v, d));
52 }
53 inline VEC3 V3WorldToLocal(VEC3 *v, CObject *obj){
54 return VEC3(V3Dot(v, &obj->GetRight()),
55 V3Dot(v, &obj->GetUp()), V3Dot(v, &obj->GetDir()));
56 }
57
58 /*
59 * ベクトルをワールド系に変換
60 */
61 inline VEC3 V3LocalToWorld(VEC3 *v, VEC3 *r, VEC3 *u, VEC3 *d){
62 return *r*v->x+*u*v->y+*d*v->z;
63 }
64 inline VEC3 V3LocalToWorld(VEC3 *v, CObject *obj){
65 return obj->GetRight()*v->x+obj->GetUp()*v->y+obj->GetDir()*v->z;
66 }
67
68 /*
69 * ベクトル成分大小分離
70 */
71 inline void V3MinMax(VEC3 a, VEC3 b, VEC3 *min, VEC3 *max){
72 if(a.x>b.x){ min->x = b.x; max->x = a.x; }else{ min->x = a.x; max->x = b.x; }
73 if(a.y>b.y){ min->y = b.y; max->y = a.y; }else{ min->y = a.y; max->y = b.y; }
74 if(a.z>b.z){ min->z = b.z; max->z = a.z; }else{ min->z = a.z; max->z = b.z; }
75 }
76
77 inline VEC3 VEC2toVEC3( VEC2 vec )
78 {
79 return VEC3( vec.x, vec.y, 0.0f );
80 }
81
82 /*
83 * D3DCOLOR 制御
84 */
85 inline void SplitXC(
86 DWORD c, // 分解する色
87 int *r, int *g, int *b // 代入先
88 ){
89 *r = (c&0x00ff0000)>>16;
90 *g = (c&0x0000ff00)>>8;
91 *b = c&0x000000ff;
92 }
93 inline void SplitAC(
94 DWORD c, // 分解する色
95 int *a, int *r, int *g, int *b // 代入先
96 ){
97 *a = (c&0xff000000)>>24;
98 *r = (c&0x00ff0000)>>16;
99 *g = (c&0x0000ff00)>>8;
100 *b = c&0x000000ff;
101 }
102 inline D3DCOLOR MaxColor(D3DCOLOR c1, D3DCOLOR c2){
103 int a1, r1, g1, b1, a2, r2, g2, b2;
104 SplitAC(c1, &a1, &r1, &g1, &b1);
105 SplitAC(c2, &a2, &r2, &g2, &b2);
106 return MAKE_AC(a1>a2 ? a1 : a2, r1>r2 ? r1 : r2, g1>g2 ? g1 : g2, b1>b2 ? b1 : b2);
107 }
108 inline D3DCOLOR MultiplyColor(D3DCOLOR c1, D3DCOLOR c2){
109 int a1, r1, g1, b1, a2, r2, g2, b2;
110 SplitAC(c1, &a1, &r1, &g1, &b1);
111 SplitAC(c2, &a2, &r2, &g2, &b2);
112 return MAKE_AC(a1*a2/255, r1*r2/255, g1*g2/255, b1*b2/255);
113 }
114 inline D3DCOLOR MixColor(D3DCOLOR c1, D3DCOLOR c2, float p1){
115 float p2 = 1.0f-p1;
116 int a1, r1, g1, b1, a2, r2, g2, b2;
117 SplitAC(c1, &a1, &r1, &g1, &b1);
118 SplitAC(c2, &a2, &r2, &g2, &b2);
119 return MAKE_AC(
120 Round(p1*a1+p2*a2), Round(p1*r1+p2*r2), Round(p1*g1+p2*g2), Round(p1*b1+p2*b2));
121 }
122 inline D3DCOLOR ScaleColor(D3DCOLOR c, float s){
123 ValueArea(&s, 0.0f, 1.0f);
124 return (Round((c>>24)*s)<<24)|(c&0x00ffffff);
125 }
126 inline D3DCOLORVALUE ACtoCV(D3DCOLOR c){
127 int a, r, g, b;
128 SplitAC(c, &a, &r, &g, &b);
129 return MAKE_CV(r/255.0f, g/255.0f, b/255.0f, a/255.0f);
130 }
131
132 // 外部グローバル
133 extern bool g_ShadowNeeded;
134 extern float g_BlinkAlpha;
135
136 #endif

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26