2008-01-05 18:11:29 +00:00
|
|
|
|
|
|
|
#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 SlimDX.Direct3D9;
|
|
|
|
using SlimDX;
|
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
|
|
using System.Drawing.Imaging;
|
|
|
|
using CodeImp.DoomBuilder.Data;
|
|
|
|
using CodeImp.DoomBuilder.Editing;
|
|
|
|
using CodeImp.DoomBuilder.IO;
|
2008-11-19 16:18:36 +00:00
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
2008-01-05 18:11:29 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2008-11-19 16:18:36 +00:00
|
|
|
namespace CodeImp.DoomBuilder.VisualModes
|
2008-01-05 18:11:29 +00:00
|
|
|
{
|
|
|
|
public abstract class VisualGeometry : IComparable<VisualGeometry>
|
|
|
|
{
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
// Texture
|
|
|
|
private ImageData texture;
|
|
|
|
|
|
|
|
// Vertices
|
|
|
|
private WorldVertex[] vertices;
|
|
|
|
private int triangles;
|
|
|
|
|
|
|
|
// Sector
|
|
|
|
private VisualSector sector;
|
|
|
|
|
2008-11-30 22:04:30 +00:00
|
|
|
// Rendering
|
|
|
|
private int renderpass;
|
|
|
|
|
2008-01-05 18:11:29 +00:00
|
|
|
// Sector buffer info
|
|
|
|
private int vertexoffset;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
// Internal properties
|
|
|
|
internal WorldVertex[] Vertices { get { return vertices; } }
|
|
|
|
internal int VertexOffset { get { return vertexoffset; } set { vertexoffset = value; } }
|
|
|
|
internal int Triangles { get { return triangles; } }
|
2008-11-30 22:04:30 +00:00
|
|
|
internal int RenderPassInt { get { return renderpass; } }
|
|
|
|
|
2008-12-02 06:53:24 +00:00
|
|
|
// These are only here so that we can call this on all geometry
|
|
|
|
// but it is only implemented in the VisualSidedef class
|
|
|
|
internal Vector3D PickIntersect { set { } }
|
|
|
|
internal float PickRayU { set { } }
|
|
|
|
|
2008-01-05 18:11:29 +00:00
|
|
|
/// <summary>
|
2008-11-30 22:04:30 +00:00
|
|
|
/// Render pass in which this geometry must be rendered. Default is Solid.
|
2008-01-05 18:11:29 +00:00
|
|
|
/// </summary>
|
2008-11-30 22:04:30 +00:00
|
|
|
public RenderPass RenderPass { get { return (RenderPass)renderpass; } set { renderpass = (int)value; } }
|
2008-01-05 18:11:29 +00:00
|
|
|
|
|
|
|
/// <summary>
|
2008-11-30 22:04:30 +00:00
|
|
|
/// Image to use as texture on this geometry.
|
2008-01-05 18:11:29 +00:00
|
|
|
/// </summary>
|
2008-11-30 22:04:30 +00:00
|
|
|
public ImageData Texture { get { return texture; } set { texture = value; } }
|
2008-01-05 18:11:29 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Returns the VisualSector this geometry has been added to.
|
|
|
|
/// </summary>
|
|
|
|
public VisualSector Sector { get { return sector; } internal set { sector = value; } }
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Destructor
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
public VisualGeometry()
|
|
|
|
{
|
2008-11-30 22:04:30 +00:00
|
|
|
// Defaults
|
|
|
|
renderpass = (int)RenderPass.Solid;
|
2008-01-05 18:11:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
// This sets the vertices for this geometry
|
|
|
|
protected void SetVertices(ICollection<WorldVertex> verts)
|
|
|
|
{
|
|
|
|
// Copy vertices
|
|
|
|
vertices = new WorldVertex[verts.Count];
|
|
|
|
verts.CopyTo(vertices, 0);
|
|
|
|
triangles = vertices.Length / 3;
|
|
|
|
if(sector != null) sector.NeedsUpdateGeo = true;
|
|
|
|
}
|
|
|
|
|
2008-12-02 06:53:24 +00:00
|
|
|
// This compares for sorting by sector
|
2008-01-05 18:11:29 +00:00
|
|
|
public int CompareTo(VisualGeometry other)
|
|
|
|
{
|
2008-11-30 11:23:20 +00:00
|
|
|
// Compare sectors
|
|
|
|
return this.sector.Sector.Index - other.sector.Sector.Index;
|
2008-01-05 18:11:29 +00:00
|
|
|
}
|
|
|
|
|
2008-12-02 06:53:24 +00:00
|
|
|
/// <summary>
|
|
|
|
/// This is called when the geometry must be tested for line intersection. This should reject
|
|
|
|
/// as fast as possible to rule out all geometry that certainly does not touch the line.
|
|
|
|
/// </summary>
|
|
|
|
public virtual bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// This is called when the geometry must be tested for line intersection. This should perform
|
|
|
|
/// accurate hit detection and set u_ray to the position on the ray where this hits the geometry.
|
|
|
|
/// </summary>
|
|
|
|
public virtual bool PickAccurate(Vector3D from, Vector3D to, Vector3D dir, ref float u_ray)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-01-05 18:11:29 +00:00
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|