-
Notifications
You must be signed in to change notification settings - Fork 1
/
Carro.cs
186 lines (154 loc) · 4.1 KB
/
Carro.cs
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
using System;
using Tao.OpenGl;
using System.Windows.Forms;
using System.Xml;
using Materiales;
using System.Collections;
/// <summary>
/// Summary description for Carro.
/// </summary>
public abstract class Carro:Element,I3dsTaken
{
public _3dsLoader car;
protected Point3D center;
protected Interior inter;
public ArrayList actList;
protected color_typeF[] colores;
public Particula tubodeescape;
public bool todo=true;
public Carro(string path,Interior interior)
{
car=load3ds(path);
car.ComputeNormals();
colores=new color_typeF[]{new color_typeF(0.5f,1.0f,0f),new color_typeF(1f,1f,0.4f),new color_typeF(1f,0.5f,1f),new color_typeF(0.5f,0.5f,1f),new color_typeF(0.7f,0f,0f)};
InitMyMaterial();
inter=interior;
actList=new ArrayList();
// this.actList.Add("capo");
// this.actList.Add("maletero");
this.Recompile();
}
public virtual color_typeF[] Colores
{
get{return colores;}
}
public abstract void EnciendeTubEsc(bool on);
public abstract bool Actions(obj_type o,bool _shadow, int[] rot, float[] trans, float[] scl);
public abstract float OscuridadCristal
{
get;
set;
}
public virtual void EnciendeParabrisas(bool on)
{
this.inter.onlp=on;
}
public override void Recompile()
{
inter.Recompile();
Gl.glNewList(idVisualizar,Gl.GL_COMPILE);
Gl.glPushMatrix();
Gl.glDisable(Gl.GL_CULL_FACE);
car.paint(false,this);
//
// Glu.GLUquadric sph=Glu.gluNewQuadric();
// Glu.gluQuadricOrientation(sph,Glu.GLU_OUTSIDE);
// Gl.glTranslated(0,0,-20);
// Glu.gluSphere(sph,3,32,32);
Gl.glEnable(Gl.GL_CULL_FACE);
Gl.glPopMatrix();
Gl.glEndList();
}
public abstract void InitMyMaterial();
public abstract Point3D ObjetivoVistaInt(int angle);
public abstract Point3D OrigenVistaInt();
public override void Draw()
{
if(idVisualizar != 0)
{
Gl.glPushMatrix();
this.Rota();
inter.Draw();
if(todo)
Gl.glCallList(idVisualizar);
if(this.tubodeescape!=null)
this.tubodeescape.Draw();
Gl.glPopMatrix();
}
}
public override Point3D PuntoRotacion
{
get
{
return center;
}
}
public virtual void ChangeMaterialFrom3ds(string mat3dsname,Material nuevo)
{
this.car.ambient[mat3dsname]=nuevo.Ambient;
this.car.diffuse[mat3dsname]=nuevo.Diffuse;
this.car.specular[mat3dsname]=nuevo.Specular;
this.car.shininess[mat3dsname]=nuevo.Shininess;
}
private _3dsLoader load3ds(string path)
{
XmlTextReader doc = new XmlTextReader(Application.StartupPath + "\\" + "Models\\" + "models.xml");
string id = "";
_3dsLoader temp = null;
string name = "";
int[] rot = null;
float[] trans = null;
float[] scl = null;
bool notdone=true;
while (doc.Read() && notdone)
{
switch (doc.NodeType)
{
case XmlNodeType.Element:
switch (doc.Name)
{
case "model":
if(doc.GetAttribute("id")!=path)
doc.Skip();
else
id = doc.GetAttribute("id");
break;
case "name":
name = (string)(doc.GetAttribute("id"));
break;
case "rot":
rot = new int[3];
rot[0] = Int32.Parse(doc.GetAttribute("x"));
rot[1] = Int32.Parse(doc.GetAttribute("y"));
rot[2] = Int32.Parse(doc.GetAttribute("z"));
break;
case "trans":
trans = new float[3];
trans[0] = Single.Parse(doc.GetAttribute("x"));
trans[1] = Single.Parse(doc.GetAttribute("y"));
trans[2] = Single.Parse(doc.GetAttribute("z"));
break;
case "scl":
scl = new float[3];
scl[0] = Single.Parse(doc.GetAttribute("x"));
scl[1] = Single.Parse(doc.GetAttribute("y"));
scl[2] = Single.Parse(doc.GetAttribute("z"));
break;
}
break;
case XmlNodeType.EndElement:
switch (doc.Name)
{
case "model":
temp = new _3dsLoader(id, name, rot, trans, scl);
center=new Point3D(trans[0],trans[1],trans[2]);
temp.Load3DS(Application.StartupPath + "\\" + "Models\\" + temp.ID);
notdone=false;
return temp;
}
break;
}
}
return null;
}
}