mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-27 14:12:16 +00:00
118 lines
3 KiB
C#
118 lines
3 KiB
C#
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
/*
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
* This program is released under GNU General Public License
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
*/
|
|
|
|
#endregion
|
|
|
|
#region ================== Namespaces
|
|
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
using System.Drawing;
|
|
using System.ComponentModel;
|
|
using CodeImp.DoomBuilder.Map;
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
using System.Drawing.Imaging;
|
|
using CodeImp.DoomBuilder.Data;
|
|
using CodeImp.DoomBuilder.Editing;
|
|
using CodeImp.DoomBuilder.IO;
|
|
using CodeImp.DoomBuilder.Rendering;
|
|
|
|
#endregion
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes.Editing
|
|
{
|
|
internal class VisualCeiling : VisualGeometry
|
|
{
|
|
#region ================== Constants
|
|
|
|
#endregion
|
|
|
|
#region ================== Variables
|
|
|
|
#endregion
|
|
|
|
#region ================== Properties
|
|
|
|
#endregion
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
// Constructor
|
|
public VisualCeiling(Sector s)
|
|
{
|
|
WorldVertex[] verts;
|
|
WorldVertex v;
|
|
|
|
// Load floor texture
|
|
base.Texture = General.Map.Data.GetFlatImage(s.LongCeilTexture);
|
|
|
|
// Make vertices
|
|
verts = new WorldVertex[s.Triangles.Vertices.Count];
|
|
for(int i = 0; i < s.Triangles.Vertices.Count; i++)
|
|
{
|
|
// Use sector brightness for color shading
|
|
PixelColor pc = new PixelColor(255, unchecked((byte)s.Brightness), unchecked((byte)s.Brightness), unchecked((byte)s.Brightness));
|
|
verts[i].c = pc.ToInt();
|
|
//verts[i].c = -1;
|
|
|
|
// Grid aligned texture coordinates
|
|
if(base.Texture.IsImageLoaded)
|
|
{
|
|
verts[i].u = s.Triangles.Vertices[i].x / base.Texture.ScaledWidth;
|
|
verts[i].v = s.Triangles.Vertices[i].y / base.Texture.ScaledHeight;
|
|
}
|
|
else
|
|
{
|
|
verts[i].u = s.Triangles.Vertices[i].x / 64;
|
|
verts[i].v = s.Triangles.Vertices[i].y / 64;
|
|
}
|
|
|
|
// Vertex coordinates
|
|
verts[i].x = s.Triangles.Vertices[i].x;
|
|
verts[i].y = s.Triangles.Vertices[i].y;
|
|
verts[i].z = (float)s.CeilHeight;
|
|
}
|
|
|
|
// The sector triangulation created clockwise triangles that
|
|
// are right up for the floor. For the ceiling we must flip
|
|
// the triangles upside down.
|
|
// Swap some vertices to flip all triangles
|
|
for(int i = 0; i < verts.Length; i += 3)
|
|
{
|
|
// Swap
|
|
v = verts[i];
|
|
verts[i] = verts[i + 1];
|
|
verts[i + 1] = v;
|
|
}
|
|
|
|
// Apply vertices
|
|
base.SetVertices(verts);
|
|
|
|
// We have no destructor
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ================== Methods
|
|
|
|
#endregion
|
|
}
|
|
}
|