当前位置: 首页>>代码示例>>C#>>正文


C# OpenBve.World类代码示例

本文整理汇总了C#中OpenBve.World的典型用法代码示例。如果您正苦于以下问题:C# World类的具体用法?C# World怎么用?C# World使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


World类属于OpenBve命名空间,在下文中一共展示了World类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderFace

 private static void RenderFace(ref World.MeshMaterial Material, World.Vertex[] Vertices, ref World.MeshFace Face, double CameraX, double CameraY, double CameraZ)
 {
     // texture
     int OpenGlNighttimeTextureIndex = Material.NighttimeTextureIndex >= 0 ? TextureManager.UseTexture(Material.NighttimeTextureIndex, TextureManager.UseMode.Normal) : 0;
     int OpenGlDaytimeTextureIndex = Material.DaytimeTextureIndex >= 0 ? TextureManager.UseTexture(Material.DaytimeTextureIndex, TextureManager.UseMode.Normal) : 0;
     if (OpenGlDaytimeTextureIndex != 0)
     {
         if (!TexturingEnabled)
         {
             GL.Enable(EnableCap.Texture2D);
             TexturingEnabled = true;
         }
         if (OpenGlDaytimeTextureIndex != LastBoundTexture)
         {
             GL.BindTexture(TextureTarget.Texture2D, OpenGlDaytimeTextureIndex);
             LastBoundTexture = OpenGlDaytimeTextureIndex;
         }
         if (TextureManager.Textures[Material.DaytimeTextureIndex].Transparency != TextureManager.TextureTransparencyMode.None)
         {
             if (!AlphaTestEnabled)
             {
                 GL.Enable(EnableCap.AlphaTest);
                 AlphaTestEnabled = true;
             }
         }
         else if (AlphaTestEnabled)
         {
             GL.Disable(EnableCap.AlphaTest);
             AlphaTestEnabled = false;
         }
     }
     else
     {
         if (TexturingEnabled)
         {
             GL.Disable(EnableCap.Texture2D);
             TexturingEnabled = false;
             LastBoundTexture = 0;
         }
         if (AlphaTestEnabled)
         {
             GL.Disable(EnableCap.AlphaTest);
             AlphaTestEnabled = false;
         }
     }
     // blend mode
     float factor;
     if (Material.BlendMode == World.MeshMaterialBlendMode.Additive)
     {
         factor = 1.0f;
         if (!BlendEnabled) GL.Enable(EnableCap.Blend);
         GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One);
         if (FogEnabled)
         {
             GL.Disable(EnableCap.Fog);
         }
     }
     else if (OpenGlNighttimeTextureIndex == 0)
     {
         float blend = inv255 * (float)Material.DaytimeNighttimeBlend + 1.0f - OptionLightingResultingAmount;
         if (blend > 1.0f) blend = 1.0f;
         factor = 1.0f - 0.8f * blend;
     }
     else
     {
         factor = 1.0f;
     }
     if (OpenGlNighttimeTextureIndex != 0)
     {
         if (LightingEnabled)
         {
             GL.Disable(EnableCap.Lighting);
             LightingEnabled = false;
         }
     }
     else
     {
         if (OptionLighting & !LightingEnabled)
         {
             GL.Enable(EnableCap.Lighting);
             LightingEnabled = true;
         }
     }
     // render daytime polygon
     int FaceType = Face.Flags & World.MeshFace.FaceTypeMask;
     switch (FaceType)
     {
         case World.MeshFace.FaceTypeTriangles:
             GL.Begin(PrimitiveType.Triangles);
             break;
         case World.MeshFace.FaceTypeTriangleStrip:
             GL.Begin(PrimitiveType.TriangleStrip);
             break;
         case World.MeshFace.FaceTypeQuads:
             GL.Begin(PrimitiveType.Quads);
             break;
         case World.MeshFace.FaceTypeQuadStrip:
             GL.Begin(PrimitiveType.QuadStrip);
             break;
         default:
//.........这里部分代码省略.........
开发者ID:leezer3,项目名称:OpenBVE,代码行数:101,代码来源:RendererS.cs

示例2: CreateStaticObject

 internal static int CreateStaticObject(StaticObject Prototype, Vector3 Position, World.Transformation BaseTransformation, World.Transformation AuxTransformation, bool AccurateObjectDisposal, double AccurateObjectDisposalZOffset, double StartingDistance, double EndingDistance, double BlockLength, double TrackPosition, double Brightness, bool DuplicateMaterials)
 {
     int a = ObjectsUsed;
     if (a >= Objects.Length) {
         Array.Resize<StaticObject>(ref Objects, Objects.Length << 1);
     }
     ApplyStaticObjectData(ref Objects[a], Prototype, Position, BaseTransformation, AuxTransformation, AccurateObjectDisposal, AccurateObjectDisposalZOffset, StartingDistance, EndingDistance, BlockLength, TrackPosition, Brightness, DuplicateMaterials);
     for (int i = 0; i < Prototype.Mesh.Faces.Length; i++) {
         switch (Prototype.Mesh.Faces[i].Flags & World.MeshFace.FaceTypeMask) {
             case World.MeshFace.FaceTypeTriangles:
                 Game.InfoTotalTriangles++;
                 break;
             case World.MeshFace.FaceTypeTriangleStrip:
                 Game.InfoTotalTriangleStrip++;
                 break;
             case World.MeshFace.FaceTypeQuads:
                 Game.InfoTotalQuads++;
                 break;
             case World.MeshFace.FaceTypeQuadStrip:
                 Game.InfoTotalQuadStrip++;
                 break;
             case World.MeshFace.FaceTypePolygon:
                 Game.InfoTotalPolygon++;
                 break;
         }
     }
     ObjectsUsed++;
     return a;
 }
开发者ID:sladen,项目名称:openbve,代码行数:29,代码来源:ObjectManager.cs

示例3: Perform

			internal double Perform(TrainManager.Train Train, int CarIndex, World.Vector3D Position, double TrackPosition, int SectionIndex, bool IsPartOfTrain, double TimeElapsed) {
				ExecuteFunctionScript(this, Train, CarIndex, Position, TrackPosition, SectionIndex, IsPartOfTrain, TimeElapsed);
				return this.LastResult;
			}
开发者ID:noidelsucre,项目名称:OpenBVE,代码行数:4,代码来源:FunctionScripts.cs

示例4: CreateAnimatedWorldObjects

 internal static void CreateAnimatedWorldObjects(AnimatedObject[] Prototypes, Vector3 Position, World.Transformation BaseTransformation, World.Transformation AuxTransformation, int SectionIndex, bool AccurateObjectDisposal, double StartingDistance, double EndingDistance, double BlockLength, double TrackPosition, double Brightness, bool DuplicateMaterials)
 {
     bool[] free = new bool[Prototypes.Length];
     bool anyfree = false;
     for (int i = 0; i < Prototypes.Length; i++) {
         free[i] = Prototypes[i].IsFreeOfFunctions();
         if (free[i]) anyfree = true;
     }
     if (anyfree) {
         for (int i = 0; i < Prototypes.Length; i++) {
             if (Prototypes[i].States.Length != 0) {
                 if (free[i]) {
                     Vector3 p = Position;
                     World.Transformation t = new OpenBve.World.Transformation(BaseTransformation, AuxTransformation);
                     Vector3 s = t.X;
                     Vector3 u = t.Y;
                     Vector3 d = t.Z;
                     p.X += Prototypes[i].States[0].Position.X * s.X + Prototypes[i].States[0].Position.Y * u.X + Prototypes[i].States[0].Position.Z * d.X;
                     p.Y += Prototypes[i].States[0].Position.X * s.Y + Prototypes[i].States[0].Position.Y * u.Y + Prototypes[i].States[0].Position.Z * d.Y;
                     p.Z += Prototypes[i].States[0].Position.X * s.Z + Prototypes[i].States[0].Position.Y * u.Z + Prototypes[i].States[0].Position.Z * d.Z;
                     double zOffset = Prototypes[i].States[0].Position.Z;
                     CreateStaticObject(Prototypes[i].States[0].Object, p, BaseTransformation, AuxTransformation, AccurateObjectDisposal, zOffset, StartingDistance, EndingDistance, BlockLength, TrackPosition, Brightness, DuplicateMaterials);
                 } else {
                     CreateAnimatedWorldObject(Prototypes[i], Position, BaseTransformation, AuxTransformation, SectionIndex, TrackPosition, Brightness);
                 }
             }
         }
     } else {
         for (int i = 0; i < Prototypes.Length; i++) {
             if (Prototypes[i].States.Length != 0) {
                 CreateAnimatedWorldObject(Prototypes[i], Position, BaseTransformation, AuxTransformation, SectionIndex, TrackPosition, Brightness);
             }
         }
     }
 }
开发者ID:sladen,项目名称:openbve,代码行数:35,代码来源:ObjectManager.cs

示例5: CreateObject

 internal static void CreateObject(UnifiedObject Prototype, Vector3 Position, World.Transformation BaseTransformation, World.Transformation AuxTransformation, int SectionIndex, bool AccurateObjectDisposal, double StartingDistance, double EndingDistance, double BlockLength, double TrackPosition, double Brightness, bool DuplicateMaterials)
 {
     if (Prototype is StaticObject) {
         StaticObject s = (StaticObject)Prototype;
         CreateStaticObject(s, Position, BaseTransformation, AuxTransformation, AccurateObjectDisposal, 0.0, StartingDistance, EndingDistance, BlockLength, TrackPosition, Brightness, DuplicateMaterials);
     } else if (Prototype is AnimatedObjectCollection) {
         AnimatedObjectCollection a = (AnimatedObjectCollection)Prototype;
         CreateAnimatedWorldObjects(a.Objects, Position, BaseTransformation, AuxTransformation, SectionIndex, AccurateObjectDisposal, StartingDistance, EndingDistance, BlockLength, TrackPosition, Brightness, DuplicateMaterials);
     }
 }
开发者ID:sladen,项目名称:openbve,代码行数:10,代码来源:ObjectManager.cs

示例6: RegisterTexture

		internal static int RegisterTexture(Bitmap Bitmap, World.ColorRGB TransparentColor)
		{
			int i = GetFreeTexture();
			int[] a = new int[1];
			GL.GenTextures(1, a);
			Textures[i] = new Texture
			{
				Queried = false,
				OpenGlTextureIndex = a[0],
				Transparency = TextureTransparencyMode.TransparentColor,
				TransparentColor = TransparentColor,
				TransparentColorUsed = 1,
				FileName = null,
				Loaded = true,
				Width =  Bitmap.Width,
				Height = Bitmap.Height,
				DontAllowUnload = true
			};
			LoadTextureRGBAforData(Bitmap, Textures[i].TransparentColor, Textures[i].TransparentColorUsed, i);
			LoadTextureRGBAforOpenGl(i);
			return i;
		}
开发者ID:leezer3,项目名称:OpenBVE,代码行数:22,代码来源:TextureManager.cs

示例7: LoadTextureRGBAforData

		// load texture rgba
		private static void LoadTextureRGBAforData(Bitmap Bitmap, World.ColorRGB TransparentColor, byte TransparentColorUsed, int TextureIndex)
		{
			try
			{
				// load bytes
				int Width, Height, Stride; byte[] Data;
				{
					if (Textures[TextureIndex].ClipWidth == 0) Textures[TextureIndex].ClipWidth = Bitmap.Width;
					if (Textures[TextureIndex].ClipHeight == 0) Textures[TextureIndex].ClipHeight = Bitmap.Height;
					Width = Textures[TextureIndex].ClipWidth;
					Height = Textures[TextureIndex].ClipHeight;
					Bitmap c = new Bitmap(Width, Height, GDIPixelFormat.Format32bppArgb);
					Graphics g = Graphics.FromImage(c);
					Rectangle dst = new Rectangle(0, 0, Width, Height);
					Rectangle src = new Rectangle(Textures[TextureIndex].ClipLeft, Textures[TextureIndex].ClipTop, Textures[TextureIndex].ClipWidth, Textures[TextureIndex].ClipHeight);
					g.DrawImage(Bitmap, dst, src, GraphicsUnit.Pixel);
					g.Dispose();
					BitmapData d = c.LockBits(new Rectangle(0, 0, Width, Height), ImageLockMode.ReadOnly, c.PixelFormat);
					Stride = d.Stride;
					Data = new byte[Stride * Height];
					System.Runtime.InteropServices.Marshal.Copy(d.Scan0, Data, 0, Stride * Height);
					c.UnlockBits(d);
					c.Dispose();
				}
				// load mode
				if (Textures[TextureIndex].LoadMode == TextureLoadMode.Bve4SignalGlow)
				{
					// bve 4 signal glow
					int p = 0, pn = Stride - 4 * Width;
					byte tr, tg, tb;
					if (TransparentColorUsed != 0)
					{
						tr = TransparentColor.R;
						tg = TransparentColor.G;
						tb = TransparentColor.B;
					}
					else
					{
						tr = 0; tg = 0; tb = 0;
					}
					// invert lightness
					byte[] Temp = new byte[Stride * Height];
					for (int y = 0; y < Height; y++)
					{
						for (int x = 0; x < Width; x++)
						{
							if (Data[p] == tb & Data[p + 1] == tg & Data[p + 2] == tr)
							{
								Temp[p] = 0;
								Temp[p + 1] = 0;
								Temp[p + 2] = 0;
							}
							else if (Data[p] != 255 | Data[p + 1] != 255 | Data[p + 2] != 255)
							{
								int b = Data[p], g = Data[p + 1], r = Data[p + 2];
								InvertLightness(ref r, ref g, ref b);
								int l = r >= g & r >= b ? r : g >= b ? g : b;
								Temp[p] = (byte)(l * b / 255);
								Temp[p + 1] = (byte)(l * g / 255);
								Temp[p + 2] = (byte)(l * r / 255);
							}
							else
							{
								Temp[p] = Data[p];
								Temp[p + 1] = Data[p + 1];
								Temp[p + 2] = Data[p + 2];
							}
							p += 4;
						} p += pn;
					} p = 0;
					// blur the image and multiply by lightness
					int s = 4;
					int n = Stride - (2 * s + 1 << 2);
					for (int y = 0; y < Height; y++)
					{
						for (int x = 0; x < Width; x++)
						{
							int q = p - s * (Stride + 4);
							int r = 0, g = 0, b = 0, c = 0;
							for (int yr = y - s; yr <= y + s; yr++)
							{
								if (yr >= 0 & yr < Height)
								{
									for (int xr = x - s; xr <= x + s; xr++)
									{
										if (xr >= 0 & xr < Width)
										{
											b += (int)Temp[q];
											g += (int)Temp[q + 1];
											r += (int)Temp[q + 2];
											c++;
										} q += 4;
									} q += n;
								}
								else q += Stride;
							} if (c == 0)
							{
								Data[p] = 0;
								Data[p + 1] = 0;
//.........这里部分代码省略.........
开发者ID:leezer3,项目名称:OpenBVE,代码行数:101,代码来源:TextureManager.cs

示例8: GetDistanceFactor

 // get distance factor
 private static double GetDistanceFactor(World.Vertex[] Vertices, ref World.MeshFace Face, ushort GlowAttenuationData, double CameraX, double CameraY, double CameraZ)
 {
     if (Face.Vertices.Length != 0) {
         World.GlowAttenuationMode mode; double halfdistance;
         World.SplitGlowAttenuationData(GlowAttenuationData, out mode, out halfdistance);
         int i = (int)Face.Vertices[0].Index;
         double dx = Vertices[i].Coordinates.X - CameraX;
         double dy = Vertices[i].Coordinates.Y - CameraY;
         double dz = Vertices[i].Coordinates.Z - CameraZ;
         switch (mode) {
             case World.GlowAttenuationMode.DivisionExponent2:
                 {
                     double t = dx * dx + dy * dy + dz * dz;
                     return t / (t + halfdistance * halfdistance);
                 }
             case World.GlowAttenuationMode.DivisionExponent4:
                 {
                     double t = dx * dx + dy * dy + dz * dz;
                     t *= t; halfdistance *= halfdistance;
                     return t / (t + halfdistance * halfdistance);
                 }
             default:
                 return 1.0;
         }
     } else {
         return 1.0;
     }
 }
开发者ID:openbve,项目名称:OpenBVE,代码行数:29,代码来源:Renderer.cs

示例9: PlaySound

		internal static void PlaySound(ref int SoundSourceIndex, int SoundBufferIndex, World.Vector3D Position, Importance Important, bool Looped) {
			PlaySound(ref SoundSourceIndex, true, SoundBufferIndex, null, -1, Position, Important, Looped, 1.0, 1.0);
		}
开发者ID:noidelsucre,项目名称:OpenBVE,代码行数:3,代码来源:SoundManager.cs

示例10: RenderBackground

 private static void RenderBackground(World.Background Data, double dx, double dy, double dz, float Alpha, float scale)
 {
     if (Data.Texture != null && Textures.LoadTexture(Data.Texture, Textures.OpenGlTextureWrapMode.RepeatClamp)) {
         if (LightingEnabled) {
             Gl.glDisable(Gl.GL_LIGHTING);
             LightingEnabled = false;
         }
         if (!TexturingEnabled) {
             Gl.glEnable(Gl.GL_TEXTURE_2D);
             TexturingEnabled = true;
         }
         if (Alpha == 1.0f) {
             if (BlendEnabled) {
                 Gl.glDisable(Gl.GL_BLEND);
                 BlendEnabled = false;
             }
         } else if (!BlendEnabled) {
             Gl.glEnable(Gl.GL_BLEND);
             BlendEnabled = true;
         }
         Gl.glBindTexture(Gl.GL_TEXTURE_2D, Data.Texture.OpenGlTextures[(int)Textures.OpenGlTextureWrapMode.RepeatClamp].Name);
         Gl.glColor4f(1.0f, 1.0f, 1.0f, Alpha);
         float y0, y1;
         if (Data.KeepAspectRatio) {
             int tw = Data.Texture.Width;
             int th = Data.Texture.Height;
             double hh = Math.PI * World.BackgroundImageDistance * (double)th / ((double)tw * (double)Data.Repetition);
             y0 = (float)(-0.5 * hh);
             y1 = (float)(1.5 * hh);
         } else {
             y0 = (float)(-0.125 * World.BackgroundImageDistance);
             y1 = (float)(0.375 * World.BackgroundImageDistance);
         }
         const int n = 32;
         World.Vector3Df[] bottom = new World.Vector3Df[n];
         World.Vector3Df[] top = new World.Vector3Df[n];
         double angleValue = 2.61799387799149 - 3.14159265358979 / (double)n;
         double angleIncrement = 6.28318530717958 / (double)n;
         /*
          * To ensure that the whole background cylinder is rendered inside the viewing frustum,
          * the background is rendered before the scene with z-buffer writes disabled. Then,
          * the actual distance from the camera is irrelevant as long as it is inside the frustum.
          * */
         for (int i = 0; i < n; i++) {
             float x = (float)(World.BackgroundImageDistance * Math.Cos(angleValue));
             float z = (float)(World.BackgroundImageDistance * Math.Sin(angleValue));
             bottom[i] = new World.Vector3Df(scale * x, scale * y0, scale * z);
             top[i] = new World.Vector3Df(scale * x, scale * y1, scale * z);
             angleValue += angleIncrement;
         }
         float textureStart = 0.5f * (float)Data.Repetition / (float)n;
         float textureIncrement = -(float)Data.Repetition / (float)n;
         double textureX = textureStart;
         for (int i = 0; i < n; i++) {
             int j = (i + 1) % n;
             // side wall
             Gl.glBegin(Gl.GL_QUADS);
             Gl.glTexCoord2d(textureX, 0.005f);
             Gl.glVertex3f(top[i].X, top[i].Y, top[i].Z);
             Gl.glTexCoord2d(textureX, 0.995f);
             Gl.glVertex3f(bottom[i].X, bottom[i].Y, bottom[i].Z);
             Gl.glTexCoord2d(textureX + textureIncrement, 0.995f);
             Gl.glVertex3f(bottom[j].X, bottom[j].Y, bottom[j].Z);
             Gl.glTexCoord2d(textureX + textureIncrement, 0.005f);
             Gl.glVertex3f(top[j].X, top[j].Y, top[j].Z);
             Gl.glEnd();
             // top cap
             Gl.glBegin(Gl.GL_TRIANGLES);
             Gl.glTexCoord2d(textureX, 0.005f);
             Gl.glVertex3f(top[i].X, top[i].Y, top[i].Z);
             Gl.glTexCoord2d(textureX + textureIncrement, 0.005f);
             Gl.glVertex3f(top[j].X, top[j].Y, top[j].Z);
             Gl.glTexCoord2d(textureX + 0.5 * textureIncrement, 0.1f);
             Gl.glVertex3f(0.0f, top[i].Y, 0.0f);
             // bottom cap
             Gl.glTexCoord2d(textureX + 0.5 * textureIncrement, 0.9f);
             Gl.glVertex3f(0.0f, bottom[i].Y, 0.0f);
             Gl.glTexCoord2d(textureX + textureIncrement, 0.995f);
             Gl.glVertex3f(bottom[j].X, bottom[j].Y, bottom[j].Z);
             Gl.glTexCoord2d(textureX, 0.995f);
             Gl.glVertex3f(bottom[i].X, bottom[i].Y, bottom[i].Z);
             Gl.glEnd();
             // finish
             textureX += textureIncrement;
         }
         Gl.glDisable(Gl.GL_TEXTURE_2D);
         TexturingEnabled = false;
         if (!BlendEnabled) {
             Gl.glEnable(Gl.GL_BLEND);
             BlendEnabled = true;
         }
     }
 }
开发者ID:openbve,项目名称:OpenBVE,代码行数:93,代码来源:Renderer.cs

示例11: RenderFace

 private static void RenderFace(ref World.MeshMaterial Material, World.Vertex[] Vertices, Textures.OpenGlTextureWrapMode wrap, ref World.MeshFace Face, double CameraX, double CameraY, double CameraZ)
 {
     // texture
     if (Material.DaytimeTexture != null) {
         if (Textures.LoadTexture(Material.DaytimeTexture, wrap)) {
             if (!TexturingEnabled) {
                 Gl.glEnable(Gl.GL_TEXTURE_2D);
                 TexturingEnabled = true;
             }
             if (Material.DaytimeTexture.OpenGlTextures[(int)wrap] != LastBoundTexture) {
                 Gl.glBindTexture(Gl.GL_TEXTURE_2D, Material.DaytimeTexture.OpenGlTextures[(int)wrap].Name);
                 LastBoundTexture = Material.DaytimeTexture.OpenGlTextures[(int)wrap];
             }
         } else {
             if (TexturingEnabled) {
                 Gl.glDisable(Gl.GL_TEXTURE_2D);
                 TexturingEnabled = false;
                 LastBoundTexture = null;
             }
         }
     } else {
         if (TexturingEnabled) {
             Gl.glDisable(Gl.GL_TEXTURE_2D);
             TexturingEnabled = false;
             LastBoundTexture = null;
         }
     }
     // blend mode
     float factor;
     if (Material.BlendMode == World.MeshMaterialBlendMode.Additive) {
         factor = 1.0f;
         if (!BlendEnabled) Gl.glEnable(Gl.GL_BLEND);
         Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE);
         if (FogEnabled) {
             Gl.glDisable(Gl.GL_FOG);
         }
     } else if (Material.NighttimeTexture == null) {
         float blend = inv255 * (float)Material.DaytimeNighttimeBlend + 1.0f - OptionLightingResultingAmount;
         if (blend > 1.0f) blend = 1.0f;
         factor = 1.0f - 0.7f * blend;
     } else {
         factor = 1.0f;
     }
     if (Material.NighttimeTexture != null) {
         if (LightingEnabled) {
             Gl.glDisable(Gl.GL_LIGHTING);
             LightingEnabled = false;
         }
     } else {
         if (OptionLighting & !LightingEnabled) {
             Gl.glEnable(Gl.GL_LIGHTING);
             LightingEnabled = true;
         }
     }
     // render daytime polygon
     int FaceType = Face.Flags & World.MeshFace.FaceTypeMask;
     switch (FaceType) {
         case World.MeshFace.FaceTypeTriangles:
             Gl.glBegin(Gl.GL_TRIANGLES);
             break;
         case World.MeshFace.FaceTypeTriangleStrip:
             Gl.glBegin(Gl.GL_TRIANGLE_STRIP);
             break;
         case World.MeshFace.FaceTypeQuads:
             Gl.glBegin(Gl.GL_QUADS);
             break;
         case World.MeshFace.FaceTypeQuadStrip:
             Gl.glBegin(Gl.GL_QUAD_STRIP);
             break;
         default:
             Gl.glBegin(Gl.GL_POLYGON);
             break;
     }
     if (Material.GlowAttenuationData != 0) {
         float alphafactor = (float)GetDistanceFactor(Vertices, ref Face, Material.GlowAttenuationData, CameraX, CameraY, CameraZ);
         Gl.glColor4f(inv255 * (float)Material.Color.R * factor, inv255 * Material.Color.G * factor, inv255 * (float)Material.Color.B * factor, inv255 * (float)Material.Color.A * alphafactor);
     } else {
         Gl.glColor4f(inv255 * (float)Material.Color.R * factor, inv255 * Material.Color.G * factor, inv255 * (float)Material.Color.B * factor, inv255 * (float)Material.Color.A);
     }
     if ((Material.Flags & World.MeshMaterial.EmissiveColorMask) != 0) {
         Gl.glMaterialfv(Gl.GL_FRONT_AND_BACK, Gl.GL_EMISSION, new float[] { inv255 * (float)Material.EmissiveColor.R, inv255 * (float)Material.EmissiveColor.G, inv255 * (float)Material.EmissiveColor.B, 1.0f });
         EmissiveEnabled = true;
     } else if (EmissiveEnabled) {
         Gl.glMaterialfv(Gl.GL_FRONT_AND_BACK, Gl.GL_EMISSION, new float[] { 0.0f, 0.0f, 0.0f, 1.0f });
         EmissiveEnabled = false;
     }
     if (Material.DaytimeTexture != null) {
         if (LightingEnabled) {
             for (int j = 0; j < Face.Vertices.Length; j++) {
                 Gl.glNormal3f(Face.Vertices[j].Normal.X, Face.Vertices[j].Normal.Y, Face.Vertices[j].Normal.Z);
                 Gl.glTexCoord2f(Vertices[Face.Vertices[j].Index].TextureCoordinates.X, Vertices[Face.Vertices[j].Index].TextureCoordinates.Y);
                 Gl.glVertex3f((float)(Vertices[Face.Vertices[j].Index].Coordinates.X - CameraX), (float)(Vertices[Face.Vertices[j].Index].Coordinates.Y - CameraY), (float)(Vertices[Face.Vertices[j].Index].Coordinates.Z - CameraZ));
             }
         } else {
             for (int j = 0; j < Face.Vertices.Length; j++) {
                 Gl.glTexCoord2f(Vertices[Face.Vertices[j].Index].TextureCoordinates.X, Vertices[Face.Vertices[j].Index].TextureCoordinates.Y);
                 Gl.glVertex3f((float)(Vertices[Face.Vertices[j].Index].Coordinates.X - CameraX), (float)(Vertices[Face.Vertices[j].Index].Coordinates.Y - CameraY), (float)(Vertices[Face.Vertices[j].Index].Coordinates.Z - CameraZ));
             }
         }
     } else {
//.........这里部分代码省略.........
开发者ID:openbve,项目名称:OpenBVE,代码行数:101,代码来源:Renderer.cs

示例12: TryParseHexColor

		internal static bool TryParseHexColor(string Expression, out World.ColorRGBA Color) {
			if (Expression.StartsWith("#")) {
				string a = Expression.Substring(1).TrimStart();
				int x; if (int.TryParse(a, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out x)) {
					int r = (x >> 16) & 0xFF;
					int g = (x >> 8) & 0xFF;
					int b = x & 0xFF;
					if (r >= 0 & r <= 255 & g >= 0 & g <= 255 & b >= 0 & b <= 255) {
						Color = new World.ColorRGBA((byte)r, (byte)g, (byte)b, 255);
						return true;
					} else {
						Color = new World.ColorRGBA(0, 0, 255, 255);
						return false;
					}
				} else {
					Color = new World.ColorRGBA(0, 0, 255, 255);
					return false;
				}
			} else {
				Color = new World.ColorRGBA(0, 0, 255, 255);
				return false;
			}
		}
开发者ID:JakubVanek,项目名称:openBVE-1,代码行数:23,代码来源:InterfaceR.cs

示例13: LoadAllTextures

		// load all textures
		private static int[] LoadAllTextures(string BaseFile, World.ColorRGB TransparentColor, byte TransparentColorUsed, TextureManager.TextureLoadMode LoadMode) {
			string Folder = System.IO.Path.GetDirectoryName(BaseFile);
			if (!System.IO.Directory.Exists(Folder)) return new int[] { };
			string Name = System.IO.Path.GetFileNameWithoutExtension(BaseFile);
			int[] Textures = new int[] { };
			string[] Files = System.IO.Directory.GetFiles(Folder);
			for (int i = 0; i < Files.Length; i++) {
				string a = System.IO.Path.GetFileNameWithoutExtension(Files[i]);
				if (a.StartsWith(Name, StringComparison.OrdinalIgnoreCase)) {
					if (a.Length > Name.Length) {
						string b = a.Substring(Name.Length).TrimStart();
						int j; if (int.TryParse(b, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out j)) {
							if (j >= 0) {
								string c = System.IO.Path.GetExtension(Files[i]);
								switch (c.ToLowerInvariant()) {
									case ".bmp":
									case ".gif":
									case ".jpg":
									case ".jpeg":
									case ".png":
									case ".tif":
									case ".tiff":
										if (j >= Textures.Length) {
											int n = Textures.Length;
											Array.Resize<int>(ref Textures, j + 1);
											for (int k = n; k < j; k++) {
												Textures[k] = -1;
											}
										}
										Textures[j] = TextureManager.RegisterTexture(Files[i], TransparentColor, TransparentColorUsed, LoadMode, TextureManager.TextureWrapMode.Repeat, TextureManager.TextureWrapMode.Repeat, true, 0, 0, 0, 0);
										TextureManager.UseTexture(Textures[j], TextureManager.UseMode.Normal);
										break;
								}
							}
						}
					}
				}
			} return Textures;
		}
开发者ID:JakubVanek,项目名称:openBVE-1,代码行数:40,代码来源:CsvRwRouteParser.cs

示例14: RenderBox

 // render cube
 private static void RenderBox(World.Vector3D Position, World.Vector3D Direction, World.Vector3D Up, World.Vector3D Side, World.Vector3D Size, double CameraX, double CameraY, double CameraZ)
 {
     if (TexturingEnabled)
     {
         GL.Disable(EnableCap.Texture2D);
         TexturingEnabled = false;
     }
     World.Vector3D[] v = new World.Vector3D[8];
     v[0] = new World.Vector3D(Size.X, Size.Y, -Size.Z);
     v[1] = new World.Vector3D(Size.X, -Size.Y, -Size.Z);
     v[2] = new World.Vector3D(-Size.X, -Size.Y, -Size.Z);
     v[3] = new World.Vector3D(-Size.X, Size.Y, -Size.Z);
     v[4] = new World.Vector3D(Size.X, Size.Y, Size.Z);
     v[5] = new World.Vector3D(Size.X, -Size.Y, Size.Z);
     v[6] = new World.Vector3D(-Size.X, -Size.Y, Size.Z);
     v[7] = new World.Vector3D(-Size.X, Size.Y, Size.Z);
     for (int i = 0; i < 8; i++)
     {
         World.Rotate(ref v[i].X, ref v[i].Y, ref v[i].Z, Direction.X, Direction.Y, Direction.Z, Up.X, Up.Y, Up.Z, Side.X, Side.Y, Side.Z);
         v[i].X += Position.X - CameraX;
         v[i].Y += Position.Y - CameraY;
         v[i].Z += Position.Z - CameraZ;
     }
     int[][] Faces = new int[6][];
     Faces[0] = new int[] { 0, 1, 2, 3 };
     Faces[1] = new int[] { 0, 4, 5, 1 };
     Faces[2] = new int[] { 0, 3, 7, 4 };
     Faces[3] = new int[] { 6, 5, 4, 7 };
     Faces[4] = new int[] { 6, 7, 3, 2 };
     Faces[5] = new int[] { 6, 2, 1, 5 };
     for (int i = 0; i < 6; i++)
     {
         GL.Begin(PrimitiveType.Quads);
         for (int j = 0; j < 4; j++)
         {
             GL.Vertex3(v[Faces[i][j]].X, v[Faces[i][j]].Y, v[Faces[i][j]].Z);
         }
         GL.End();
     }
 }
开发者ID:leezer3,项目名称:OpenBVE,代码行数:41,代码来源:RendererS.cs

示例15: FindTexture

		// find texture
		private static int FindTexture(string FileName, World.ColorRGB TransparentColor, byte TransparentColorUsed, TextureLoadMode LoadMode, TextureWrapMode WrapModeX, TextureWrapMode WrapModeY, int ClipLeft, int ClipTop, int ClipWidth, int ClipHeight)
		{
			for (int i = 1; i < Textures.Length; i++)
			{
				if (Textures[i] != null && Textures[i].FileName != null)
				{
					if (string.Compare(Textures[i].FileName, FileName, StringComparison.OrdinalIgnoreCase) == 0)
					{
						if (Textures[i].LoadMode == LoadMode & Textures[i].WrapModeX == WrapModeX & Textures[i].WrapModeY == WrapModeY)
						{
							if (Textures[i].ClipLeft == ClipLeft & Textures[i].ClipTop == ClipTop & Textures[i].ClipWidth == ClipWidth & Textures[i].ClipHeight == ClipHeight)
							{
								if (TransparentColorUsed == 0)
								{
									if (Textures[i].TransparentColorUsed == 0)
									{
										return i;
									}
								}
								else
								{
									if (Textures[i].TransparentColorUsed != 0)
									{
										if (Textures[i].TransparentColor.R == TransparentColor.R & Textures[i].TransparentColor.G == TransparentColor.G & Textures[i].TransparentColor.B == TransparentColor.B)
										{
											return i;
										}
									}
								}
							}
						}
					}
				}
			}
			return -1;
		}
开发者ID:leezer3,项目名称:OpenBVE,代码行数:37,代码来源:TextureManager.cs


注:本文中的OpenBve.World类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。