port from perforce

This commit is contained in:
2026-04-18 22:31:51 +02:00
commit 8d0ab5b7cc
8409 changed files with 3972376 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tweaky", "Tweaky\Tweaky.csproj", "{17A0CF60-7011-4715-8241-8499B6D3E130}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{17A0CF60-7011-4715-8241-8499B6D3E130}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{17A0CF60-7011-4715-8241-8499B6D3E130}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17A0CF60-7011-4715-8241-8499B6D3E130}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17A0CF60-7011-4715-8241-8499B6D3E130}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,10 @@
#pragma once
#include "filemon.h"
ANY(float, g_DemoTime) = 12.5f;
RANGE(float, 0.0f, 1.0f, g_Alpha) = 0.5f;
COMBO(int, "0, 1, 2, 3", g_DemoMode) = 1;
ANY(bool, g_Doof) = true;
//ajdhjashdjsfsdf
//sdfgdfgdfg

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace Tweaky
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new TweakyMainWindow());
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Tweaky")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Tweaky")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3b28bafe-1621-4e21-8f5d-dd2cfd18e6ca")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4927
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Tweaky.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tweaky.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,37 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4927
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Tweaky.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public global::System.Collections.Specialized.StringCollection LastOpenedFiles {
get {
return ((global::System.Collections.Specialized.StringCollection)(this["LastOpenedFiles"]));
}
set {
this["LastOpenedFiles"] = value;
}
}
}
}

View File

@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Tweaky.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="LastOpenedFiles" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

View File

@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{17A0CF60-7011-4715-8241-8499B6D3E130}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Tweaky</RootNamespace>
<AssemblyName>Tweaky</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="TweakyCore.cs" />
<Compile Include="TweakyMainWindow.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="TweakyMainWindow.Designer.cs">
<DependentUpon>TweakyMainWindow.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="TweakyMainWindow.resx">
<DependentUpon>TweakyMainWindow.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="Config.h">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,453 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.IO;
using System.Globalization;
using System.Data;
namespace Tweaky
{
public class TweakyCore
{
private Regex EntryPattern = new Regex(@"((?<type>ANY\(.*\))|(?<type>RANGE\(.*\))|(?<type>COMBO\(.*\)))\s*\=\s*(?<value>.*)\s*;");
private Regex AnyPattern = new Regex(@"ANY\((?<type>\w*),\s*(?<name>.*)\)");
private Regex ComboPattern = new Regex(@"COMBO\((?<type>\w*)\s*,\s*(?<options>.*),\s*(?<name>.*)\)");
private Regex RangePattern = new Regex(@"RANGE\((?<type>\w*)\s*,\s*(?<from>.*)\s*,\s*(?<to>.*),\s*(?<name>.*)\)");
private List<VarEntryBase> varEntries = new List<VarEntryBase>();
private Timer saveTimer;
public string FilePath {get; protected set; }
public bool HasWatchableVarEntries { get; protected set; }
public TweakyCore(string filePath)
{
this.FilePath = filePath;
this.ReadFileContent();
}
public void BuildUiElements(Control rootControl)
{
var table = new TableLayoutPanel();
table.AutoSize = true;
table.ColumnCount = 3;
table.RowCount = varEntries.Count;
foreach (RowStyle style in table.RowStyles)
style.SizeType = SizeType.AutoSize;
var currentRowIndex = 0;
foreach (var entry in varEntries)
{
var localEntry = entry;
Control editControl = entry.CreateUi();
if (editControl != null)
{
var nameLabel = new Label();
nameLabel.Text = entry.Name;
nameLabel.Dock = DockStyle.Fill;
nameLabel.AutoSize = true;
nameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
var resetControl = new Button();
resetControl.Text = "Reset";
resetControl.Dock = DockStyle.Fill;
resetControl.AutoSize = true;
resetControl.Click += (s, e) => localEntry.Reset();
resetControl.Enabled = false;
table.Controls.Add(nameLabel, 0, currentRowIndex);
table.Controls.Add(editControl, 1, currentRowIndex);
table.Controls.Add(resetControl, 2, currentRowIndex);
localEntry.OnValueChanged += () =>
{
resetControl.Enabled = !localEntry.HasDefaultValue;
};
currentRowIndex++;
}
}
rootControl.Controls.Add(table);
}
protected void ReadFileContent()
{
using (var stringReader = new StreamReader(FilePath))
{
string line;
while ((line = stringReader.ReadLine()) != null)
{
var entryMatch = EntryPattern.Match(line.Trim());
if (!entryMatch.Success)
{
varEntries.Add(new VarEntryBase()
{
Name = line,
});
continue;
}
var maintype = entryMatch.Groups["type"].Value;
var anyMatch = AnyPattern.Match(maintype);
var rangeMatch = RangePattern.Match(maintype);
var comboMatch = ComboPattern.Match(maintype);
VarEntryBase newEntry = null;
if (anyMatch.Success)
{
var type = anyMatch.Groups["type"].Value;
newEntry = VarEntryUtility.CreateType(typeof(VarEntryT<>), type,
VarEntryUtility.ConvertToObject(type, entryMatch.Groups["value"].Value));
newEntry.Name = anyMatch.Groups["name"].Value;
this.HasWatchableVarEntries = true;
}
else if (rangeMatch.Success)
{
var type = rangeMatch.Groups["type"].Value;
newEntry = VarEntryUtility.CreateType(typeof(RangeEntryT<>), type,
VarEntryUtility.ConvertToObject(type, entryMatch.Groups["value"].Value),
VarEntryUtility.ConvertToObject(type, rangeMatch.Groups["from"].Value),
VarEntryUtility.ConvertToObject(type, rangeMatch.Groups["to"].Value));
newEntry.Name = rangeMatch.Groups["name"].Value;
this.HasWatchableVarEntries = true;
}
else if (comboMatch.Success)
{
var type = comboMatch.Groups["type"].Value;
var options = comboMatch.Groups["options"].Value
.Trim('\"').Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
.Select(o => VarEntryUtility.ConvertToObject(type, o.Trim()))
.ToList();
newEntry = VarEntryUtility.CreateType(typeof(ComboEntryT<>), type,
VarEntryUtility.ConvertToObject(type, entryMatch.Groups["value"].Value),
options);
newEntry.Name = comboMatch.Groups["name"].Value;
this.HasWatchableVarEntries = true;
}
newEntry.OnValueChanged += () => OnValueChanged();
varEntries.Add(newEntry);
}
}
}
protected void OnValueChanged()
{
if (saveTimer != null)
return; // save is already pending
saveTimer = new Timer();
saveTimer.Interval = 1200; // > one second till the save call is progressed
saveTimer.Tick += (s, e) => WriteFileContent();
saveTimer.Start();
}
public void WriteFileContent()
{
if (saveTimer != null)
{
saveTimer.Stop();
saveTimer.Dispose();
saveTimer = null;
}
using (var streamWriter = new StreamWriter(FilePath, false))
{
foreach (var entry in varEntries)
streamWriter.Write(entry.ToString() + "\r\n");
}
}
}
public static class VarEntryUtility
{
public static string GetTypeName<T>()
{
if (typeof(T) == typeof(bool))
return "bool";
else if (typeof(T) == typeof(int))
return "int";
else if (typeof(T) == typeof(float))
return "float";
return string.Empty;
}
private static Type GetType(Type baseType, string type)
{
switch (type)
{
case "int":
return baseType.MakeGenericType(typeof(int));
case "float":
return baseType.MakeGenericType(typeof(float));
case "bool":
return baseType.MakeGenericType(typeof(bool));
default:
throw new ArgumentException(type);
}
}
public static VarEntryBase CreateType(Type baseType, string type, params object[] args)
{
return Activator.CreateInstance(GetType(baseType, type), args) as VarEntryBase;
}
public static object ConvertToObject(string type, string rawValue)
{
switch (type)
{
case "bool":
return bool.Parse(rawValue);
case "int":
return int.Parse(rawValue);
case "float":
return float.Parse(rawValue.TrimEnd('f'), CultureInfo.InvariantCulture);
default:
return null;
}
}
public static string ConvertToString<T>(object rawValue)
{
if (typeof(T) == typeof(bool))
return (bool)rawValue == true ? "true" : "false";
if (typeof(T) == typeof(int))
return ((int)rawValue).ToString(CultureInfo.InvariantCulture);
if (typeof(T) == typeof(float))
return ((float)rawValue).ToString(CultureInfo.InvariantCulture);
return null;
}
}
public class VarEntryBase
{
public string Name;
public Action OnValueChanged;
public virtual Control CreateUi() { return null; }
public virtual void Reset() {}
public override string ToString()
{
return this.Name;
}
public virtual bool HasDefaultValue { get { return false; } }
}
public class VarEntryT<T> : VarEntryBase
{
public VarEntryT(T defaultValue)
{
this.CurrentValue = this.DefaultValue = defaultValue;
}
public T CurrentValue;
public T DefaultValue;
public override string ToString()
{
return string.Format("ANY({0}, {1}) = {2};",
VarEntryUtility.GetTypeName<T>(),
this.Name,
VarEntryUtility.ConvertToString<T>(this.CurrentValue));
}
protected float ToFloat(object value)
{
if (value.GetType() == typeof(int))
return (float)(int)value;
else
return (float)value;
}
protected T FromFloat(float value)
{
if (typeof(T) == typeof(int))
return (T)(object)(int)value;
else
return (T)(object)value; ;
}
private CheckBox checkBox;
private NumericUpDown numBox;
public override Control CreateUi()
{
if (typeof(T) == typeof(bool))
{
checkBox = new CheckBox();
checkBox.Dock = DockStyle.Left;
checkBox.Checked = (bool)(object)this.CurrentValue;
checkBox.CheckedChanged += (s, e) =>
{
this.CurrentValue = (T)(object)checkBox.Checked;
if (this.OnValueChanged != null)
this.OnValueChanged();
};
return checkBox;
}
else
{
numBox = new NumericUpDown();
numBox.DecimalPlaces = 6;
numBox.Dock = DockStyle.Fill;
numBox.Value = (decimal)ToFloat(this.CurrentValue);
numBox.ValueChanged += (s, e) =>
{
var oldValue = this.CurrentValue;
this.CurrentValue = FromFloat((float)numBox.Value);
if (this.OnValueChanged != null && !oldValue.Equals(this.CurrentValue))
this.OnValueChanged();
};
return numBox;
}
}
public override void Reset()
{
this.CurrentValue = this.DefaultValue;
if (typeof(T) == typeof(bool))
checkBox.Checked = (bool)(object)this.CurrentValue;
else
numBox.Value = (decimal)ToFloat(this.CurrentValue);
this.OnValueChanged();
}
public override bool HasDefaultValue { get { return this.CurrentValue.Equals(this.DefaultValue); } }
}
public class ComboEntryT<T> : VarEntryT<T>
{
public IEnumerable<T> Values;
public ComboEntryT(T defaultValue, IEnumerable<object> values)
: base(defaultValue)
{
this.Values = values.Select(o => (T)o);
}
public override string ToString()
{
var options = string.Join(", ", this.Values
.Select(o => VarEntryUtility.ConvertToString<T>(o))
.ToArray());
return string.Format("COMBO({0}, \"{1}\", {2}) = {3};",
VarEntryUtility.GetTypeName<T>(),
options,
this.Name,
VarEntryUtility.ConvertToString<T>(this.CurrentValue));
}
private ComboBox comboBox;
public override Control CreateUi()
{
comboBox = new ComboBox();
comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
foreach (var option in Values)
comboBox.Items.Add(option);
comboBox.SelectedItem = Values.FirstOrDefault(o => o.Equals(this.CurrentValue));
comboBox.Dock = DockStyle.Fill;
comboBox.SelectedValueChanged += (s, e) =>
{
var oldValue = this.CurrentValue;
this.CurrentValue = (T)comboBox.SelectedItem;
if (OnValueChanged != null && !oldValue.Equals(this.CurrentValue))
OnValueChanged();
};
return comboBox;
}
public override void Reset()
{
this.CurrentValue = this.DefaultValue;
comboBox.SelectedItem = Values.FirstOrDefault(o => o.Equals(this.CurrentValue));
this.OnValueChanged();
}
}
public class RangeEntryT<T> : VarEntryT<T>
{
public T From;
public T To;
public RangeEntryT(T defaultValue, T from, T to)
: base(defaultValue)
{
this.From = from;
this.To = to;
}
public override string ToString()
{
return string.Format("RANGE({0}, {1}, {2}, {3}) = {4};",
VarEntryUtility.GetTypeName<T>(),
VarEntryUtility.ConvertToString<T>(this.From),
VarEntryUtility.ConvertToString<T>(this.To),
this.Name,
VarEntryUtility.ConvertToString<T>(this.CurrentValue));
}
private TrackBar trackBar;
public override Control CreateUi()
{
var panel = new Panel();
panel.Dock = DockStyle.Fill;
panel.Height = 24;
var textBox = new TextBox();
textBox.MaximumSize = new System.Drawing.Size(50, 24);
textBox.Enabled = false;
textBox.Text = VarEntryUtility.ConvertToString<T>(this.CurrentValue);
textBox.Dock = DockStyle.Left;
trackBar = new TrackBar();
trackBar.TickStyle = TickStyle.None;
int Multiplicator = 100;
trackBar.Minimum = (int)(ToFloat(this.From) * Multiplicator);
trackBar.Maximum = (int)(ToFloat(this.To) * Multiplicator);
trackBar.Value = (int)(ToFloat(this.CurrentValue) * Multiplicator);
trackBar.Dock = DockStyle.Fill;
trackBar.ValueChanged += (s, e) =>
{
var oldValue = ToFloat(this.CurrentValue);
this.CurrentValue = FromFloat(trackBar.Value / (float)Multiplicator);
if (this.OnValueChanged != null && !oldValue.Equals(this.CurrentValue))
this.OnValueChanged();
textBox.Text = VarEntryUtility.ConvertToString<T>(this.CurrentValue);
};
panel.Controls.Add(trackBar);
panel.Controls.Add(textBox);
return panel;
}
public override void Reset()
{
this.CurrentValue = this.DefaultValue;
int Multiplicator = 100;
trackBar.Value = (int)(ToFloat(this.CurrentValue) * Multiplicator);
this.OnValueChanged();
}
}
}

View File

@@ -0,0 +1,89 @@
namespace Tweaky
{
partial class TweakyMainWindow
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.fileTabControl = new System.Windows.Forms.TabControl();
this.descriptionLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// fileTabControl
//
this.fileTabControl.AllowDrop = true;
this.fileTabControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.fileTabControl.HotTrack = true;
this.fileTabControl.Location = new System.Drawing.Point(0, 0);
this.fileTabControl.Name = "fileTabControl";
this.fileTabControl.SelectedIndex = 0;
this.fileTabControl.Size = new System.Drawing.Size(553, 515);
this.fileTabControl.TabIndex = 0;
this.fileTabControl.DragDrop += new System.Windows.Forms.DragEventHandler(this.TweakyMainWindow_DragDrop);
this.fileTabControl.MouseClick += new System.Windows.Forms.MouseEventHandler(this.fileTabControl_MouseClick);
this.fileTabControl.DragEnter += new System.Windows.Forms.DragEventHandler(this.TweakyMainWindow_DragEnter);
//
// descriptionLabel
//
this.descriptionLabel.AllowDrop = true;
this.descriptionLabel.Dock = System.Windows.Forms.DockStyle.Fill;
this.descriptionLabel.Location = new System.Drawing.Point(0, 0);
this.descriptionLabel.Name = "descriptionLabel";
this.descriptionLabel.Size = new System.Drawing.Size(553, 515);
this.descriptionLabel.TabIndex = 1;
this.descriptionLabel.Text = "Please add new configurable files by drag and drop them into this window.";
this.descriptionLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.descriptionLabel.DragDrop += new System.Windows.Forms.DragEventHandler(this.TweakyMainWindow_DragDrop);
this.descriptionLabel.DragEnter += new System.Windows.Forms.DragEventHandler(this.TweakyMainWindow_DragEnter);
//
// TweakyMainWindow
//
this.AllowDrop = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoScroll = true;
this.ClientSize = new System.Drawing.Size(553, 515);
this.Controls.Add(this.descriptionLabel);
this.Controls.Add(this.fileTabControl);
this.Name = "TweakyMainWindow";
this.Text = "Tweaky";
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.TweakyMainWindow_DragDrop);
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.TweakyMainWindow_DragEnter);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TweakyMainWindow_FormClosing);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TabControl fileTabControl;
private System.Windows.Forms.Label descriptionLabel;
}
}

View File

@@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Text.RegularExpressions;
using System.Globalization;
namespace Tweaky
{
public partial class TweakyMainWindow : Form
{
private Dictionary<TabPage, TweakyCore> loadedFilesMap = new Dictionary<TabPage, TweakyCore>();
public TweakyMainWindow()
{
InitializeComponent();
if (Properties.Settings.Default.LastOpenedFiles != null)
foreach (var filePath in Properties.Settings.Default.LastOpenedFiles)
this.AddFile(filePath);
}
private void fileTabControl_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Middle)
{
for (int i = fileTabControl.TabPages.Count - 1; i >= 0; i--)
{
if (fileTabControl.GetTabRect(i).Contains(e.Location))
{
var tabPage = (sender as TabControl).TabPages[i];
loadedFilesMap.Remove(tabPage);
(sender as TabControl).TabPages.Remove(tabPage);
if (loadedFilesMap.Count == 0)
{
fileTabControl.Visible = false;
descriptionLabel.Visible = true;
}
break;
}
}
}
}
private void TweakyMainWindow_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
var filePaths = (string[])(e.Data.GetData(DataFormats.FileDrop));
foreach (var fileLoc in filePaths)
this.AddFile(fileLoc);
}
}
private void AddFile(string filePath)
{
if (File.Exists(filePath) && !loadedFilesMap.Values.Any(p => p.FilePath == filePath))
{
var tweakyCore = new TweakyCore(filePath);
if (!tweakyCore.HasWatchableVarEntries)
return;
var tabPage = new TabPage(Path.GetFileName(filePath));
tabPage.AutoSize = true;
tabPage.AutoScroll = true;
fileTabControl.TabPages.Add(tabPage);
tweakyCore.BuildUiElements(tabPage);
loadedFilesMap.Add(tabPage, tweakyCore);
fileTabControl.Visible = true;
descriptionLabel.Visible = false;
}
}
private void TweakyMainWindow_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}
private void TweakyMainWindow_FormClosing(object sender, FormClosingEventArgs e)
{
Properties.Settings.Default.LastOpenedFiles = new System.Collections.Specialized.StringCollection();
foreach (var tweakyCore in loadedFilesMap.Values)
{
tweakyCore.WriteFileContent();
Properties.Settings.Default.LastOpenedFiles.Add(tweakyCore.FilePath);
}
Properties.Settings.Default.Save();
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
</configuration>

View File

@@ -0,0 +1,22 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tweaky", "Tweaky\Tweaky.csproj", "{17A0CF60-7011-4715-8241-8499B6D3E130}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{17A0CF60-7011-4715-8241-8499B6D3E130}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{17A0CF60-7011-4715-8241-8499B6D3E130}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17A0CF60-7011-4715-8241-8499B6D3E130}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17A0CF60-7011-4715-8241-8499B6D3E130}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Binary file not shown.

View File

@@ -0,0 +1,10 @@
#pragma once
#include "filemon.h"
ANY(float, g_DemoTime) = 10.5;
RANGE(float, 0, 1, g_Alpha) = 0.96;
COMBO(int, "0, 1, 2, 3", g_DemoMode) = 3;
ANY(bool, g_Doof) = true;
//ajdhjashdjsfsdf
//sdfgdfgdfg

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace Tweaky
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new TweakyMainWindow());
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Tweaky")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Tweaky")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3b28bafe-1621-4e21-8f5d-dd2cfd18e6ca")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34003
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Tweaky.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tweaky.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,37 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34003
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Tweaky.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public global::System.Collections.Specialized.StringCollection LastOpenedFiles {
get {
return ((global::System.Collections.Specialized.StringCollection)(this["LastOpenedFiles"]));
}
set {
this["LastOpenedFiles"] = value;
}
}
}
}

View File

@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Tweaky.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="LastOpenedFiles" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

View File

@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{17A0CF60-7011-4715-8241-8499B6D3E130}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Tweaky</RootNamespace>
<AssemblyName>Tweaky</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="TweakyCore.cs" />
<Compile Include="TweakyMainWindow.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="TweakyMainWindow.Designer.cs">
<DependentUpon>TweakyMainWindow.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="TweakyMainWindow.resx">
<DependentUpon>TweakyMainWindow.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="Config.h">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,453 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.IO;
using System.Globalization;
using System.Data;
namespace Tweaky
{
public class TweakyCore
{
private Regex EntryPattern = new Regex(@"((?<type>ANY\(.*\))|(?<type>RANGE\(.*\))|(?<type>COMBO\(.*\)))\s*\=\s*(?<value>.*)\s*;");
private Regex AnyPattern = new Regex(@"ANY\((?<type>\w*),\s*(?<name>.*)\)");
private Regex ComboPattern = new Regex(@"COMBO\((?<type>\w*)\s*,\s*(?<options>.*),\s*(?<name>.*)\)");
private Regex RangePattern = new Regex(@"RANGE\((?<type>\w*)\s*,\s*(?<from>.*)\s*,\s*(?<to>.*),\s*(?<name>.*)\)");
private List<VarEntryBase> varEntries = new List<VarEntryBase>();
private Timer saveTimer;
public string FilePath {get; protected set; }
public bool HasWatchableVarEntries { get; protected set; }
public TweakyCore(string filePath)
{
this.FilePath = filePath;
this.ReadFileContent();
}
public void BuildUiElements(Control rootControl)
{
var table = new TableLayoutPanel();
table.AutoSize = true;
table.ColumnCount = 3;
table.RowCount = varEntries.Count;
foreach (RowStyle style in table.RowStyles)
style.SizeType = SizeType.AutoSize;
var currentRowIndex = 0;
foreach (var entry in varEntries)
{
var localEntry = entry;
Control editControl = entry.CreateUi();
if (editControl != null)
{
var nameLabel = new Label();
nameLabel.Text = entry.Name;
nameLabel.Dock = DockStyle.Fill;
nameLabel.AutoSize = true;
nameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
var resetControl = new Button();
resetControl.Text = "Reset";
resetControl.Dock = DockStyle.Fill;
resetControl.AutoSize = true;
resetControl.Click += (s, e) => localEntry.Reset();
resetControl.Enabled = false;
table.Controls.Add(nameLabel, 0, currentRowIndex);
table.Controls.Add(editControl, 1, currentRowIndex);
table.Controls.Add(resetControl, 2, currentRowIndex);
localEntry.OnValueChanged += () =>
{
resetControl.Enabled = !localEntry.HasDefaultValue;
};
currentRowIndex++;
}
}
rootControl.Controls.Add(table);
}
protected void ReadFileContent()
{
using (var stringReader = new StreamReader(FilePath))
{
string line;
while ((line = stringReader.ReadLine()) != null)
{
var entryMatch = EntryPattern.Match(line.Trim());
if (!entryMatch.Success)
{
varEntries.Add(new VarEntryBase()
{
Name = line,
});
continue;
}
var maintype = entryMatch.Groups["type"].Value;
var anyMatch = AnyPattern.Match(maintype);
var rangeMatch = RangePattern.Match(maintype);
var comboMatch = ComboPattern.Match(maintype);
VarEntryBase newEntry = null;
if (anyMatch.Success)
{
var type = anyMatch.Groups["type"].Value;
newEntry = VarEntryUtility.CreateType(typeof(VarEntryT<>), type,
VarEntryUtility.ConvertToObject(type, entryMatch.Groups["value"].Value));
newEntry.Name = anyMatch.Groups["name"].Value;
this.HasWatchableVarEntries = true;
}
else if (rangeMatch.Success)
{
var type = rangeMatch.Groups["type"].Value;
newEntry = VarEntryUtility.CreateType(typeof(RangeEntryT<>), type,
VarEntryUtility.ConvertToObject(type, entryMatch.Groups["value"].Value),
VarEntryUtility.ConvertToObject(type, rangeMatch.Groups["from"].Value),
VarEntryUtility.ConvertToObject(type, rangeMatch.Groups["to"].Value));
newEntry.Name = rangeMatch.Groups["name"].Value;
this.HasWatchableVarEntries = true;
}
else if (comboMatch.Success)
{
var type = comboMatch.Groups["type"].Value;
var options = comboMatch.Groups["options"].Value
.Trim('\"').Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
.Select(o => VarEntryUtility.ConvertToObject(type, o.Trim()))
.ToList();
newEntry = VarEntryUtility.CreateType(typeof(ComboEntryT<>), type,
VarEntryUtility.ConvertToObject(type, entryMatch.Groups["value"].Value),
options);
newEntry.Name = comboMatch.Groups["name"].Value;
this.HasWatchableVarEntries = true;
}
newEntry.OnValueChanged += () => OnValueChanged();
varEntries.Add(newEntry);
}
}
}
protected void OnValueChanged()
{
if (saveTimer != null)
return; // save is already pending
saveTimer = new Timer();
saveTimer.Interval = 1200; // > one second till the save call is progressed
saveTimer.Tick += (s, e) => WriteFileContent();
saveTimer.Start();
}
public void WriteFileContent()
{
if (saveTimer != null)
{
saveTimer.Stop();
saveTimer.Dispose();
saveTimer = null;
}
using (var streamWriter = new StreamWriter(FilePath, false))
{
foreach (var entry in varEntries)
streamWriter.Write(entry.ToString() + "\r\n");
}
}
}
public static class VarEntryUtility
{
public static string GetTypeName<T>()
{
if (typeof(T) == typeof(bool))
return "bool";
else if (typeof(T) == typeof(int))
return "int";
else if (typeof(T) == typeof(float))
return "float";
return string.Empty;
}
private static Type GetType(Type baseType, string type)
{
switch (type)
{
case "int":
return baseType.MakeGenericType(typeof(int));
case "float":
return baseType.MakeGenericType(typeof(float));
case "bool":
return baseType.MakeGenericType(typeof(bool));
default:
throw new ArgumentException(type);
}
}
public static VarEntryBase CreateType(Type baseType, string type, params object[] args)
{
return Activator.CreateInstance(GetType(baseType, type), args) as VarEntryBase;
}
public static object ConvertToObject(string type, string rawValue)
{
switch (type)
{
case "bool":
return bool.Parse(rawValue);
case "int":
return int.Parse(rawValue);
case "float":
return float.Parse(rawValue.TrimEnd('f'), CultureInfo.InvariantCulture);
default:
return null;
}
}
public static string ConvertToString<T>(object rawValue)
{
if (typeof(T) == typeof(bool))
return (bool)rawValue == true ? "true" : "false";
if (typeof(T) == typeof(int))
return ((int)rawValue).ToString(CultureInfo.InvariantCulture);
if (typeof(T) == typeof(float))
return ((float)rawValue).ToString(CultureInfo.InvariantCulture);
return null;
}
}
public class VarEntryBase
{
public string Name;
public Action OnValueChanged;
public virtual Control CreateUi() { return null; }
public virtual void Reset() {}
public override string ToString()
{
return this.Name;
}
public virtual bool HasDefaultValue { get { return false; } }
}
public class VarEntryT<T> : VarEntryBase
{
public VarEntryT(T defaultValue)
{
this.CurrentValue = this.DefaultValue = defaultValue;
}
public T CurrentValue;
public T DefaultValue;
public override string ToString()
{
return string.Format("ANY({0}, {1}) = {2};",
VarEntryUtility.GetTypeName<T>(),
this.Name,
VarEntryUtility.ConvertToString<T>(this.CurrentValue));
}
protected float ToFloat(object value)
{
if (value.GetType() == typeof(int))
return (float)(int)value;
else
return (float)value;
}
protected T FromFloat(float value)
{
if (typeof(T) == typeof(int))
return (T)(object)(int)value;
else
return (T)(object)value; ;
}
private CheckBox checkBox;
private NumericUpDown numBox;
public override Control CreateUi()
{
if (typeof(T) == typeof(bool))
{
checkBox = new CheckBox();
checkBox.Dock = DockStyle.Left;
checkBox.Checked = (bool)(object)this.CurrentValue;
checkBox.CheckedChanged += (s, e) =>
{
this.CurrentValue = (T)(object)checkBox.Checked;
if (this.OnValueChanged != null)
this.OnValueChanged();
};
return checkBox;
}
else
{
numBox = new NumericUpDown();
numBox.DecimalPlaces = 6;
numBox.Dock = DockStyle.Fill;
numBox.Value = (decimal)ToFloat(this.CurrentValue);
numBox.ValueChanged += (s, e) =>
{
var oldValue = this.CurrentValue;
this.CurrentValue = FromFloat((float)numBox.Value);
if (this.OnValueChanged != null && !oldValue.Equals(this.CurrentValue))
this.OnValueChanged();
};
return numBox;
}
}
public override void Reset()
{
this.CurrentValue = this.DefaultValue;
if (typeof(T) == typeof(bool))
checkBox.Checked = (bool)(object)this.CurrentValue;
else
numBox.Value = (decimal)ToFloat(this.CurrentValue);
this.OnValueChanged();
}
public override bool HasDefaultValue { get { return this.CurrentValue.Equals(this.DefaultValue); } }
}
public class ComboEntryT<T> : VarEntryT<T>
{
public IEnumerable<T> Values;
public ComboEntryT(T defaultValue, IEnumerable<object> values)
: base(defaultValue)
{
this.Values = values.Select(o => (T)o);
}
public override string ToString()
{
var options = string.Join(", ", this.Values
.Select(o => VarEntryUtility.ConvertToString<T>(o))
.ToArray());
return string.Format("COMBO({0}, \"{1}\", {2}) = {3};",
VarEntryUtility.GetTypeName<T>(),
options,
this.Name,
VarEntryUtility.ConvertToString<T>(this.CurrentValue));
}
private ComboBox comboBox;
public override Control CreateUi()
{
comboBox = new ComboBox();
comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
foreach (var option in Values)
comboBox.Items.Add(option);
comboBox.SelectedItem = Values.FirstOrDefault(o => o.Equals(this.CurrentValue));
comboBox.Dock = DockStyle.Fill;
comboBox.SelectedValueChanged += (s, e) =>
{
var oldValue = this.CurrentValue;
this.CurrentValue = (T)comboBox.SelectedItem;
if (OnValueChanged != null && !oldValue.Equals(this.CurrentValue))
OnValueChanged();
};
return comboBox;
}
public override void Reset()
{
this.CurrentValue = this.DefaultValue;
comboBox.SelectedItem = Values.FirstOrDefault(o => o.Equals(this.CurrentValue));
this.OnValueChanged();
}
}
public class RangeEntryT<T> : VarEntryT<T>
{
public T From;
public T To;
public RangeEntryT(T defaultValue, T from, T to)
: base(defaultValue)
{
this.From = from;
this.To = to;
}
public override string ToString()
{
return string.Format("RANGE({0}, {1}, {2}, {3}) = {4};",
VarEntryUtility.GetTypeName<T>(),
VarEntryUtility.ConvertToString<T>(this.From),
VarEntryUtility.ConvertToString<T>(this.To),
this.Name,
VarEntryUtility.ConvertToString<T>(this.CurrentValue));
}
private TrackBar trackBar;
public override Control CreateUi()
{
var panel = new Panel();
panel.Dock = DockStyle.Fill;
panel.Height = 24;
var textBox = new TextBox();
textBox.MaximumSize = new System.Drawing.Size(50, 24);
textBox.Enabled = false;
textBox.Text = VarEntryUtility.ConvertToString<T>(this.CurrentValue);
textBox.Dock = DockStyle.Left;
trackBar = new TrackBar();
trackBar.TickStyle = TickStyle.None;
int Multiplicator = 100;
trackBar.Minimum = (int)(ToFloat(this.From) * Multiplicator);
trackBar.Maximum = (int)(ToFloat(this.To) * Multiplicator);
trackBar.Value = (int)(ToFloat(this.CurrentValue) * Multiplicator);
trackBar.Dock = DockStyle.Fill;
trackBar.ValueChanged += (s, e) =>
{
var oldValue = ToFloat(this.CurrentValue);
this.CurrentValue = FromFloat(trackBar.Value / (float)Multiplicator);
if (this.OnValueChanged != null && !oldValue.Equals(this.CurrentValue))
this.OnValueChanged();
textBox.Text = VarEntryUtility.ConvertToString<T>(this.CurrentValue);
};
panel.Controls.Add(trackBar);
panel.Controls.Add(textBox);
return panel;
}
public override void Reset()
{
this.CurrentValue = this.DefaultValue;
int Multiplicator = 100;
trackBar.Value = (int)(ToFloat(this.CurrentValue) * Multiplicator);
this.OnValueChanged();
}
}
}

View File

@@ -0,0 +1,89 @@
namespace Tweaky
{
partial class TweakyMainWindow
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.fileTabControl = new System.Windows.Forms.TabControl();
this.descriptionLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// fileTabControl
//
this.fileTabControl.AllowDrop = true;
this.fileTabControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.fileTabControl.HotTrack = true;
this.fileTabControl.Location = new System.Drawing.Point(0, 0);
this.fileTabControl.Name = "fileTabControl";
this.fileTabControl.SelectedIndex = 0;
this.fileTabControl.Size = new System.Drawing.Size(553, 515);
this.fileTabControl.TabIndex = 0;
this.fileTabControl.DragDrop += new System.Windows.Forms.DragEventHandler(this.TweakyMainWindow_DragDrop);
this.fileTabControl.MouseClick += new System.Windows.Forms.MouseEventHandler(this.fileTabControl_MouseClick);
this.fileTabControl.DragEnter += new System.Windows.Forms.DragEventHandler(this.TweakyMainWindow_DragEnter);
//
// descriptionLabel
//
this.descriptionLabel.AllowDrop = true;
this.descriptionLabel.Dock = System.Windows.Forms.DockStyle.Fill;
this.descriptionLabel.Location = new System.Drawing.Point(0, 0);
this.descriptionLabel.Name = "descriptionLabel";
this.descriptionLabel.Size = new System.Drawing.Size(553, 515);
this.descriptionLabel.TabIndex = 1;
this.descriptionLabel.Text = "Please add new configurable files by drag and drop them into this window.";
this.descriptionLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.descriptionLabel.DragDrop += new System.Windows.Forms.DragEventHandler(this.TweakyMainWindow_DragDrop);
this.descriptionLabel.DragEnter += new System.Windows.Forms.DragEventHandler(this.TweakyMainWindow_DragEnter);
//
// TweakyMainWindow
//
this.AllowDrop = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoScroll = true;
this.ClientSize = new System.Drawing.Size(553, 515);
this.Controls.Add(this.descriptionLabel);
this.Controls.Add(this.fileTabControl);
this.Name = "TweakyMainWindow";
this.Text = "Tweaky";
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.TweakyMainWindow_DragDrop);
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.TweakyMainWindow_DragEnter);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TweakyMainWindow_FormClosing);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TabControl fileTabControl;
private System.Windows.Forms.Label descriptionLabel;
}
}

View File

@@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Text.RegularExpressions;
using System.Globalization;
namespace Tweaky
{
public partial class TweakyMainWindow : Form
{
private Dictionary<TabPage, TweakyCore> loadedFilesMap = new Dictionary<TabPage, TweakyCore>();
public TweakyMainWindow()
{
InitializeComponent();
if (Properties.Settings.Default.LastOpenedFiles != null)
foreach (var filePath in Properties.Settings.Default.LastOpenedFiles)
this.AddFile(filePath);
}
private void fileTabControl_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Middle)
{
for (int i = fileTabControl.TabPages.Count - 1; i >= 0; i--)
{
if (fileTabControl.GetTabRect(i).Contains(e.Location))
{
var tabPage = (sender as TabControl).TabPages[i];
loadedFilesMap.Remove(tabPage);
(sender as TabControl).TabPages.Remove(tabPage);
if (loadedFilesMap.Count == 0)
{
fileTabControl.Visible = false;
descriptionLabel.Visible = true;
}
break;
}
}
}
}
private void TweakyMainWindow_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
var filePaths = (string[])(e.Data.GetData(DataFormats.FileDrop));
foreach (var fileLoc in filePaths)
this.AddFile(fileLoc);
}
}
private void AddFile(string filePath)
{
if (File.Exists(filePath) && !loadedFilesMap.Values.Any(p => p.FilePath == filePath))
{
var tweakyCore = new TweakyCore(filePath);
if (!tweakyCore.HasWatchableVarEntries)
return;
var tabPage = new TabPage(Path.GetFileName(filePath));
tabPage.AutoSize = true;
tabPage.AutoScroll = true;
fileTabControl.TabPages.Add(tabPage);
tweakyCore.BuildUiElements(tabPage);
loadedFilesMap.Add(tabPage, tweakyCore);
fileTabControl.Visible = true;
descriptionLabel.Visible = false;
}
}
private void TweakyMainWindow_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}
private void TweakyMainWindow_FormClosing(object sender, FormClosingEventArgs e)
{
Properties.Settings.Default.LastOpenedFiles = new System.Collections.Specialized.StringCollection();
foreach (var tweakyCore in loadedFilesMap.Values)
{
tweakyCore.WriteFileContent();
Properties.Settings.Default.LastOpenedFiles.Add(tweakyCore.FilePath);
}
Properties.Settings.Default.Save();
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
</configuration>

View File

@@ -0,0 +1,10 @@
#pragma once
#include "filemon.h"
ANY(float, g_DemoTime) = 12.5f;
RANGE(float, 0.0f, 1.0f, g_Alpha) = 0.5f;
COMBO(int, "0, 1, 2, 3", g_DemoMode) = 1;
ANY(bool, g_Doof) = true;
//ajdhjashdjsfsdf
//sdfgdfgdfg

Binary file not shown.

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
</configuration>

Binary file not shown.

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
</configuration>

View File

@@ -0,0 +1,10 @@
E:\blu-flame.org\evoke-64k\trunk\Tweaky\Tweaky\bin\Debug\Tweaky.exe.config
E:\blu-flame.org\evoke-64k\trunk\Tweaky\Tweaky\bin\Debug\Config.h
E:\blu-flame.org\evoke-64k\trunk\Tweaky\Tweaky\bin\Debug\Tweaky.exe
E:\blu-flame.org\evoke-64k\trunk\Tweaky\Tweaky\bin\Debug\Tweaky.pdb
E:\blu-flame.org\evoke-64k\trunk\Tweaky\Tweaky\obj\Debug\Tweaky.csprojResolveAssemblyReference.cache
E:\blu-flame.org\evoke-64k\trunk\Tweaky\Tweaky\obj\Debug\Tweaky.TweakyMainWindow.resources
E:\blu-flame.org\evoke-64k\trunk\Tweaky\Tweaky\obj\Debug\Tweaky.Properties.Resources.resources
E:\blu-flame.org\evoke-64k\trunk\Tweaky\Tweaky\obj\Debug\Tweaky.csproj.GenerateResource.Cache
E:\blu-flame.org\evoke-64k\trunk\Tweaky\Tweaky\obj\Debug\Tweaky.exe
E:\blu-flame.org\evoke-64k\trunk\Tweaky\Tweaky\obj\Debug\Tweaky.pdb

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,49 @@
# Blender3D v246 OBJ File: atari.blend
# www.blender3d.org
v -0.993693 7.438359 -0.000000
v 1.006307 7.438359 0.000000
v -0.993695 -7.114214 -0.000000
v 1.006306 -7.114214 0.000000
v -7.638318 -7.373180 0.000000
v -7.638318 -5.373180 -0.000000
v -1.462695 7.438359 0.000000
v -3.462695 7.438360 -0.000000
v -3.462695 7.438360 -0.000000
v -1.462695 7.438359 0.000000
v -0.993693 7.438359 -0.000000
v 1.006307 7.438359 0.000000
v -7.638318 -5.373180 -0.000000
v -7.638318 -7.373180 0.000000
v -0.993695 -7.114214 -0.000000
v 1.006306 -7.114214 0.000000
v -1.462696 -0.052856 0.000000
v -3.462696 -0.052856 -0.000000
v -2.519978 -4.180912 0.000000
v -3.934192 -2.766699 -0.000000
v 3.933834 -2.766700 0.000000
v 2.519620 -4.180914 -0.000000
v 3.462338 -0.052857 0.000000
v 1.462337 -0.052856 -0.000000
v 7.637960 -5.373180 0.000000
v 7.637960 -7.373180 -0.000000
v 1.462339 7.438359 -0.000000
v 3.462339 7.438358 -0.000000
v 3.462339 7.438358 -0.000000
v 1.462339 7.438359 -0.000000
v 7.637960 -5.373180 0.000000
v 7.637960 -7.373180 -0.000000
usemtl Material
s 1
f 3 1 2 4
f 8 9 10 7
f 1 11 12 2
f 5 14 13 6
f 4 16 15 3
f 18 8 7 17
f 6 20 19 5
f 20 18 17 19
f 21 31 32 22
f 23 21 22 24
f 29 23 24 30
f 31 25 26 32
f 30 27 28 29

View File

@@ -0,0 +1,12 @@
FILE atari.obj
FLATTEN
FLOATBITS 12
COLOR 192 192 192 64
EXTRUDE 1
SUBDIVIDE
SUBDIVIDE
SUBDIVIDE
SUPER 0.25

View File

@@ -0,0 +1,46 @@
# Blender3D v246 OBJ File: commod.blend
# www.blender3d.org
v 6.490464 3.638708 -0.000000
v 3.611959 0.214475 0.000000
v -0.109388 3.638713 -0.000001
v -0.109388 0.214476 0.000000
v 6.490464 3.730206 -0.000000
v 3.611959 0.305973 0.000000
v -0.109388 3.730211 -0.000001
v -0.109388 0.305974 0.000000
v 0.289035 -7.356400 -0.000000
v -3.941339 -4.426592 0.000000
v -5.872333 -8.448413 0.000000
v 0.131454 -3.652155 0.000000
v 0.289035 -7.356400 -0.000000
v 0.287997 7.421998 -0.000000
v 0.146595 3.754244 -0.000000
v 0.146595 3.754244 -0.000000
v 0.287997 7.421998 -0.000000
v 0.131454 -3.652155 0.000000
v -3.972942 4.483369 -0.000000
v -5.872331 8.469555 -0.000000
v -6.921259 -0.003901 0.000000
v -12.237351 0.014822 -0.000000
v -0.109388 -3.602269 0.000000
v -0.109388 -0.178032 0.000001
v 6.550732 -3.602271 -0.000000
v 3.604821 -0.178037 0.000000
v -0.109388 -3.602269 0.000000
v -0.109388 -0.178032 0.000001
v 6.550732 -3.602271 -0.000000
v 3.604821 -0.178037 0.000000
usemtl Material
s 1
f 3 1 2 4
f 1 5 6 2
f 4 8 7 3
f 10 18 9 11
f 18 12 13 9
f 17 14 15 16
f 16 19 20 17
f 19 21 22 20
f 21 10 11 22
f 27 23 24 28
f 30 26 25 29
f 28 30 29 27

View File

@@ -0,0 +1,13 @@
FILE commod.obj
FLATTEN
FLOATBITS 12
COLOR 192 192 192 64
EXTRUDE 1
SUBDIVIDE
SUBDIVIDE
SUBDIVIDE
SUPER 0.25

View File

@@ -0,0 +1,41 @@
# Blender3D v246 OBJ File: crystal.blend
# www.blender3d.org
v 0.353553 -0.045309 -0.353553
v 0.482963 -0.045309 0.129410
v 0.129409 -0.045309 0.482963
v -0.353553 -0.045309 0.353553
v -0.482963 -0.045309 -0.129410
v -0.129409 -0.045309 -0.482963
v 0.640755 3.946158 -0.640755
v 0.875288 3.946158 0.234532
v 0.234533 3.946158 0.875287
v -0.640755 3.946158 0.640755
v -0.875288 3.946158 -0.234532
v -0.234533 3.946158 -0.875287
v 0.574351 4.390408 -0.574351
v -0.210228 4.390408 -0.784578
v -0.784579 4.390408 -0.210227
v -0.574351 4.390408 0.574351
v 0.210227 4.390408 0.784578
v 0.784579 4.390408 0.210227
v 0.000000 4.786534 -0.000000
usemtl (null)
s off
f 1 7 8 2
f 2 8 9 3
f 3 9 10 4
f 4 10 11 5
f 5 11 12 6
f 7 1 6 12
f 7 12 14 13
f 12 11 15 14
f 11 10 16 15
f 10 9 17 16
f 9 8 18 17
f 8 7 13 18
f 19 13 14
f 19 14 15
f 19 15 16
f 19 16 17
f 19 17 18
f 19 18 13

View File

@@ -0,0 +1,7 @@
FILE crystal.obj
FLOATBITS 14
COLOR 255 255 255 255
UNINDEX

View File

@@ -0,0 +1,90 @@
# Blender3D v246 OBJ File: duck.blend
# www.blender3d.org
v 2.565486 -0.102426 -1.000000
v 2.565486 -0.102426 1.000000
v -3.066047 -0.014552 1.000000
v -3.066046 -0.014552 -1.000000
v 2.259124 2.302860 -1.000000
v 2.259121 2.302860 1.000000
v -1.594982 2.266742 0.879797
v -1.594982 2.266742 -0.879797
v 2.259124 2.302860 -1.745345
v 2.259123 -0.420440 -1.984043
v -2.259122 -0.420440 -1.984043
v -1.053419 2.266742 -1.745345
v -3.481300 1.470057 0.999999
v -2.350906 2.439857 0.879796
v -2.350906 2.439857 -0.879798
v -3.481299 1.470057 -1.000001
v 2.259122 -0.420440 1.984043
v 2.259121 2.302860 1.745346
v -1.053421 2.266741 1.745345
v -2.259123 -0.420440 1.984042
v 3.243165 0.302860 -0.999999
v 4.133813 4.112998 -0.999999
v 4.133810 4.112998 1.000001
v 3.243165 0.302860 1.000001
v 2.259123 -0.681183 -1.000000
v 2.259123 -0.681183 1.000000
v -2.259123 -0.681183 1.000000
v -2.259122 -0.681183 -1.000000
v -3.351362 3.104919 -1.680221
v -3.351364 3.104919 1.680219
v -0.267524 3.758731 -1.680220
v -0.267526 3.758731 1.680220
v -1.469109 4.989134 -0.805017
v -1.469110 4.989134 0.805016
v -2.396492 5.168098 0.805016
v -2.396492 5.168098 -0.805018
v -3.167788 3.950947 0.586844
v -3.167787 3.950947 -0.573384
v -3.254336 3.552009 -0.626610
v -3.254336 3.552009 0.640070
v -4.586704 3.563728 -0.626611
v -4.586705 3.563728 0.640069
v -4.500156 3.962667 0.586843
v -4.500155 3.962667 -0.573385
usemtl Material
s 1
f 5 8 7 6
f 1 10 9 5
f 10 1 4 11
f 8 12 11 4
f 5 9 12 8
f 9 10 11 12
f 7 14 13 3
f 4 16 15 8
f 3 13 16 4
f 13 14 15 16
f 6 18 17 2
f 7 19 18 6
f 3 20 19 7
f 2 17 20 3
f 17 18 19 20
f 21 1 5 22
f 6 23 22 5
f 2 24 23 6
f 1 21 24 2
f 21 22 23 24
f 25 1 2 26
f 3 27 26 2
f 4 28 27 3
f 1 25 28 4
f 25 26 27 28
f 15 14 30 29
f 8 15 29 31
f 14 7 32 30
f 7 8 31 32
f 32 31 33 34
f 30 32 34 35
f 31 29 36 33
f 33 36 35 34
f 35 36 38 37
f 36 29 39 38
f 30 35 37 40
f 29 30 40 39
f 39 40 42 41
f 40 37 43 42
f 38 39 41 44
f 37 38 44 43
f 41 42 43 44

View File

@@ -0,0 +1,13 @@
FILE duck.obj
/FLATTEN
FLOATBITS 13
COLOR 255 255 0 64
SUBDIVIDE
SUBDIVIDE
SUBDIVIDE
SUBDIVIDE

View File

@@ -0,0 +1,796 @@
# 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware
# File Created: 26.08.2010 19:01:07
#
# object icemage
#
v -31.997184753418 8.518324851990 1.905359268188
v -32.248725891113 8.663727760315 1.179888963699
v -31.741449356079 13.918359756470 0.960696041584
v -33.351200103760 14.890666961670 1.247375607491
v -34.428703308105 14.972445487976 0.003240784630
v -32.913181304932 13.966187477112 1.555379629135
v -31.419591903687 12.239754676819 1.244592308998
v -34.317237854004 13.697469711304 0.047062538564
v -35.646945953369 13.086496353149 3.019788265228
v -35.455146789551 13.103430747986 3.132490634918
v -35.388469696045 12.936099052429 2.932483434677
v -35.488666534424 12.919167518616 2.827769756317
v -32.623897552490 14.953702926636 0.577370464802
v -33.186286926270 15.217096328735 0.297459393740
v -32.994422912598 15.283218383789 -0.144497826695
v -31.696132659912 17.737085342407 0.577826857567
v -32.300117492676 17.615146636963 0.619406938553
v -32.171882629395 17.157648086548 0.362521439791
v -31.776174545288 17.397022247314 0.094636894763
v -32.014652252197 16.241344451904 0.994761586189
v -32.146949768066 15.875457763672 0.617083787918
v -32.277004241943 17.447294235229 1.250655055046
v -31.966382980347 15.314019203186 1.302740216255
v -32.346618652344 15.861530303955 1.517609000206
v -34.129589080811 14.837094306946 1.082531690598
v -33.803535461426 14.966871261597 1.520578026772
v -33.493278503418 14.229289054871 1.439657568932
v -33.819332122803 14.099517822266 1.001611351967
v -33.185504913330 14.362272262573 0.003669964848
v -33.486526489258 14.600859642029 -0.259475737810
v -33.158847808838 14.584714889526 -0.458941310644
v -33.013996124268 14.346125602722 -0.051740445197
v -32.490406036377 16.801723480225 0.694725692272
v -32.417407989502 16.851558685303 0.453657954931
v -32.447746276855 16.825757980347 1.242824196815
v -31.698184967041 17.244626998901 1.459532380104
v -31.889875411987 15.730410575867 1.462653875351
v -32.267963409424 16.849966049194 1.399473428726
v -32.116271972656 16.168849945068 1.712698221207
v -32.095588684082 17.223117828369 1.406516790390
v -32.315593719482 10.293083190918 1.120679140091
v -32.833709716797 9.745144844055 0.685264527798
v -31.682670593262 10.375526428223 1.170535802841
v -32.075202941895 7.750069141388 2.727233409882
v -32.382041931152 7.918982982635 1.449484348297
v -32.304779052734 9.277928352356 1.724194645882
v -32.571289062500 8.881817817688 1.056186079979
v -32.314037322998 4.585237503052 3.958039760590
v -32.329174041748 4.647766113281 3.929004669189
v -32.586460113525 4.533944129944 4.063166141510
v -32.584995269775 4.714251041412 4.099331378937
v -31.984312057495 8.330290794373 2.361292123795
v -32.661346435547 8.134746551514 0.905057311058
v -32.076263427734 7.854726314545 0.413680732250
v -32.447658538818 0.729999244213 3.941976785660
v -32.603538513184 1.583035826683 2.835028171539
v -33.862712860107 1.583035826683 3.012344360352
v -33.706836700439 0.729998052120 4.119290828705
v -31.965906143188 -0.127986118197 4.653245925903
v -32.579566955566 -0.127986118197 2.122603893280
v -34.376995086670 -0.127986118197 2.375716209412
v -34.267936706543 -0.127986118197 4.977413177490
v -32.278182983398 16.415470123291 0.967835783958
v -32.087730407715 16.377042770386 0.619961500168
v -32.258853912354 16.462001800537 1.354497432709
v -32.042587280273 16.503486633301 1.603141903877
v -32.418418884277 17.250982284546 0.649399399757
v -32.257862091064 17.011964797974 0.357009440660
v -31.832599639893 17.080101013184 -0.103324390948
v -31.721597671509 16.884466171265 1.637370586395
v -32.388339996338 17.152757644653 1.248728632927
v -32.294517517090 17.034914016724 1.459627151489
v -31.887567520142 16.761873245239 1.371733665466
v -31.786783218384 16.479820251465 1.642531871796
v -31.897682189941 16.657316207886 1.540611624718
v -31.938133239746 16.939834594727 1.563921332359
v -31.849966049194 17.158941268921 1.445300340652
v -31.839788436890 16.504594802856 1.646515250206
v -31.859815597534 16.213878631592 2.451771259308
v -31.784297943115 16.583820343018 2.022721052170
v -31.831111907959 16.792280197144 1.563358426094
v -31.819379806519 16.929647445679 1.496272563934
v -31.740087509155 16.824638366699 1.653789281845
v -32.072494506836 16.766401290894 1.009122371674
v -32.133773803711 16.798997879028 1.014418482780
v -32.093978881836 16.822822570801 1.022916197777
v -32.023941040039 16.777864456177 1.018185973167
v -31.898504257202 15.281540870667 2.305564641953
v -31.977479934692 14.988492965698 1.750282883644
v -32.373943328857 15.227070808411 1.895742297173
v -32.232769012451 15.403326988220 2.330358028412
v -31.791402816772 16.296525955200 1.917162895203
v -32.174171447754 15.662533760071 1.369217753410
v -31.969768524170 16.302444458008 1.937056303024
v -31.895473480225 16.621128082275 1.760307073593
v -35.817985534668 13.159472465515 2.940819025040
v -35.123023986816 13.259115219116 3.107459783554
v -35.042957305908 13.012639045715 2.954074144363
v -35.737918853760 12.912999153137 2.787436485291
v -33.115123748779 13.386695861816 8.624922752380
v -33.328956604004 13.452832221985 8.688874244690
v -33.319099426270 13.593267440796 8.563547134399
v -33.105266571045 13.527137756348 8.499597549438
v -32.205413818359 11.105333328247 0.551453411579
v -32.980075836182 11.376443862915 0.827435016632
v -33.475486755371 11.590643882751 0.307396829128
v -31.571304321289 7.080128192902 2.889817714691
v -31.929550170898 6.771647453308 2.076762676239
v -32.498611450195 6.754424571991 2.373501062393
v -32.357044219971 7.119402885437 3.200647592545
v -31.715494155884 16.962827682495 1.684719920158
v -31.887651443481 16.992288589478 1.743818402290
v -32.194412231445 17.074079513550 1.635889172554
v -32.112483978271 17.155117034912 1.574225068092
v -31.810945510864 17.112775802612 1.648246169090
v -31.830513000488 16.675849914551 2.021351099014
v -31.866664886475 16.499996185303 1.904148697853
v -31.815505981445 16.638198852539 1.763145446777
v -31.879470825195 16.703378677368 1.718359947205
v -31.965751647949 16.453798294067 1.666112184525
v -32.037227630615 16.602193832397 1.561128735542
v -32.004058837891 16.596693038940 1.787257552147
v -31.945905685425 16.450057983398 1.920449137688
v -31.988615036011 16.695301055908 1.329406380653
v -32.202102661133 16.784200668335 1.345346212387
v -31.990421295166 16.734109878540 1.088752746582
v -32.203907012939 16.823011398315 1.104692578316
v -31.928482055664 16.835548400879 1.352544546127
v -32.141967773438 16.924449920654 1.368484258652
v -31.930284500122 16.874366760254 1.111891150475
v -32.143772125244 16.963270187378 1.127830982208
v -32.218090057373 15.451521873474 3.314572811127
v -32.164306640625 15.278358459473 1.775196433067
v -32.134185791016 15.260808944702 2.997768402100
v -32.107719421387 15.566678047180 2.030409336090
v -32.042339324951 14.783009529114 2.479770898819
v -32.016777038574 15.015810966492 2.385302782059
v -32.781795501709 16.834943771362 1.089307785034
v -33.008132934570 16.379281997681 0.058881696314
v -32.677524566650 17.618532180786 1.089307188988
v -32.934581756592 17.094129562378 -0.240780636668
v -33.292987823486 -0.127986118197 6.356444835663
v -34.099445343018 -0.127986118197 6.577024459839
v -32.539005279541 -0.127986118197 3.425388097763
v -33.787651062012 -0.127986118197 3.044495344162
v -33.433540344238 0.223619341850 6.138091087341
v -34.107284545898 0.223619341850 6.322371959686
v -32.595272064209 0.652186334133 3.641833066940
v -33.693809509277 0.652186334133 3.239802837372
v -33.982563018799 13.178085327148 7.281796455383
v -34.333179473877 13.315762519836 7.415574550629
v -34.317176818848 13.626564025879 7.131840229034
v -33.966564178467 13.488887786865 6.998062610626
v -32.206527709961 14.465166091919 6.508258342743
v -32.076953887939 4.895846843719 4.213287353516
v -32.498676300049 4.978840351105 3.404784679413
v -33.071250915527 4.980308532715 3.703355789185
v -32.672336578369 4.876806259155 4.523750782013
v -33.479885101318 12.946027755737 8.193766593933
v -33.821929931641 13.065222740173 8.285115242004
v -33.728969573975 13.349129676819 8.165291786194
v -33.386924743652 13.229945182800 8.073944091797
v -33.866264343262 13.910938262939 9.298095703125
v -33.802604675293 14.041048049927 9.177555084229
v -33.580593109131 13.960398674011 9.199933052063
v -33.644256591797 13.830294609070 9.320478439331
v -34.282409667969 13.309967994690 7.423308849335
v -34.646903991699 13.473879814148 7.415839195251
v -34.395587921143 13.382693290710 8.568157196045
v -34.045284271240 13.241168975830 8.614869117737
v -34.509410858154 13.762405395508 7.141604900360
v -34.245056152344 13.649977684021 8.474081993103
v -34.144908905029 13.598495483398 7.149076938629
v -33.894744873047 13.508457183838 8.520791053772
v -33.863643646240 14.704897880554 8.028573989868
v -33.831069946289 14.464674949646 8.206997871399
v -34.161434173584 14.513258934021 8.328614234924
v -34.194015502930 14.753490447998 8.150190353394
v -33.909530639648 13.997517585754 6.886907100677
v -34.461536407471 14.100785255432 7.071669101715
v -33.833976745605 13.704867362976 7.301520347595
v -34.385982513428 13.808127403259 7.486295223236
v -32.304779052734 9.277928352356 1.724194645882
v -32.571289062500 8.881817817688 1.056186079979
v -33.266887664795 12.070313453674 7.983743190765
v -35.297782897949 13.115639686584 9.381443023682
v -34.243774414063 15.566042900085 7.942427635193
v -31.145057678223 17.461441040039 0.536246299744
v -31.422748565674 17.057958602905 0.308585911989
v -31.413185119629 8.518324851990 1.600832104683
v -30.829187393188 8.518324851990 1.296304941177
v -31.462324142456 10.293083190918 0.429220288992
v -31.237754821777 8.737154006958 0.660303592682
v -32.015861511230 9.762223243713 0.041592024267
v -31.714895248413 8.636934280396 0.966273128986
v -32.572116851807 9.729071617126 0.181619226933
v -31.297702789307 13.966187477112 -0.276111185551
v -31.657979965210 14.890666961670 -0.672249794006
v -33.463691711426 13.044974327087 -0.584959506989
v -33.841983795166 14.896970748901 -0.892094075680
v -32.743053436279 14.757488250732 -1.335632085800
v -32.744380950928 13.478013992310 -1.282303214073
v -31.443386077881 14.966871261597 -1.155155062675
v -31.918712615967 14.837094306946 -1.423970341682
v -31.484939575195 14.229289054871 -0.837222278118
v -31.960266113281 14.099517822266 -1.106037378311
v -32.231945037842 14.953702926636 0.133005708456
v -32.427921295166 14.607201576233 0.355187982321
v -32.579875946045 15.217096328735 -0.390034586191
v -32.846023559570 14.362272262573 -0.117091588676
v -32.854248046875 14.506834983826 -0.473890781403
v -31.121664047241 16.649293899536 1.147350311279
v -31.265048980713 16.716506958008 1.327266931534
v -31.541818618774 16.436847686768 1.567088127136
v -31.381027221680 16.345188140869 1.291296720505
v -31.704357147217 15.590689659119 0.607241630554
v -31.669996261597 16.321453094482 0.589885711670
v -31.429101943970 16.302482604980 0.906704843044
v -31.722351074219 16.202447891235 0.973716855049
v -31.989900588989 15.781081199646 0.348373144865
v -31.813554763794 16.136959075928 0.724047362804
v -31.668016433716 17.568565368652 1.279842138290
v -31.121946334839 17.293586730957 1.167494177818
v -31.974452972412 15.533119201660 0.785701155663
v -31.466215133667 15.606966018677 1.454222798347
v -32.193275451660 12.240173339844 -3.845551252365
v -32.407695770264 12.178560256958 -3.847173452377
v -32.206195831299 12.075271606445 -3.633208274841
v -32.340045928955 12.031950950623 -3.594486713409
v -31.331628799438 17.121456146240 1.351514339447
v -31.255022048950 16.696878433228 0.369969636202
v -31.379299163818 16.895051956177 0.293755739927
v -31.122577667236 17.078544616699 0.556102812290
v -31.164323806763 16.625259399414 0.599251747131
v -31.864589691162 16.713165283203 0.130561813712
v -31.092498779297 16.980318069458 1.155432462692
v -31.960203170776 12.455036163330 -3.659325838089
v -32.605667114258 12.211319923401 -3.870613574982
v -31.922100067139 12.218555450439 -3.476807117462
v -32.567565917969 11.974842071533 -3.688097953796
v -29.708450317383 7.800247192383 -4.776975154877
v -29.891532897949 8.371130943298 -4.760089874268
v -30.767707824707 7.892626285553 -5.155910015106
v -30.584623336792 7.511089324951 -5.172795295715
v -31.655244827271 16.730957031250 1.355006933212
v -31.649015426636 16.624225616455 1.522708177567
v -31.544023513794 15.311674118042 2.280770063400
v -31.516208648682 15.112933158875 1.833988308907
v -31.711137771606 17.123373031616 1.503736376762
v -31.577495574951 17.050094604492 1.425683498383
v -31.183095932007 16.887014389038 1.379608631134
v -32.028301239014 11.376443862915 -0.251602113247
v -32.606121063232 11.590643882751 -0.678216218948
v -33.251434326172 11.613685607910 -0.371195673943
v -30.835031509399 9.384673118591 0.968822896481
v -31.233854293823 8.978951454163 0.368816524744
v -31.092916488647 7.859561920166 2.215020418167
v -30.110631942749 7.750069141388 1.702806711197
v -30.462715148926 8.330290794373 1.567853689194
v -31.228704452515 8.367003440857 1.954616785049
v -30.982673645020 7.918982982635 0.719781637192
v -31.269193649292 8.134746551514 0.179117724299
v -31.706787109375 7.553994178772 1.080193877220
v -31.106275558472 6.387320995331 1.239339828491
v -30.631996154785 6.695800304413 2.059120416641
v -30.537212371826 6.370097637177 0.942601263523
v -29.887220382690 6.735074996948 1.670755863190
v -30.835031509399 9.384673118591 0.968822896481
v -31.395812988281 9.352155685425 1.688188552856
v -31.233854293823 8.978951454163 0.368816524744
v -32.088600158691 8.935916900635 0.351322680712
v -29.644744873047 3.813707113266 1.598033905029
v -29.659885406494 3.881285905838 1.584394216537
v -31.260017395020 2.097736597061 -1.285754442215
v -30.817529678345 0.729999065399 -0.544374883175
v -29.402599334717 3.801919698715 1.427372455597
v -30.136091232300 2.097736597061 -1.871825218201
v -29.373783111572 3.972135782242 1.490752935410
v -29.693603515625 0.729997932911 -1.130449056625
v -31.692405700684 -0.127986118197 -1.849611520767
v -30.795936584473 -0.127986118197 0.311684042215
v -30.088041305542 -0.127986118197 -2.686208009720
v -28.741167068481 -0.127986118197 -0.759780406952
v -31.578828811646 15.887893676758 1.674004077911
v -31.745822906494 16.320714950562 2.505528450012
v -31.808404922485 15.785044670105 2.626383543015
v -31.672298431396 16.188924789429 2.438270568848
v -31.708578109741 16.573745727539 2.017269372940
v -31.751691818237 16.790170669556 1.556319952011
v -31.674287796021 16.771411895752 1.552067637444
v -31.659198760986 16.908330917358 1.484740018845
v -31.726860046387 16.689754486084 2.086827278137
v -31.640680313110 16.650588989258 2.007683753967
v -31.528463363647 16.694005966187 0.969953894615
v -31.460699081421 16.709432601929 0.965959072113
v -31.491317749023 16.742624282837 0.979526340961
v -31.570585250854 16.717535018921 0.985545933247
v -31.712223052979 17.050382614136 1.623583555222
v -31.521949768066 16.822437286377 1.715049862862
v -31.598213195801 17.011877059937 1.632930397987
v -31.243717193604 16.947568893433 1.567442417145
v -31.309574127197 17.048273086548 1.516418218613
v -31.729145050049 16.489873886108 1.638548970222
v -31.616680145264 16.255460739136 1.911635160446
v -31.703607559204 15.462508201599 1.335338711739
v -31.668401718140 16.473613739014 1.889873743057
v -31.766733169556 16.456445693970 1.964226245880
v -31.619279861450 16.407691955566 1.641167640686
v -31.527168273926 16.534318923950 1.524406194687
v -31.528451919556 16.533403396606 1.753015518188
v -31.603404998779 16.404481887817 1.895789742470
v -31.629404067993 16.670101165771 1.700355768204
v -31.701160430908 16.622983932495 1.754912495613
v -31.512697219849 16.762035369873 1.530852437019
v -31.629613876343 16.585748672485 1.741165995598
v -31.761871337891 16.612373352051 1.743553638458
v -31.084661483765 8.354222297668 -7.097832679749
v -28.737159729004 7.216344356537 -3.752846240997
v -30.204565048218 8.893461227417 -5.629972457886
v -29.309412002563 8.798869132996 -4.884624481201
v -28.954425811768 7.968389511108 -5.235550880432
v -29.849805831909 7.906418323517 -5.982896804810
v -29.847072601318 8.387351036072 -4.548900604248
v -29.457881927490 8.075687408447 -5.256869316101
v -30.775289535522 8.476111412048 -5.423805713654
v -30.027734756470 8.053167343140 -5.567494869232
v -29.992691040039 4.305690765381 1.234726071358
v -29.571168899536 4.036267280579 2.001631259918
v -29.420114517212 4.376801490784 0.944743931293
v -28.975786209106 4.090212821960 1.695297122002
v -31.582000732422 16.641191482544 1.300131917000
v -31.604055404663 16.682695388794 1.060935854912
v -31.374748229980 16.712675094604 1.044995784760
v -31.352695465088 16.671171188354 1.284191727638
v -31.599693298340 16.791795730591 1.328872680664
v -31.370388031006 16.821773529053 1.312933087349
v -31.392442703247 16.863290786743 1.073737740517
v -31.621749877930 16.833311080933 1.089677572250
v -31.906486511230 14.767882347107 2.479254484177
v -32.141658782959 15.468361854553 3.321377515793
v -32.057750701904 15.277648925781 3.004572868347
v -31.880922317505 15.000683784485 2.384785175323
v -31.683845520020 15.224857330322 1.773367166519
v -31.673698425293 15.518347740173 2.028757572174
v -30.869192123413 16.094652175903 -0.095114916563
v -30.821786880493 16.574121475220 0.948193311691
v -30.640996932983 17.932716369629 0.948192775249
v -30.719123840332 17.384508132935 -0.394777327776
v -29.145776748657 0.223619028926 0.980777859688
v -28.461166381836 0.223619028926 0.853902697563
v -30.213954925537 0.652186095715 -1.836133003235
v -30.861829757690 0.652186155319 -0.781108260155
v -29.177198410034 -0.127986118197 1.237716913223
v -28.357734680176 -0.127986118197 1.085850000381
v -30.251062393188 -0.127986118197 -2.048913717270
v -31.032918930054 -0.127986222506 -0.924024283886
v -27.484622955322 8.664202690125 -5.921338081360
v -32.073020935059 7.356976032257 -4.695828914642
v -29.741661071777 7.656284809113 -4.793882369995
v -29.846357345581 7.681778907776 -5.004799842834
v -29.596649169922 7.730965137482 -5.120641708374
v -29.491954803467 7.705473423004 -4.909721851349
v -30.141965866089 8.537597656250 -4.452879905701
v -29.692926406860 8.541932106018 -4.574271202087
v -30.124855041504 8.600554466248 -4.945173263550
v -29.778091430664 8.351603507996 -4.919981479645
v -33.325271606445 17.505264282227 1.287179350853
v -32.397495269775 17.129987716675 -0.724039196968
v -33.306945800781 17.422872543335 1.314238667488
v -32.379295349121 17.046024322510 -0.696891903877
v -32.043392181396 17.330255508423 0.222997710109
v -32.411384582520 17.479423522949 1.020757794380
v -34.054271697998 19.959398269653 -0.566653847694
v -33.336788177490 19.527635574341 -1.913185358047
v -32.100658416748 18.944868087769 0.643081605434
v -31.719804763794 18.779035568237 0.181376591325
v -30.391792297363 17.501203536987 0.133264541626
v -31.319505691528 17.877267837524 2.144440174103
v -31.335071563721 17.993915557861 2.115446090698
v -30.407360076904 17.617853164673 0.104271054268
v -32.974411010742 21.034385681152 -0.465645283461
v -32.339542388916 20.702020645142 -1.983207583427
v -31.596229553223 17.672687530518 1.360634326935
v -31.778337478638 19.166721343994 0.850791215897
v -31.228239059448 17.523519515991 0.562875032425
v -31.626792907715 19.164421081543 0.389084637165
v -31.395812988281 9.352155685425 1.688188552856
v -32.088600158691 8.935916900635 0.351322680712
v -33.306945800781 17.422872543335 1.314238667488
v -32.379295349121 17.046024322510 -0.696891903877
v -30.391792297363 17.501203536987 0.133264541626
v -31.319505691528 17.877267837524 2.144440174103
v -33.325271606445 17.505264282227 1.287179350853
v -32.397495269775 17.129987716675 -0.724039196968
v -31.335071563721 17.993915557861 2.115446090698
v -30.407360076904 17.617853164673 0.104271054268
v -32.167892456055 15.150259017944 0.817123830318
v -32.292480468750 15.263488769531 0.611842215061
v -31.852001190186 15.027585029602 0.608804821968
v -32.062038421631 14.993104934692 0.684888422489
v -31.847116470337 15.102244377136 0.384583324194
v -32.246578216553 15.187336921692 0.246905580163
v -34.054271697998 19.959398269653 -0.566653847694
v -33.336788177490 19.527635574341 -1.913185358047
v -32.974411010742 21.034385681152 -0.465645283461
v -32.339542388916 20.702020645142 -1.983207583427
v -32.928104400635 13.206510543823 7.910933494568
v -32.943916320801 13.348491668701 7.829181671143
v -32.784313201904 13.303127288818 7.711736202240
v -32.768505096436 13.161140441895 7.793483734131
v -33.836784362793 13.215758323669 6.877782344818
v -34.089855194092 13.310139656067 7.098917484283
v -33.459545135498 12.944771766663 7.640221118927
v -33.202205657959 12.858826637268 7.459089756012
v -34.131282806396 13.625467300415 6.914244651794
v -33.397373199463 13.208617210388 7.565878868103
v -33.878219604492 13.531089782715 6.693112373352
v -33.140037536621 13.122680664063 7.384747505188
v -21.875457763672 10.284508705139 0.569477081299
v -21.581298828125 10.570493698120 0.008087125607
v -36.512210845947 6.479164600372 -9.387242317200
v -36.455619812012 6.534179210663 -9.495234489441
v -21.717227935791 9.742151260376 0.376089453697
v -21.423061370850 10.028150558472 -0.185298517346
v -36.481769561768 6.374832630157 -9.424442291260
v -36.425182342529 6.429849624634 -9.532436370850
# 426 vertices
g icemage
f 16 19 18 17
f 190 43 41 1
f 2 1 41 42
f 195 2 42 196
f 4 6 7 3
f 200 199 8 5
f 4 5 25 26
f 6 4 26 27
f 8 6 27 28
f 5 8 28 25
f 3 208 13 4
f 4 13 14 5
f 5 14 15 200
f 29 13 208 32
f 14 13 29 30
f 14 30 31 15
f 38 35 65 66
f 21 20 63 64
f 221 220 21 64
f 17 22 222 16
f 224 23 24 20
f 63 20 24 65
f 10 26 25 9
f 11 27 26 10
f 12 28 27 11
f 9 25 28 12
f 29 32 400 397
f 398 30 29 397
f 31 30 398 402
f 222 22 40 36
f 68 34 33 67
f 69 235 34 68
f 33 35 71 67
f 10 9 96 97
f 11 10 97 98
f 98 99 12 11
f 12 99 96 9
f 102 101 100 103
f 73 38 66 75
f 91 90 89 88
f 77 249 36 40
f 40 22 71 72
f 41 43 104 105
f 42 41 105 106
f 196 42 106 254
f 387 271 184 183
f 44 257 260 52
f 45 44 52 53
f 263 45 53 54
f 257 107 108 263
f 45 263 108 109
f 44 45 109 110
f 44 110 107 257
f 46 52 260 269
f 53 52 46 47
f 388 54 53 47
f 48 55 56 49
f 49 56 57 50
f 58 51 50 57
f 51 58 55 48
f 55 59 60 56
f 56 60 61 57
f 57 61 62 58
f 58 62 59 55
f 66 65 24 39
f 64 63 33 34
f 235 221 64 34
f 63 65 35 33
f 79 286 285 80
f 18 68 67 17
f 69 68 18 19
f 67 71 22 17
f 289 83 82 81
f 38 72 71 35
f 289 81 116 292
f 84 87 86 85
f 112 111 298 115
f 115 114 113 112
f 94 78 39 93
f 78 75 66 39
f 74 307 117 78
f 120 123 122 121
f 75 118 119 73
f 73 81 82 76
f 82 83 70 76
f 73 84 85 38
f 38 85 86 72
f 72 86 87 76
f 87 84 73 76
f 23 89 90 24
f 24 90 91 39
f 91 88 316 95
f 92 94 93 37
f 78 94 92 74
f 93 95 316 37
f 95 93 39 91
f 97 96 186 187
f 98 97 187 154
f 185 99 98 154
f 186 96 99 185
f 150 159 160 151
f 151 160 161 152
f 153 152 161 162
f 150 153 162 159
f 105 104 7 6
f 106 105 6 8
f 254 106 8 199
f 156 108 107 155
f 109 108 156 157
f 110 109 157 158
f 155 107 110 158
f 70 111 112 76
f 76 112 113 72
f 72 113 114 40
f 40 114 115 77
f 77 115 298 249
f 292 116 80 285
f 79 117 307 286
f 80 118 117 79
f 80 116 119 118
f 81 73 119 116
f 78 120 121 75
f 75 121 122 118
f 118 122 123 117
f 117 123 120 78
f 124 125 127 126
f 128 130 131 129
f 124 128 129 125
f 125 129 131 127
f 127 131 130 126
f 126 130 128 124
f 340 132 136 339
f 137 134 341 342
f 134 137 136 132
f 339 136 133 343
f 137 342 344 135
f 136 137 135 133
f 346 138 139 345
f 138 140 141 139
f 146 148 149 147
f 142 146 147 143
f 143 147 149 145
f 144 148 146 142
f 187 186 185 154
f 49 156 155 48
f 157 156 49 50
f 157 50 51 158
f 48 155 158 51
f 101 160 159 100
f 102 161 160 101
f 162 161 102 103
f 159 162 103 100
f 164 163 166 165
f 167 170 169 168
f 168 169 172 171
f 173 171 172 174
f 167 173 174 170
f 163 169 170 166
f 164 172 169 163
f 174 172 164 165
f 170 174 165 166
f 176 175 178 177
f 175 179 180 178
f 176 181 179 175
f 182 181 176 177
f 180 182 177 178
f 16 188 189 19
f 190 191 192 43
f 193 194 192 191
f 195 196 194 193
f 198 3 7 197
f 200 201 202 199
f 198 203 204 201
f 197 205 203 198
f 202 206 205 197
f 201 204 206 202
f 3 198 207 208
f 198 201 209 207
f 201 200 15 209
f 207 210 32 208
f 209 211 210 207
f 209 15 31 211
f 213 214 215 212
f 216 217 218 219
f 221 217 216 220
f 188 16 222 223
f 224 219 225 23
f 218 215 225 219
f 226 227 204 203
f 228 226 203 205
f 229 228 205 206
f 227 229 206 204
f 210 399 400 32
f 210 211 401 399
f 211 31 402 401
f 222 36 230 223
f 232 233 234 231
f 69 232 231 235
f 234 233 236 212
f 226 237 238 227
f 228 239 237 226
f 239 228 229 240
f 229 227 238 240
f 242 243 244 241
f 245 246 214 213
f 247 88 89 248
f 250 230 36 249
f 230 251 236 223
f 192 252 104 43
f 194 253 252 192
f 196 254 253 194
f 387 255 256 271
f 258 259 260 257
f 261 262 259 258
f 263 54 262 261
f 257 263 264 265
f 261 266 264 263
f 258 267 266 261
f 258 257 265 267
f 268 269 260 259
f 262 270 268 259
f 388 270 262 54
f 272 273 274 275
f 273 276 277 274
f 276 278 279 277
f 278 272 275 279
f 275 274 280 281
f 274 277 282 280
f 279 283 282 277
f 279 275 281 283
f 214 284 225 215
f 217 231 234 218
f 235 231 217 221
f 218 234 212 215
f 287 288 285 286
f 189 188 233 232
f 69 19 189 232
f 233 188 223 236
f 289 290 291 83
f 213 212 236 251
f 289 292 293 290
f 294 295 296 297
f 299 300 298 111
f 300 299 301 302
f 305 284 303 304
f 303 284 214 246
f 74 303 306 307
f 308 309 310 311
f 246 245 312 313
f 245 314 291 290
f 70 83 291 314
f 245 213 295 294
f 213 251 296 295
f 251 314 297 296
f 297 314 245 294
f 23 225 248 89
f 225 284 247 248
f 247 315 316 88
f 92 37 305 304
f 303 74 92 304
f 305 37 316 315
f 315 247 284 305
f 237 357 317 238
f 239 318 357 237
f 358 318 239 240
f 317 358 240 238
f 319 320 321 322
f 320 323 324 321
f 325 326 324 323
f 319 322 326 325
f 252 197 7 104
f 253 202 197 252
f 254 199 202 253
f 327 328 265 264
f 266 329 327 264
f 267 330 329 266
f 328 330 267 265
f 70 314 299 111
f 314 251 301 299
f 251 230 302 301
f 230 250 300 302
f 250 249 298 300
f 292 285 288 293
f 287 286 307 306
f 288 287 306 313
f 288 313 312 293
f 290 293 312 245
f 303 246 309 308
f 246 313 310 309
f 313 306 311 310
f 306 303 308 311
f 331 332 333 334
f 335 336 337 338
f 331 334 336 335
f 334 333 337 336
f 333 332 338 337
f 332 331 335 338
f 134 132 340 341
f 341 340 339 342
f 339 343 344 342
f 141 140 347 348
f 140 138 346 347
f 346 345 348 347
f 345 139 141 348
f 349 350 351 352
f 353 354 350 349
f 354 355 351 350
f 356 353 349 352
f 357 318 358 317
f 273 272 328 327
f 329 276 273 327
f 329 330 278 276
f 272 278 330 328
f 241 244 322 321
f 242 241 321 324
f 326 243 242 324
f 322 244 243 326
f 360 361 362 359
f 359 362 364 363
f 360 359 363 365
f 366 361 360 365
f 364 362 361 366
f 369 367 368 370
f 370 368 380 377
f 372 383 384 375
f 371 372 375 376
f 373 375 384 381
f 374 376 375 373
f 382 386 376 374
f 367 369 378 379
f 378 377 380 379
f 385 386 384 383
f 385 371 376 386
f 382 381 384 386
f 391 392 389 390
f 396 394 393 395
f 397 400 224 20
f 21 398 397 20
f 220 402 398 21
f 224 400 399 219
f 399 401 216 219
f 401 402 220 216
f 404 403 405 406
f 408 407 410 409
f 411 414 413 412
f 412 413 416 415
f 417 415 416 418
f 411 417 418 414
f 407 413 414 410
f 408 416 413 407
f 418 416 408 409
f 414 418 409 410
f 419 420 422 421
f 423 425 426 424
f 419 423 424 420
f 420 424 426 422
f 422 426 425 421
f 421 425 423 419
# 358 polygons

View File

@@ -0,0 +1,9 @@
FILE magier.obj
FLOATBITS 18
COLOR 160 160 192 48
SUBDIVIDE
SUBDIVIDE
SUBDIVIDE

View File

@@ -0,0 +1,55 @@
# Blender3D v246 OBJ File: pipe.blend
# www.blender3d.org
v 1.000000 -0.068392 -1.000000
v 1.000000 -0.068392 1.000000
v -1.000000 -0.068392 1.000000
v -1.000000 -0.068392 -1.000000
v 1.000000 1.931608 -1.000000
v 0.999999 1.931608 1.000000
v -1.000000 1.931608 1.000000
v -1.000000 1.931608 -1.000000
v -1.000000 7.137950 0.999999
v -1.000000 7.137950 -1.000000
v 0.999999 7.137950 1.000000
v 1.000000 7.137950 -1.000000
v 0.999999 8.430844 2.308585
v 1.000000 9.845057 0.894372
v -1.000000 9.845057 0.894372
v -1.000000 8.430844 2.308585
v -1.000000 11.799010 3.262538
v -1.000001 9.799011 3.262538
v 0.999999 9.799010 3.262539
v 1.000000 11.799009 3.262538
v 0.999999 11.799009 6.610482
v 0.999998 9.799010 6.610483
v -1.000002 11.799010 6.610482
v -1.000002 9.799011 6.610482
v -1.000002 9.885715 9.740471
v -1.000003 8.471502 8.326259
v 0.999997 8.471501 8.326258
v 0.999998 9.885714 9.740470
usemtl Material
s off
f 1 5 6 2
f 2 6 7 3
f 3 7 8 4
f 5 1 4 8
f 8 7 9 10
f 7 6 11 9
f 5 8 10 12
f 6 5 12 11
f 11 12 14 13
f 12 10 15 14
f 9 11 13 16
f 10 9 16 15
f 15 16 18 17
f 16 13 19 18
f 14 15 17 20
f 13 14 20 19
f 19 20 21 22
f 20 17 23 21
f 18 19 22 24
f 17 18 24 23
f 23 24 26 25
f 21 23 25 28
f 22 21 28 27

View File

@@ -0,0 +1,48 @@
# Blender3D v246 OBJ File: speaker.blend
# www.blender3d.org
v 1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
v 1.329818 0.525312 -1.329816
v 1.329816 0.525312 1.329818
v -1.329818 0.525312 1.329817
v -1.329817 0.525312 -1.329817
v -4.513914 1.206360 -4.513916
v -4.513916 1.206361 4.513912
v 4.513912 1.206361 4.513916
v 4.513917 1.206360 -4.513913
v -1.000000 -0.628519 -1.000000
v -1.000000 -0.628519 1.000000
v 1.000000 -0.628519 1.000000
v 1.000000 -0.628519 -1.000000
v -1.000000 -1.110448 1.000000
v -1.000000 -1.110448 -1.000000
v 1.000000 -1.110448 1.000000
v 1.000000 -1.110448 -1.000000
v 0.409877 -0.126748 0.409877
v 0.409877 -0.126748 -0.409876
v -0.409876 -0.126748 -0.409877
v -0.409877 -0.126748 0.409877
usemtl Material
s off
f 5 8 7 6
f 1 5 6 2
f 2 6 7 3
f 3 7 8 4
f 5 1 4 8
f 12 16 13 9
f 14 10 9 13
f 15 11 10 14
f 16 12 11 15
f 16 15 14 13
f 3 4 18 17
f 2 3 17 19
f 4 1 20 18
f 1 2 19 20
f 20 19 17 18
f 11 12 22 21
f 12 9 23 22
f 10 11 21 24
f 9 10 24 23
f 22 23 24 21

View File

@@ -0,0 +1,13 @@
FILE speaker.obj
FLOATBITS 12
COLOR 192 192 192 64
SUBDIVIDE
SUBDIVIDE
SUBDIVIDE
SUBDIVIDE
SUBDIVIDE

View File

@@ -0,0 +1,746 @@
# 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware
# File Created: 26.08.2010 19:00:58
#
# object yeti
#
v 1.314332127571 10.623770713806 1.420240998268
v 0.625918507576 10.517333030701 -0.526583313942
v 4.180276393890 17.195013046265 3.114506483078
v 4.850432872772 18.508104324341 -1.657061100006
v 4.060075759888 14.474054336548 1.769938468933
v -0.210936114192 14.025011062622 2.174564361572
v 4.353685379028 13.984340667725 -2.981467485428
v 2.066122293472 12.645709991455 1.764097332954
v 1.592382907867 11.209568977356 -1.731272697449
v -0.351546078920 13.067730903625 1.409396290779
v 1.702728748322 10.285366058350 0.728078603745
v 4.107552051544 18.050165176392 1.806145668030
v 4.937689304352 13.950608253479 -0.724246323109
v 3.771867513657 13.440473556519 -0.119294166565
v 2.363398551941 14.853709220886 0.849438130856
v 1.231210708618 12.911808013916 1.105312705040
v 0.776429951191 11.803779602051 1.086931228638
v 3.176019430161 16.640167236328 1.976472973824
v -0.493189245462 8.650757789612 0.510106861591
v 0.560467302799 8.809416770935 -1.298832654953
v 1.795096039772 9.138214111328 0.887199282646
v 1.241387605667 8.873748779297 2.078572511673
v -0.063236355782 16.776367187500 3.432990312576
v -0.149306580424 14.022768020630 3.082942962646
v 3.408163547516 14.440959930420 1.539299845695
v 3.767860174179 16.336364746094 2.781335353851
v 0.585282623768 10.529923439026 2.054375410080
v 0.105524852872 9.734599113464 2.366200685501
v 0.429444968700 11.356166839600 -0.881854951382
v -0.634224951267 11.198785781860 -0.740007579327
v 2.040129899979 11.267612457275 1.036928892136
v 1.402403354645 11.592227935791 1.951820135117
v -0.023261681199 11.007268905640 2.275835275650
v 0.752508461475 10.940473556519 2.067555189133
v 0.598677039146 11.656700134277 1.826556682587
v -0.161381125450 11.763227462769 1.925493717194
v 0.897665858269 12.768471717834 1.547745466232
v -0.095756396651 12.868602752686 1.753116846085
v -0.136435151100 12.122369766235 1.787559509277
v 0.686979055405 12.059694290161 1.658589243889
v 1.786469697952 13.892630577087 1.921871066093
v 0.111171841621 13.700503349304 2.584665536880
v 0.024621203542 13.242889404297 1.933269262314
v 1.416505455971 13.183135032654 1.701570153236
v 0.671737015247 19.294443130493 -2.484138250351
v 3.314612865448 18.157123565674 -2.005704879761
v 3.201619625092 15.928068161011 -2.885510206223
v 0.124579235911 16.981613159180 -3.827348947525
v 3.163069248199 -0.294663816690 6.847945690155
v 5.076788902283 -0.294663816690 6.223717689514
v 1.707496166229 -0.010998446494 2.385535717010
v 3.621215581894 -0.010998446494 1.761307597160
v 0.238128811121 7.458798408508 1.691676855087
v 1.359109878540 8.209510803223 1.622428774834
v 0.238128691912 7.232666015625 -0.791580855846
v 1.359109878540 8.196269035339 0.246045008302
v 4.987578392029 18.123369216919 1.694012045860
v 4.457374095917 16.583663940430 1.997020363808
v 4.279422760010 14.948985099792 1.385898232460
v 5.448926448822 15.047858238220 0.593832254410
v 6.484005451202 14.838102340698 -1.623559951782
v 6.321901321411 18.593492507935 -0.841494858265
v 8.317439079285 15.172784805298 3.453292369843
v 7.220720767975 14.388467788696 4.137443542480
v 7.572786808014 12.430075645447 5.189960479736
v 9.230917930603 11.755267143250 5.368982315063
v 10.844825744629 11.872086524963 3.723229169846
v 10.553778648376 13.638566017151 2.283097982407
v 12.019544601440 16.563951492310 8.847179412842
v 10.816220283508 16.585742950439 9.058531761169
v 10.668390274048 15.567550659180 9.506174087524
v 11.647694587708 14.912013053894 9.755078315735
v 12.806382179260 14.809663772583 9.150767326355
v 12.965273857117 15.847500801086 8.693296432495
v 10.117362022400 17.155076980591 6.269696712494
v 8.205344200134 16.277963638306 6.985670089722
v 7.795433521271 13.702623367310 8.166699409485
v 10.741980552673 12.099314689636 7.966635704041
v 12.484533309937 13.002366065979 6.467772960663
v 12.194471359253 15.725602149963 5.100582599640
v 8.658669471741 14.571877479553 3.607074022293
v 8.143432617188 14.073976516724 3.875048398972
v 8.085231781006 13.382689476013 3.525587558746
v 8.628991127014 13.314910888672 2.948162078857
v 8.960724830627 13.830489158630 2.331645488739
v 9.024043083191 14.538259506226 2.684873342514
v 9.864500999451 15.254542350769 9.291102409363
v 11.941793441772 13.935882568359 8.830650329590
v 12.955663681030 14.940114974976 10.528685569763
v 10.878380775452 16.258773803711 10.989130020142
v 10.465517997742 16.605640411377 8.133187294006
v 11.479391098022 17.609884262085 9.831212997437
v 13.556679725647 16.291212081909 9.370770454407
v 12.552516937256 14.940005302429 7.793585777283
v 4.070079326630 4.635048389435 4.121130466461
v 1.558646321297 4.486677169800 4.965374469757
v 3.121975421906 4.639068126678 1.358950972557
v 1.190529108047 4.497227668762 2.012906074524
v 1.371363162994 5.284864425659 3.807677507401
v 3.058949470520 5.418428897858 3.279914140701
v 2.856006860733 5.493698596954 2.273089170456
v 1.144548773766 5.100633144379 2.682417392731
v 5.235395431519 1.267968416214 3.098830699921
v 3.814800262451 0.158752471209 -1.256348729134
v -0.770572721958 0.158752784133 0.239333629608
v 1.192423939705 1.267969369888 4.417592048645
v 11.372889518738 16.501575469971 7.719831943512
v 9.957793235779 16.347127914429 8.211069107056
v 9.769875526428 15.106131553650 9.243859291077
v 11.406728744507 14.230610847473 9.583378791809
v 12.738918304443 14.214807510376 8.602041244507
v 12.731384277344 15.177521705627 7.721199512482
v 0.209453314543 21.996494293213 5.323814392090
v 1.346630334854 22.276943206787 4.506127834320
v 1.274773716927 21.889976501465 3.665192365646
v 0.260266214609 22.921991348267 2.881885051727
v -0.495462775230 22.508146286011 5.176055431366
v 0.434058725834 18.503526687622 2.600007057190
v 2.744607925415 19.292034149170 2.064757823944
v 2.994823694229 19.725376129150 1.225018262863
v -1.024152755737 19.489009857178 5.193631172180
v 0.394533455372 19.622484207153 5.221730709076
v 1.601295948029 20.445066452026 4.589701652527
v 2.188350677490 20.825193405151 2.249223232269
v -0.814185619354 20.990585327148 5.267087936401
v 0.222079247236 20.925880432129 5.160559654236
v 1.956332683563 21.532526016235 4.672331333160
v 1.735772609711 22.165149688721 2.570432901382
v 0.549379646778 22.385635375977 1.404956102371
v 1.232834458351 20.728425979614 4.318493366241
v 1.381327390671 21.440717697144 4.321575164795
v 0.057782933116 20.602193832397 4.788325786591
v -0.214439749718 19.949258804321 4.754437446594
v 1.723861455917 20.723516464233 2.891973018646
v 1.291361451149 22.034339904785 2.630550622940
v 0.578930079937 21.001504898071 3.232609033585
v -0.043895080686 20.993633270264 2.728995323181
v -0.205326437950 19.871749877930 2.873221158981
v 0.924375176430 19.247634887695 2.480952978134
v -0.665877819061 20.298532485962 4.633618354797
v -0.273819565773 20.299499511719 4.756604671478
v -0.234876766801 21.243244171143 4.639650344849
v -0.198173791170 20.362071990967 4.780577182770
v 0.197509706020 20.458591461182 4.845102310181
v 0.047884151340 21.337074279785 4.735821247101
v -0.300373435020 21.254243850708 4.684960842133
v 0.286611765623 20.531881332397 4.825314044952
v 0.635717928410 20.673826217651 4.790056228638
v 0.323594927788 21.525690078735 4.798839092255
v 0.007018841803 21.373706817627 4.841049194336
v 0.759402155876 20.749210357666 4.690922260284
v 1.044423341751 20.930545806885 4.609981060028
v 0.643846035004 21.649518966675 4.637950897217
v 0.370059430599 21.451038360596 4.719588756561
v 11.370756149292 15.403600692749 8.371135711670
v 11.075138092041 15.408411026001 8.421906471252
v 11.046102523804 15.212824821472 8.495439529419
v 11.304404258728 15.048144340515 8.575037956238
v 11.586236000061 15.016310691833 8.408514976501
v 11.619465827942 15.214001655579 8.329041481018
v -0.788815259933 19.639696121216 4.662641048431
v -0.467963755131 19.599403381348 4.764943122864
v -0.411437600851 20.092605590820 4.778760433197
v -0.710743844509 20.131189346313 4.681683063507
v -0.294105172157 19.634372711182 4.744843959808
v 0.001451201737 19.692813873291 4.751884460449
v -0.101606592536 20.160507202148 4.794797420502
v -0.377689898014 20.111114501953 4.793797969818
v 0.102887794375 19.747312545776 4.730805397034
v 0.357470959425 19.846076965332 4.647753715515
v 0.201370924711 20.238107681274 4.699004173279
v -0.044060893357 20.149099349976 4.785582542419
v 0.610186159611 20.165969848633 1.971378684044
v 0.140422150493 19.723609924316 4.419354438782
v 0.125103801489 20.104207992554 4.434136867523
v 0.600193917751 20.497343063354 1.996145725250
v 11.132748603821 14.081577301025 12.261481285095
v 11.344567298889 13.947119712830 12.214531898499
v 11.395352363586 13.914007186890 12.538464546204
v 11.183533668518 14.048475265503 12.585412979126
v 11.754401206970 15.740092277527 12.048895835876
v 12.495170593262 15.269845008850 11.884695053101
v 12.953685760498 15.740643501282 12.604961395264
v 12.212916374207 16.210893630981 12.769162178040
v 5.046970367432 17.185993194580 2.600825071335
v 5.034593105316 15.812689781189 2.853672027588
v 5.085008144379 15.022797584534 2.569435358047
v 6.773377895355 14.102838516235 4.067620277405
v 6.826600074768 14.735031127930 4.387204170227
v 7.297788619995 15.567758560181 4.142139434814
v 0.575494229794 19.858240127563 4.560906410217
v 0.785040438175 19.994735717773 4.472736835480
v 0.488455951214 20.410673141479 4.558507442474
v 0.271131455898 20.263231277466 4.643347263336
v -0.553714632988 21.243156433105 4.536312580109
v -1.433292627335 22.240844726563 4.795571327209
v -1.816316246986 22.717163085938 3.498183250427
v -0.026917345822 23.182056427002 4.227444648743
v -0.337901383638 10.986615180969 2.321347475052
v -1.104154586792 10.973947525024 2.415193080902
v -1.323405981064 11.662999153137 2.111299514771
v -0.516992390156 11.779050827026 1.963051676750
v -1.902063012123 10.831643104553 2.152791738510
v -2.377029657364 10.344623565674 0.954103469849
v -2.484564065933 10.949427604675 0.315402299166
v -2.065407991409 11.586920738220 2.248194456100
v -1.605675339699 10.726692199707 -0.368705689907
v -0.689090073109 9.694777488708 -0.561212480068
v -1.147760391235 11.607524871826 -0.914222896099
v -4.339358329773 16.314424514771 3.626734972000
v -3.643629074097 16.208965301514 2.317269086838
v -3.075538873672 14.776071548462 1.429522633553
v -4.469233989716 14.560177803040 2.633969068527
v -10.429918289185 8.924689292908 4.579857349396
v -10.520167350769 9.003962516785 4.758938312531
v -10.306502342224 9.072105407715 4.980929851532
v -10.117010116577 8.875373840332 4.668329238892
v -1.569898843765 16.997430801392 -3.593836069107
v -1.326125979424 18.978244781494 -2.165946006775
v -4.374059200287 17.878072738647 -1.537585616112
v -4.041964530945 15.643017768860 -2.444267034531
v -2.688011169434 12.735500335693 2.310749053955
v -2.046218395233 12.862777709961 1.567772865295
v -2.421931266785 11.638953208923 -1.228927493095
v -4.975103378296 14.357153892517 -1.801578044891
v -4.703036785126 14.248079299927 0.400856524706
v -4.424059391022 13.877016067505 0.750735044479
v -0.823632359505 12.382283210754 -1.113528490067
v -0.817737281322 13.950378417969 -2.013253211975
v -0.493189245462 8.957030296326 0.101068302989
v -1.566474318504 8.794699668884 -1.274345397949
v -2.807840347290 9.127334594727 0.951287925243
v -1.353462100029 22.415794372559 2.802138566971
v -10.016528129578 9.132749557495 5.028144836426
v -9.932551383972 9.057652473450 4.849781513214
v -2.161795377731 13.767850875854 2.284933567047
v -0.349008202553 13.619172096252 2.600627660751
v -0.418317526579 13.177232742310 1.936998009682
v -1.867313981056 13.021327018738 2.074200868607
v -1.505555152893 12.702034950256 1.963621616364
v -0.441641181707 12.872829437256 1.793002963066
v -0.491593062878 12.131579399109 1.829858660698
v -1.355699777603 12.046169281006 2.015032768250
v 0.086794272065 16.741462707520 3.411396503448
v 0.000724926591 13.987863540649 3.061349391937
v -3.859236955643 14.483927726746 2.253036499023
v -3.993047952652 15.852533340454 3.189259529114
v 0.092090904713 18.027463912964 4.476171493530
v -0.116254843771 17.052566528320 2.559793710709
v -2.227766036987 8.863530158997 2.177206993103
v -1.211458325386 9.758448600769 2.455739259720
v -0.549831867218 9.554021835327 2.418000459671
v -0.493189245462 8.337011337280 2.245642662048
v -1.005219459534 10.657509803772 2.386000156403
v -0.299399316311 10.616191864014 2.204678297043
v -1.498715639114 11.666466712952 1.316044807434
v -0.361890435219 11.941252708435 1.408053636551
v -0.207519352436 20.754594802856 -1.004854917526
v -5.100049495697 18.557579040527 -1.031350374222
v -2.969249010086 -0.257548689842 3.435474634171
v -2.404259204865 -0.132012546062 -1.231137752533
v -4.402620792389 -0.132012546062 -1.473081231117
v -4.967611312866 -0.257548689842 3.193531036377
v -5.722054004669 1.205904603004 0.107997611165
v -1.500251889229 1.205871105194 0.619037091732
v -5.176235198975 -0.056890159845 -4.400267601013
v -0.954445183277 -0.056889243424 -3.889132261276
v -4.698151588440 18.087125778198 1.963422179222
v -4.881496429443 16.774679183960 2.326860427856
v -6.297142982483 17.526973724365 1.072813034058
v -4.364029407501 14.474310874939 0.921766996384
v -5.204586029053 14.471834182739 -0.193547293544
v -6.351468086243 14.453694343567 -1.939906835556
v -7.011885166168 17.173263549805 -1.356396913528
v -5.996282577515 16.860298156738 2.022351026535
v -5.131925106049 16.072990417480 2.431679248810
v -7.009764671326 13.393430709839 2.497391939163
v -7.491403579712 13.558509826660 2.256341457367
v -4.916592121124 15.322458267212 2.043268203735
v -6.652422904968 13.067894935608 2.191553354263
v -7.620923519135 11.747973442078 0.505180597305
v -7.255540370941 11.885508537292 1.198909282684
v -8.045276641846 12.324373245239 -0.086816988885
v -8.544428825378 12.776358604431 0.333025634289
v -8.410820960999 12.733423233032 1.315567016602
v -9.090394020081 14.267187118530 2.567953586578
v -7.416586399078 13.760046958923 2.804419994354
v -8.064449310303 12.104849815369 5.519719123840
v -10.654025077820 12.457002639771 5.534173011780
v -6.546365261078 12.123166084290 2.412967920303
v -6.792917728424 10.162062644958 4.677184104919
v -7.363391876221 10.785151481628 1.530357599258
v -8.784414291382 8.268274307251 2.743216276169
v -8.907815933228 11.117248535156 -0.152283146977
v -10.994162559509 9.155460357666 2.088630437851
v -10.003880500793 13.130916595459 -0.000861645734
v -12.128422737122 11.730845451355 3.292875289917
v -9.209101676941 9.817576408386 6.054382324219
v -10.711824417114 9.773313522339 5.967722415924
v -8.476883888245 8.817212104797 5.003099441528
v -9.730105400085 7.830090999603 3.995076417923
v -11.298230171204 8.255322456360 3.681793689728
v -11.857752799988 9.407767295837 4.762355327606
v -7.795100688934 12.905997276306 1.623378753662
v -8.572031974792 8.752280235291 5.144316196442
v -10.437286376953 8.307763099670 3.535209417343
v -10.949327468872 6.454314708710 4.640764236450
v -9.084073066711 6.898839473724 6.249881267548
v -9.747138977051 9.728564262390 6.236776828766
v -10.259181022644 7.875117778778 7.342337608337
v -12.124428749084 7.430591106415 5.733224391937
v -11.612391471863 9.284042358398 4.627660751343
v -8.525933265686 5.432276248932 4.259545803070
v -8.716138839722 5.386947154999 4.095461368561
v -8.645595550537 5.065109729767 4.102601528168
v -8.455398559570 5.110433578491 4.266685962677
v -3.508063554764 4.668843269348 0.389148205519
v -3.363759279251 5.636010169983 1.117675781250
v -3.571665525436 5.975960731506 2.209834337234
v -4.078780651093 5.064280986786 3.225779771805
v -1.505940675735 4.592480659485 0.794044971466
v -1.643558382988 5.308066368103 1.547214269638
v -1.476429462433 4.999841690063 3.741227865219
v -1.851463794708 5.648015975952 2.639372825623
v -2.345488548279 8.403146743774 2.449186563492
v -1.224507331848 7.653771400452 2.512281179428
v -2.345488548279 8.391988754272 1.063202857971
v -1.224507331848 7.427639007568 0.029023583978
v -9.747764587402 8.741217613220 6.305990219116
v -10.929364204407 8.498507499695 6.110970497131
v -9.291212081909 8.288903236389 5.386250495911
v -10.003801345825 7.644118785858 4.660173892975
v -11.267092704773 7.774911403656 4.335814476013
v -11.740447044373 8.234076499939 5.272163867950
v -2.647537946701 18.607414245605 2.403655767441
v -0.398358345032 18.544706344604 2.567007780075
v -3.177245140076 19.814607620239 0.286162763834
v 1.042062282562 21.082956314087 -0.560458004475
v 0.060336455703 18.605728149414 2.950746059418
v -2.518361330032 20.796836853027 3.281527757645
v -2.087504386902 19.914682388306 4.453348159790
v -1.590026617050 21.105251312256 1.043216586113
v 0.769906103611 21.894365310669 0.154594197869
v -1.599653840065 20.973529815674 1.832125663757
v -0.890138566494 22.184608459473 1.911024808884
v -0.833358108997 21.057140350342 2.772016286850
v -0.193734630942 19.245420455933 2.292565822601
v -1.190763831139 22.378578186035 1.611273765564
v -2.673269271851 21.928880691528 3.181867837906
v -1.639484167099 21.142704010010 4.568805694580
v -2.025445938110 21.726961135864 3.222366094589
v -2.020741939545 21.001731872559 3.281077146530
v -1.362013339996 20.753194808960 4.339628219604
v -0.736630856991 20.701667785645 4.860389709473
v -1.240293264389 20.054353713989 4.436268329620
v -0.867165565491 19.970785140991 4.969744205475
v -0.750081062317 20.308370590210 4.607372283936
v -1.136039257050 20.399627685547 4.487499237061
v -0.872017204762 21.324506759644 4.433781623840
v -1.197673797607 20.476682662964 4.467945098877
v -1.534822702408 20.635271072388 4.299048900604
v -1.171107053757 21.480421066284 4.342116832733
v -0.860022306442 21.329694747925 4.505421161652
v -1.582044243813 20.713603973389 4.234140872955
v -1.819215536118 20.888000488281 4.007954120636
v -1.417783737183 21.698492050171 4.231680393219
v -1.184795141220 21.520507812500 4.456363677979
v -1.849651455879 20.974643707275 3.858372926712
v -2.002878665924 21.191648483276 3.634537696838
v -1.579282402992 21.841094970703 3.911918401718
v -1.426054954529 21.624097824097 4.135755538940
v -0.833851635456 19.582759857178 4.638945102692
v -1.161524534225 19.614780426025 4.543101310730
v -1.075525045395 20.167078018188 4.572563648224
v -0.771468758583 20.138029098511 4.662826538086
v -1.273487329483 19.667001724243 4.433852672577
v -1.497527360916 19.770359039307 4.279274940491
v -1.321674704552 20.293586730957 4.414492607117
v -1.108669519424 20.193805694580 4.566733360291
v -1.571323990822 19.839405059814 4.201626777649
v -1.705143213272 19.960283279419 3.994483232498
v -1.495726823807 20.411911010742 4.167451858521
v -1.364056110382 20.290054321289 4.373929023743
v -0.132663473487 20.159912109375 1.729213118553
v -1.359064936638 19.852714538574 3.955346345901
v -1.297272562981 20.232295989990 3.989447832108
v -0.125787690282 20.479883193970 1.756808638573
v -10.107940673828 5.393135070801 5.211322784424
v -9.442782402039 5.551656246185 5.785136699677
v -10.358691215515 4.600616455078 5.720925331116
v -9.693542480469 4.759130001068 6.294745445251
v -1.772950768471 20.059461593628 3.827646493912
v -1.868857145309 20.220109939575 3.639699459076
v -1.614065289497 20.609409332275 3.895127534866
v -1.515480995178 20.443634033203 4.083107948303
# 395 vertices
g yeti
f 113 114 198 117
f 33 34 35 36
f 11 31 32 1
f 2 208 30 29
f 18 15 5 3
f 160 155 158 159
f 45 46 47 48
f 8 5 15 16
f 9 7 13 14
f 229 7 9 228
f 19 230 20 55
f 115 116 198 114
f 2 29 31 11
f 155 156 157 158
f 5 8 14 13
f 42 43 44 41
f 37 38 39 40
f 23 24 25 26
f 248 249 18 3
f 208 2 20 230
f 2 11 21 20
f 11 1 22 21
f 22 28 252 253
f 249 6 24 23
f 6 15 25 24
f 15 18 26 25
f 18 249 23 26
f 27 255 252 28
f 22 1 27 28
f 27 1 32 17
f 31 14 8 32
f 228 9 29 30
f 29 9 14 31
f 32 8 16 17
f 255 27 34 33
f 27 17 35 34
f 17 257 36 35
f 257 255 33 36
f 16 10 38 37
f 10 257 39 38
f 257 17 40 39
f 17 16 37 40
f 15 6 42 41
f 6 10 43 42
f 10 16 44 43
f 16 15 41 44
f 258 4 46 45
f 4 7 47 46
f 7 229 48 47
f 229 258 45 48
f 49 51 52 50
f 50 103 106 49
f 50 52 104 103
f 51 105 104 52
f 49 106 105 51
f 57 12 3 58
f 3 5 59 58
f 5 13 60 59
f 13 7 61 60
f 7 4 62 61
f 4 12 57 62
f 186 189 190 185
f 187 188 189 186
f 60 84 83 59
f 60 61 85 84
f 61 62 86 85
f 57 81 86 62
f 63 64 76 75
f 65 77 76 64
f 66 78 77 65
f 66 67 79 78
f 67 68 80 79
f 63 75 80 68
f 108 107 75 76
f 77 109 108 76
f 78 110 109 77
f 111 110 78 79
f 112 111 79 80
f 107 112 80 75
f 82 64 63 81
f 83 65 64 82
f 84 66 65 83
f 67 66 84 85
f 68 67 85 86
f 81 63 68 86
f 87 88 89 90
f 91 92 93 94
f 87 90 92 91
f 177 178 179 180
f 89 88 94 93
f 88 87 91 94
f 101 100 95 97
f 98 102 101 97
f 99 102 98 96
f 54 53 99 100
f 56 54 100 101
f 102 55 56 101
f 53 55 102 99
f 95 96 106 103
f 97 95 103 104
f 98 97 104 105
f 106 96 98 105
f 70 69 107 108
f 71 70 108 109
f 110 72 71 109
f 73 72 110 111
f 74 73 111 112
f 69 74 112 107
f 21 22 54 56
f 22 253 53 54
f 253 19 55 53
f 99 96 95 100
f 3 12 119 118
f 12 4 120 119
f 258 338 120 4
f 248 3 118 339
f 119 123 122 118
f 120 124 123 119
f 343 124 120 338
f 122 121 339 118
f 134 135 136 139
f 124 128 127 123
f 129 128 124 343
f 139 136 137 138
f 127 114 113 126
f 127 128 115 114
f 129 116 115 128
f 126 113 117 125
f 123 127 131 130
f 127 126 132 131
f 126 125 354 132
f 121 122 133 356
f 122 123 130 133
f 130 131 135 134
f 131 132 136 135
f 132 354 137 136
f 356 133 139 138
f 133 130 134 139
f 140 141 142 195
f 143 144 145 146
f 147 148 149 150
f 151 152 153 154
f 69 70 156 155
f 70 71 157 156
f 71 72 158 157
f 72 73 159 158
f 73 74 160 159
f 74 69 155 160
f 161 162 163 164
f 165 166 167 168
f 169 170 171 172
f 174 175 386 385
f 174 173 176 175
f 89 182 181 90
f 89 93 183 182
f 92 184 183 93
f 90 181 184 92
f 178 177 181 182
f 179 178 182 183
f 180 179 183 184
f 181 177 180 184
f 57 58 186 185
f 58 59 187 186
f 59 83 188 187
f 83 82 189 188
f 82 81 190 189
f 81 57 185 190
f 191 192 193 194
f 196 117 198 197
f 199 202 201 200
f 204 203 206 205
f 207 209 30 208
f 211 210 213 212
f 215 214 217 216
f 219 218 221 220
f 222 223 212 213
f 224 227 226 225
f 229 228 224 225
f 19 328 231 230
f 233 197 198 116
f 207 204 205 209
f 216 217 235 234
f 213 226 227 222
f 237 236 239 238
f 240 243 242 241
f 244 247 246 245
f 248 210 211 249
f 208 230 231 207
f 207 231 232 204
f 204 232 250 203
f 250 253 252 251
f 249 244 245 6
f 6 245 246 212
f 212 246 247 211
f 211 247 244 249
f 254 251 252 255
f 250 251 254 203
f 254 256 206 203
f 205 206 222 227
f 228 30 209 224
f 209 205 227 224
f 206 256 223 222
f 255 199 200 254
f 254 200 201 256
f 256 201 202 257
f 257 202 199 255
f 223 240 241 10
f 10 241 242 257
f 257 242 243 256
f 256 243 240 223
f 212 236 237 6
f 6 237 238 10
f 10 238 239 223
f 223 239 236 212
f 258 219 220 259
f 259 220 221 225
f 225 221 218 229
f 229 218 219 258
f 260 263 262 261
f 263 260 265 264
f 263 264 266 262
f 261 262 266 267
f 260 261 267 265
f 268 270 269 210
f 210 269 271 213
f 213 271 272 226
f 226 272 273 225
f 225 273 274 259
f 259 274 270 268
f 276 275 278 277
f 279 276 277 280
f 272 271 282 281
f 272 281 283 273
f 273 283 284 274
f 270 274 284 285
f 286 289 288 287
f 290 287 288 291
f 292 290 291 293
f 292 293 295 294
f 294 295 297 296
f 286 296 297 289
f 298 288 289 299
f 291 288 298 300
f 293 291 300 301
f 302 295 293 301
f 303 297 295 302
f 299 289 297 303
f 304 285 286 287
f 282 304 287 290
f 281 282 290 292
f 294 283 281 292
f 296 284 283 294
f 285 284 296 286
f 305 308 307 306
f 309 312 311 310
f 305 309 310 308
f 313 316 315 314
f 307 311 312 306
f 306 312 309 305
f 318 317 320 319
f 321 317 318 322
f 324 323 321 322
f 325 319 324 326
f 327 318 319 325
f 322 318 327 328
f 326 324 322 328
f 320 264 265 323
f 317 266 264 320
f 321 267 266 317
f 265 267 321 323
f 329 298 299 330
f 331 300 298 329
f 301 300 331 332
f 333 302 301 332
f 334 303 302 333
f 330 299 303 334
f 232 327 325 250
f 250 325 326 253
f 253 326 328 19
f 324 319 320 323
f 210 336 335 268
f 268 335 337 259
f 258 259 337 338
f 248 339 336 210
f 335 336 341 340
f 337 335 340 342
f 343 338 337 342
f 341 336 339 121
f 344 347 346 345
f 342 340 349 348
f 129 343 342 348
f 347 138 137 346
f 349 350 196 197
f 349 197 233 348
f 129 348 233 116
f 350 125 117 196
f 340 352 351 349
f 349 351 353 350
f 350 353 354 125
f 121 356 355 341
f 341 355 352 340
f 352 344 345 351
f 351 345 346 353
f 353 346 137 354
f 356 138 347 355
f 355 347 344 352
f 357 195 359 358
f 360 363 362 361
f 364 367 366 365
f 368 371 370 369
f 330 216 234 329
f 329 234 235 331
f 331 235 217 332
f 332 217 214 333
f 333 214 215 334
f 334 215 216 330
f 372 375 374 373
f 376 379 378 377
f 380 383 382 381
f 384 173 174 385
f 176 387 386 175
f 385 386 387 384
f 307 308 389 388
f 307 388 390 311
f 310 311 390 391
f 308 310 391 389
f 314 388 389 313
f 315 390 388 314
f 316 391 390 315
f 389 391 316 313
f 270 275 276 269
f 269 276 279 271
f 271 279 280 282
f 282 280 277 304
f 304 277 278 285
f 285 278 275 270
f 392 395 394 393
f 20 21 56 55
f 327 232 231 328
# 339 polygons

View File

@@ -0,0 +1,9 @@
FILE yeti.obj
FLOATBITS 18
COLOR 256 256 256 24
SUBDIVIDE
SUBDIVIDE
SUBDIVIDE

View File

@@ -0,0 +1,30 @@
#pragma once
#ifndef BINMESHDATA_HEADER
#define BINMESHDATA_HEADER
struct BinVertex
{
float m_Pos[ 3 ];
};
struct BinMesh
{
int m_PrimitiveCount;
unsigned char* m_pTopology;
BinVertex* m_pVertex;
void Set( int PrimitiveCount,
unsigned char* Vertex,
unsigned char* Topology )
{
m_PrimitiveCount= PrimitiveCount;
m_pVertex= (BinVertex*)Vertex;
m_pTopology= Topology;
}
static const unsigned char c_FinishPoly= 255;
static const unsigned char c_FarVertex= 254;
};
#endif

View File

@@ -0,0 +1,957 @@
#include "defines.h"
#include "ConfigFiles.h"
#include "globals.h"
#include "ShaderFactory.h"
#include "textinfo.h"
#include "entityinfo.h"
#include "intrin.h"
#include "greebledata.h"
#include "cave.h"
HANDLE g_FileChangeNotification= NULL;
static std::string g_strShaderData;
extern int g_iActLoadStep;
void StopFileWatch()
{
if (g_FileChangeNotification != INVALID_HANDLE_VALUE && g_FileChangeNotification != NULL)
{
FindCloseChangeNotification(g_FileChangeNotification);
}
g_FileChangeNotification= NULL;
}
void StartFileWatch()
{
StopFileWatch();
std::string strPath= ".\\cfg\\";
g_FileChangeNotification= FindFirstChangeNotification(
strPath.c_str(),
FALSE,
FILE_NOTIFY_CHANGE_LAST_WRITE );
}
bool CheckFileWatch()
{
if (g_FileChangeNotification == INVALID_HANDLE_VALUE || g_FileChangeNotification == NULL)
{
return false;
}
DWORD dwRet= WaitForSingleObject( g_FileChangeNotification, 1 );
if( WAIT_OBJECT_0 == dwRet )
{
FindNextChangeNotification( g_FileChangeNotification );
g_iActLoadStep= 0;
ReadDataFromDisc();
// Shader neu compilieren
PrepareShaders();
//Texte neu setzen
CreateTextRenderJobs();
SetCrystalPos();
return true;
}
return false;
}
void ReadSceneTxt()
{
FrameWork::TextFileReader tfr;
tfr.read( "cfg/scene.txt" );
for( int i= 0; i < (int)tfr.getFileLines().size(); ++i )
{
std::string strAct= tfr.getFileLines()[ i ];
std::string strCommandFull;
if( FrameWork::StringHelper::splitAt( strAct, "=", strCommandFull ) )
{
}
std::stringstream ss;
ss << strAct;
if( strCommandFull.size() < 4 )
{
continue;
}
int iFunc= strCommandFull[ strCommandFull.size() - 1 ] - '0';
iFunc+= 10 * ( strCommandFull[ strCommandFull.size() - 2 ] - '0' );
iFunc+= 100 * ( strCommandFull[ strCommandFull.size() - 3 ] - '0' );
std::string strCommand;
strCommand= strCommandFull.substr( 0, strCommandFull.size() - 3 );
if( strCommand == "SCENE" )
{
DWORD dwMask= 0;
for( int j= 0; j < 32; ++j )
{
char c= '.';
ss >> c;
if( c != '.' )
{
dwMask|= 1 << j;
}
}
g_SceneMask[ iFunc ]= dwMask;
}
}
}
int g_iCurSpriptLength;
int g_iCurSpriptParams;
void ReadScriptTxt()
{
/*
g_iCurSpriptLength= 0;
g_iCurSpriptParams= 0;
FrameWork::TextFileReader tfrScript;
tfrScript.read( "cfg/script.txt" );
//#ifdef SCRIPTEDITOR
for( int i= 0; i < (int)tfrScript.getFileLines().size(); ++i )
{
std::string strAct= tfrScript.getFileLines()[ i ];
std::string strCommandFull;
if( FrameWork::StringHelper::splitAt( strAct, "=", strCommandFull ) )
{
}
std::stringstream ss;
ss << strAct;
if( strCommandFull == "SKIP" )
{
#ifdef SCRIPTEDITOR
ss >> g_iSkipTicks;
#endif
}
if( strCommandFull == "CLEAN" )
{
g_iCurSpriptLength= 0;
g_iCurSpriptParams= 0;
}
else if( strCommandFull == "CSPEED" )
{
g_Script[ g_iCurSpriptLength++ ]= CSPEED;
ss >> g_ScriptParamFloat[ g_iCurSpriptParams++ ];
}
else if( strCommandFull == "OSPEED" )
{
g_Script[ g_iCurSpriptLength++ ]= OSPEED;
ss >> g_ScriptParamFloat[ g_iCurSpriptParams++ ];
}
else if( strCommandFull == "CTIME" )
{
g_Script[ g_iCurSpriptLength++ ]= CTIME;
ss >> g_ScriptParamFloat[ g_iCurSpriptParams++ ];
}
else if( strCommandFull == "OTIME" )
{
g_Script[ g_iCurSpriptLength++ ]= OTIME;
ss >> g_ScriptParamFloat[ g_iCurSpriptParams++ ];
}
else if( strCommandFull == "CAM" )
{
g_Script[ g_iCurSpriptLength++ ]= CAM;
int iVal= 0;
ss >> iVal;
g_Script[ g_iCurSpriptLength++ ]= iVal;
}
else if( strCommandFull == "CAM" )
{
g_Script[ g_iCurSpriptLength++ ]= CAM;
int iVal= 0;
ss >> iVal;
g_Script[ g_iCurSpriptLength++ ]= iVal;
}
else if( strCommandFull == "OBJ" )
{
g_Script[ g_iCurSpriptLength++ ]= OBJ;
int iVal= 0;
ss >> iVal;
g_Script[ g_iCurSpriptLength++ ]= iVal;
iVal= 0;
ss >> iVal;
g_Script[ g_iCurSpriptLength++ ]= iVal;
}
else if( strCommandFull == "TICK" )
{
g_Script[ g_iCurSpriptLength++ ]= TICK;
int iVal= 0;
ss >> iVal;
g_Script[ g_iCurSpriptLength++ ]= iVal;
}
else if( strCommandFull == "QUIT" )
{
g_Script[ g_iCurSpriptLength++ ]= QUIT;
}
}
//#endif
*/
}
void SetParamValue( int Bank, int i, float fVal )
{
g_GreebleParam[ Bank * 4 + i ]= fVal;
}
void ReadParamTxt()
{
FrameWork::TextFileReader tfrSong;
tfrSong.read( "cfg/param.txt" );
for( int i= 0; i < (int)tfrSong.getFileLines().size(); ++i )
{
std::string strAct= tfrSong.getFileLines()[ i ];
std::string strCommandFull;
if( FrameWork::StringHelper::splitAt( strAct, "=", strCommandFull ) )
{
}
std::stringstream ss;
ss << strAct;
#ifdef SINGLEEDITMODE
if( strCommandFull == "PCUR" )
{
ss >> g_iCurrentPortrait;
}
else if( strCommandFull == "OCUR" )
{
ss >> g_iCurrentObject;
}
else if( strCommandFull == "OCOUNT" )
{
ss >> g_iCurrentObjectCount;
}
else if( strCommandFull == "CCUR" )
{
ss >> g_iCurrentCamera;
}
#endif
if( strCommandFull.size() < 4 )
{
continue;
}
int iFunc= strCommandFull[ strCommandFull.size() - 1 ] - '0';
iFunc+= 10 * ( strCommandFull[ strCommandFull.size() - 2 ] - '0' );
iFunc+= 100 * ( strCommandFull[ strCommandFull.size() - 3 ] - '0' );
std::string strCommand;
strCommand= strCommandFull.substr( 0, strCommandFull.size() - 3 );
if( strCommand == "BANK" )
{
for( int j= 0; j < 4; ++j )
{
float fVal= 0.0f;
ss >> fVal;
int iVal= (int)( fVal * 64.0f + 0.5f );
fVal= (float)( iVal ) / 64.0f;
SetParamValue( iFunc, j, fVal );
}
}
else if( strCommand == "SIZE" )
{
ss >> g_GreebleObj[ iFunc ].m_iSizeX;
ss >> g_GreebleObj[ iFunc ].m_iSizeY;
}
else if( strCommand == "BASE" )
{
ss >> g_GreebleObj[ iFunc ].m_iBaseMeshType;
ss >> g_GreebleObj[ iFunc ].m_iBaseBank;
}
else if( strCommand == "OFFSET" )
{
ss >> g_GreebleObj[ iFunc ].m_iOffsetFunc;
ss >> g_GreebleObj[ iFunc ].m_iOffsetBank;
}
else if( strCommand == "HEIGHT" )
{
ss >> g_GreebleObj[ iFunc ].m_iHeightFunc;
ss >> g_GreebleObj[ iFunc ]. m_iHeightBank;
}
else if( strCommand == "MIX" )
{
ss >> g_GreebleObj[ iFunc ].m_iMixFunc;
ss >> g_GreebleObj[ iFunc ].m_iMixBank;
}
else if( strCommand == "COLOR" )
{
float fR;
float fG;
float fB;
float fA;
ss >> fR;
ss >> fG;
ss >> fB;
ss >> fA;
fR= min( 255.0f, fR );
fG= min( 255.0f, fG );
fB= min( 255.0f, fB );
fA= min( 255.0f, fA );
DWORD dwColor= ( (int)fA << 24 ) |
( (int)fR << 16 ) |
( (int)fG << 8 ) |
( (int)fB );
g_GreebleObj[ iFunc ].m_dwColor= dwColor;
}
#ifdef SINGLEFUNCEDITOR
/*if( strCommand == "DRAW" )
{
ss >> g_iCamFunc;
ss >> g_iPaintFunc[ 0 ];
ss >> g_iPaintFunc[ 1 ];
}
if( strCommand == "CAMREPEAT" )
{
ss >> g_iCamRepeat;
}*/
#endif
}
}
void ReadShader( char* pcTarget, const char* pcVarName, const char* pcFileName )
{
FrameWork::TextFileReader tfrShaderTxt;
tfrShaderTxt.read( pcFileName );
//shorten the data?
int iPos= 0;
for( int i= 0; i < (int)tfrShaderTxt.getFileLines().size(); ++i )
{
std::string strAct= tfrShaderTxt.getFileLines()[ i ];
bool bNonWhiteFound= false;
for( size_t j= 0; j < strAct.size(); ++j )
{
char c= strAct[ j ];
if( c == ' ' && !bNonWhiteFound )
{
continue;
}
if( c == '\t' && !bNonWhiteFound )
{
continue;
}
bNonWhiteFound= true;
if( c == '/' && strAct[ j + 1 ] == '/' )
{
break;
}
pcTarget[ iPos ]= c;
iPos++;
}
// better readability?
pcTarget[ iPos ]= 13;
iPos++;
}
pcTarget[ iPos ]= 0;
std::stringstream ss;
ss << "const char " << pcVarName << "[]=\n";
ss << "\"";
int iCount= 0;
char cPrevious= 0;
while( pcTarget[ iCount ] != 0 )
{
char c= pcTarget[ iCount ];
if( c == 13 )
{
if( 13 != cPrevious && 10 != cPrevious )
{
ss << "\\n\"\n\"";
}
}
else
{
ss << c;
}
cPrevious= c;
iCount++;
}
ss << "\";\n\n";
g_strShaderData+= ss.str();
}
void ReadShaders()
{
g_strShaderData= "";
ReadShader( g_ShaderVSGeneral, "g_ShaderVSGeneral", "cfg/vsgeneral.txt" );
ReadShader( g_ShaderPSPhong, "g_ShaderPSPhong", "cfg/psphong.txt" );
ReadShader( g_ShaderPSCrystal, "g_ShaderPSCrystal", "cfg/pscrystal.txt" );
ReadShader( g_ShaderPSDepth, "g_ShaderPSDepth", "cfg/psdepth.txt" );
ReadShader( g_ShaderPSText, "g_ShaderPSText", "cfg/pstext.txt" );
ReadShader( g_ShaderPSEnvLit, "g_ShaderPSEnvLit", "cfg/psenvlit.txt" );
ReadShader( g_ShaderVSSky, "g_ShaderVSSky", "cfg/vssky.txt" );
ReadShader( g_ShaderPSSky, "g_ShaderPSSky", "cfg/pssky.txt" );
ReadShader( g_ShaderVSOcean, "g_ShaderVSOcean", "cfg/vsocean.txt" );
ReadShader( g_ShaderPSOcean, "g_ShaderPSOcean", "cfg/psocean.txt" );
ReadShader( g_ShaderVSFSQuad, "g_ShaderVSFSQuad", "cfg/vsfsquad.txt" );
ReadShader( g_ShaderPSTexGen, "g_ShaderPSTexGen", "cfg/pstexgen.txt" );
ReadShader( g_ShaderPSPSSM, "g_ShaderPSPSSM", "cfg/pspssm.txt" );
ReadShader( g_ShaderPSAmbOcc, "g_ShaderPSAmbOcc", "cfg/psao.txt" );
ReadShader( g_ShaderPSDOF, "g_ShaderPSDOF", "cfg/psdof.txt" );
ReadShader( g_ShaderPSRay, "g_ShaderPSRay", "cfg/psray.txt" );
ReadShader( g_ShaderPSBlur, "g_ShaderPSBlur", "cfg/psblur.txt" );
ReadShader( g_ShaderPSTerrain, "g_ShaderPSTerrain", "cfg/psterrain.txt" );
ReadShader( g_ShaderVSFluid, "g_ShaderVSFluid", "cfg/vsfluid.txt" );
ReadShader( g_ShaderPSFluid, "g_ShaderPSFluid", "cfg/psfluid.txt" );
}
void ReadTextInfos()
{
m_iTextCount= -1;
int iCharPos= 0;
STextInfo* pInfo= m_TextInfos;
FrameWork::TextFileReader tfr;
tfr.read( "cfg/text.txt" );
for( int i= 0; i < (int)tfr.getFileLines().size(); ++i )
{
std::string strAct= tfr.getFileLines()[ i ];
std::string strCommandFull;
if( FrameWork::StringHelper::splitAt( strAct, "=", strCommandFull ) )
{
}
std::stringstream ss;
ss << strAct;
if( strCommandFull == "Text" )
{
if( m_iTextCount < m_iMaxTextCount )
{
m_iTextCount++;
pInfo= m_TextInfos + m_iTextCount;
}
strcpy_s( m_pcTextData + iCharPos, sizeof( m_pcTextData ) - iCharPos, strAct.c_str() );
iCharPos+= strAct.size() + 1;
if( m_iTextCount == 0 )
{
pInfo->m_v3Pos.x= 0.0f;
pInfo->m_v3Pos.y= 0.0f;
pInfo->m_v3Pos.z= 0.0f;
pInfo->m_v3Rot.x= 0.0f;
pInfo->m_v3Rot.y= 0.0f;
pInfo->m_v3Rot.z= 0.0f;
pInfo->m_v3Scale.x= 1.0f;
pInfo->m_v3Scale.y= 1.0f;
pInfo->m_v3Scale.z= 1.0f;
}
else
{
*pInfo= m_TextInfos[ m_iTextCount - 1 ];
}
pInfo->m_v3Move.x= 0.0f;
pInfo->m_v3Move.y= 0.0f;
pInfo->m_v3Move.z= 0.0f;
pInfo->m_iTimeStart= 0;
pInfo->m_iTimeLength= 0;
}
else if( strCommandFull == "Pos" )
{
ss >> pInfo->m_v3Pos.x;
ss >> pInfo->m_v3Pos.y;
ss >> pInfo->m_v3Pos.z;
}
else if( strCommandFull == "Rot" )
{
ss >> pInfo->m_v3Rot.x;
ss >> pInfo->m_v3Rot.y;
ss >> pInfo->m_v3Rot.z;
pInfo->m_v3Rot.x*= c_PI / 180.0f;
pInfo->m_v3Rot.y*= c_PI / 180.0f;
pInfo->m_v3Rot.z*= c_PI / 180.0f;
}
else if( strCommandFull == "Scale" )
{
ss >> pInfo->m_v3Scale.x;
ss >> pInfo->m_v3Scale.y;
ss >> pInfo->m_v3Scale.z;
}
else if( strCommandFull == "Move" )
{
ss >> pInfo->m_v3Move.x;
ss >> pInfo->m_v3Move.y;
ss >> pInfo->m_v3Move.z;
}
else if( strCommandFull == "Time" )
{
ss >> pInfo->m_iTimeStart;
ss >> pInfo->m_iTimeLength;
}
}
m_iTextCount++;
}
void ReadEntityInfos()
{
m_iEntityCount= -1;
int iCharPos= 0;
SEntityInfo* pInfo= m_EntityInfos;
FrameWork::TextFileReader tfr;
tfr.read( "cfg/entity.txt" );
for( int i= 0; i < (int)tfr.getFileLines().size(); ++i )
{
std::string strAct= tfr.getFileLines()[ i ];
std::string strCommandFull;
if( FrameWork::StringHelper::splitAt( strAct, "=", strCommandFull ) )
{
}
std::stringstream ss;
ss << strAct;
if( strCommandFull == "Entity" )
{
if( m_iEntityCount < m_iMaxEntityCount )
{
m_iEntityCount++;
pInfo= m_EntityInfos + m_iEntityCount;
}
strcpy_s( m_pcEntityData + iCharPos, sizeof( m_pcEntityData ) - iCharPos, strAct.c_str() );
iCharPos+= strAct.size() + 1;
if( m_iEntityCount == 0 )
{
pInfo->m_v3Pos.x= 0.0f;
pInfo->m_v3Pos.y= 0.0f;
pInfo->m_v3Pos.z= 0.0f;
pInfo->m_v3Rot.x= 0.0f;
pInfo->m_v3Rot.y= 0.0f;
pInfo->m_v3Rot.z= 0.0f;
pInfo->m_v3Scale.x= 1.0f;
pInfo->m_v3Scale.y= 1.0f;
pInfo->m_v3Scale.z= 1.0f;
}
else
{
*pInfo= m_EntityInfos[ m_iEntityCount - 1 ];
}
pInfo->m_v3Move.x= 0.0f;
pInfo->m_v3Move.y= 0.0f;
pInfo->m_v3Move.z= 0.0f;
pInfo->m_iTimeStart= 0;
pInfo->m_iTimeLength= 0;
}
else if( strCommandFull == "Pos" )
{
ss >> pInfo->m_v3Pos.x;
ss >> pInfo->m_v3Pos.y;
ss >> pInfo->m_v3Pos.z;
}
else if( strCommandFull == "Rot" )
{
ss >> pInfo->m_v3Rot.x;
ss >> pInfo->m_v3Rot.y;
ss >> pInfo->m_v3Rot.z;
pInfo->m_v3Rot.x*= c_PI / 180.0f;
pInfo->m_v3Rot.y*= c_PI / 180.0f;
pInfo->m_v3Rot.z*= c_PI / 180.0f;
}
else if( strCommandFull == "Scale" )
{
ss >> pInfo->m_v3Scale.x;
ss >> pInfo->m_v3Scale.y;
ss >> pInfo->m_v3Scale.z;
}
else if( strCommandFull == "Move" )
{
ss >> pInfo->m_v3Move.x;
ss >> pInfo->m_v3Move.y;
ss >> pInfo->m_v3Move.z;
}
else if( strCommandFull == "Time" )
{
ss >> pInfo->m_iTimeStart;
ss >> pInfo->m_iTimeLength;
}
}
m_iEntityCount++;
}
void ReadCrystalInfos()
{
m_iCrystalCount= -1;
SCrystalInfo* pInfo= m_CrystalInfos;
FrameWork::TextFileReader tfr;
tfr.read( "cfg/cryspos.txt" );
for( int i= 0; i < (int)tfr.getFileLines().size(); ++i )
{
std::string strAct= tfr.getFileLines()[ i ];
std::string strCommandFull;
if( FrameWork::StringHelper::splitAt( strAct, "=", strCommandFull ) )
{
}
std::stringstream ss;
ss << strAct;
if( strCommandFull == "Crystal" )
{
if( m_iCrystalCount < m_iMaxCrystalCount )
{
m_iCrystalCount++;
pInfo= m_CrystalInfos + m_iCrystalCount;
}
if( m_iCrystalCount == 0 )
{
pInfo->m_v3Pos.x= 0.0f;
pInfo->m_v3Pos.y= 0.0f;
pInfo->m_v3Pos.z= 0.0f;
pInfo->m_v3Rot.x= 0.0f;
pInfo->m_v3Rot.y= 0.0f;
pInfo->m_v3Rot.z= 0.0f;
pInfo->m_fScale= 1.0f;
}
else
{
*pInfo= m_CrystalInfos[ m_iCrystalCount - 1 ];
}
}
else if( strCommandFull == "Pos" )
{
ss >> pInfo->m_v3Pos.x;
ss >> pInfo->m_v3Pos.y;
ss >> pInfo->m_v3Pos.z;
}
else if( strCommandFull == "Rot" )
{
ss >> pInfo->m_v3Rot.x;
ss >> pInfo->m_v3Rot.y;
ss >> pInfo->m_v3Rot.z;
pInfo->m_v3Rot.x*= c_PI / 180.0f;
pInfo->m_v3Rot.y*= c_PI / 180.0f;
pInfo->m_v3Rot.z*= c_PI / 180.0f;
}
else if( strCommandFull == "Scale" )
{
ss >> pInfo->m_fScale;
}
}
m_iCrystalCount++;
}
void ReadDataFromDisc()
{
ReadParamTxt();
ReadScriptTxt();
ReadShaders();
ReadTextInfos();
ReadEntityInfos();
ReadCrystalInfos();
ReadSceneTxt();
/*static bool bWritten= false;
if( bWritten )
{
return;
}*/
#ifdef CREATE_HEADER
WriteHeader();
#endif
}
void WriteHeaderFunc()
{
std::ofstream ofs( "greeblearrays.h" );
ofs << "const float g_GreebleParam[ 4 * 48 ]=" << "\n";
ofs << "{" << "\n";
for( int i= 0; i < 4 * 48; ++i )
{
char pcSpecial[ 1024 ];
sprintf_s(
pcSpecial,
1024,
"%1.9ff,\n",
g_GreebleParam[ i ] );
ofs << pcSpecial;
}
ofs << "};" << "\n";
ofs << "\n";
{
int iBytes= sizeof( g_GreebleObj );
ofs << "const unsigned char byteObjectData[ " << iBytes <<" ]=" << "\n";
ofs << "{" << "\n";
int iLine= 0;
for( int i= 0; i < iBytes; ++i )
{
ofs << (int)(((unsigned char*)g_GreebleObj)[ i ]) << ",";
iLine++;
if( iLine == 8 )
{
ofs << "\n";
iLine= 0;
}
}
ofs << "\n" << "};" << "\n";
ofs << "Greeble::SObjectDescription* g_GreebleObj= (Greeble::SObjectDescription*)byteObjectData;\n\n";
}
}
void WriteHeaderScript()
{
/*
std::ofstream ofs( "scriptdata.h" );
ofs << "const int g_iScriptLength= " << g_iCurSpriptLength << ";\n";
ofs << "const unsigned char g_Script[ g_iScriptLength ]=" << "\n";
ofs << "{" << "\n";
for( int i= 0; i < g_iCurSpriptLength; ++i )
{
ofs << (int)g_Script[ i ] << ",\n";
}
ofs << "};" << "\n";
ofs << "const float g_ScriptParamFloat[ " << g_iCurSpriptParams << " ]=" << "\n";
ofs << "{" << "\n";
for( int i= 0; i < g_iCurSpriptParams; ++i )
{
char pcSpecial[ 1024 ];
sprintf_s(
pcSpecial,
1024,
"%1.9ff,\n",
g_ScriptParamFloat[ i ] );
ofs << pcSpecial;
}
ofs << "};" << "\n";
ofs << "\n";
ofs << "\n";
*/
}
void WriteSceneHeader()
{
std::ofstream ofs( "scenedata.h" );
int iLast= g_SceneMaskCount - 1;
while( g_SceneMask[ iLast ] == 0 )
{
iLast--;
}
ofs << "DWORD g_SceneMask[]=" << "\n";
ofs << "{" << "\n";
for( int i= 0; i <= iLast; ++i )
{
ofs << g_SceneMask[ i ] << ",\n";
}
ofs << "};" << "\n";
ofs << "\n";
}
void WriterShaderInclude()
{
std::ofstream ofs( "shaderdata.h" );
ofs << g_strShaderData;
}
void WriterTextInclude()
{
std::ofstream ofs( "textdata.h" );
ofs << "int m_iTextCount= " << m_iTextCount <<";\n";
ofs << "\n";
ofs << "const char m_pcTextData[]=\n";
ofs << "{\n";
int iZeroCount= 0;
for( int i= 0; i < 65536; ++i )
{
char pcSpecial[ 1024 ];
sprintf_s(
pcSpecial,
1024,
"\t%d,\n",
(int)m_pcTextData[ i ] );
ofs << pcSpecial;
if( m_pcTextData[ i ] == 0 )
{
iZeroCount++;
if( iZeroCount == m_iTextCount )
{
break;
}
}
}
ofs << "};\n";
ofs << "\n";
ofs << "const DWORD c_BinaryText[]= " << "\n";
ofs << "{\n";
for( int i= 0; i < (int)m_iTextCount; ++i )
{
int dwords= m_iTextCount * sizeof( STextInfo ) / 4;
if( dwords > 0 )
{
DWORD* pdwData= (DWORD*)&(m_TextInfos);
for( int j= 0; j < dwords; ++j )
{
char pcSpecial[ 1024 ];
sprintf_s( pcSpecial,
1024,
"\t%d,\n",
pdwData[ j ] );
ofs << pcSpecial;
}
}
}
if( m_iTextCount == 0 )
{
ofs << "0";
}
ofs << "};\n";
ofs << "\n";
ofs << "STextInfo* m_TextInfos= (STextInfo*)c_BinaryText;\n";
ofs << "\n";
}
void WriterEntityInclude()
{
std::ofstream ofs( "entitydata.h" );
ofs << "int m_iEntityCount= " << m_iEntityCount <<";\n";
ofs << "\n";
ofs << "const char m_pcEntityData[]=\n";
ofs << "{\n";
int iZeroCount= 0;
for( int i= 0; i < 65536; ++i )
{
char pcSpecial[ 1024 ];
sprintf_s(
pcSpecial,
1024,
"\t%d,\n",
(int)m_pcEntityData[ i ] );
ofs << pcSpecial;
if( m_pcEntityData[ i ] == 0 )
{
iZeroCount++;
if( iZeroCount == m_iEntityCount )
{
break;
}
}
}
ofs << "};\n";
ofs << "\n";
ofs << "const DWORD c_BinaryEntity[]= " << "\n";
ofs << "{\n";
for( int i= 0; i < (int)m_iEntityCount; ++i )
{
int dwords= m_iEntityCount * sizeof( SEntityInfo ) / 4;
if( dwords > 0 )
{
DWORD* pdwData= (DWORD*)&(m_EntityInfos);
for( int j= 0; j < dwords; ++j )
{
char pcSpecial[ 1024 ];
sprintf_s( pcSpecial,
1024,
"\t%d,\n",
pdwData[ j ] );
ofs << pcSpecial;
}
}
}
if( m_iEntityCount == 0 )
{
ofs << "0";
}
ofs << "};\n";
ofs << "\n";
ofs << "SEntityInfo* m_EntityInfos= (SEntityInfo*)c_BinaryEntity;\n";
ofs << "\n";
}
void WriterCrystalInclude()
{
std::ofstream ofs( "crystaldata.h" );
ofs << "int m_iCrystalCount= " << m_iCrystalCount <<";\n";
ofs << "\n";
ofs << "const DWORD c_BinaryCrystal[]= " << "\n";
ofs << "{\n";
for( int i= 0; i < (int)m_iCrystalCount; ++i )
{
int dwords= m_iCrystalCount * sizeof( SCrystalInfo ) / 4;
if( dwords > 0 )
{
DWORD* pdwData= (DWORD*)&(m_CrystalInfos);
for( int j= 0; j < dwords; ++j )
{
char pcSpecial[ 1024 ];
sprintf_s( pcSpecial,
1024,
"\t%d,\n",
pdwData[ j ] );
ofs << pcSpecial;
}
}
}
if( m_iCrystalCount == 0 )
{
ofs << "0";
}
ofs << "};\n";
ofs << "\n";
ofs << "SCrystalInfo* m_CrystalInfos= (SCrystalInfo*)c_BinaryCrystal;\n";
ofs << "\n";
}
void WriteHeader()
{
WriteHeaderFunc();
//#ifdef SCRIPTEDITOR
WriteHeaderScript();
//#endif
WriterShaderInclude();
WriterTextInclude();
WriterEntityInclude();
WriterCrystalInclude();
WriteSceneHeader();
}

View File

@@ -0,0 +1,44 @@
#pragma once
#include "defines.h"
#include <windows.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <cstdio>
#include "StringHelper.h"
#include "TextFileReader.h"
extern HANDLE g_FileChangeNotification;
void StopFileWatch();
void StartFileWatch();
void ReadDataFromDisc();
bool CheckFileWatch();
void WriteHeader();
extern int g_iCurSpriptLength;
extern int g_iCurSpriptParams;
void ReadTextInfos();
void ReadEntityInfos();
void ReadCrystalInfos();
void ReadScriptTxt();
void ReadSceneTxt();
void ReadShader( char* pcTarget, const char* pcFileName );
void ReadShaders();
void WriteHeaderFunc();
void ReadParamTxt();

View File

@@ -0,0 +1,233 @@
/***********************************************************************************/
/** \file EditorHelp.cpp
** \brief Implementation zur Klasse EditorHelp
*************************************************************************************
** Autor: Christian Roesch
*************************************************************************************
** -tut nichts-
**
*//*********************************************************************************/
// includes
#include "EditorHelp.h"
#include <cmath>
#include <ctime>
#include <cassert>
#include <sstream>
bool EditorHelp::m_KeyPressed[ 256 ]= { false };
bool EditorHelp::m_KeyDown[ 256 ]= { false };
HWND EditorHelp::m_hwnd= NULL;
bool EditorHelp::m_bShowDebugData= true;
LPD3DXFONT EditorHelp::m_pDebugFont= NULL;
extern int c_iScreenSizeY;
extern int c_iScreenSizeX;
extern IDirect3DDevice9 *g_d3d_device;
// Methoden-Definitionen
EditorHelp::EditorHelp()
{
}
EditorHelp::~EditorHelp()
{
}
void EditorHelp::SetHWND( HWND hwnd )
{
m_hwnd= hwnd;
}
void EditorHelp::CheckKeys()
{
if( m_hwnd == NULL )
{
m_hwnd= GetForegroundWindow();
}
if( m_hwnd == GetForegroundWindow() )
{
for( int i= 0; i < 256; i++ )
{
SHORT iKey= GetAsyncKeyState( i );
m_KeyPressed[ i ]= false;
if( iKey & 0x8000 )
{
if( m_KeyDown[ i ] == false )
{
m_KeyPressed[ i ]= true;
}
m_KeyDown[ i ]= true;
}
else
{
m_KeyDown[ i ]= false;
}
}
}
else
{
for( int i= 0; i < 256; i++ )
{
m_KeyPressed[ i ]= false;
m_KeyDown[ i ]= false;
}
}
}
float EditorHelp::GetKeyDownVal( float fCurrent,
int KeyAdd,
int KeySub,
float fDefault,
float fSlow,
float fFast )
{
return GetKeyVal( fCurrent,
m_KeyDown[ KeyAdd ],
m_KeyDown[ KeySub ],
fDefault,
fSlow,
fFast );
}
float EditorHelp::GetKeyPressedVal( float fCurrent,
int KeyAdd,
int KeySub,
float fDefault,
float fSlow,
float fFast )
{
return GetKeyVal( fCurrent,
m_KeyPressed[ KeyAdd ],
m_KeyPressed[ KeySub ],
fDefault,
fSlow,
fFast );
}
float EditorHelp::GetKeyVal( float fCurrent,
bool bAdd,
bool bSub,
float fDefault,
float fSlow,
float fFast )
{
//Konventionen fuer Tastenbelegung eingehalten?
assert( fSlow <= fDefault );
assert( fDefault <= fFast );
float fChange= fDefault;
if( m_KeyDown[ VK_SHIFT ] )
{
fChange= fFast;
}
if( m_KeyDown[ VK_CONTROL ] )
{
fChange= fSlow;
}
int iVal= (int)Round( fCurrent / fChange );
if( bAdd )
{
return (float)(iVal + 1 ) * fChange;
}
if( bSub )
{
return (float)(iVal - 1 ) * fChange;
}
return fCurrent;
}
float EditorHelp::Round(float Val )
{
return floor(Val + 0.5f);
}
void EditorHelp::PrintDebug( int iLine, int iColumn, char* pcData )
{
PrintDebugPos( 2.0f + (float)iLine * 12.0f,
2.0f + (float)iColumn * 9.0f,
pcData );
}
void EditorHelp::PrintDebugPos( float fY, float fX, char* pcData )
{
if( m_bShowDebugData )
{
RECT r= {
0 + (int)fX,
0 + (int)fY,
c_iScreenSizeX + (int)fX,
c_iScreenSizeY + (int)fX };
m_pDebugFont->DrawText(
NULL,
pcData,
strlen(pcData),
&r,
DT_TOP | DT_LEFT,
0xff000000 );
r.top-=1;
r.left-=1;
m_pDebugFont->DrawText(
NULL,
pcData,
strlen(pcData),
&r,
DT_TOP | DT_LEFT,
0xffffffff );
}
}
std::string EditorHelp::GetDateString()
{
time_t t;
struct tm ts;
t = time(NULL);
localtime_s( &ts, &t );
std::stringstream ss;
ss << ts.tm_mon + 1 << "_";
ss << ts.tm_mday << "_";
ss << ts.tm_hour << "_";
ss << ts.tm_min << "_";
ss << ts.tm_sec;
return ss.str();
}
void EditorHelp::PreparePrint()
{
if( m_pDebugFont != NULL )
{
return;
}
static D3DXFONT_DESC FontDescription=
{
50,
20,
0,
8,
FALSE,
0,
0,
5, // CLEARTYPE_QUALITY
0,
"Courier"
};
FontDescription.Height= 12;
FontDescription.Width= 9;
D3DXCreateFontIndirect( g_d3d_device,
&FontDescription,
&m_pDebugFont );
}
/************************************************************************************
** Ende der Datei: EditorHelp.cpp
************************************************************************************/

View File

@@ -0,0 +1,88 @@
/***********************************************************************************/
/** \file EditorHelp.h
** \brief Header File zur Klasse EditorHelp
*************************************************************************************
** Autor: Christian Roesch
*************************************************************************************
** _tut nichts_
**
*//*********************************************************************************/
#ifndef _EditorHelp_H
#define _EditorHelp_H
// includes
#include <windows.h>
#include <string>
#include <d3dx9core.h>
// Klassen-Deklaration
/***********************************************************************************/
/** \brief EditorHelp _tut nichts_
*************************************************************************************
** Genau genommen _tut dies nichts_
**
*//*********************************************************************************/
class EditorHelp
{
public:
EditorHelp();
~EditorHelp();
static float Round(float Val );
static void CheckKeys();
static float GetKeyDownVal( float fCurrent,
int KeyAdd,
int KeySub,
float fDefault,
float fSlow,
float fFast );
static float GetKeyPressedVal( float fCurrent,
int KeyAdd,
int KeySub,
float fDefault,
float fSlow,
float fFast );
static bool m_KeyPressed[ 256 ];
static bool m_KeyDown[ 256 ];
static void PrintDebug( int iLine, int iColumn, char* pcData );
static void PrintDebugPos( float fY, float fX, char* pcData );
static std::string GetDateString();
static void SetHWND( HWND hwnd );
static bool m_bShowDebugData;
static void PreparePrint();
protected:
private:
static HWND m_hwnd;
static LPD3DXFONT m_pDebugFont;
static float GetKeyVal( float fCurrent,
bool bAdd,
bool bSub,
float fDefault,
float fSlow,
float fFast );
};
#endif//_EditorHelp_H
class EditorHelp;
/************************************************************************************
** Ende der Datei: EditorHelp.h
************************************************************************************/

View File

@@ -0,0 +1,78 @@
#include "defines.h"
#include "Environment.h"
#include "shader.h"
#include "globals.h"
#include "intrin.h"
void Environment::Init()
{
}
void Environment::Update(const D3DXMATRIX &mView /*, const D3DXMATRIX &mProj*/ )
{
D3DXVECTOR3 vViewPos;
// Extract view position
vViewPos.x = -(mView._41 * mView._11 + mView._42 * mView._12 + mView._43 * mView._13);
vViewPos.y = -(mView._41 * mView._21 + mView._42 * mView._22 + mView._43 * mView._23);
vViewPos.z = -(mView._41 * mView._31 + mView._42 * mView._32 + mView._43 * mView._33);
// Extract orientation
D3DXVECTOR3 vRight(1.0f, 0.0f, 0.0f); // (mView._11, mView._21, mView._31);
D3DXVECTOR3 vUp(0.0f, 1.0f, 0.0f); // (mView._12, mView._22, mView._32);
D3DXVECTOR3 vLook(0.0f, 0.0f, 1.0f); // (mView._13, mView._23, mView._33);
// Cube face orientations
const D3DXVECTOR3 aFaceOrientations[MaxFaceCount][3] = {
{ -vLook, vUp, vRight }, { vLook, vUp, -vRight },
{ vRight, -vLook, vUp }, { vRight, vLook, -vUp },
{ vRight, vUp, vLook }, { -vRight, vUp, -vLook }
};
// Copy projection
for(int i = 0; i < MaxFaceCount; i++)
{
// Get orientation
const D3DXVECTOR3 *pFaceOrientation = aFaceOrientations[i];
const D3DXVECTOR3 &vFaceRight = pFaceOrientation[0];
const D3DXVECTOR3 &vFaceUp = pFaceOrientation[1];
const D3DXVECTOR3 &vFaceLook = pFaceOrientation[2];
D3DXMATRIX &mEnvLocal = m_LocalMatrix[i];
// Compose local matrix
D3DXMatrixIdentity(&mEnvLocal);
memcpy(mEnvLocal.m[0], &vFaceRight, sizeof(float) * 3);
memcpy(mEnvLocal.m[1], &vFaceUp, sizeof(float) * 3);
memcpy(mEnvLocal.m[2], &vFaceLook, sizeof(float) * 3);
D3DXMATRIX &mEnvView = m_ViewMatrix[i];
// Compose view matrix
D3DXMatrixIdentity(&mEnvView);
mEnvView._11 = vFaceRight.x; mEnvView._21 = vFaceRight.y; mEnvView._31 = vFaceRight.z;
mEnvView._12 = vFaceUp.x; mEnvView._22 = vFaceUp.y; mEnvView._32 = vFaceUp.z;
mEnvView._13 = vFaceLook.x; mEnvView._23 = vFaceLook.y; mEnvView._33 = vFaceLook.z;
mEnvView._41 = -D3DXVec3Dot(&vViewPos, &vFaceRight);
mEnvView._42 = -D3DXVec3Dot(&vViewPos, &vFaceUp);
mEnvView._43 = -D3DXVec3Dot(&vViewPos, &vFaceLook);
D3DXMATRIX &mEnvProj = m_ProjMatrix[i];
// 90°
D3DXMatrixPerspectiveFovLH(&mEnvProj,
c_PI / 2.0f, 1.0f,
0.1f, 10000.0f);
// mEnvProj._33 = mProj._33;
// mEnvProj._34 = mProj._34;
// mEnvProj._43 = mProj._43;
// mEnvProj._44 = mProj._44;
// Copy remaining data
memcpy(&m_ViewPos[i], &vViewPos, sizeof(D3DXVECTOR3));
memcpy(&m_ViewDir[i], &vFaceLook, sizeof(D3DXVECTOR3));
}
}

View File

@@ -0,0 +1,54 @@
#pragma once
/***********************************************************************************/
/** \file Environment.h
** \brief Header File zur Klasse Environment
*************************************************************************************
** Autor: Christian Roesch
*************************************************************************************
** _tut nichts_
**
*//*********************************************************************************/
#ifndef _ENVIRONMENT_H
#define _ENVIRONMENT_H
// includes
#include <d3dx9.h>
#include <cassert>
// Klassen-Deklaration
extern IDirect3DDevice9* g_d3d_device;
/***********************************************************************************/
/** \brief Environment _tut nichts_
*************************************************************************************
** Genau genommen _tut dies nichts_
**
*//*********************************************************************************/
class Environment
{
public:
static const int MaxFaceCount = 6;
void Init();
void Update(const D3DXMATRIX &mView /*, const D3DXMATRIX &mProj*/ );
D3DXMATRIX m_ViewMatrix[MaxFaceCount];
D3DXMATRIX m_ProjMatrix[MaxFaceCount];
D3DXVECTOR3 m_ViewPos[MaxFaceCount];
D3DXVECTOR3 m_ViewDir[MaxFaceCount];
D3DXMATRIX m_LocalMatrix[MaxFaceCount];
};
#endif//_Environment_H
class Environment;
/************************************************************************************
** Ende der Datei: Environment.h
************************************************************************************/

View File

@@ -0,0 +1,314 @@
#include "FluidContext.h"
#include "globals.h"
#include "intrin.h"
void FluidContext::BuildUp(int screenX, int screenY, D3DMULTISAMPLE_TYPE multiSampleType)
{
currentFluid = NULL;
D3DVERTEXELEMENT9 decl[] =
{
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
{0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},
{1, 0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
{1, 16, D3DDECLTYPE_FLOAT1, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1},
D3DDECL_END()
};
g_d3d_device->CreateVertexDeclaration(decl, &vertexDecl);
D3DVERTEXELEMENT9 quadDecl[] =
{
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
{0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
D3DDECL_END()
};
g_d3d_device->CreateVertexDeclaration(quadDecl, &quadVertexDecl);
float* quadData;
g_d3d_device->CreateVertexBuffer(sizeof(float) * 20, D3DUSAGE_WRITEONLY, 0, D3DPOOL_MANAGED, &quadVertexBuffer, NULL);
quadVertexBuffer->Lock(0, sizeof(float) * 20, (void**)&quadData, 0);
::memcpy(quadData, particleQuadVerts, sizeof(float) * 20);
quadVertexBuffer->Unlock();
int* quadIndexData;
g_d3d_device->CreateIndexBuffer(6 * sizeof(int), D3DUSAGE_WRITEONLY, D3DFMT_INDEX32, D3DPOOL_MANAGED, &quadIndexBuffer, NULL);
quadIndexBuffer->Lock(0, 0, (void**)&quadIndexData, 0);
quadIndexData[0] = 0;
quadIndexData[1] = 1;
quadIndexData[2] = 2;
quadIndexData[3] = 2;
quadIndexData[4] = 0;
quadIndexData[5] = 3;
quadIndexBuffer->Unlock();
// build up the render targets
renderTargetWidth = screenX;
renderTargetHeight = screenY;
renderTargetDDX = D3DXVECTOR4(1.0f / renderTargetWidth, 1.0f / renderTargetHeight, 0.00f, 0.0f );
g_d3d_device->CreateRenderTarget( screenX,
screenY,
D3DFMT_A16B16G16R16F,
multiSampleType,
0,
FALSE,
&renderSurface,
NULL);
}
void FluidContext::RenderParticles(const FluidParticleSystem& particleInfo)
{
g_d3d_device->SetStreamSource(0, quadVertexBuffer, 0, sizeof(float) * 5);
g_d3d_device->SetStreamSourceFreq(0, D3DSTREAMSOURCE_INDEXEDDATA | particleInfo.InstanceCount);
g_d3d_device->SetStreamSource(1, particleInfo.InstanceDataBuffer, 0, sizeof(InstanceData));
g_d3d_device->SetStreamSourceFreq(1, D3DSTREAMSOURCE_INSTANCEDATA | 1ul);
g_d3d_device->SetVertexDeclaration(vertexDecl);
g_d3d_device->SetIndices(quadIndexBuffer);
g_d3d_device->SetTexture(0, NULL); // pos
g_d3d_device->SetTexture(1, NULL); // normal
// Begin
{
g_Shaders[ FluidPosition ].Activate();
g_d3d_device->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
g_d3d_device->SetRenderTarget(0, renderSurface); // pos
g_d3d_device->Clear(0, NULL, D3DCLEAR_TARGET, 0x0, 1.0f, 0);
g_d3d_device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);
g_d3d_device->StretchRect( renderSurface, NULL,
currentFluid->renderSurfacePingPong[0], NULL, D3DTEXF_LINEAR );
}
{
g_Shaders[ FluidNormal ].Activate();
g_d3d_device->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
g_d3d_device->SetRenderTarget(0, renderSurface); // normal
g_d3d_device->Clear(0, NULL, D3DCLEAR_TARGET, 0x0, 1.0f, 0);
g_d3d_device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);
g_d3d_device->StretchRect( renderSurface, NULL,
currentFluid->renderSurfacePingPong[2], NULL, D3DTEXF_LINEAR );
}
g_d3d_device->SetStreamSourceFreq(0, 1);
g_d3d_device->SetStreamSourceFreq(1, 1);
g_d3d_device->SetStreamSource(1, NULL, 0, 0);
}
void FluidContext::RenderParticleDepth(const FluidParticleSystem& particleInfo)
{
g_d3d_device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
D3DXMATRIX mat;
D3DXMatrixMultiply( &mat, &g_matView, &g_matProjection );
D3DXMatrixTranspose( &mat, &mat );
g_d3d_device->SetVertexShaderConstantF( 31, (float*)&mat, 4 );
g_d3d_device->SetPixelShaderConstantF( 31, (float*)&mat, 4 );
g_d3d_device->SetVertexShaderConstantF( 35, (float*)&g_matView, 4 );
g_d3d_device->SetPixelShaderConstantF( 35, (float*)&g_matView, 4 );
g_d3d_device->SetStreamSource(0, quadVertexBuffer, 0, sizeof(float) * 5);
g_d3d_device->SetStreamSourceFreq(0, D3DSTREAMSOURCE_INDEXEDDATA | particleInfo.InstanceCount);
g_d3d_device->SetStreamSource(1, particleInfo.InstanceDataBuffer, 0, sizeof(InstanceData));
g_d3d_device->SetStreamSourceFreq(1, D3DSTREAMSOURCE_INSTANCEDATA | 1ul);
g_d3d_device->SetVertexDeclaration(vertexDecl);
g_d3d_device->SetIndices(quadIndexBuffer);
g_Shaders[ FluidDepth ].Activate();
g_d3d_device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);
g_d3d_device->SetStreamSourceFreq(0, 1);
g_d3d_device->SetStreamSourceFreq(1, 1);
g_d3d_device->SetStreamSource(1, NULL, 0, 0);
}
void FluidContext::Begin(const Fluid& fluid)
{
g_d3d_device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
currentFluid = &fluid;
g_d3d_device->SetPixelShaderConstantF(20, fluid.Settings.Softness, 1);
g_d3d_device->SetPixelShaderConstantF(21, fluid.Settings.LightTransferAmmount, 1);
g_d3d_device->SetPixelShaderConstantF(22, fluid.Settings.SpecularFactor, 1);
g_d3d_device->SetPixelShaderConstantF(23, fluid.Settings.SpecularPower, 1);
g_d3d_device->SetPixelShaderConstantF(24, fluid.Settings.TranslucencyAmmount, 1);
g_d3d_device->SetPixelShaderConstantF(25, fluid.Settings.TextureScale, 1);
g_d3d_device->SetPixelShaderConstantF(26, fluid.Settings.SurfaceTension, 1);
g_d3d_device->SetPixelShaderConstantF(27, fluid.Settings.RefractAmmount, 1);
g_d3d_device->SetPixelShaderConstantF(28, fluid.Settings.DepthDifferenceBlur, 1);
D3DXMATRIX mat;
D3DXMatrixMultiply( &mat, &g_matView, &g_matProjection );
D3DXMatrixTranspose( &mat, &mat );
g_d3d_device->SetVertexShaderConstantF( 31, (float*)&mat, 4 );
g_d3d_device->SetPixelShaderConstantF( 31, (float*)&mat, 4 );
g_d3d_device->SetVertexShaderConstantF( 35, (float*)&g_matView, 4 );
g_d3d_device->SetPixelShaderConstantF( 35, (float*)&g_matView, 4 );
}
void FluidContext::End()
{
g_d3d_device->SetStreamSourceFreq(0, 1);
g_d3d_device->SetStreamSourceFreq(1, 1);
g_d3d_device->SetStreamSource(1, NULL, 0, 0);
g_d3d_device->SetVertexDeclaration(quadVertexDecl);
//quadddx
g_d3d_device->SetVertexShaderConstantF(30, (float*)&currentFluid->renderTargetPingPongDDX, 1);
g_d3d_device->SetDepthStencilSurface(NULL);
// blur
{
g_Shaders[ FluidBlur ].Activate();
for (int i = 0; i < 3; ++i)
{
g_d3d_device->SetSamplerState( i, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
g_d3d_device->SetSamplerState( i, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
g_d3d_device->SetSamplerState( i, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
g_d3d_device->SetSamplerState( i, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP );
g_d3d_device->SetSamplerState( i, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP );
}
for (int k = 0; k < *currentFluid->Settings.BlurSteps * 2; ++k)
{
g_d3d_device->SetRenderTarget(0, currentFluid->renderSurfacePingPong[0 + ((k+1)%2)]);
g_d3d_device->SetRenderTarget(1, currentFluid->renderSurfacePingPong[2 + ((k+1)%2)]);
// ddx
g_d3d_device->SetPixelShaderConstantF(29, (float*)&(k == 0 ? renderTargetDDX : currentFluid->renderTargetPingPongDDX), 1);
for (int i = 0; i < renderTextureCount; ++i)
g_d3d_device->SetTexture( i, currentFluid->renderTexturePingPong[i*2 + k%2]);
HRESULT hr = g_d3d_device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, screenQuadVerts, 20);
}
}
currentFluid = NULL;
}
void FluidContext::Display(const Fluid& fluid)
{
g_Shaders[ FluidCompose ].Activate();
g_d3d_device->SetRenderState( D3DRS_ZENABLE, FALSE );
g_d3d_device->SetSamplerState( 3, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP );
g_d3d_device->SetSamplerState( 3, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP );
g_d3d_device->SetTexture(0, fluid.renderTexturePingPong[1]); // pos
g_d3d_device->SetTexture(1, fluid.renderTexturePingPong[3]); // normal
g_d3d_device->SetTexture(2, fluid.Settings.DiffuseTexture); // diffuse, herp
g_d3d_device->SetTexture(3, g_pFullScreenRT[ RT_COLOR ] /*backgroundTexture*/); // background, derp
g_d3d_device->SetRenderTarget(1, NULL);
g_d3d_device->SetRenderTarget(2, NULL);
g_d3d_device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, screenQuadVerts, 20);
}
FluidParticleSystem FluidContext::GenerateFluidParticleSystem(unsigned int instanceCount, InstanceData* initialData)
{
FluidParticleSystem result;
result.InstanceDataBuffer = NULL;
result.InstanceCount = instanceCount;
result.IsVisible = false;
if(instanceCount > 0)
{
InstanceData* instanceData;
g_d3d_device->CreateVertexBuffer(sizeof(InstanceData) * instanceCount, D3DUSAGE_WRITEONLY, 0, D3DPOOL_MANAGED, &result.InstanceDataBuffer, NULL);
if (initialData != NULL)
{
result.InstanceDataBuffer->Lock(0, sizeof(InstanceData) * instanceCount, (void**)&instanceData, 0);
::memcpy(instanceData, initialData, sizeof(InstanceData) * instanceCount);
result.InstanceDataBuffer->Unlock();
}
}
return result;
}
Fluid FluidContext::GenerateFluid(const FluidSettings& settings)
{
Fluid result;
result.Settings = settings;
result.renderTargetPingPongDDX = D3DXVECTOR4( 1.0f / (renderTargetWidth * *settings.RenderTextureSizeScale), 1.0f / (renderTargetHeight * *settings.RenderTextureSizeScale), 0.0f, 0.0f );
for (int i = 0; i < renderTextureCount; ++i)
{
for (int k = 0; k < 2; ++k)
{
g_d3d_device->CreateTexture((UINT)(renderTargetWidth * *settings.RenderTextureSizeScale),
(UINT)(renderTargetHeight * *settings.RenderTextureSizeScale),
1,
D3DUSAGE_RENDERTARGET,
D3DFMT_A16B16G16R16F,
D3DPOOL_DEFAULT,
&result.renderTexturePingPong[i * 2 + k],
NULL);
result.renderTexturePingPong[i * 2 + k]->GetSurfaceLevel(0, &result.renderSurfacePingPong[i * 2 + k]);
}
}
return result;
}
void FluidContext::MeltObject(int objectIndex, int fluidIndex, int pointMapIndex, float time)
{
if (g_FluidParticleSystem[fluidIndex].InstanceCount == 0 || !g_FluidParticleSystem[fluidIndex].IsVisible)
return;
float thickness = 4.0f;
// initial fill the particle system
InstanceData* instanceData;
g_FluidParticleSystem[fluidIndex].InstanceDataBuffer->Lock(0, sizeof(InstanceData) * g_FluidParticleSystem[fluidIndex].InstanceCount, (void**)&instanceData, 0);//D3DLOCK_DISCARD);
g_Random.setSeed(0);
D3DXMATRIX mat = g_Objects[ objectIndex ].GetTransformation();
for (unsigned int k = 0; k < g_FluidParticleSystem[fluidIndex].InstanceCount / 4; ++k)
for (unsigned int m = 0; m < 4; ++m)
{
unsigned int i = k*4+m;
D3DXVECTOR3 pmPos = D3DXVECTOR3(g_FluidPointMap[pointMapIndex][k].x, g_FluidPointMap[pointMapIndex][k].y, g_FluidPointMap[pointMapIndex][k].z);
D3DXVec3TransformCoord(&pmPos, &pmPos, &mat);
float drop = time - g_StartMeltTime;
drop -= (1.0f - g_FluidPointMap[pointMapIndex][k].w) * (g_EndMeltTime - g_StartMeltTime);
drop *= max(0.5f, 1.0f - (1.0f - g_FluidPointMap[pointMapIndex][k].w));
drop = max(0.0f, drop);
drop = mypow(drop, 2.0f);
if (drop > 1.0f)
drop += mypow(drop - 1.0f, 4.0f);
instanceData[i].pos[0] = (pmPos.x + g_PointMapDistance[pointMapIndex] * thickness * g_Random.genFloat(-0.25f, 0.25f) );
instanceData[i].pos[1] = (pmPos.y + g_PointMapDistance[pointMapIndex] * thickness * g_Random.genFloat(-0.25f, 0.25f) ) - drop;
instanceData[i].pos[2] = (pmPos.z + g_PointMapDistance[pointMapIndex] * thickness * g_Random.genFloat(-0.25f, 0.25f) );
instanceData[i].size = g_FluidParticleSize[fluidIndex];
instanceData[i].intensity = min(5.0f, drop) / 5.0f;
}
g_FluidParticleSystem[fluidIndex].InstanceDataBuffer->Unlock();
}

View File

@@ -0,0 +1,117 @@
#pragma once
#include <d3dx9.h>
extern IDirect3DDevice9* g_d3d_device;
struct InstanceData
{
float pos[3];
float size;
float intensity;
};
struct FluidSettings
{
float* Softness;
float* LightTransferAmmount;
float* SpecularFactor;
float* SpecularPower;
float* TextureScale;
float* TranslucencyAmmount;
float* SurfaceTension;
float* RefractAmmount;
float* DepthDifferenceBlur;
int* BlurSteps;
float* RenderTextureSizeScale;
IDirect3DBaseTexture9* DiffuseTexture;
};
struct Fluid
{
FluidSettings Settings;
IDirect3DTexture9* renderTexturePingPong[4];
IDirect3DSurface9* renderSurfacePingPong[4];
D3DXVECTOR4 renderTargetPingPongDDX;
};
struct FluidParticleSystem
{
bool IsVisible;
unsigned int InstanceCount;
IDirect3DVertexBuffer9* InstanceDataBuffer;
};
class FluidContext
{
public:
void BuildUp(int screenX, int screenY, D3DMULTISAMPLE_TYPE multiSampleType);
void RenderParticles(const FluidParticleSystem& particleInfo);
void RenderParticleDepth(const FluidParticleSystem& particleInfo);
void Begin(const Fluid& fluid);
void End();
void Display(const Fluid& fluid);
FluidParticleSystem GenerateFluidParticleSystem(unsigned int instanceCount, InstanceData* initialData = NULL);
Fluid GenerateFluid(const FluidSettings& settings);
static void MeltObject(int objectIndex, int fluidIndex, int pointMapIndex, float time);
private:
IDirect3DVertexDeclaration9* quadVertexDecl;
IDirect3DVertexDeclaration9* vertexDecl;
IDirect3DIndexBuffer9* quadIndexBuffer;
IDirect3DVertexBuffer9* quadVertexBuffer;
IDirect3DSurface9* renderSurface;
static const int renderTextureCount = 2; // pos, normal
int renderTargetWidth;
int renderTargetHeight;
D3DXVECTOR4 renderTargetDDX;
const Fluid* currentFluid;
};
static const float particleQuadVerts[20] =
{
-1.0f,-1.0f, 0.0f,
0.0f, 1.0f,
-1.0f, 1.0f, 0.0f,
0.0f, 0.0f,
1.0f, 1.0f, 0.0f,
1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
1.0f, 1.0f
};
static const float screenQuadVerts[30] =
{
-1.0f,-1.0f, 1.0f,
0.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
0.0f, 0.0f,
1.0f, 1.0f, 1.0f,
1.0f, 0.0f,
1.0f, -1.0f, 1.0f,
1.0f, 1.0f,
-1.0f,-1.0f, 1.0f,
0.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 0.0f
};

View File

@@ -0,0 +1,843 @@
#pragma once
#include "Greeble.h"
#include "intrin.h"
#ifdef EXTRACODE
#include "greebledata.h"
#else
#include "greeblearrays.h"
#endif
#include "globals.h"
Greeble g_Greeble;
float Greeble::GetFloatParam( int iBank, int iOffset )
{
return g_GreebleParam[ iBank * 4 + iOffset ];
}
void Greeble::AddToScene( float fCurTime, int iObject, int iObjDesc )
{
iObjID= iObject;
pObj= g_GreebleObj + iObjDesc;
fTime= fCurTime;
PrepMesh();
}
void Greeble::CreateFloatFieldPlasma( int ParamBank, float* pFloat, float fStepX, int iStepsX, float fStepY, int iStepsY, float fTime )
{
const float fAmplifyX= GetFloatParam( ParamBank, 0 );
const float fAmplifyY= GetFloatParam( ParamBank, 1 );
const float fBaseValue= GetFloatParam( ParamBank, 2 );
const float fStretchAmplify= GetFloatParam( ParamBank, 3 );
const float fStretchX= GetFloatParam( ParamBank + 1, 0 );
const float fStretchX2= GetFloatParam( ParamBank + 1, 1 );
const float fSpeedX= GetFloatParam( ParamBank + 1, 2 );
const float fSpeedX2= GetFloatParam( ParamBank + 1, 3 );
const float fStretchY= GetFloatParam( ParamBank + 2, 0 );
const float fStretchY2= GetFloatParam( ParamBank + 2, 1 );
const float fSpeedY= GetFloatParam( ParamBank + 2, 2 );
const float fSpeedY2= GetFloatParam( ParamBank + 2, 3 );
const float fStartX= 0.0f;
const float fStartY= 0.0f;
float fY= fStartY;
for( int iY= 0; iY < iStepsY; ++iY, fY+= fStepY )
{
float fX= fStartX;
for( int iX= 0; iX < iStepsX; ++iX, fX+= fStepX )
{
float fVal= fBaseValue +
fAmplifyX * sin( fX * fStretchX +
fSpeedX * fTime +
fStretchAmplify * sin( fStretchX2 * fY + fTime * fSpeedX2 ) ) +
fAmplifyY * sin( fY * fStretchY +
fSpeedY * fTime +
fStretchAmplify * sin( fStretchY2 * fX + fTime * fSpeedY2 ) );
int iOffset= iY * iStepsX + iX;
pFloat[ iOffset ]= fVal;
}
}
}
void Greeble::CreateTwistedBow( int ParamBank, float* pFloat, float fStepX, int iStepsX, float fStepY, int iStepsY, float fTime )
{
const float fStrength= GetFloatParam( ParamBank, 0 );
const float fAmpliHorz= GetFloatParam( ParamBank, 1 );
const float fRepHorz= GetFloatParam( ParamBank, 2 );
const float fSpeedHorz= GetFloatParam( ParamBank, 3 );
const float fTwistVert= GetFloatParam( ParamBank + 1, 0 );
const float fAmpliVert= GetFloatParam( ParamBank + 1, 1 );
const float fRepVert= GetFloatParam( ParamBank + 1, 2 );
const float fSpeedVert= GetFloatParam( ParamBank + 1, 3 );
const float fStartX= 0.0f;
const float fStartY= 0.0f;
float fY= fStartY;
for( int iY= 0; iY < iStepsY; ++iY, fY+= fStepY )
{
float fX= fStartX;
for( int iX= 0; iX < iStepsX; ++iX, fX+= fStepX )
{
float fBow= sin( 0.5f * fY );
float fVal= fStrength +
fAmpliHorz * sin( fSpeedHorz * fTime + fRepHorz * fY ) +
fAmpliVert * sin( fSpeedVert * fTime + fRepVert * fX + fTwistVert * fY );
fVal*= fBow;
int iOffset= iY * iStepsX + iX;
pFloat[ iOffset ]= fVal;
}
}
}
void Greeble::Create3DMeshPlane( float* pFloat, float fStartX, float fStepX, int iStepsX, float fStartY, float fStepY, int iStepsY )
{
float fY= fStartY;
for( int iY= 0; iY < iStepsY; ++iY, fY+= fStepY )
{
float fX= fStartX;
for( int iX= 0; iX < iStepsX; ++iX, fX+= fStepX )
{
int iOffset= iY * iStepsX + iX;
PreMesh[ iOffset ].Pos().x= fX;
PreMesh[ iOffset ].Pos().y= pFloat[ iOffset ];
PreMesh[ iOffset ].Pos().z= fY;
}
}
}
void Greeble::Create3DMeshCylinder( float* pFloat, float fBaseRadiusX, float fBaseRadiusZ, int iStepsX, float fStartY, float fStepY, int iStepsY )
{
const float fStepX= c_2PI / (float)( iStepsX - 1 );
float fY= fStartY;
for( int iY= 0; iY < iStepsY; ++iY, fY+= fStepY )
{
float fX= 0.0f;
for( int iX= 0; iX < iStepsX; ++iX, fX+= fStepX )
{
int iOffset= iY * iStepsX + iX;
float fR= pFloat[ iOffset ];
PreMesh[ iOffset ].Pos().x= sin( fX ) * ( fR + fBaseRadiusX );
PreMesh[ iOffset ].Pos().y= fY;
PreMesh[ iOffset ].Pos().z= cos( fX ) * ( fR + fBaseRadiusZ );
}
}
}
void Greeble::Create3DMeshSphere( float* pFloat, float fBaseRadiusX, float fBaseRadiusY, float fBaseRadiusZ, int iStepsX, int iStepsY )
{
const float fStepX= c_2PI / (float)( iStepsX - 1 );
const float Length= c_PI - 0.01f;
const float fStepY= Length / (float)( iStepsY - 1 );
float fY= ( c_PI - Length )* 0.5f;
for( int iY= 0; iY < iStepsY; ++iY, fY+= fStepY )
{
float SinY= sin( fY );
float CosY= cos( fY );
float fX= 0.0f;
for( int iX= 0; iX < iStepsX; ++iX, fX+= fStepX )
{
int iOffset= iY * iStepsX + iX;
float fR= pFloat[ iOffset ] * SinY;
PreMesh[ iOffset ].Pos().x= SinY * sin( fX ) * ( fR + fBaseRadiusX );
PreMesh[ iOffset ].Pos().y= CosY * ( fR + fBaseRadiusY );
PreMesh[ iOffset ].Pos().z= SinY * cos( fX ) * ( fR + fBaseRadiusZ );
}
}
}
void Greeble::Create3DMeshTorus( float* pFloat, float fBaseRadiusX, float fBaseRadiusZ, float fInnerRadiusXZ, float fInnerRadiusY, int iStepsX, int iStepsY )
{
const float fStepX= c_2PI / (float)( iStepsX - 1 );
const float fStepY= c_2PI / (float)( iStepsY - 1 );
float fY= 0.0f;
for( int iY= 0; iY < iStepsY; ++iY, fY+= fStepY )
{
float SinY= sin( fY );
float CosY= cos( fY );
float fX= 0.0f;
for( int iX= 0; iX < iStepsX; ++iX, fX+= fStepX )
{
int iOffset= iY * iStepsX + iX;
float fR= pFloat[ iOffset ];
float SinX= sin( fX );
float CosX= cos( fX );
PreMesh[ iOffset ].Pos().x= SinY * ( fBaseRadiusX + CosX * fInnerRadiusXZ + fR);
PreMesh[ iOffset ].Pos().y= SinX * ( fInnerRadiusY + fR );
PreMesh[ iOffset ].Pos().z= CosY * ( fBaseRadiusZ + CosX * fInnerRadiusXZ + fR );
}
}
}
void Greeble::CreateNormals( int iStepsX, int iStepsY )
{
for( int iY= 0; iY < iStepsY; ++iY )
{
for( int iX= 0; iX < iStepsX; ++iX )
{
int iOffset= iY * iStepsX + iX;
int iOffsetLeft= iY * iStepsX + ( iX + 1 ) % iStepsX;
int iOffsetRight= iY * iStepsX + ( iX + iStepsX - 1 ) % iStepsX;
int iOffsetBottom= ( ( iY + 1 ) % iStepsY ) * iStepsX + iX;
int iOffsetTop= ( ( iY + iStepsY - 1 ) % iStepsY ) * iStepsX + iX;
D3DXVECTOR3 vec3V(
PreMesh[ iOffsetLeft ].Pos() - PreMesh[ iOffsetRight ].Pos() );
D3DXVECTOR3 vec3H(
PreMesh[ iOffsetTop ].Pos() - PreMesh[ iOffsetBottom ].Pos() );
D3DXVec3Cross( &PreMesh[ iOffset ].Normal(), &vec3V, &vec3H );
D3DXVec3Normalize( &PreMesh[ iOffset ].Normal(), &PreMesh[ iOffset ].Normal() );
}
}
}
void Greeble::CreateNormalsBreakXY( int iStepsX, int iStepsY )
{
for( int iY= 0; iY < iStepsY; ++iY )
{
for( int iX= 0; iX < iStepsX; ++iX )
{
int iOffset= iY * iStepsX + iX;
int iOffsetLeft= iY * iStepsX + ( iX + 1 ) % iStepsX;
int iOffsetRight= iY * iStepsX + ( iX + iStepsX - 1 ) % iStepsX;
int iOffsetBottom= ( ( iY + 1 ) % iStepsY ) * iStepsX + iX;
int iOffsetTop= ( ( iY + iStepsY - 1 ) % iStepsY ) * iStepsX + iX;
if( iX == 0 )
{
iOffsetRight= iOffset;
}
if( iX == iStepsX - 1 )
{
iOffsetLeft= iOffset;
}
if( iY == 0 )
{
iOffsetTop= iOffset;
}
if( iY == iStepsY - 1 )
{
iOffsetBottom= iOffset;
}
D3DXVECTOR3 vec3V(
PreMesh[ iOffsetLeft ].Pos() - PreMesh[ iOffsetRight ].Pos() );
D3DXVECTOR3 vec3H(
PreMesh[ iOffsetTop ].Pos() - PreMesh[ iOffsetBottom ].Pos() );
D3DXVec3Cross( &PreMesh[ iOffset ].Normal(), &vec3V, &vec3H );
D3DXVec3Normalize( &PreMesh[ iOffset ].Normal(), &PreMesh[ iOffset ].Normal() );
}
}
}
void Greeble::CreateNormalsBreakX( int iStepsX, int iStepsY )
{
for( int iY= 0; iY < iStepsY; ++iY )
{
for( int iX= 0; iX < iStepsX; ++iX )
{
int iOffset= iY * iStepsX + iX;
int iOffsetLeft= iY * iStepsX + ( iX + 1 ) % iStepsX;
int iOffsetRight= iY * iStepsX + ( iX + iStepsX - 1 ) % iStepsX;
int iOffsetBottom= ( ( iY + 1 ) % iStepsY ) * iStepsX + iX;
int iOffsetTop= ( ( iY + iStepsY - 1 ) % iStepsY ) * iStepsX + iX;
if( iX == 0 )
{
iOffsetRight= iOffset;
}
if( iX == iStepsX - 1 )
{
iOffsetLeft= iOffset;
}
D3DXVECTOR3 vec3V(
PreMesh[ iOffsetLeft ].Pos() - PreMesh[ iOffsetRight ].Pos() );
D3DXVECTOR3 vec3H(
PreMesh[ iOffsetTop ].Pos() - PreMesh[ iOffsetBottom ].Pos() );
D3DXVec3Cross( &PreMesh[ iOffset ].Normal(), &vec3V, &vec3H );
D3DXVec3Normalize( &PreMesh[ iOffset ].Normal(), &PreMesh[ iOffset ].Normal() );
}
}
}
void Greeble::CreateNormalsBreakY( int iStepsX, int iStepsY )
{
for( int iY= 0; iY < iStepsY; ++iY )
{
for( int iX= 0; iX < iStepsX; ++iX )
{
int iOffset= iY * iStepsX + iX;
int iOffsetLeft= iY * iStepsX + ( iX + 1 ) % iStepsX;
int iOffsetRight= iY * iStepsX + ( iX + iStepsX - 1 ) % iStepsX;
int iOffsetBottom= ( ( iY + 1 ) % iStepsY ) * iStepsX + iX;
int iOffsetTop= ( ( iY + iStepsY - 1 ) % iStepsY ) * iStepsX + iX;
if( iY == 0 )
{
iOffsetTop= iOffset;
}
if( iY == iStepsY - 1 )
{
iOffsetBottom= iOffset;
}
D3DXVECTOR3 vec3V(
PreMesh[ iOffsetLeft ].Pos() - PreMesh[ iOffsetRight ].Pos() );
D3DXVECTOR3 vec3H(
PreMesh[ iOffsetTop ].Pos() - PreMesh[ iOffsetBottom ].Pos() );
D3DXVec3Cross( &PreMesh[ iOffset ].Normal(), &vec3V, &vec3H );
D3DXVec3Normalize( &PreMesh[ iOffset ].Normal(), &PreMesh[ iOffset ].Normal() );
}
}
}
void Greeble::PrepAO( int iStepsX, int iStepsY, float* pFloatHeight, float* pFloatCenterMix, float* pFloatAOVert, float* pFloatAOVHorz, float* pFloatAOIntermediate )
{
const float fBase= 1.0f / 2.0f;
for( int iY= 0; iY < iStepsY; ++iY )
{
for( int iX= 0; iX < iStepsX; ++iX )
{
int iOffset= iY * iStepsX + iX;
float fHeight= pFloatHeight[ iOffset ];
float fMix= pFloatCenterMix[ iOffset ];
if( fHeight > 0.01f )
{
pFloatAOIntermediate[ iOffset ]= minimum( ( fMix ) * sqrt( fBase / fHeight ), 0.5f );
}
else
{
pFloatAOIntermediate[ iOffset ]= 0.5f;
}
}
}
for( int iY= 0; iY < iStepsY; ++iY )
{
for( int iX= 0; iX < iStepsX; ++iX )
{
int iOffset= iY * iStepsX + iX;
int iOffsetRight= iY * iStepsX + ( iX + iStepsX - 1 ) % iStepsX;
int iOffsetTop= ( ( iY + iStepsY - 1 ) % iStepsY ) * iStepsX + iX;
pFloatAOVHorz[ iOffset ]= pFloatAOIntermediate[ iOffset ] + pFloatAOIntermediate[ iOffsetRight ];
pFloatAOVert[ iOffset ]= pFloatAOIntermediate[ iOffset ] + pFloatAOIntermediate[ iOffsetTop ];
}
}
}
DWORD ShadeColor( DWORD dwBaseColor, float fShade )
{
DWORD dwRGB[3]=
{
( dwBaseColor & 0xff0000 ) >> 16,
( dwBaseColor & 0xff00 ) >> 8,
( dwBaseColor & 0xff )
};
dwRGB[0]= (int)( (float)dwRGB[0] * fShade );
dwRGB[1]= (int)( (float)dwRGB[1] * fShade );
dwRGB[2]= (int)( (float)dwRGB[2] * fShade );
return dwRGB[0] << 16 | dwRGB[1] << 8 | dwRGB[2] | ( 0xff000000 & dwBaseColor );
}
void Greeble::CreateFinal3DMesh( int iStepsX, int iStepsY, float* pFloatHeight, float* pFloatCenterMix, float* pFloatAOVert, float* pFloatAOVHorz, DWORD dwBaseColor )
{
g_Objects[ iObjID ].Lock();
const int QuadsPerStep= 5;
for( int iY= 0; iY < iStepsY - 1; ++iY )
{
for( int iX= 0; iX < iStepsX - 1; ++iX )
{
int iOffsetVert[ 4 ]=
{
iY * iStepsX + iX,
iY * iStepsX + iX + 1,
iY * iStepsX + iX + iStepsX + 1,
iY * iStepsX + iX + iStepsX
};
float fHeight= pFloatHeight[ iOffsetVert[ 0 ] ];
float fMix= pFloatCenterMix[ iOffsetVert[ 0 ] ];
D3DXVECTOR3 v[ 8 ]=
{
PreMesh[ iOffsetVert[ 0 ] ].Pos(),
PreMesh[ iOffsetVert[ 1 ] ].Pos(),
PreMesh[ iOffsetVert[ 2 ] ].Pos(),
PreMesh[ iOffsetVert[ 3 ] ].Pos(),
PreMesh[ iOffsetVert[ 0 ] ].Pos() + PreMesh[ iOffsetVert[ 0 ] ].Normal() * fHeight,
PreMesh[ iOffsetVert[ 1 ] ].Pos() + PreMesh[ iOffsetVert[ 1 ] ].Normal() * fHeight,
PreMesh[ iOffsetVert[ 2 ] ].Pos() + PreMesh[ iOffsetVert[ 2 ] ].Normal() * fHeight,
PreMesh[ iOffsetVert[ 3 ] ].Pos() + PreMesh[ iOffsetVert[ 3 ] ].Normal() * fHeight,
};
D3DXVECTOR3 vCenter= 0.25f * ( v[4] + v[5] + v[6] + v[7] );
D3DXVec3Lerp( &v[4], &v[4], &vCenter, fMix );
D3DXVec3Lerp( &v[5], &v[5], &vCenter, fMix );
D3DXVec3Lerp( &v[6], &v[6], &vCenter, fMix );
D3DXVec3Lerp( &v[7], &v[7], &vCenter, fMix );
D3DXVECTOR3 n[8]=
{
PreMesh[ iOffsetVert[ 0 ] ].Normal(),
PreMesh[ iOffsetVert[ 1 ] ].Normal(),
PreMesh[ iOffsetVert[ 2 ] ].Normal(),
PreMesh[ iOffsetVert[ 3 ] ].Normal(),
};
{
D3DXVECTOR3 v1= PreMesh[ iOffsetVert[ 1 ] ].Pos() - PreMesh[ iOffsetVert[ 0 ] ].Pos();
D3DXVECTOR3 v2= v[4] - PreMesh[ iOffsetVert[ 0 ] ].Pos();
D3DXVec3Cross( &n[4], &v2, &v1 );
D3DXVec3Normalize( &n[4], &n[4] );
}
{
D3DXVECTOR3 v1= PreMesh[ iOffsetVert[ 2 ] ].Pos() - PreMesh[ iOffsetVert[ 1 ] ].Pos();
D3DXVECTOR3 v2= v[5] - PreMesh[ iOffsetVert[ 1 ] ].Pos();
D3DXVec3Cross( &n[5], &v2, &v1 );
D3DXVec3Normalize( &n[5], &n[5] );
}
{
D3DXVECTOR3 v1= PreMesh[ iOffsetVert[ 3 ] ].Pos() - PreMesh[ iOffsetVert[ 2 ] ].Pos();
D3DXVECTOR3 v2= v[6] - PreMesh[ iOffsetVert[ 2 ] ].Pos();
D3DXVec3Cross( &n[6], &v2, &v1 );
D3DXVec3Normalize( &n[6], &n[6] );
}
{
D3DXVECTOR3 v1= PreMesh[ iOffsetVert[ 0 ] ].Pos() - PreMesh[ iOffsetVert[ 3 ] ].Pos();
D3DXVECTOR3 v2= v[7] - PreMesh[ iOffsetVert[ 3 ] ].Pos();
D3DXVec3Cross( &n[7], &v2, &v1 );
D3DXVec3Normalize( &n[7], &n[7] );
}
/*int iFinalOffset= iY * ( iStepsX - 1 )+ iX;
iFinalOffset*= VertsPerStep;*/
float AOLeft= pFloatAOVHorz[ iOffsetVert[ 0 ] ];
float AORight= pFloatAOVHorz[ iOffsetVert[ 1 ] ];
float AOTop= pFloatAOVert[ iOffsetVert[ 0 ] ];
float AOBottom= pFloatAOVert[ iOffsetVert[ 3 ] ];
DWORD dwColor[ 5 ]=
{
ShadeColor( dwBaseColor, 1.0f ),
ShadeColor( dwBaseColor, AOTop ),
ShadeColor( dwBaseColor, AORight ),
ShadeColor( dwBaseColor, AOBottom ),
ShadeColor( dwBaseColor, AOLeft ),
};
/*dwColor[ 1 ]= (int)( 255.4f * AOTop );
dwColor[ 2 ]= (int)( 255.4f * AORight );
dwColor[ 3 ]= (int)( 255.4f * AOBottom );
dwColor[ 4 ]= (int)( 255.4f * AOLeft );
dwColor[ 1 ]= dwColor[ 1 ] << 16 | dwColor[ 1 ] << 8 | dwColor[ 1 ] | 0xff000000;
dwColor[ 2 ]= dwColor[ 2 ] << 16 | dwColor[ 2 ] << 8 | dwColor[ 2 ] | 0xff000000;
dwColor[ 3 ]= dwColor[ 3 ] << 16 | dwColor[ 3 ] << 8 | dwColor[ 3 ] | 0xff000000;
dwColor[ 4 ]= dwColor[ 4 ] << 16 | dwColor[ 4 ] << 8 | dwColor[ 4 ] | 0xff000000;*/
int iQuadOffsets[]=
{
4, 0, 0, // Deckel
5, 1, 0,
7, 3, 0,
6, 2, 0,
0, 4, 1, // Flanke oben
1, 4, 1,
4, 4, 0,
5, 4, 0,
1, 5, 2, // Flanke rechts
2, 5, 2,
5, 5, 0,
6, 5, 0,
2, 6, 3, // Flanke unten
3, 6, 3,
6, 6, 0,
7, 6, 0,
3, 7, 4, // Flanke links
0, 7, 4,
7, 7, 0,
4, 7, 0,
};
for( int i= 0; i < QuadsPerStep * 4; ++i )
{
Renderjob::SVertex V;
V.Pos()= v[ iQuadOffsets[ i * 3 ] ];
V.Normal()= n[ iQuadOffsets[ i * 3 + 1 ] ];
V.dwColor= dwColor[ iQuadOffsets[ i * 3 + 2 ] ];
V.tu= 0.0f;
V.tv= 0.0f;
g_Objects[ iObjID ].AddVertex( V );
}
}
}
int iV= 0;
for( int i= 0; i < QuadsPerStep * ( iStepsX - 1 ) * ( iStepsY - 1 ); ++i )
{
g_Objects[ iObjID ].AddIndex( iV + 2);
g_Objects[ iObjID ].AddIndex( iV + 1);
g_Objects[ iObjID ].AddIndex( iV + 0);
g_Objects[ iObjID ].AddIndex( iV + 3);
g_Objects[ iObjID ].AddIndex( iV + 1);
g_Objects[ iObjID ].AddIndex( iV + 2);
iV+= 4;
assert( iV <= g_Objects[ iObjID ].GetVertCount() );
}
g_Objects[ iObjID ].Unlock();
}
void Greeble::Create2DFunc( int FuncType, int iParamBank, float* pFloat, int iSizeX, int iSizeY, float fTime )
{
switch( FuncType )
{
case -1:
{
for( int i= 0; i < iSizeX * iSizeY; ++i )
{
pFloat[ i ]= 0.0f;
}
}
break;
case 0:
case 1:
case 2:
case 3:
{
for( int i= 0; i < iSizeX * iSizeY; ++i )
{
pFloat[ i ]= GetFloatParam( iParamBank, FuncType );
}
}
break;
case 4:
{
const float fPiX= c_2PI / (float)( iSizeX - 1 );
const float fPiY= c_2PI / (float)( iSizeY - 1 );
CreateFloatFieldPlasma(
iParamBank, // ParamBank,
pFloat, // pFloat,
fPiX, // fStepX
iSizeX, // iStepsX,
fPiY, // fStepY
iSizeY, // iStepsY
fTime );
}
break;
case 5:
{
const float fPiX= c_2PI / (float)( iSizeX - 1 );
const float fPiY= c_2PI / (float)( iSizeY - 1 );
CreateTwistedBow(
iParamBank, // ParamBank,
pFloat, // pFloat,
fPiX, // fStepX
iSizeX, // iStepsX,
fPiY, // fStepY
iSizeY, // iStepsY
fTime );
}
break;
}
}
void Greeble::PrepMesh()
{
const int iSizeX= pObj->m_iSizeX;
const int iSizeY= pObj->m_iSizeY;
Create2DFunc(
pObj->m_iOffsetFunc,
pObj->m_iOffsetBank,
PreFloats,
iSizeX,
iSizeY,
fTime);
/*const float fPiX= c_2PI / (float)( iSizeX - 1 );
const float fPiY= c_2PI / (float)( iSizeY - 1 );
CreateFloatFieldPlasma(
pObj->m_iOffsetBank, // ParamBank,
PreFloats, // pFloat,
fPiX, // fStepX
iSizeX, // iStepsX,
fPiY, // fStepY
iSizeY // iStepsY
);*/
switch( pObj->m_iBaseMeshType )
{
case 0:
{
const float fPlaneSizeX= GetFloatParam( pObj->m_iBaseBank, 0 );
const float fPlaneSizeY= GetFloatParam( pObj->m_iBaseBank, 1 );
float fPlaneStepX= 2.0f * fPlaneSizeX / (float)( iSizeX - 1 );
float fPlaneStepY= 2.0f * fPlaneSizeY / (float)( iSizeY - 1 );
Create3DMeshPlane(
PreFloats, // pFloat,
-fPlaneSizeX, // fStartX
fPlaneStepX, // fStepX
iSizeX, // iStepsX,
-fPlaneSizeY, // fStartY
fPlaneStepY, // fStepY
iSizeY // iStepsY
);
CreateNormalsBreakXY(
iSizeX,
iSizeY
);
}
break;
case 1:
{
const float fBaseRadiusX= GetFloatParam( pObj->m_iBaseBank, 0 );
const float fBaseRadiusZ= GetFloatParam( pObj->m_iBaseBank, 1 );
const float fCylinderSizeY= GetFloatParam( pObj->m_iBaseBank, 2 );
float fCylinderStepY= 2.0f * fCylinderSizeY / (float)( iSizeY - 1 );
Create3DMeshCylinder(
PreFloats, // float* pFloat,
fBaseRadiusX, // float fBaseRadiusX,
fBaseRadiusZ, // float fBaseRadiusZ,
iSizeX, // int iStepsX,
-fCylinderSizeY, // float fStartY,
fCylinderStepY, // float fStepY,
iSizeY // int iStepsY
);
CreateNormalsBreakY(
iSizeX,
iSizeY
);
}
break;
case 2:
{
const float fBaseRadiusX= GetFloatParam( pObj->m_iBaseBank, 0 );
const float fBaseRadiusY= GetFloatParam( pObj->m_iBaseBank, 1 );
const float fBaseRadiusZ= GetFloatParam( pObj->m_iBaseBank, 2 );
Create3DMeshSphere(
PreFloats, // float* pFloat,
fBaseRadiusX, // fBaseRadiusX
fBaseRadiusY, // fBaseRadiusY
fBaseRadiusZ, // fBaseRadiusZ
iSizeX, // int iStepsX,
iSizeY // int iStepsY,
);
CreateNormalsBreakY(
iSizeX,
iSizeY
);
}
break;
case 3:
{
Create3DMeshTorus(
PreFloats, // float* pFloat,
GetFloatParam( pObj->m_iBaseBank, 0 ),
GetFloatParam( pObj->m_iBaseBank, 1 ),
GetFloatParam( pObj->m_iBaseBank, 2 ),
GetFloatParam( pObj->m_iBaseBank, 3 ),
iSizeX, // int iStepsX,
iSizeY // int iStepsY,
);
CreateNormals(
iSizeX,
iSizeY
);
}
break;
}
Create2DFunc(
pObj->m_iHeightFunc,
pObj->m_iHeightBank,
PreFloat(1),
iSizeX,
iSizeY,
fTime );
Create2DFunc(
pObj->m_iMixFunc,
pObj->m_iMixBank,
PreFloat(2),
iSizeX,
iSizeY,
fTime );
/*W
CreateFloatFieldPlasma(
pObj->m_iHeightBank, // ParamBank,
PreFloat(1), // pFloat,
fPiX, // fStepX
iSizeX, // iStepsX,
fPiY, // fStepY
iSizeY // iStepsY
);
CreateFloatFieldPlasma(
pObj->m_iMixBank, // ParamBank,
PreFloat(2), // pFloat,
fPiX, // fStepX
iSizeX, // iStepsX,
fPiY, // fStepY
iSizeY // iStepsY
);
*/
PrepAO(
iSizeX,
iSizeY ,
PreFloat(1), // pFloatHeight,
PreFloat(2), // pFloatCenterMix,
PreFloat(3), // pFloatAOVert,
PreFloat(4), // pFloatAOVHorz
PreFloat(5) // Intermediate
);
CreateFinal3DMesh(
iSizeX,
iSizeY ,
PreFloat(1), // pFloatHeight,
PreFloat(2), // pFloatCenterMix,
PreFloat(3), // pFloatAOVert,
PreFloat(4), // pFloatAOVHorz
pObj->m_dwColor
);
}
/*void Greeble::CreateInterpolationMatrix( D3DXMATRIX* pMat, int iBank, float fTime )
{
D3DXVECTOR3 vecPos(
GetFloatParam( iBank, 0 ),
GetFloatParam( iBank, 1 ),
GetFloatParam( iBank, 2 ) );
D3DXVECTOR3 vecPos2(
GetFloatParam( iBank + 1, 0 ),
GetFloatParam( iBank + 1, 1 ),
GetFloatParam( iBank + 1, 2 ) );
D3DXVECTOR3 vecRot(
GetFloatParam( iBank + 2, 0 ),
GetFloatParam( iBank + 2, 1 ),
GetFloatParam( iBank + 2, 2 ) );
D3DXVECTOR3 vecRot2(
GetFloatParam( iBank + 3, 0 ),
GetFloatParam( iBank + 3, 1 ),
GetFloatParam( iBank + 3, 2 ) );
vecPos+= vecPos2 * fTime * GetFloatParam( iBank + 1, 3 );
vecRot+= vecRot2 * fTime * GetFloatParam( iBank + 3, 3 );
vecRot*= c_2PI;
D3DXMATRIX matPos;
D3DXMatrixTranslation( &matPos, vecPos.x, vecPos.y, vecPos.z );
D3DXMATRIX matRot;
D3DXMatrixRotationYawPitchRoll( &matRot, vecRot.x, vecRot.y, vecRot.z );
*pMat= matRot * matPos;
}
void Greeble::RenderMesh( SObjectDescription* pObj, float fTime )
{
g_d3d_device->SetRenderState( D3DRS_LIGHTING, TRUE );
g_d3d_device->SetLight( 0, &d3dLight[ 0 ] );
g_d3d_device->LightEnable( 0, TRUE );
g_d3d_device->SetLight( 1, &d3dLight[ 1 ] );
g_d3d_device->LightEnable( 1, TRUE );
g_d3d_device->SetLight( 2, &d3dLight[ 2 ] );
g_d3d_device->LightEnable( 2, TRUE );
g_d3d_device->SetRenderState( D3DRS_ZENABLE, TRUE );
g_d3d_device->SetRenderState( D3DRS_ALPHATESTENABLE, FALSE );
g_d3d_device->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
g_d3d_device->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW );
g_d3d_device->SetRenderState( D3DRS_TEXTUREFACTOR, pObj->m_dwColor );
g_d3d_device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE );
g_d3d_device->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
g_d3d_device->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_TFACTOR );
//g_d3d_device->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
//g_d3d_device->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
D3DXMATRIX mat;
float zf= 400.0f;
float zn= 0.125f;
float xScale = 1.0f;
float yScale= xScale / (float)c_iScreenSizeY * (float)c_iScreenSizeX;
mat._11= xScale; mat._12= 0; mat._13= 0; mat._14= 0;
mat._21= 0; mat._22= yScale; mat._23= 0; mat._24= 0;
mat._31= 0; mat._32= 0; mat._33= zf/(zf-zn); mat._34= 1;
mat._41= 0; mat._42= 0; mat._43= -zn*zf/(zf-zn);mat._44= 0;
g_d3d_device->SetTransform( D3DTS_PROJECTION, &mat );
D3DXMatrixIdentity( &mat );
g_d3d_device->SetTransform( D3DTS_WORLD, &mat );
SetTransformation( pObj, fTime );
{
g_d3d_device->SetFVF( c_dwFVFMesh );
int iPrimCount= PrepMesh( pObj, fTime );
SVertexMesh* pVertices= FinalMesh;
while( iPrimCount > 0 )
{
int iActPrimCount= iPrimCount;
if( iActPrimCount > 16384 )
{
iActPrimCount= 16384;
}
g_d3d_device->DrawPrimitiveUP(
D3DPT_TRIANGLELIST,
iActPrimCount,
pVertices,
sizeof( SVertexMesh )
);
pVertices+= iActPrimCount * 3;
iPrimCount-= iActPrimCount;
}
}
}*/

View File

@@ -0,0 +1,146 @@
#pragma once
#include <d3dx9.h>
#include "renderjob.h"
struct Greeble
{
struct SObjectDescription
{
int m_iSizeX;
int m_iSizeY;
int m_iBaseMeshType;
int m_iBaseBank;
int m_iOffsetFunc;
int m_iOffsetBank;
int m_iHeightFunc;
int m_iHeightBank;
int m_iMixFunc;
int m_iMixBank;
DWORD m_dwColor;
};
void AddToScene( float fTime, int iObject, int iObjDesc );
Renderjob::SVertex PreMesh[ 128 * 128 ];
float PreFloats[ 128 * 128 * 16 ];
static const int PreFloatBlock= 128 * 128;
int iObjID;
SObjectDescription* pObj;
float fTime;
float GetFloatParam( int iBank, int iOffset );
float* PreFloat( int i )
{
return PreFloats + i * PreFloatBlock;
}
Renderjob::SVertex FinalMesh[ 128 * 128 * 32 ];
void CreateFloatFieldPlasma(
int ParamBank, float* pFloat,
float fStepX, int iStepsX,
float fStepY, int iStepsY,
float fTime);
void CreateTwistedBow(
int ParamBank, float* pFloat,
float fStepX, int iStepsX,
float fStepY, int iStepsY,
float fTime );
void Create3DMeshPlane(
float* pFloat,
float fStartX, float fStepX, int iStepsX,
float fStartY, float fStepY, int iStepsY
);
void Create3DMeshCylinder(
float* pFloat,
float fBaseRadiusX, float fBaseRadiusZ, int iStepsX,
float fStartY, float fStepY, int iStepsY
);
void Create3DMeshSphere(
float* pFloat,
float fBaseRadiusX, float fBaseRadiusY, float fBaseRadiusZ,
int iStepsX, int iStepsY
);
void Create3DMeshTorus(
float* pFloat,
float fBaseRadiusX, float fBaseRadiusZ,
float fInnerRadiusXZ, float fInnerRadiusY,
int iStepsX, int iStepsY
);
void CreateNormals(
int iStepsX,
int iStepsY
);
void CreateNormalsBreakXY(
int iStepsX,
int iStepsY
);
void CreateNormalsBreakX(
int iStepsX,
int iStepsY
);
void CreateNormalsBreakY(
int iStepsX,
int iStepsY
);
void PrepAO(
int iStepsX,
int iStepsY,
float* pFloatHeight,
float* pFloatCenterMix,
float* pFloatAOVert,
float* pFloatAOVHorz,
float* pFloatAOIntermediate
);
void CreateFinal3DMesh(
int iStepsX,
int iStepsY,
float* pFloatHeight,
float* pFloatCenterMix,
float* pFloatAOVert,
float* pFloatAOVHorz,
DWORD dwBaseColor
);
void Create2DFunc(
int FuncType,
int iParamBank,
float* pFloat,
int iSizeX,
int iSizeY,
float fTime );
void PrepMesh();
/*void CreateInterpolationMatrix(
D3DXMATRIX* pMat,
int iBank,
float fTime);
void SetTransformation( SObjectDescription* pObj, float fTime );
void RenderMesh( SObjectDescription* pObj, float fTime );*/
};
extern Greeble g_Greeble;

View File

@@ -0,0 +1,646 @@
#include "intrin.h"
#include "OBJMesh.h"
#include "BinMeshData.h"
#ifdef EXTRACODE
#include "StringHelper.h"
#include "TextFileReader.h"
#include <sstream>
#include <map>
#include <vector>
#include <cmath>
#endif
ObjMesh g_objMesh;
#ifdef EXTRACODE
float ObjMesh::m_fMaxRoundError= 0.0f;
float ObjMesh::RoundFloat( float f, int iBits )
{
DWORD dw= *((DWORD*)&f);
int e= ( ( dw >> 23 ) & 0xff ) - 127;
if( e == - 127)
{
m_fMaxRoundError= max( fabs( f ), m_fMaxRoundError );
return 0.0f;
}
DWORD dwMask= 0xffffffff << ( 32 - iBits );
float Add= powf( 2.0f, (float)( e - iBits + 8 ) );
const int iTests= 7;
float fValues[ iTests ];
for( int i= 0; i < iTests; ++i )
{
fValues[ i ]= f + Add * (float)( i - iTests / 2 ) ;
((DWORD*)(fValues))[ i ]&= dwMask;
}
int iNearest= 0;
for( int i= 1; i < iTests; ++i )
{
if( fabs( f - fValues[ iNearest ] ) > fabs( f - fValues[ i ] ) )
{
iNearest= i;
}
}
m_fMaxRoundError= max( fabs( f - fValues[ iNearest ] ), m_fMaxRoundError );
return fValues[ iNearest ];
}
std::vector< unsigned char > TopologyRaw;
std::vector<BinVertex> VertexRaw;
bool ObjMesh::LoadMesh(
const char* pcFileName,
int FloatBits,
bool bFlatten,
BinMesh& bm,
int& IndexBytes,
int& VertexBytes )
{
std::map< VertexInfo, int > mapVertexData;
std::vector< Vertex > VertexData;
std::vector< int > Topology;
std::vector< Vertex > PrePos;
std::vector< Vertex > PreNormal;
Topology.reserve( 1000 );
PrePos.reserve( 1000 );
PreNormal.reserve( 1000 );
FrameWork::TextFileReader tfrData;
if( !tfrData.read( pcFileName ) )
{
return false;
}
m_FaceCount= 0;
for( int i= 0; i < (int)tfrData.getFileLines().size(); ++i )
{
std::string strAct= tfrData.getFileLines()[ i ];
std::string strCommand;
if( FrameWork::StringHelper::splitAt( strAct, " ", strCommand ) )
{
FrameWork::StringHelper::trim(
strCommand,
FrameWork::StringHelper::getSpaceTab() );
FrameWork::StringHelper::toUpper( strCommand );
}
if( strCommand == "V" )
{
std::stringstream ss;
ss << strAct;
Vertex vxPos;
vxPos.position.x= 0;
vxPos.position.y= 0;
vxPos.position.z= 0;
ss >> vxPos.position.x;
ss >> vxPos.position.y;
ss >> vxPos.position.z;
PrePos.push_back( vxPos );
}
else if( strCommand == "VN" )
{
std::stringstream ss;
ss << strAct;
Vertex vxNorm;
vxNorm.normal.x= 0;
vxNorm.normal.y= 0;
vxNorm.normal.z= 0;
ss >> vxNorm.normal.x;
ss >> vxNorm.normal.y;
ss >> vxNorm.normal.z;
PreNormal.push_back( vxNorm );
}
else if( strCommand == "F" )
{
FrameWork::StringHelper::trim(
strAct,
FrameWork::StringHelper::getSpaceTab() );
std::vector< std::string > strVerts;
FrameWork::StringHelper::tokenize(
strAct, " ", strVerts );
std::vector< int > Read;
for( size_t j= 0; j < strVerts.size(); ++j )
{
std::vector< std::string > vecIndex;
std::string strIndex= strVerts[ j ];
FrameWork::StringHelper::trim(
strIndex,
FrameWork::StringHelper::getSpaceTab() );
FrameWork::StringHelper::tokenize(
strIndex, "/", vecIndex );
for( int jj= 0; jj < 3; ++jj )
{
std::stringstream ss;
if( jj < (int)vecIndex.size() )
{
ss << vecIndex[ jj ];
}
int iValue= -1;
ss >> iValue;
Read.push_back( iValue );
}
}
m_FaceCount++;
Topology.push_back( Read.size() / 3 );
for( int i=0; i < (int)Read.size(); i+= 3 )
{
int iIndex= i;
VertexInfo vInfo;
vInfo.m_iPos= Read[ iIndex ];
vInfo.m_iUV= Read[ iIndex + 1];
vInfo.m_iNormal= Read[ iIndex + 2];
int iMapIndex;
std::map< VertexInfo, int >::iterator it=
mapVertexData.find( vInfo );
if( it != mapVertexData.end() )
{
iMapIndex= it->second;
}
else
{
iMapIndex= (int)VertexData.size();
mapVertexData[ vInfo ]= iMapIndex;
Vertex vNew;
vNew.position= PrePos[ vInfo.m_iPos - 1 ].position;
if( (size_t)vInfo.m_iNormal - 1 >= PreNormal.size() )
{
// Normalen werden sowieso generiert
vNew.normal= D3DXVECTOR3(0, 0, 0 );
}
else
{
vNew.normal= PreNormal[ vInfo.m_iNormal - 1 ].normal;
}
VertexData.push_back( vNew );
}
Topology.push_back( iMapIndex );
}
}
}
//neuordnen der Topology koennte Speicherplatz sparen bei der Kompression
D3DXVECTOR3 PosPredictor( 0.0f, 0.0f, 0.0f );
int IndexPredictor= 0;
TopologyRaw.resize( 0 );
VertexRaw.resize( 0 );
std::map< int, int > IndexMapping;
bm.m_PrimitiveCount= 0;
for(size_t i= 0; i < Topology.size(); ++i )
{
int iCount= Topology[ i ];
for( int j= 0; j < iCount; ++j )
{
int iIndex= Topology[ i + 1 + j ];
//Index schon gespeichert?
std::map< int, int >::iterator it= IndexMapping.find( iIndex );
if( it == IndexMapping.end() )
{
//Vertex ist neu
D3DXVECTOR3 PosData= VertexData[ iIndex ].position - PosPredictor;
IndexMapping[ iIndex ]= VertexRaw.size();
BinVertex v;
v.m_Pos[ 0 ]= PosData.x;
v.m_Pos[ 1 ]= PosData.y;
v.m_Pos[ 2 ]= PosData.z;
if( bFlatten )
{
v.m_Pos[ 2 ]= 0.0f;
}
//Positionswert hier runden macht Kompression besser
v.m_Pos[ 0 ]= RoundFloat( v.m_Pos[ 0 ], FloatBits );
v.m_Pos[ 1 ]= RoundFloat( v.m_Pos[ 1 ], FloatBits );
v.m_Pos[ 2 ]= RoundFloat( v.m_Pos[ 2 ], FloatBits );
VertexRaw.push_back( v );
//PosPredictor+= D3DXVECTOR3( v.m_Pos[ 0 ], v.m_Pos[ 1 ], v.m_Pos[ 2 ] );
TopologyRaw.push_back( 0 );
IndexPredictor++;
}
else
{
//Vertex schon vorhanden
int iIndexTransformed= IndexPredictor - it->second;
while( iIndexTransformed >= BinMesh::c_FarVertex )
{
iIndexTransformed-= BinMesh::c_FarVertex;
TopologyRaw.push_back( BinMesh::c_FarVertex );
}
TopologyRaw.push_back( iIndexTransformed );
}
}
TopologyRaw.push_back( BinMesh::c_FinishPoly );
bm.m_PrimitiveCount++;
i+= iCount;
}
bm.m_pTopology= &(TopologyRaw[ 0 ]);
bm.m_pVertex= &(VertexRaw[ 0 ]);
IndexBytes= TopologyRaw.size();
VertexBytes= VertexRaw.size() * sizeof(BinVertex);
return LoadMesh( &bm );
m_VertexCount= (unsigned int)VertexData.size();
m_IndexCount= (unsigned int)Topology.size();
for(size_t i= 0; i < VertexData.size(); ++i )
{
m_VertexBuffer[ i ]= VertexData[ i ];
}
for(size_t i= 0; i < Topology.size(); ++i )
{
m_IndexBuffer[ i ]= Topology[ i ];
}
}
#endif
bool ObjMesh::LoadMesh( BinMesh* pBinMesh )
{
m_IndexCount= 0;
m_FaceCount= 0;
m_VertexCount= 0;
int IndexPredictor= 0;
unsigned char* pData= pBinMesh->m_pTopology;
int iFaceType= 0;
int iVertex= IndexPredictor;
int New= 1;
while( m_FaceCount < pBinMesh->m_PrimitiveCount )
{
unsigned char c= *pData++;
switch( c )
{
case BinMesh::c_FinishPoly:
m_IndexBuffer[ m_IndexCount ]= iFaceType;
m_IndexCount+= iFaceType + 1;
m_FaceCount++;
iFaceType= 0;
break;
case BinMesh::c_FarVertex:
iVertex-= BinMesh::c_FarVertex;
New= 0;
break;
case 0:
IndexPredictor+= New;
m_VertexCount+= New;
default:
iFaceType++;
m_IndexBuffer[ m_IndexCount + iFaceType ]= iVertex - c;
iVertex= IndexPredictor;
New= 1;
break;
}
}
D3DXVECTOR3 PosPredictor( 0.0f, 0.0f, 0.0f );
for( int i= 0; i < m_VertexCount; ++i )
{
D3DXVECTOR3 p(
pBinMesh->m_pVertex[ i ].m_Pos[ 0 ],
pBinMesh->m_pVertex[ i ].m_Pos[ 1 ],
pBinMesh->m_pVertex[ i ].m_Pos[ 2 ] );
PosPredictor= p;
m_VertexBuffer[ i ].position= PosPredictor;
}
return true;
}
void ObjMesh::GenerateNormals()
{
for( int i= 0; i < m_VertexCount; ++i )
{
m_VertexBuffer[ i ].normal= D3DXVECTOR3( 0, 0, 0);
}
for(int i= 0; i < m_IndexCount; )
{
int iCount= m_IndexBuffer[ i ];
++i;
for( int j= 0; j < iCount; ++j )
{
int iIndex= m_IndexBuffer[ i + j ];
int iIndexPrev= m_IndexBuffer[ i + ( ( j + iCount - 1 ) % iCount ) ];
int iIndexNext= m_IndexBuffer[ i + ( ( j + 1 ) % iCount ) ];
D3DXVECTOR3 p1( m_VertexBuffer[ iIndexPrev ].position - m_VertexBuffer[ iIndex ].position );
D3DXVECTOR3 p2( m_VertexBuffer[ iIndexNext ].position - m_VertexBuffer[ iIndex ].position );
D3DXVec3Cross( &p1, &p2, &p1 );
m_VertexBuffer[ iIndex ].normal+= p1;
}
i+= iCount;
}
for( int i= 0; i < m_VertexCount; ++i )
{
D3DXVec3Normalize( &( m_VertexBuffer[ i ].normal ), &( m_VertexBuffer[ i ].normal ) );
}
}
void ObjMesh::UnIndex()
{
m_OP.Reset();
m_OP.m_NextVertexCount= 0;
for(int i= 0; i < m_IndexCount; )
{
int iCount= m_IndexBuffer[ i ];
++i;
for( int j= 0; j < iCount; ++j )
{
int iIndex= m_IndexBuffer[ i + j ];
m_OP.m_NextVB[ m_OP.m_NextVertexCount ]= m_VertexBuffer[ iIndex ];
m_IndexBuffer[ i + j ]= m_OP.m_NextVertexCount;
m_OP.m_NextVertexCount++;
}
i+= iCount;
}
//Klatteratatsch ins Mesh kopieren...
mymemcpy( m_VertexBuffer, m_OP.m_NextVB, sizeof( m_VertexBuffer ) );
m_VertexCount= m_OP.m_NextVertexCount;
}
void ObjMesh::CatmullClarkSubdivide()
{
if( m_IndexCount >= MaxIndexBuffer / 4 )
{
return;
}
if( m_VertexCount >= MaxVertexBuffer * 9 / 4 )
{
return;
}
// neuer VB ist so:
// alter VB bzw. verschobene Originalpunkte
// ein Vertex pro Face (FacePunkte)
// ein Vertex pro Edge (EdgePunkte)
//neuer IB ist so:
// 4 / alte Ecke0 / EdgePunkt / FaceFacePunkt / EdgePunkt
// 4 / alte Ecke1 / EdgePunkt / FaceFacePunkt / EdgePunkt
//...
// 4 / alte EckeN / EdgePunkt / FaceFacePunkt / EdgePunkt ( N== Vertexcount )
//beim kopieren dann ueberall noch 4
m_OP.Reset();
m_OP.m_NextVertexCount= m_VertexCount + m_FaceCount; //Basis Vertices sind die alte Ecken und die neuen FacePunkte
int iFace= 0;
for(int i= 0; i < m_IndexCount; )
{
int iCount= m_IndexBuffer[ i ];
++i;
D3DXVECTOR3& fp= m_OP.m_NextVB[ m_VertexCount + iFace ].position;
unsigned short int* pIB= m_OP.m_NextIB + m_OP.m_NextIndexCount;
for( int j= 0; j < iCount; ++j )
{
int iIndex= m_IndexBuffer[ i + j ];
fp+= m_VertexBuffer[ iIndex ].position;
pIB[ j * 5 ]= 4;
pIB[ j * 5 + 1]= iIndex;
pIB[ j * 5 + 3 ]= m_VertexCount + iFace; // erste Haelfte IB fertig
}
fp/= (float)iCount; // jetzt ist der FacePunkt fertig
for( int j= 0; j < iCount; ++j )
{
int iIndex= m_IndexBuffer[ i + j ];
int iIndexNext= m_IndexBuffer[ i + ( ( j + 1 ) % iCount ) ];
int Edge= m_OP.MakeEdgeID( iIndex, iIndexNext );
m_OP.m_NextVB[ m_OP.m_EdgeID[ Edge ] ].position+= fp; // Summe aller FacePunkte zu dieser Ecke sind hier
pIB[ j * 5 + 2 ]= m_OP.m_EdgeID[ Edge ];
pIB[ ( j * 5 + 9 ) % ( iCount * 5 ) ]= m_OP.m_EdgeID[ Edge ]; // IB fertig!
m_OP.m_NextVB[ iIndex ].position+= fp; //Summe aller FacePunkte die an diesen Originalpunkt grenzen
}
i+= iCount;
iFace++;
m_OP.m_NextIndexCount+= iCount * 5;
m_OP.m_NextFaceCount+= iCount;
}
// Originalpunkte verschieben
for( int i= 0; i < m_VertexCount; ++i )
{
bool bOpenEdges= false; // gab es offene Kanten (d.h. einseitig benutze?)
D3DXVECTOR3 vEdges(0,0,0);
D3DXVECTOR3 vOpenEdges(0,0,0);
int iEdgeCount= 0;
int iOpenEdgeCount= 0;
for( int j=0; j < m_OP.m_iEdgeCount; ++j )
{
int V1= ( m_OP.m_EdgeConfiguration[ j ] & 0x0000ffff );
int V2= ( m_OP.m_EdgeConfiguration[ j ] & 0xffff0000 ) >> 16;
if( V1 == i || V2 == i )
{
D3DXVECTOR3 vMid= m_VertexBuffer[ V1 ].position + m_VertexBuffer[ V2 ].position;
if( m_OP.m_EdgeUsage[ j ] == 1 )
{
bOpenEdges= true;
iOpenEdgeCount++;
vOpenEdges+= vMid;
}
iEdgeCount++;
vEdges+= vMid;
}
}
if( bOpenEdges )
{
m_OP.m_NextVB[ i ].position= vOpenEdges / (float)( iOpenEdgeCount * 4 ) +
m_VertexBuffer[ i ].position * 0.5f;
}
else
{
m_OP.m_NextVB[ i ].position=
m_OP.m_NextVB[ i ].position / (float)iEdgeCount +
vEdges / (float)iEdgeCount +
m_VertexBuffer[ i ].position * (float)( iEdgeCount - 3 );
m_OP.m_NextVB[ i ].position/= (float)iEdgeCount;
}
}
//EdgePunkte anpassen
for( int j=0; j < m_OP.m_iEdgeCount; ++j )
{
int V1= ( m_OP.m_EdgeConfiguration[ j ] & 0x0000ffff );
int V2= ( m_OP.m_EdgeConfiguration[ j ] & 0xffff0000 ) >> 16;
if( m_OP.m_EdgeUsage[ j ] < 2 )
{
m_OP.m_NextVB[ m_OP.m_EdgeID[ j ] ].position= D3DXVECTOR3( 0,0,0 );
m_OP.m_EdgeUsage[ j ]= 0;
}
m_OP.m_NextVB[ m_OP.m_EdgeID[ j ] ].position+= m_VertexBuffer[ V1 ].position;
m_OP.m_NextVB[ m_OP.m_EdgeID[ j ] ].position+= m_VertexBuffer[ V2 ].position;
m_OP.m_NextVB[ m_OP.m_EdgeID[ j ] ].position/= (float)(m_OP.m_EdgeUsage[ j ] + 2 );
}
//Klatteratatsch ins Mesh kopieren...
mymemcpy( m_VertexBuffer, m_OP.m_NextVB, sizeof( m_VertexBuffer ) );
mymemcpy( m_IndexBuffer, m_OP.m_NextIB, sizeof( m_IndexBuffer ) );
m_VertexCount= m_OP.m_NextVertexCount;
m_IndexCount= m_OP.m_NextIndexCount;
m_FaceCount= m_OP.m_NextFaceCount;
}
void ObjMesh::Extrude( float fExtend )
{
m_OP.Reset();
for(int i= 0; i < m_IndexCount; )
{
int iCount= m_IndexBuffer[ i ];
m_IndexBuffer[ i + m_IndexCount ]= iCount;
++i;
for( int j= 0; j < iCount; ++j )
{
int iIndex= m_IndexBuffer[ i + j ];
int iIndexNext= m_IndexBuffer[ i + ( ( j + 1 ) % iCount ) ];
int ID= m_OP.MakeEdgeID( iIndex, iIndexNext );
if( iIndex > iIndexNext )
{
m_OP.m_EdgeUsage[ ID ]+= 0x80;
}
m_IndexBuffer[ i + m_IndexCount + iCount - j - 1 ]= iIndex + m_VertexCount;
}
i+= iCount;
}
for( int i= 0; i < m_VertexCount; ++i )
{
m_VertexBuffer[ i + m_VertexCount].position= m_VertexBuffer[ i ].position;
m_VertexBuffer[ i ].position.z-= fExtend;
m_VertexBuffer[ i + m_VertexCount].position.z+= fExtend;
}
m_IndexCount*= 2;
m_FaceCount*= 2;
for( int i= 0; i < m_OP.m_iEdgeCount; ++i )
{
if( (m_OP.m_EdgeUsage[ i ] & 0x7f ) == 1 )
{
int iAdd= m_OP.m_EdgeUsage[ i ] == 1 ? 0 : m_VertexCount;
int V1= ( m_OP.m_EdgeConfiguration[ i ] & 0x0000ffff );
int V2= ( m_OP.m_EdgeConfiguration[ i ] & 0xffff0000 ) >> 16;
m_IndexBuffer[ m_IndexCount++ ]= 4;
m_IndexBuffer[ m_IndexCount++ ]= V1+ iAdd;
iAdd= m_VertexCount - iAdd;
m_IndexBuffer[ m_IndexCount++ ]= V1+ iAdd;
m_IndexBuffer[ m_IndexCount++ ]= V2+ iAdd;
iAdd= m_VertexCount - iAdd;
m_IndexBuffer[ m_IndexCount++ ]= V2+ iAdd;
m_FaceCount+= 1;
}
}
m_VertexCount*= 2;
}
void ObjMesh::SuperEllip( float fStrength )
{
if( m_VertexCount == 0 )
{
return;
}
float fMax= m_VertexBuffer[ 0 ].position.z;
float fMin= m_VertexBuffer[ 0 ].position.z;
for( int i= 1; i < m_VertexCount; ++i )
{
fMax= maximum( m_VertexBuffer[ i ].position.z, fMax );
fMin= minimum( m_VertexBuffer[ i ].position.z, fMin );
}
float fMid= ( fMax + fMin ) * 0.5f;
float fExt= ( fMax - fMin ) * 0.5f;
for( int i= 0; i < m_VertexCount; ++i )
{
float Pos= ( m_VertexBuffer[ i ].position.z - fMid ) / fExt;
Pos= signpow( Pos, fStrength );
m_VertexBuffer[ i ].position.z= fMid + Pos * fExt;
}
}
void ObjMesh::OpInfo::Reset()
{
mymemset( m_NextVB, 0, sizeof( m_NextVB ) );
mymemset( m_NextIB, 0, sizeof( m_NextIB ) );
mymemset( m_EdgeConfiguration, 0, sizeof( m_EdgeConfiguration ) );
mymemset( m_EdgeUsage, 0, sizeof( m_EdgeUsage ) );
mymemset( m_EdgeID, 0, sizeof( m_EdgeID ) );
m_NextVertexCount= 0;
m_NextIndexCount= 0;
m_NextFaceCount= 0;
m_iEdgeCount= 0;
}
int ObjMesh::OpInfo::MakeEdgeID( unsigned short VertexA, unsigned short VertexB )
{
unsigned int EdgeConfiguration= VertexA > VertexB ? ( VertexA << 16 | VertexB ) : ( VertexB << 16 | VertexA );
for( int i=0; i < m_iEdgeCount; ++i )
{
if( m_EdgeConfiguration[ i ] == EdgeConfiguration )
{
m_EdgeUsage[ i ]++;
return i;
}
}
m_EdgeConfiguration[ m_iEdgeCount ]= EdgeConfiguration;
m_EdgeUsage[ m_iEdgeCount ]++;
m_EdgeID[ m_iEdgeCount ]= m_NextVertexCount;
m_NextVertexCount++;
return m_iEdgeCount++;
}
/* Vertex m_NextVB[ ObjMesh::MaxVertexBuffer ];
unsigned short int m_NextIB[ ObjMesh::MaxIndexBuffer ];
int m_NextVertexCount;
int m_NextIndexCount;
int m_NextFaceCount;
int m_iEdgeCount;
unsigned int m_EdgeConfiguration[ ObjMesh::MaxIndexBuffer ];
unsigned char m_EdgeUsage[ ObjMesh::MaxIndexBuffer ];
unsigned short int m_EdgeID[ ObjMesh::MaxIndexBuffer ];
}*/

View File

@@ -0,0 +1,105 @@
#pragma once
#include "d3dx9.h"
#ifndef OBJMESH_HEADER
#define OBJMESH_HEADER
struct BinMesh;
class ObjMesh
{
private:
struct Vertex
{
D3DXVECTOR3 position;
D3DXVECTOR3 normal;
};
struct VertexInfo
{
int m_iPos;
int m_iNormal;
int m_iUV;
bool operator<( const VertexInfo& v )const
{
if( m_iPos == v.m_iPos )
{
if( m_iNormal == v.m_iNormal )
{
return m_iUV < v.m_iUV;
}
return m_iNormal < v.m_iNormal;
}
return m_iPos < v.m_iPos;
}
};
int m_VertexCount;
int m_IndexCount;
int m_FaceCount;
static const int MaxVertexBuffer= 65536;
static const int MaxIndexBuffer= 65536 * 9 / 2;
Vertex m_VertexBuffer[ MaxVertexBuffer ];
unsigned short int m_IndexBuffer[ MaxIndexBuffer ];
struct OpInfo
{
void Reset();
Vertex m_NextVB[ ObjMesh::MaxVertexBuffer ];
unsigned short int m_NextIB[ ObjMesh::MaxIndexBuffer ];
int m_NextVertexCount;
int m_NextIndexCount;
int m_NextFaceCount;
int m_iEdgeCount;
unsigned int m_EdgeConfiguration[ ObjMesh::MaxIndexBuffer ];
unsigned char m_EdgeUsage[ ObjMesh::MaxIndexBuffer ];
int MakeEdgeID( unsigned short VertexA, unsigned short VertexB );
unsigned short int m_EdgeID[ ObjMesh::MaxIndexBuffer ];
};
OpInfo m_OP;
public:
#ifdef EXTRACODE
bool LoadMesh(
const char* pcFileName,
int FloatBits,
bool bFlatten,
BinMesh& BM,
int& IndexBytes,
int& VertexBytes );
static float ObjMesh::RoundFloat( float f, int iBits );
static float m_fMaxRoundError;
#endif
bool LoadMesh( BinMesh* pBinMesh );
void GenerateNormals();
void CatmullClarkSubdivide();
void Extrude( float fExtend );
void SuperEllip( float fStrength );
void Bevel( float fExtend, float fMinAngle );
void UnIndex();
inline unsigned int GetVertexCount() const { return m_VertexCount; };
inline unsigned int GetIndexCount() const { return m_IndexCount; };
inline unsigned int GetFaceCount() const { return m_FaceCount; };
Vertex* GetVertexBuffer()
{
return m_VertexBuffer;
}
unsigned short int* GetIndexBuffer()
{
return m_IndexBuffer;
}
};
extern ObjMesh g_objMesh;
#endif

View File

@@ -0,0 +1,156 @@
#include "defines.h"
#include "PSSM.h"
#include "shader.h"
#include "globals.h"
#include "intrin.h"
void PSSM::Init()
{
m_iSplitCount = -1;
m_fRange = 0.0f;
}
void PSSM::UpdateSplits(const D3DXVECTOR3 &vLightDir, const D3DXMATRIX &mView, const D3DXMATRIX &mProj)
{
assert( m_iSplitCount >= 0 && m_iSplitCount <= MaxSplitCount );
assert( m_fRange >= 0.0f );
// Extract cam data
D3DXVECTOR3 vCamPos(
-(mView._11 * mView._41 + mView._12 * mView._42 + mView._13 * mView._43),
-(mView._21 * mView._41 + mView._22 * mView._42 + mView._23 * mView._43),
-(mView._31 * mView._41 + mView._32 * mView._42 + mView._33 * mView._43) );
D3DXVECTOR3 vCamRight(mView._11, mView._21, mView._31);
D3DXVECTOR3 vCamUp(mView._12, mView._22, mView._32);
D3DXVECTOR3 vCamLook(mView._13, mView._23, mView._33);
// Extract plane distances
float fNearPlane = mProj._43 / -mProj._33;
float fFarPlane = mProj._43 / (1.0f - mProj._33);
// Extract FOV
float fTanHalfFOVX = 1.0f / mProj._11;
float fTanHalfFOVY = 1.0f / mProj._22;
// Compute maximum shadow split clip plane
float fMaxClipPlane = max( fFarPlane,
max(2.0f * fTanHalfFOVX * fFarPlane, 2.0f * fTanHalfFOVY * fFarPlane) );
// Adjust range
if(fFarPlane - fNearPlane > m_fRange)
fFarPlane = fNearPlane + m_fRange;
// Compute frustum depth
float fFrustumDepth = fFarPlane - fNearPlane;
// Complete light vector set
D3DXVECTOR3 vLightUp(0.0f, 1.0f, 0.0f), vLightRight;
if(abs(D3DXVec3Dot(&vLightUp, &vLightDir)) > 0.95f)
vLightUp = D3DXVECTOR3(0.0f, 0.0f, 1.0f);
D3DXVec3Cross(&vLightRight, &vLightUp, &vLightDir);
D3DXVec3Normalize(&vLightRight, &vLightRight);
D3DXVec3Cross(&vLightUp, &vLightDir, &vLightRight);
D3DXVec3Normalize(&vLightUp, &vLightUp);
// Loop over splits
for(int iSplit = 0; iSplit < m_iSplitCount; iSplit++)
{
// Compute both uniform and logarithmic split distribution
float fUniformSplitNear = fNearPlane + fFrustumDepth * ((float)iSplit / m_iSplitCount);
float fUniformSplitFar = fNearPlane + fFrustumDepth * ((float)(iSplit + 1) / m_iSplitCount);
float fLogSplitNear = fNearPlane * mypow(fFarPlane / fNearPlane, (float)iSplit / m_iSplitCount);
float fLogSplitFar = fNearPlane * mypow(fFarPlane / fNearPlane, (float)(iSplit + 1) / m_iSplitCount);
// Take average of both distributions
float fSplitNear = (fUniformSplitNear + fLogSplitNear) / 2.0f;
float fSplitFar = (fUniformSplitFar + fLogSplitFar) / 2.0f;
// Center
D3DXVECTOR3 vSplitCenter = vCamPos + (fSplitNear + fSplitFar) / 2.0f * vCamLook;
// Compute split view matrix
D3DXMatrixIdentity(&m_ViewMatrices[iSplit]);
memcpy(&m_ViewMatrices[iSplit]._11, &vLightRight, sizeof(float) * 3);
memcpy(&m_ViewMatrices[iSplit]._21, &vLightUp, sizeof(float) * 3);
memcpy(&m_ViewMatrices[iSplit]._31, &vLightDir, sizeof(float) * 3);
D3DXMatrixTranspose(&m_ViewMatrices[iSplit], &m_ViewMatrices[iSplit]);
m_ViewMatrices[iSplit]._41 = -D3DXVec3Dot(&vSplitCenter, &vLightRight);
m_ViewMatrices[iSplit]._42 = -D3DXVec3Dot(&vSplitCenter, &vLightUp);
m_ViewMatrices[iSplit]._43 = -D3DXVec3Dot(&vSplitCenter, &vLightDir);
// Update split view
m_ViewPos[iSplit] = vSplitCenter;
m_ViewDir[iSplit] = vLightDir;
D3DXVECTOR3 splitCorners[8];
// Compute all eight frustum split corner points
ComputeCornerPoints(splitCorners, fSplitNear, fSplitFar, fTanHalfFOVX, fTanHalfFOVY,
vCamPos, vCamRight, vCamUp, vCamLook, 0.1f);
float fMinX = FLT_MAX, fMaxX = FLT_MIN;
float fMinY = FLT_MAX, fMaxY = FLT_MIN;
float fMinZ = FLT_MAX, fMaxZ = FLT_MIN;
// Loop over corner points
for(int i = 0; i < 8; i++)
{
// Transform corner to view space
D3DXVECTOR4 vViewSpaceCorner;
D3DXVec3Transform(&vViewSpaceCorner, &splitCorners[i], &m_ViewMatrices[iSplit]);
// Find min and max values
if(vViewSpaceCorner.x > fMaxX) fMaxX = vViewSpaceCorner.x;
if(vViewSpaceCorner.x < fMinX) fMinX = vViewSpaceCorner.x;
if(vViewSpaceCorner.y > fMaxY) fMaxY = vViewSpaceCorner.y;
if(vViewSpaceCorner.y < fMinY) fMinY = vViewSpaceCorner.y;
if(vViewSpaceCorner.z > fMaxZ) fMaxZ = vViewSpaceCorner.z;
if(vViewSpaceCorner.z < fMinZ) fMinZ = vViewSpaceCorner.z;
}
// Bias
fMinX -= 2.0f; fMinY -= 2.0f; fMinZ -= 2.0f;
fMaxX += 2.0f; fMaxY += 2.0f; fMaxZ += 2.0f;
// Compute split projection matrix
D3DXMatrixOrthoOffCenterLH(&m_ProjMatrices[iSplit],
fMinX, fMaxX,
fMinY, fMaxY,
fMinZ - fMaxClipPlane, fMaxZ + fMaxClipPlane);
}
}
void PSSM::ComputeCornerPoints(D3DXVECTOR3 *pCorners,
float fNear, float fFar, float fTanHalfFOVX, float fTanHalfFOVY,
const D3DXVECTOR3 &vCamPos, const D3DXVECTOR3 &vCamRight,
const D3DXVECTOR3 &vCamUp, const D3DXVECTOR3 &vCamLook,
float fOverlap)
{
float fNearHalfWidth = fTanHalfFOVX * fNear;
float fNearHalfHeight = fTanHalfFOVY * fNear;
float fFarHalfWidth = fTanHalfFOVX * fFar;
float fFarHalfHeight = fTanHalfFOVY * fFar;
D3DXVECTOR3 vNearCenter = vCamPos + fNear * vCamLook;
D3DXVECTOR3 vFarCenter = vCamPos + fFar * vCamLook;
// Compute eight frustum split corner points
pCorners[0] = vNearCenter + fNearHalfWidth * vCamRight + fNearHalfHeight * vCamUp;
pCorners[1] = vNearCenter + fNearHalfWidth * vCamRight - fNearHalfHeight * vCamUp;
pCorners[2] = vNearCenter - fNearHalfWidth * vCamRight + fNearHalfHeight * vCamUp;
pCorners[3] = vNearCenter - fNearHalfWidth * vCamRight - fNearHalfHeight * vCamUp;
pCorners[4] = vFarCenter + fFarHalfWidth * vCamRight + fFarHalfHeight * vCamUp;
pCorners[5] = vFarCenter + fFarHalfWidth * vCamRight - fFarHalfHeight * vCamUp;
pCorners[6] = vFarCenter - fFarHalfWidth * vCamRight + fFarHalfHeight * vCamUp;
pCorners[7] = vFarCenter - fFarHalfWidth * vCamRight - fFarHalfHeight * vCamUp;
D3DXVECTOR3 vCenter = (vNearCenter + vFarCenter) / 2.0f;
// Apply split overlap scaling
for(int i = 0; i < 8; i++)
pCorners[i] += (pCorners[i] - vCenter) * fOverlap;
}

View File

@@ -0,0 +1,63 @@
#pragma once
/***********************************************************************************/
/** \file PSSM.h
** \brief Header File zur Klasse PSSM
*************************************************************************************
** Autor: Christian Roesch
*************************************************************************************
** _tut nichts_
**
*//*********************************************************************************/
#ifndef _PSSM_H
#define _PSSM_H
// includes
#include <d3dx9.h>
#include <cassert>
// Klassen-Deklaration
extern IDirect3DDevice9* g_d3d_device;
/***********************************************************************************/
/** \brief PSSM _tut nichts_
*************************************************************************************
** Genau genommen _tut dies nichts_
**
*//*********************************************************************************/
class PSSM
{
public:
static const int MaxSplitCount = 16;
void Init();
void UpdateSplits(const D3DXVECTOR3 &vLightDir, const D3DXMATRIX &mView, const D3DXMATRIX &mProj);
int m_iSplitCount;
float m_fRange;
D3DXMATRIX m_ViewMatrices[MaxSplitCount];
D3DXMATRIX m_ProjMatrices[MaxSplitCount];
D3DXVECTOR3 m_ViewPos[MaxSplitCount];
D3DXVECTOR3 m_ViewDir[MaxSplitCount];
private:
void ComputeCornerPoints(D3DXVECTOR3 *pCorners,
float fNear, float fFar, float fFTanHalfFOVX, float fTanHalfFOVY,
const D3DXVECTOR3 &vCamPos, const D3DXVECTOR3 &vCamRight,
const D3DXVECTOR3 &vCamUp, const D3DXVECTOR3 &vCamLook,
float fOverlap);
};
#endif//_PSSM_H
class PSSM;
/************************************************************************************
** Ende der Datei: PSSM.h
************************************************************************************/

View File

@@ -0,0 +1,84 @@
#include "PointMapGenerator.h"
#include "globals.h"
int PointMapGenerator::GeneratePointMap(IDirect3DVertexBuffer9* vertexBuffer, IDirect3DIndexBuffer9* indexBuffer, int vertexCount, int indexCount, int vertexStride, int positionOffset, int normalOffset, float distanceFromVertex, D3DXVECTOR4* outPointMap, int takeEveryNtVertex)
{
char* vertexData;
PMG_INDEX_FORMAT* indexData;
vertexBuffer->Lock(0, 0, (void**)&vertexData, D3DLOCK_READONLY);
indexBuffer->Lock(0, 0, (void**)&indexData, D3DLOCK_READONLY);
int pointCount = GeneratePointMap(vertexData, indexData, vertexCount, indexCount, vertexStride, positionOffset, normalOffset, distanceFromVertex, outPointMap, takeEveryNtVertex);
vertexBuffer->Unlock();
indexBuffer->Unlock();
return pointCount;
}
int PointMapGenerator::GeneratePointMap(char* vertexData, PMG_INDEX_FORMAT* indexData, int vertexCount, int indexCount, int vertexStride, int positionOffset, int normalOffset, float distanceFromVertex, D3DXVECTOR4* outPointMap, int takeEveryNtVertex)
{
int pointCount = 0;
float maxY = 0;
float minY = 0;
for (int i = 0; i < indexCount; ++i)
{
// Assertion does not hold, so what?
if ( indexData[i] >= vertexCount )
continue;
assert ( indexData[i] < vertexCount );
D3DXVECTOR3* v = (D3DXVECTOR3*)&vertexData[indexData[i] * vertexStride + positionOffset];
if (i == 0 || maxY < v->y)
{
maxY = v->y;
}
if (i == 0 || minY > v->y)
{
minY = v->y;
}
}
for (int i = 0; i < indexCount; i += takeEveryNtVertex)
{
// Assertion does not hold, so what?
if ( indexData[i] >= vertexCount )
continue;
assert ( indexData[i] < vertexCount );
D3DXVECTOR3* v = (D3DXVECTOR3*)&vertexData[indexData[i] * vertexStride + positionOffset];
D3DXVECTOR3* n = (D3DXVECTOR3*)&vertexData[indexData[i] * vertexStride + normalOffset];
D3DXVECTOR3 result = (*v) + (*n) * distanceFromVertex * g_Random.genFloat();
outPointMap[pointCount++] = D3DXVECTOR4(
result.x,
result.y,
result.z,
((v->y - minY) / (maxY - minY)) * 0.2 + g_Random.genFloat(0.0f, 0.8f));
}
return pointCount;
}
void PointMapGenerator::FillPointMap(int pointMapIndex, int objectIndex, int fluidIndex, int takeEveryNtVertex)
{
int pointCount = GeneratePointMap(
g_Objects[ objectIndex ].GetVB(),
g_Objects[ objectIndex ].GetIB(),
g_Objects[ objectIndex ].GetVertCount(),
g_Objects[ objectIndex ].GetIndexCount(),
sizeof(Renderjob::SVertex),
0,
3 * sizeof(FLOAT),
g_PointMapDistance[pointMapIndex],
g_FluidPointMap[pointMapIndex],
takeEveryNtVertex);
assert( pointCount <= 100000 );
g_FluidParticleSystem[fluidIndex] = g_FluidContext.GenerateFluidParticleSystem(pointCount * 4);
}

View File

@@ -0,0 +1,15 @@
#pragma once
#include <d3d9.h>
#include <d3dx9.h>
#define PMG_INDEX_FORMAT short
class PointMapGenerator
{
public:
static int GeneratePointMap(IDirect3DVertexBuffer9* vertexBuffer, IDirect3DIndexBuffer9* indexBuffer, int vertexCount, int indexCount, int vertexStride, int positionOffset, int normalOffset, float distanceFromVertex, D3DXVECTOR4* outPointMap, int takeEveryNtVertex);
static int GeneratePointMap(char* vertexData, PMG_INDEX_FORMAT* indexData, int vertexCount, int indexCount, int vertexStride, int positionOffset, int normalOffset, float distanceFromVertex, D3DXVECTOR4* outPointMap, int takeEveryNtVertex);
static void FillPointMap(int pointMapIndex, int objectIndex, int fluidIndex, int takeEveryNtVertex );
};

View File

@@ -0,0 +1,70 @@
#pragma once
/***********************************************************************************/
/** \file Renderpipe.h
** \brief Header File zur Klasse Renderpipe
*************************************************************************************
** Autor: Christian Roesch
*************************************************************************************
** _tut nichts_
**
*//*********************************************************************************/
#ifndef _Renderpipe_H
#define _Renderpipe_H
// includes
#include <d3dx9.h>
#include <cassert>
// Klassen-Deklaration
extern IDirect3DDevice9* g_d3d_device;
/***********************************************************************************/
/** \brief Renderpipe _tut nichts_
*************************************************************************************
** Genau genommen _tut dies nichts_
**
*//*********************************************************************************/
class Renderpipe
{
public:
static void PrepareRenderTargets(UINT nScreenX, UINT nScreenY, UINT nShadowXY, UINT nEnvXY, UINT nEnvBlurXY,
D3DMULTISAMPLE_TYPE multiSampleType);
static void PrepareDefaultRenderStates(RenderTargetSurfaceIndices colorSurface = RTS_COLOR_MS,
RenderTargetSurfaceIndices depthSurface = RTS_DEFAULT_DS,
RenderTargetIndices linearDepthTexture = RT_DEPTH);
static void PrepareShadowRenderStates();
static void PreparePreRenderStates(RenderTargetSurfaceIndices colorSurface = RTS_DEPTH_MS,
RenderTargetSurfaceIndices depthSurface = RTS_DEFAULT_DS);
static void PrepareFullScreenQuadRenderStates(RenderTargetIndices linearDepthTexture = RT_DEPTH,
RenderTargetIndices colorTexture = RT_COLOR);
static void PrepareWithoutPostProcessing(RenderTargetSurfaceIndices colorSurface = RTS_COLOR_MS,
RenderTargetSurfaceIndices depthSurface = RTS_DEFAULT_DS);
static void SimpleRenderPass();
static void FullRenderPass();
static void CubeRenderPass();
static void CubeBlurPass();
static void RenderScene(const D3DXMATRIX &mView, const D3DXMATRIX &mProj,
const D3DXVECTOR3 &vCamPos, const D3DXVECTOR3 &vCamDir,
RenderTargetSurfaceIndices colorSurfaceMS, RenderTargetSurfaceIndices colorSurface,
RenderTargetSurfaceIndices linearDepthSurfaceMS, RenderTargetSurfaceIndices linearDepthSurface,
RenderTargetSurfaceIndices depthSurface, RenderTargetIndices linearDepthTexture);
static void RenderPostProcessing(bool bSubmerged, bool bOcean, bool bSSAO);
static void RenderReflection();
};
#endif//_Renderpipe_H
class Renderpipe;
/************************************************************************************
** Ende der Datei: Renderpipe.h
************************************************************************************/

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,310 @@
#include "defines.h"
#include "shader.h"
#include "globals.h"
D3DXMATRIX Shader::s_matVP;
void RenderLoading( int iPercent );
void Shader::Init()
{
m_pVSShader= NULL;
m_pPSShader= NULL;
#ifdef EXTRACODE
m_iRevision= 0;
#endif
// per default Texturen einfach lassen wie sie sind
m_iUsedTextureStageCount= -1;
for( int i= 0; i < m_iMaxTextureStageCount; ++i )
{
m_iTextureIndices[ i ]= TI_IgnoreSetting;
m_iTextureSettings[ i ]= TI_IgnoreSetting;
}
}
void Shader::DeInit()
{
Release();
}
void Shader::Release()
{
if( m_pVSShader != NULL )
{
m_pVSShader->Release();
m_pVSShader= NULL;
}
if( m_pPSShader != NULL )
{
m_pPSShader->Release();
m_pPSShader= NULL;
}
}
void Shader::CompileVS(const char* pShaderCode, const char* pEntryPoint, IDirect3DVertexShader9 **ppCachedShader )
{
#ifdef EXTRACODE
std::string strCurrentCode( pShaderCode );
if( strCurrentCode == m_strVSCode )
{
return;
}
m_strVSCode= strCurrentCode;
#endif
if(ppCachedShader && *ppCachedShader)
{
m_pVSShader = *ppCachedShader;
return;
}
ID3DXBuffer* tmp= NULL;
#if LAPTOPMODE == 1
Compile( pShaderCode, pEntryPoint, "vs_2_0", &tmp );
#else
Compile( pShaderCode, pEntryPoint, "vs_3_0", &tmp );
#endif
if( tmp == NULL )
{
return;
}
g_d3d_device->CreateVertexShader( (DWORD*)tmp->GetBufferPointer(), &m_pVSShader );
tmp->Release();
#ifdef EXTRACODE
m_iRevision++;
#endif
if(ppCachedShader)
*ppCachedShader = m_pVSShader;
RenderLoading( 1 );
}
void Shader::CompilePS(const char* pShaderCode, const char* pEntryPoint )
{
#ifdef EXTRACODE
std::string strCurrentCode( pShaderCode );
if( strCurrentCode == m_strPSCode )
{
return;
}
m_strPSCode= strCurrentCode;
#endif
ID3DXBuffer* tmp= NULL;
#if LAPTOPMODE == 1
Compile( pShaderCode, pEntryPoint, "ps_2_0", &tmp );
#else
Compile( pShaderCode, pEntryPoint, "ps_3_0", &tmp );
#endif
if( tmp == NULL )
{
return;
}
g_d3d_device->CreatePixelShader( (DWORD*)tmp->GetBufferPointer(), &m_pPSShader );
tmp->Release();
#ifdef EXTRACODE
m_iRevision++;
#endif
RenderLoading( 1 );
}
void Shader::Compile( const char* pShaderCode, const char* pEntryPoint, const char* ShaderModel, ID3DXBuffer** tmp )
{
int iLength= 0;
while(pShaderCode[ iLength ] != 0 )
{
iLength++;
}
#ifndef _DEBUG
D3DXCompileShader( pShaderCode, iLength, 0, 0, pEntryPoint, ShaderModel, D3DXSHADER_OPTIMIZATION_LEVEL3|D3DXSHADER_PREFER_FLOW_CONTROL, tmp, 0, 0 );
#else
ID3DXBuffer *errors;
if( D3DXCompileShader( pShaderCode, iLength, 0, 0, pEntryPoint, ShaderModel, D3DXSHADER_DEBUG*0+1*(D3DXSHADER_OPTIMIZATION_LEVEL3|D3DXSHADER_PREFER_FLOW_CONTROL), tmp, &errors, 0 ) <0 )
{
OutputDebugString( "Error in D3DXCompileShader:\n" );
OutputDebugString( pShaderCode );
OutputDebugString( "\n" );
OutputDebugString( (char*)errors->GetBufferPointer() );
errors->Release();
//assert( false );
return;
}
OutputDebugString( "Shader compiled.\n" );
#endif
}
void Shader::Activate()
{
g_d3d_device->SetPixelShader( m_pPSShader );
g_d3d_device->SetVertexShader( m_pVSShader );
for( int i= 0; i <= m_iUsedTextureStageCount; ++i )
{
if( m_iTextureIndices[ i ] != TI_IgnoreSetting )
{
g_d3d_device->SetTexture(
i,
g_pTextures[ m_iTextureIndices[ i ] ].GetPointer() );
g_d3d_device->SetSamplerState( i, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP );
g_d3d_device->SetSamplerState( i, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP );
g_d3d_device->SetSamplerState( i, D3DSAMP_ADDRESSW, D3DTADDRESS_WRAP );
if( m_iTextureSettings[ i ] == TI_CLAMP )
{
g_d3d_device->SetSamplerState( i, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP );
g_d3d_device->SetSamplerState( i, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP );
g_d3d_device->SetSamplerState( i, D3DSAMP_ADDRESSW, D3DTADDRESS_CLAMP );
}
}
}
}
void Shader::Deactivate()
{
g_d3d_device->SetPixelShader( NULL );
g_d3d_device->SetVertexShader( NULL );
}
void Shader::SetTransform(const D3DXMATRIX &mWorld, const D3DXMATRIX &mWorldInverse)
{
/***********************************************************************************/
// Konstanten fuer Shader setzen
D3DXMATRIX float4x4Mat;
//[VS] float4x4 matWVP : register(c0);
D3DXMatrixMultiply( &float4x4Mat, &mWorld, &s_matVP );
D3DXMatrixTranspose( &float4x4Mat, &float4x4Mat );
g_d3d_device->SetVertexShaderConstantF( 0, (float*)&float4x4Mat, 4 );
//[VS] float4x4 matWorld : register(c12);
D3DXMatrixTranspose( &float4x4Mat, &mWorld );
g_d3d_device->SetVertexShaderConstantF( 12, (float*)&float4x4Mat, 4 );
//[VS] float4x4 matWorldI : register(c16);
D3DXMatrixTranspose( &float4x4Mat, &mWorldInverse );
g_d3d_device->SetVertexShaderConstantF( 16, (float*)&float4x4Mat, 4 );
}
void Shader::SetCamera(const D3DXMATRIX &mView, const D3DXMATRIX &mProj,
const D3DXVECTOR3 &vCamPos, const D3DXVECTOR3 &vCamDir,
D3DXMATRIX *pMatVP)
{
/***********************************************************************************/
// Konstanten fuer Shader setzen
D3DXMATRIX float4x4Mat;
float float4Vec[4];
//[VS] float4x4 matWVP : register(c0);
D3DXMatrixMultiply( &s_matVP, &mView, &mProj );
D3DXMatrixTranspose( &float4x4Mat, &s_matVP );
g_d3d_device->SetVertexShaderConstantF( 0, (float*)&float4x4Mat, 4 );
// Output view projection matrix, if requested
if(pMatVP)
memcpy(pMatVP, &s_matVP, sizeof(D3DXMATRIX));
//[VS] float3x3 viewMatrixRotInv : register(c7);
g_d3d_device->SetVertexShaderConstantF( 7, (float*)&mView, 3 );
//[VS] float4 projScaleOffsetInv : register(c11);
float4Vec[0] = 1.0f / mProj._11;
float4Vec[1] = 1.0f / mProj._22;
float4Vec[2] = -(mProj._31 + mProj._41) * float4Vec[0];
float4Vec[3] = -(mProj._32 + mProj._42) * float4Vec[1];
g_d3d_device->SetVertexShaderConstantF( 11, float4Vec, 1 );
//[VS] float3 viewPos : register(c4);
//[PS] float3 viewPos : register(c2);
memcpy(float4Vec, &vCamPos, sizeof(float)*3);
g_d3d_device->SetVertexShaderConstantF( 4, float4Vec, 1 );
g_d3d_device->SetPixelShaderConstantF( 2, float4Vec, 1 );
//[VS] float3 viewDir : register(c10);
//[PS] float3 viewDir : register(c4);
memcpy(float4Vec, &vCamDir, sizeof(float)*3);
g_d3d_device->SetVertexShaderConstantF( 10, float4Vec, 1 );
g_d3d_device->SetPixelShaderConstantF( 4, float4Vec, 1 );
}
void Shader::SetResolution(int iResX, int iResY)
{
/***********************************************************************************/
// Konstanten fuer Shader setzen
float float4Vec[4];
//[VS] float2 res : register(c5);
//[PS] float2 res : register(c0);
float4Vec[0] = (float)iResX;
float4Vec[1] = (float)iResY;
float4Vec[2] = 1.f / float4Vec[0];
float4Vec[3] = 1.f / float4Vec[1];
g_d3d_device->SetVertexShaderConstantF( 5, float4Vec, 1 );
g_d3d_device->SetPixelShaderConstantF( 0, float4Vec, 1 );
}
void Shader::SetConstants(bool bHDR)
{
/***********************************************************************************/
// Konstanten fuer Shader setzen
float float4Vec[4];
// Set screen resoluton
SetResolution(d3dpp.BackBufferWidth,
d3dpp.BackBufferHeight);
//[VS] float3 lightDir : register(c6);
//[PS] float3 lightDir : register(c1);
memcpy(float4Vec, &g_LightDir, sizeof(float)*3);
g_d3d_device->SetVertexShaderConstantF( 6, float4Vec, 1 );
g_d3d_device->SetPixelShaderConstantF( 1, float4Vec, 1 );
//[PS] float demoTime : register(c3);
float4Vec[0]= 64.0f * (float)g_Camera.m_iDemoTime / (float)g_iCamTickFactor;
float4Vec[1]= g_Camera.m_fDOF * g_Camera.m_fDOF;
float4Vec[2]= g_fCamTime;//g_fClouds;
float4Vec[3]= g_fShaderBeat;//g_fPlasmaGrid;
g_d3d_device->SetPixelShaderConstantF( 3, float4Vec, 1 );
//[PS] float4 glow : register(c61);
{
float4Vec[0] = g_fGlow;
float4Vec[1] = g_fGlow;
float4Vec[2] = (g_Camera.m_iScene == g_CubeMapCamera.m_iScene) ? 1.0f : 0.0f;
float4Vec[3] = bHDR ? 1.0f : 0.0f;
g_d3d_device->SetPixelShaderConstantF( 61, float4Vec, 1 );
}
}
void Shader::SetTextureStageSettings(
int iTextureStage,
int iTextureIndex,
int iTextureSettings )
{
assert( iTextureStage < m_iMaxTextureStageCount );
if( iTextureStage > m_iUsedTextureStageCount )
{
m_iUsedTextureStageCount= iTextureStage;
}
m_iTextureIndices[ iTextureStage ]= iTextureIndex;
m_iTextureSettings[ iTextureStage ]= iTextureSettings;
}

View File

View File

@@ -0,0 +1,161 @@
#pragma once
#include "globals.h"
#include "shader.h"
// --> Neuen Shader hinzufuegen:
//
// in globals.h und globals.cpp ein neues Char Array fuer den Quellcode des Shader anlegen
// in globals.h das Enum ShaderIndices erweitern
// eine Datei im cfg Verzeichnis anlegen, die diesen Shader enthaelt
// in ConfigFiles.cpp die Funktion ReadShaders() erweitern, damit die Datei in das Array eingelesen wird
// den Shader in PrepareShaders compilieren
void RenderLoading( int iPercent );
void PrepareShaders()
{
IDirect3DVertexShader9* pVSGeneral = NULL;
IDirect3DVertexShader9* pVSFSQuad = NULL;
#ifdef EXTRACODE
OutputDebugString( "Creating shaders: \n" );
DWORD dwTicks = GetTickCount();
#endif
//Postprocessing Zeug
g_Shaders[ PreDepth ].CompileVS(g_ShaderVSGeneral, "vs_main", &pVSGeneral );
g_Shaders[ PreDepth ].CompilePS(g_ShaderPSDepth, "ps_main" );
g_Shaders[ PSSM_Proj ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ PSSM_Proj ].CompilePS(g_ShaderPSPSSM, "ps_main" );
g_Shaders[ SSAO ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ SSAO ].CompilePS(g_ShaderPSAmbOcc, "ps_main" );
g_Shaders[ SSAO_BlurH ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ SSAO_BlurH ].CompilePS(g_ShaderPSAmbOcc, "ps_blur_hor" );
g_Shaders[ SSAO_BlurV ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ SSAO_BlurV ].CompilePS(g_ShaderPSAmbOcc, "ps_blur_ver" );
g_Shaders[ DOF_Intensity ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ DOF_Intensity ].CompilePS(g_ShaderPSDOF, "ps_blur_intensity" );
g_Shaders[ DOF ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ DOF ].CompilePS(g_ShaderPSDOF, "ps_main" );
g_Shaders[ BlurBilH ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ BlurBilH ].CompilePS(g_ShaderPSBlur, "ps_blur_bil_hor" );
g_Shaders[ BlurBilV ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ BlurBilV ].CompilePS(g_ShaderPSBlur, "ps_blur_bil_ver" );
g_Shaders[ Underwater ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ Underwater ].CompilePS(g_ShaderPSRay, "ps_underwater" );
g_Shaders[ Underwater ].SetTextureStageSettings( 3, TI_Wave );
g_Shaders[ Underwater_Filter ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ Underwater_Filter ].CompilePS(g_ShaderPSRay, "ps_underwater_filter" );
g_Shaders[ Underwater_Filter ].SetTextureStageSettings( 3, TI_Wave );
g_Shaders[ Ray_Mask ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ Ray_Mask ].CompilePS(g_ShaderPSRay, "ps_ray_mask" );
g_Shaders[ Ray_Extrude ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ Ray_Extrude ].CompilePS(g_ShaderPSRay, "ps_ray_extrude" );
g_Shaders[ Extract_InvAlpha ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ Extract_InvAlpha ].CompilePS(g_ShaderPSBlur, "ps_extract_inv_alpha" );
g_Shaders[ BlurH ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ BlurH ].CompilePS(g_ShaderPSBlur, "ps_blur_hor" );
g_Shaders[ BlurV ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ BlurV ].CompilePS(g_ShaderPSBlur, "ps_blur_ver" );
g_Shaders[ Crystal ].CompileVS(g_ShaderVSGeneral, "vs_main", &pVSGeneral );
g_Shaders[ Crystal ].CompilePS(g_ShaderPSCrystal, "ps_main" );
g_Shaders[ Phong ].CompileVS(g_ShaderVSGeneral, "vs_main", &pVSGeneral );
g_Shaders[ Phong ].CompilePS(g_ShaderPSPhong, "ps_main" );
g_Shaders[ Sky ].CompileVS(g_ShaderVSSky, "vs_main" );
g_Shaders[ Sky ].CompilePS(g_ShaderPSSky, "ps_sky" );
g_Shaders[ Sky ].SetTextureStageSettings( 0, TI_RandomCube );
g_Shaders[ CaveSky ].CompileVS(g_ShaderVSSky, "vs_main" );
g_Shaders[ CaveSky ].CompilePS(g_ShaderPSSky, "ps_cave_sky" );
g_Shaders[ CaveSky ].SetTextureStageSettings( 0, TI_RandomCube );
g_Shaders[ EnvSky ].CompileVS(g_ShaderVSSky, "vs_main" );
g_Shaders[ EnvSky ].CompilePS(g_ShaderPSSky, "ps_env" );
g_Shaders[ Ocean ].CompileVS(g_ShaderVSOcean, "vs_main" );
g_Shaders[ Ocean ].CompilePS(g_ShaderPSOcean, "ps_main" );
g_Shaders[ Ocean ].SetTextureStageSettings( 0, TI_Wave );
g_Shaders[ Terrain ].CompileVS(g_ShaderVSGeneral, "vs_main", &pVSGeneral );
g_Shaders[ Terrain ].CompilePS(g_ShaderPSTerrain, "ps_terrain" );
g_Shaders[ Terrain ].SetTextureStageSettings( 0, TI_Wave );
g_Shaders[ Terrain ].SetTextureStageSettings( 1, TI_RandomCube );
g_Shaders[ Cave ].CompileVS(g_ShaderVSGeneral, "vs_main", &pVSGeneral );
g_Shaders[ Cave ].CompilePS(g_ShaderPSTerrain, "ps_cave" );
g_Shaders[ Cave ].SetTextureStageSettings( 0, TI_Wave );
g_Shaders[ Cave ].SetTextureStageSettings( 1, TI_RandomCube );
g_Shaders[ CaveGround ].CompileVS(g_ShaderVSGeneral, "vs_main", &pVSGeneral );
g_Shaders[ CaveGround ].CompilePS(g_ShaderPSTerrain, "ps_cave_ground" );
g_Shaders[ CaveGround ].SetTextureStageSettings( 0, TI_Wave );
g_Shaders[ CaveGround ].SetTextureStageSettings( 1, TI_RandomCube );
g_Shaders[ FluidDepth ].CompileVS(g_ShaderVSFluid, "vsDepth" );
g_Shaders[ FluidDepth ].CompilePS(g_ShaderPSFluid, "psDepth" );
g_Shaders[ FluidPosition ].CompileVS(g_ShaderVSFluid, "vsDeferred" );
g_Shaders[ FluidPosition ].CompilePS(g_ShaderPSFluid, "psPosition" );
g_Shaders[ FluidNormal ].CompileVS(g_ShaderVSFluid, "vsDeferred" );
g_Shaders[ FluidNormal ].CompilePS(g_ShaderPSFluid, "psNormal" );
g_Shaders[ FluidBlur ].CompileVS(g_ShaderVSFluid, "vsCompose" );
g_Shaders[ FluidBlur ].CompilePS(g_ShaderPSFluid, "psBlur" );
g_Shaders[ FluidCompose ].CompileVS(g_ShaderVSFluid, "vsCompose" );
g_Shaders[ FluidCompose ].CompilePS(g_ShaderPSFluid, "psCompose" );
g_Shaders[ TerrainDepth ].CompileVS(g_ShaderVSGeneral, "vs_main", &pVSGeneral );
g_Shaders[ TerrainDepth ].CompilePS(g_ShaderPSDepth, "ps_main" );
g_Shaders[ TexGen_Perlin ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ TexGen_Perlin ].CompilePS(g_ShaderPSTexGen, "ps_perlin" );
g_Shaders[ TexGen_Wave ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ TexGen_Wave ].CompilePS(g_ShaderPSTexGen, "ps_wave" );
g_Shaders[ TexGen_Normal ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ TexGen_Normal ].CompilePS(g_ShaderPSTexGen, "ps_normal" );
g_Shaders[ TexGen_CubeBlur ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ TexGen_CubeBlur ].CompilePS(g_ShaderPSTexGen, "ps_cube_blur" );
g_Shaders[ Overlay_Logo ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ Overlay_Logo ].CompilePS(g_ShaderPSTexGen, "ps_logo" );
g_Shaders[ Overlay_Fade ].CompileVS(g_ShaderVSFSQuad, "vs_main", &pVSFSQuad );
g_Shaders[ Overlay_Fade ].CompilePS(g_ShaderPSTexGen, "ps_fade" );
g_Shaders[ SkyDepth ].CompileVS(g_ShaderVSSky, "vs_main" );
g_Shaders[ SkyDepth ].CompilePS(g_ShaderPSDepth, "ps_main" );
g_Shaders[ Text ].CompileVS(g_ShaderVSGeneral, "vs_main", &pVSGeneral );
g_Shaders[ Text ].CompilePS(g_ShaderPSText, "ps_main" );
g_Shaders[ Text ].SetTextureStageSettings( 0, TI_Wave );
g_Shaders[ Text ].SetTextureStageSettings( 1, TI_RandomCube );
g_Shaders[ EnvLit ].CompileVS(g_ShaderVSGeneral, "vs_main", &pVSGeneral );
g_Shaders[ EnvLit ].CompilePS(g_ShaderPSEnvLit, "ps_main" );
#ifdef EXTRACODE
char cTime[256];
dwTicks = GetTickCount() - dwTicks;
sprintf_s( cTime, "Shader Compilation Time: %d \n", dwTicks );
OutputDebugString( cTime );
#endif
}

View File

@@ -0,0 +1,213 @@
/***********************************************************************************/
/** \file StringHelper.cpp
** \brief Implementation zur Klasse StringHelper
*************************************************************************************
** Autor: Christian Roesch
*************************************************************************************
** -tut nichts-
**
*//*********************************************************************************/
// includes
#include "StringHelper.h"
#include <cstdio>
std::vector< char > FrameWork::StringHelper::m_SpaceTab;
FrameWork::StringHelper::StringHelperPreparer FrameWork::StringHelper::m_shpDummy;
// Methoden-Definitionen
namespace FrameWork
{
/***********************************************************************************/
/** Schneidet einen String an den Separatoren auseinander. Der vorderste Teil wird
*** abgeschnitten, falls der Separator gefunden wird. Der Eingabestring wird auf den
*** Teil hinter dem Seperator gestutzt
***
*** \param strInput [in\out] Ursprungsstring
*** \param strSeperator Seperator
*** \param strOutput der vorne abgeschnittene Teil
***
*** \return true, wenn Seperator gefunden
*//*********************************************************************************/
bool StringHelper::splitAt(
std::string& strInput,
const std::string& strSeperator,
std::string& strOutput )
{
size_t tStart= strInput.find( strSeperator );
if( tStart == std::string::npos )
{
strOutput= strInput;
return false;
}
strOutput= strInput.substr( 0, tStart );
strInput= strInput.substr( tStart + strSeperator.size() );
return true;
}
/***********************************************************************************/
/** Schneidet einen String an den Separatoren auseinander. Der vorderste Teil wird
*** abgeschnitten, falls der Separator gefunden wird. Der Eingabestring wird auf den
*** Teil hinter dem Seperator gestutzt
***
*** \param strInput [in\out] Ursprungsstring
*** \param strSeperator Seperator
*** \param strOutput der vorne abgeschnittene Teil
***
*** \return true, strInput nicht leer und strOutput enthaelt Daten
*** false, strInput leer und strOutput keine enthaelt Daten
*//*********************************************************************************/
bool StringHelper::splitLoop(
std::string& strInput,
const std::string& strSeperator,
std::string& strOutput )
{
if( strInput.empty() )
{
return false;
}
size_t tStart= strInput.find( strSeperator );
if( tStart == std::string::npos )
{
strOutput= strInput;
strInput= "";
}
else
{
strOutput= strInput.substr( 0, tStart );
strInput= strInput.substr( tStart + strSeperator.size() );
}
return true;
}
bool StringHelper::tokenize( std::string& strInput,
const std::string& strSeperator,
std::vector< std::string >& vecOutput )
{
std::string strCommand;
while( FrameWork::StringHelper::splitAt( strInput, strSeperator, strCommand ) )
{
vecOutput.push_back( strCommand );
}
vecOutput.push_back( strInput );
return true;
}
bool StringHelper::trimFront( std::string& strData, char cWhiteSpace )
{
int i= 0;
if( (int)strData.size() == 0 )
{
return false;
}
while( strData[ i ] == cWhiteSpace )
{
i++;
}
if( i > 0 )
{
strData= strData.substr( i );
return true;
}
return false;
}
bool StringHelper::trimBack( std::string& strData, char cWhiteSpace )
{
int i= (int)strData.size() - 1;
if( i == -1 )
{
return false;
}
while( strData[ i ] == cWhiteSpace )
{
i--;
}
if( i < (int)strData.size() - 1 )
{
strData= strData.substr( 0, i + 1 );
return true;
}
return false;
}
bool StringHelper::trim( std::string& strData, char cWhiteSpace )
{
bool bTrimmed= trimFront( strData, cWhiteSpace );
bTrimmed|= trimBack( strData, cWhiteSpace );
return bTrimmed;
}
bool StringHelper::trimFront( std::string& strData, std::vector< char >& WhiteSpaces )
{
bool bTrimmed;
do
{
bTrimmed= false;
for( int i= 0; i < (int)WhiteSpaces.size(); ++i )
{
bTrimmed|= trimFront( strData, WhiteSpaces[ i ] );
}
} while( bTrimmed );
return bTrimmed;
}
bool StringHelper::trimBack( std::string& strData, std::vector< char >& WhiteSpaces )
{
bool bTrimmed;
do
{
bTrimmed= false;
for( int i= 0; i < (int)WhiteSpaces.size(); ++i )
{
bTrimmed|= trimBack( strData, WhiteSpaces[ i ] );
}
} while( bTrimmed );
return bTrimmed;
}
bool StringHelper::trim( std::string& strData, std::vector< char >& WhiteSpaces )
{
bool bTrimmed= trimFront( strData, WhiteSpaces );
bTrimmed|= trimBack( strData, WhiteSpaces );
return bTrimmed;
}
std::vector< char >& StringHelper::getSpaceTab()
{
return m_SpaceTab;
}
void StringHelper::toUpper( std::string& strData )
{
for( int i= 0; i < (int)strData.size(); ++i )
{
strData[ i ]= toupper( strData[ i ] );
}
}
void StringHelper::toLower( std::string& strData )
{
for( int i= 0; i < (int)strData.size(); ++i )
{
strData[ i ]= tolower( strData[ i ] );
}
}
}
/************************************************************************************
** Ende der Datei: StringHelper.cpp
************************************************************************************/

View File

@@ -0,0 +1,100 @@
/***********************************************************************************/
/** \file StringHelper.h
** \brief Header File zur Klasse StringHelper
*************************************************************************************
** Autor: Christian Roesch
*************************************************************************************
** _tut nichts_
**
*//*********************************************************************************/
#ifndef _StringHelper_H
#define _StringHelper_H
// includes
#include <string>
#include <vector>
// Klassen-Deklaration
namespace FrameWork
{
/***********************************************************************************/
/** \brief StringHelper _tut nichts_
*************************************************************************************
** Genau genommen _tut dies nichts_
**
*//*********************************************************************************/
class StringHelper
{
public:
static bool splitAt(
std::string& strInput,
const std::string& strSeperator,
std::string& strOutput );
static bool splitLoop(
std::string& strInput,
const std::string& strSeperator,
std::string& strOutput );
static bool tokenize( std::string& strInput,
const std::string& strSeperator,
std::vector< std::string >& vecOutput );
static bool trim(
std::string& strData,
std::vector< char >& WhiteSpaces );
static bool trim(
std::string& strData,
char cWhiteSpace );
static bool trimFront(
std::string& strData,
std::vector< char >& WhiteSpaces );
static bool trimFront(
std::string& strData,
char cWhiteSpace );
static bool trimBack(
std::string& strData,
std::vector< char >& WhiteSpaces );
static bool trimBack(
std::string& strData,
char cWhiteSpace );
static void toUpper( std::string& strData );
static void toLower( std::string& strData );
struct StringHelperPreparer
{
StringHelperPreparer()
{
StringHelper::m_SpaceTab.push_back( ' ' );
StringHelper::m_SpaceTab.push_back( '\t' );
}
};
static std::vector< char >& getSpaceTab();
protected:
private:
static StringHelperPreparer m_shpDummy;
static std::vector< char > m_SpaceTab;
};
}
#endif//_StringHelper_H
class FrameWork::StringHelper;
/************************************************************************************
** Ende der Datei: StringHelper.h
************************************************************************************/

View File

@@ -0,0 +1,32 @@
#pragma once
struct STargetValue
{
float m_fValue;
float m_fTarget;
float m_fSpeed;
float m_fAcceleration;
float m_fFriction;
STargetValue
( float fValue,
float fTarget,
float fSpeed,
float fAcceleration,
float fFriction )
{
m_fValue= fValue;
m_fTarget= fTarget;
m_fSpeed= fSpeed;
m_fAcceleration= fAcceleration;
m_fFriction= fFriction;
}
void timeStep()
{
m_fValue+= m_fSpeed;
float fDist= m_fTarget - m_fValue;
m_fSpeed+= fDist * m_fAcceleration;
m_fSpeed*= m_fFriction;
}
};

View File

@@ -0,0 +1,910 @@
#include "TerrainGrid.h"
#include "tweak/main.txt"
#include "globals.h"
#include <d3dx9.h>
#include <cassert>
#include "intrin.h"
void RenderLoading( int iPercent );
static const unsigned short edgeTable[256] =
{
0x000, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,
0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
0x190, 0x99 , 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,
0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,
0x230, 0x339, 0x33 , 0x13a, 0x636, 0x73f, 0x435, 0x53c,
0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,
0x3a0, 0x2a9, 0x1a3, 0xaa , 0x7a6, 0x6af, 0x5a5, 0x4ac,
0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,
0x460, 0x569, 0x663, 0x76a, 0x66 , 0x16f, 0x265, 0x36c,
0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,
0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff , 0x3f5, 0x2fc,
0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,
0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55 , 0x15c,
0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,
0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc ,
0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,
0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,
0xcc , 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,
0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,
0x15c, 0x55 , 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,
0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,
0x2fc, 0x3f5, 0xff , 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,
0x36c, 0x265, 0x16f, 0x66 , 0x76a, 0x663, 0x569, 0x460,
0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,
0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa , 0x1a3, 0x2a9, 0x3a0,
0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,
0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33 , 0x339, 0x230,
0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,
0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99 , 0x190,
0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,
0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x000
};
static const char triTable[256][16] =
{
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1},
{3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1},
{3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1},
{3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1},
{9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1},
{9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1},
{2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1},
{8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1},
{9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1},
{4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1},
{3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1},
{1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1},
{4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1},
{4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1},
{5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1},
{2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1},
{9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1},
{0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1},
{2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1},
{10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1},
{5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1},
{5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1},
{9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1},
{0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1},
{1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1},
{10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1},
{8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1},
{2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1},
{7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1},
{2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1},
{11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1},
{5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1},
{11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1},
{11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1},
{1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1},
{9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1},
{5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1},
{2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1},
{5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1},
{6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1},
{3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1},
{6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1},
{5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1},
{1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1},
{10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1},
{6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1},
{8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1},
{7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1},
{3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1},
{5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1},
{0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1},
{9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1},
{8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1},
{5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1},
{0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1},
{6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1},
{10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1},
{10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1},
{8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1},
{1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1},
{0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1},
{10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1},
{3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1},
{6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1},
{9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1},
{8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1},
{3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1},
{6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1},
{0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1},
{10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1},
{10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1},
{2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1},
{7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1},
{7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1},
{2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1},
{1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1},
{11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1},
{8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1},
{0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1},
{7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1},
{10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1},
{2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1},
{6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1},
{7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1},
{2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1},
{1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1},
{10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1},
{10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1},
{0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1},
{7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1},
{6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1},
{8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1},
{9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1},
{6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1},
{4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1},
{10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1},
{8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1},
{0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1},
{1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1},
{8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1},
{10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1},
{4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1},
{10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1},
{5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1},
{11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1},
{9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1},
{6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1},
{7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1},
{3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1},
{7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1},
{3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1},
{6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1},
{9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1},
{1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1},
{4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1},
{7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1},
{6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1},
{3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1},
{0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1},
{6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1},
{0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1},
{11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1},
{6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1},
{5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1},
{9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1},
{1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1},
{1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1},
{10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1},
{0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1},
{5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1},
{10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1},
{11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1},
{9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1},
{7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1},
{2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1},
{8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1},
{9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1},
{9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1},
{1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1},
{9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1},
{9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1},
{5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1},
{0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1},
{10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1},
{2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1},
{0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1},
{0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1},
{9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1},
{5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1},
{3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1},
{5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1},
{8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1},
{0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1},
{9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1},
{1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1},
{3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1},
{4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1},
{9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1},
{11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1},
{11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1},
{2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1},
{9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1},
{3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1},
{1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1},
{4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1},
{3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1},
{0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1},
{9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1},
{1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}
};
static const unsigned char edgeConnection[12][2] =
{
{0,1}, {1,2}, {2,3}, {3,0},
{4,5}, {5,6}, {6,7}, {7,4},
{0,4}, {1,5}, {2,6}, {3,7}
};
static const D3DVECTOR gridVertices[8] =
{
{0,0,1}, {1,0,1}, {1,0,0}, {0,0,0},
{0,1,1}, {1,1,1}, {1,1,0}, {0,1,0}
};
const int c_iMaxTerrainVertices= 1 << 19;
static D3DXVECTOR3 vertices[c_iMaxTerrainVertices];
const int c_iMaxTerrainIndices = 1 << 21;
static int indices[c_iMaxTerrainIndices];
const int c_iMaxTerrainStepsXZ = 512;
const int c_iMaxTerrainStepsY = 256;
static float isoValues[c_iMaxTerrainStepsXZ * c_iMaxTerrainStepsY * 2];
static int indexValues[c_iMaxTerrainStepsXZ * c_iMaxTerrainStepsY * 5];
float IsoSphere(const D3DXVECTOR3& pos, const D3DXVECTOR3& center, const D3DXVECTOR3& scale, float r)
{
D3DXVECTOR3 v = pos - center;
v.x *= scale.x;
v.y *= scale.y;
v.z *= scale.z;
return sqrtf(v.x * v.x + v.y * v.y + v.z * v.z) - r;
}
float IsoPlane(const D3DXVECTOR3& pos, const D3DXVECTOR3& center, const D3DXVECTOR3& normal)
{
D3DXVECTOR3 v = pos - center;
return D3DXVec3Dot(&v, &normal);
}
/*
__forceinline D3DXVECTOR3 D3DXOOV3(float x, float y, float z)
{
return D3DXVECTOR3(1.0f / x, 1.0f / y, 1.0f / z);
}
*/
#define D3DXOOV3(x, y, z) D3DXVECTOR3(1.0f / x, 1.0f / y, 1.0f / z)
__forceinline float IsoDifference(float iso1, float iso2)
{
return max(iso1, -iso2);
}
__forceinline float IsoMerge(float iso1, float iso2)
{
return min(iso1, iso2);
}
__forceinline int mod(int x, int a)
{
int r = x % a;
if (r < 0) r += a;
return r;
}
__forceinline int int_floor(float x)
{
int i = (int) x;
return i > x ? i - 1 : i;
}
__forceinline float lerp(float a, float b, float t)
{
return (1 - t) * a + t * b;
}
float TerrainGrid::IsoSurfaceCave(const D3DXVECTOR3& pos)
{
float iso = IsoSphere(pos, D3DXVECTOR3(0.5f, 0.5f, 0.5f), D3DXOOV3(1, 1, 1), 0.4f);
iso = IsoMerge(
iso,
IsoSphere(pos, D3DXVECTOR3(0.125f, 0.65f, 0.75f), D3DXOOV3(1, 1.0f, 1), 0.25f) );
iso = IsoMerge(
iso,
IsoSphere(pos, D3DXVECTOR3(0.0f, 0.625f, 0.625f), D3DXOOV3(1, 1.0f, 1), 0.2f) );
iso = IsoMerge(
iso,
IsoSphere(pos, D3DXVECTOR3(0.0f, 0.875f, 0.625f), D3DXOOV3(1, 1.0f, 1), 0.1875f) );
iso = IsoMerge(
iso,
IsoSphere(pos, D3DXVECTOR3(0.0625f, 0.59f, 0.5f), D3DXOOV3(1, 0.75f, 1), 0.125f) );
iso = IsoMerge(
iso,
IsoSphere(pos, D3DXVECTOR3(0.25f, 0.57f, 0.25f), D3DXOOV3(2, 1.0f, 1), 0.125f) );
iso = IsoDifference(
iso,
IsoSphere(pos, D3DXVECTOR3(0.125f, 0.375f, 0.5f), D3DXOOV3(0.125f, 1.0f, 0.125f), 0.25f) );
iso = IsoDifference(
iso,
IsoSphere(pos, D3DXVECTOR3(0.1875f, 0.275f, 0.56f), D3DXOOV3(0.0625f, 1.0f, 0.0625f), 0.25f) );
iso-= PerlinNoise_2D(pos.x, pos.z, 128) * 6.0f / 32.0f;
iso-= PerlinNoise_2D(pos.x, pos.y, 192) / 16.0f;
iso-= PerlinNoise_2D(pos.y, pos.z, 192) / 16.0f;
iso = IsoDifference(
IsoSphere(pos, D3DXVECTOR3(0.9f, 0.5f, 0.5f), D3DXOOV3(1, 1, 1), 0.85f),
iso );
iso = IsoDifference(
iso,
IsoPlane(pos, D3DXVECTOR3(0.0f, 0.97f, 0.0f), D3DXVECTOR3(0.0f, -1.0f, 0.0f)) );
// iso = IsoDifference(
// iso,
// IsoPlane(pos, D3DXVECTOR3(0.97f, 0.0f, 0.0f), D3DXVECTOR3(-1.0f, 0.0f, 0.0f)) );
iso = IsoDifference(
iso,
IsoPlane(pos, D3DXVECTOR3(0.0f, 0.0f, 0.97f), D3DXVECTOR3(0.0f, 0.0f, -1.0f)) );
// iso = IsoDifference(
// iso,
// IsoPlane(pos, D3DXVECTOR3(0.0f, 0.0f, 0.03f), D3DXVECTOR3(0.0f, 0.0f, 1.0f)) );
return iso;
}
float TerrainGrid::IsoSurfaceCaveGround(const D3DXVECTOR3& pos)
{
float iso1 = IsoMerge(
IsoSphere(pos, D3DXVECTOR3(0.5f, 0.4f, 0.5f), D3DXOOV3(1, 1, 1), 0.25f),
IsoSphere(pos, D3DXVECTOR3(0.5f, 0.1f, 0.5f), D3DXOOV3(1, 1, 1), 0.37f) );
float iso2 = IsoMerge(
IsoSphere(pos, D3DXVECTOR3(0.5f, 0.5f, 0.42f), D3DXOOV3(1, 1, 1), 0.17f),
IsoSphere(pos, D3DXVECTOR3(0.57f, 0.38f, 0.6f), D3DXOOV3(1, 1, 1), 0.11f) );
float iso= IsoMerge( iso1, iso2 );
iso-= PerlinNoise_2D(pos.x, pos.z, 128) * 12.0f / 32.0f;
iso-= PerlinNoise_2D(pos.x, pos.y, 192) / 8.0f;
iso-= PerlinNoise_2D(pos.y, pos.z, 192) / 8.0f;
return iso;
}
int index = 0;
static const float random[] = {
0.016096199,
-0.041969635,
-0.054145098,
0.021143436,
-0.0094251214,
0.088897280,
0.36951837,
-0.16126564,
0.010747797,
0.094805837,
-0.19188920,
0.25969765,
0.022508329,
0.023705304,
-0.0098044397,
0.066074423,
0.024152935,
-0.089513578,
-0.38613912,
0.075401597,
0.0086482586,
-0.090612829,
-0.032468367,
-0.031355500,
-0.010738159,
0.026182247,
-0.15096381,
0.17182341,
-0.035797309,
-0.029005880,
-0.27913427,
-0.22096422,
0.031160533,
0.016560698,
-0.25966603,
-0.16343403,
-0.011228019,
0.050174236,
0.012509584,
-0.28846321,
0.0097525716,
-0.030592179,
0.15790334,
0.16756034,
0.048684187,
-0.069313243,
0.35656410,
-0.0073550940,
0.018086834,
0.035755921,
-0.13925140,
0.20644069,
-0.016748196,
-0.033889730,
0.12365069,
0.34854794,
0.0099919019,
0.023382772,
-0.11413296,
0.096547559,
-0.019580711,
-0.056822035,
0.036674835,
-0.33782470};
float IsoMountain(const D3DXVECTOR3& pos)
{
return IsoSphere(pos, D3DXVECTOR3(0.5f + random[index++], 0.05f, 0.5f + random[index++]), D3DXOOV3(0.25f, 0.7f + random[index++], 0.15f), 0.25f + random[index++]);
}
float TerrainGrid::IsoSurfaceIsle(const D3DXVECTOR3& pos1)
{
// Koordinaten entsprechen nicht altem System "halber Unitcube"
D3DXVECTOR3 pos= pos1;
pos.y*= 0.5f;
float island = IsoMerge(
IsoSphere(pos, D3DXVECTOR3(0.5f, 0.10f, 0.5f), D3DXOOV3(1, 1, 1), 0.25f),
IsoSphere(pos, D3DXVECTOR3(0.5f, 0.01f, 0.5f), D3DXOOV3(1, 0.5f, 1), 0.4f));
// Small Mountains
index = 0;
float mountains = IsoSphere(pos, D3DXVECTOR3(0.5f, 0.1f, 0.84f), D3DXOOV3(0.15f, 0.8f, 0.2f), 0.3f);
for (int i = 0; i < 16; ++i)
{
mountains = IsoMerge(mountains, IsoMountain(pos));
}
mountains += PerlinNoise_2D(pos.x, pos.z, 256) * 0.2f;
mountains += PerlinNoise_2D(pos.y, pos.z, 256) * 0.1f;
// Big mountains
float hill = IsoSphere(pos, D3DXVECTOR3(0.5f, 0.18f, 0.5f), D3DXOOV3(0.3f, 0.8f, 0.3f), 0.4f);
hill += PerlinNoise_2D(pos.x, pos.y, 480) * 0.05f;
hill += PerlinNoise_2D(pos.y, pos.z, 480) * 0.05f;
hill += PerlinNoise_2D(pos.z, pos.x, 480) * 0.05f;
// Canal for the arc
float canal = IsoSphere(pos, D3DXVECTOR3(0.5f, 0.1f, 0.74f), D3DXOOV3(1.0f, 0.5f, 0.12f), 0.2f);
canal += PerlinNoise_2D(pos.x, pos.y, 512) * 0.2f;
canal += PerlinNoise_2D(pos.y, pos.z, 512) * 0.2f;
// Bridge for the arc
float bridge = IsoDifference(
IsoSphere(pos, D3DXVECTOR3(0.5f, 0.25f, 0.75f), D3DXOOV3(0.1f, 0.4f, 0.68f), 0.2f),
canal);
bridge += PerlinNoise_2D(pos.x, pos.y, 384) * 0.1f;
bridge -= PerlinNoise_2D(pos.y, pos.z, 384) * 0.1f;
bridge += PerlinNoise_2D(pos.z, pos.x, 384) * 0.1f;
bridge = IsoDifference(bridge, IsoPlane(pos, D3DXVECTOR3(0.5, 0.35f, 0.75f), D3DXVECTOR3(0, -1, 0)));
// Merge everything together
float iso = IsoMerge(IsoMerge(IsoMerge(island, mountains), bridge), hill);
// Globale verwirbelungen
iso -= PerlinNoise_2D(pos.x, pos.z, 192) * 0.2f;
iso += PerlinNoise_2D(pos.y, pos.x, 192) * 0.1f;
return iso;
}
const float M_PI = 3.141592768f;
const int textureSize = 1024;
float TerrainGrid::PerlinNoise_2D(float x, float y, float scale)
{
const D3DCOLOR* color = (const D3DCOLOR*)noiseLock.pBits;
int ix1, ix2, iy1, iy2;
float t1, t2;
float c1, c2, c3, c4;
x *= scale; y *= scale;
ix1 = int_floor(x);
t1 = x - ix1;
ix2 = ix1 + 1;
iy1 = int_floor(y);
t2 = y - iy1;
iy2 = iy1 + 1;
ix1 = mod(ix1, textureSize);
ix2 = mod(ix2, textureSize);
iy1 = mod(iy1, textureSize);
iy2 = mod(iy2, textureSize);
t1 = (1-cos(t1 * M_PI))/2;
t2 = (1-cos(t2 * M_PI))/2;
c1 = (float)(color[iy1 * textureSize + ix1] >> 24);
c2 = (float)(color[iy1 * textureSize + ix2] >> 24);
c3 = (float)(color[iy2 * textureSize + ix1] >> 24);
c4 = (float)(color[iy2 * textureSize + ix2] >> 24);
return lerp(lerp(c1, c2, t1), lerp(c3, c4, t1), t2) / 128.0f - 1.0f;
}
D3DXVECTOR3 TerrainGrid::VertexInterp(float isolevel, D3DXVECTOR3 p1, D3DXVECTOR3 p2, float valp1, float valp2)
{
D3DXVECTOR3 p;
float mu = (isolevel - valp1) / (valp2 - valp1);
p.x = p1.x + mu * (p2.x - p1.x);
p.y = p1.y + mu * (p2.y - p1.y);
p.z = p1.z + mu * (p2.z - p1.z);
return(p);
}
int TerrainGrid::Polygonise(GRIDCELL grid, float isolevel, TRIANGLE* triangles)
{
unsigned short i, flag;
D3DXVECTOR3 vertlist[12];
int cubeindex = 0;
flag = 1;
for (i = 0; i < 8; ++i, flag <<= 1)
if (grid.val[i] <= isolevel) cubeindex |= flag;
if (edgeTable[cubeindex] == 0)
return 0;
flag = 1;
for (i = 0; i < 12; ++i, flag <<= 1)
if (edgeTable[cubeindex] & flag)
vertlist[i] = VertexInterp(isolevel,
grid.p[edgeConnection[i][0]],
grid.p[edgeConnection[i][1]],
grid.val[edgeConnection[i][0]],
grid.val[edgeConnection[i][1]]);
for (i = 0; triTable[cubeindex][i] != -1; ++i)
triangles[i / 3].p[i % 3] = vertlist[triTable[cubeindex][i]];
return i / 3;
}
D3DXVECTOR3 TerrainGrid::GetNormal(D3DXVECTOR3 input, iso_surface_function pIsoSurface)
{
float fEps= 0.01f;
return D3DXVECTOR3(
(this->*pIsoSurface)(input + D3DXVECTOR3(fEps, 0, 0)) - (this->*pIsoSurface)(input - D3DXVECTOR3(fEps, 0, 0)),
(this->*pIsoSurface)(input + D3DXVECTOR3(0, fEps, 0)) - (this->*pIsoSurface)(input - D3DXVECTOR3(0, fEps, 0)),
(this->*pIsoSurface)(input + D3DXVECTOR3(0, 0, fEps)) - (this->*pIsoSurface)(input - D3DXVECTOR3(0, 0, fEps)));
}
void TerrainGrid::Init( int StepsXZ, int StepsY, iso_surface_function pIsoSurface )
{
assert( StepsXZ < c_iMaxTerrainStepsXZ );
assert( StepsY < c_iMaxTerrainStepsY );
const float xres = 1.0f / StepsXZ;
const float yres = 1.0f / StepsY;
const float zres = 1.0f / StepsXZ;
g_pTextures[TI_Wave].Lock();
noiseLock = g_pTextures[TI_Wave].GetData();
vertexCount = 0;
indexCount = 0;
// Clear
mymemset(indexValues, -1, sizeof(indexValues));
int StepsXZPP = StepsXZ + 1;
int StepsYPP = StepsY + 1;
int StepsXYZPP = StepsXZPP * StepsYPP;
int iIndexCacheSmallLayerSize = StepsXYZPP;
int iIndexCacheBigLayerSize = iIndexCacheSmallLayerSize * 2;
int iNextCacheLayer = 0;
int iNextIndexCacheLayer = 0;
int iPrevIndexCacheLayerBaseValue = 0;
bool bFirstRun = true;
for (int x = 0; x < StepsXZ; ++x)
{
// Old layer, new layer
int iCacheLayers[2] = { (iNextCacheLayer + 1) % 2, iNextCacheLayer };
// Overwrite oldest layer next time
iNextCacheLayer = iCacheLayers[0];
for (int r = 0; r < 1 + bFirstRun; r++)
{
// New layer first, old layer afterwards on first run
int iCacheBase = iCacheLayers[1 - r] * StepsXYZPP;
int xpp = x + 1 - r;
for (int y = 0; y < StepsYPP; ++y)
{
int iCacheBaseY = iCacheBase + y * StepsXZPP;
for (int z = 0; z < StepsXZPP; ++z)
{
D3DXVECTOR3 gridP = D3DXVECTOR3((float)xpp, (float)y, (float)z);
gridP.x *= xres;
gridP.y *= yres;
gridP.z *= zres;
isoValues[ iCacheBaseY + z ] = (this->*pIsoSurface)( gridP );
}
}
}
bFirstRun = false;
// Old layer, new layer
int iIndexOuterCacheLayers[2] = { (iNextIndexCacheLayer + 1) % 2, iNextIndexCacheLayer };
// Overwrite oldest layer next time
iNextIndexCacheLayer = iIndexOuterCacheLayers[0];
// Layer bases
int *pIndexValueLayers[3] = {
indexValues + iIndexOuterCacheLayers[0] * iIndexCacheBigLayerSize,
indexValues + 2 * iIndexCacheBigLayerSize,
indexValues + iIndexOuterCacheLayers[1] * iIndexCacheBigLayerSize };
// Layer value bases
int iIndexValueLayerBaseValues[3] = {
iPrevIndexCacheLayerBaseValue,
vertexCount,
vertexCount };
// Current vertex count is base for next time
iPrevIndexCacheLayerBaseValue = iIndexValueLayerBaseValues[2];
for (int y = 0; y < StepsY; ++y)
{
for (int z = 0; z < StepsXZ; ++z)
{
TRIANGLE triangles[5];
GRIDCELL grid;
for (int i = 0; i < 8; ++i)
{
D3DXVECTOR3 &gridP = grid.p[i];
gridP = gridVertices[i];
gridP += D3DXVECTOR3((float)x, (float)y, (float)z);
int iCacheBase = iCacheLayers[ (int)gridVertices[i].x ] * StepsXYZPP;
int iCacheBaseY = iCacheBase + (int)gridP.y * StepsXZPP;
grid.val[i] = isoValues[ iCacheBaseY + (int)gridP.z ];
gridP.x *= xres;
gridP.y *= yres;
gridP.z *= zres;
// assert( grid.val[i] == IsoSurface(gridP) );
}
int nTriangles = Polygonise(grid, 0, triangles);
float fCellXL = x * xres, fCellXU = fCellXL + xres;
float fCellYL = y * yres, fCellYU = fCellYL + yres;
float fCellZL = z * zres, fCellZU = fCellZL + zres;
for (int i = 0; i < nTriangles; ++i)
{
const TRIANGLE &tri = triangles[i];
for (int j = 3; j-- > 0; )
{
const D3DXVECTOR3 &pos = tri.p[j];
// Compute edge deviations
float fEdgeXL = pos.x - fCellXL, fEdgeXU = fCellXU - pos.x;
float fEdgeYL = pos.y - fCellYL, fEdgeYU = fCellYU - pos.y;
float fEdgeZL = pos.z - fCellZL, fEdgeZU = fCellZU - pos.z;
int iEdgeX = (fEdgeXL > fEdgeXU);
int iEdgeY = (fEdgeYL > fEdgeYU);
int iEdgeZ = (fEdgeZL > fEdgeZU);
float fEdgeXD = (iEdgeX) ? fEdgeXU : fEdgeXL;
float fEdgeYD = (iEdgeY) ? fEdgeYU : fEdgeYL;
float fEdgeZD = (iEdgeZ) ? fEdgeZU : fEdgeZL;
// Compute layer
int iEdgeLayer = (fEdgeXD > fEdgeYD && fEdgeXD > fEdgeZD)
? 1 // Center layer
: 2 * iEdgeX; // Top / bottom layer
int *pLayerIndexValues = pIndexValueLayers[iEdgeLayer];
int iLayerIndexBaseValue = iIndexValueLayerBaseValues[iEdgeLayer];
int *pIndexValue;
// Center layer
if (iEdgeLayer == 1)
{
// Get index value
int iCacheBaseY = (y + iEdgeY) * StepsXZPP;
int iCacheIndex = iCacheBaseY + (z + iEdgeZ);
pIndexValue = &pLayerIndexValues[iCacheIndex];
}
// Top / bottom layer
else
{
int iOnY = (fEdgeYD > fEdgeZD);
int iEdgeZY = (iOnY) ? iEdgeZ : iEdgeY;
// Get index value
int iCacheBaseY = ( (y + (1 - iOnY) * iEdgeZY) * 2 + iOnY ) * StepsXZPP;
int iCacheIndex = iCacheBaseY + ( z + iOnY * iEdgeZY );
pIndexValue = &pLayerIndexValues[iCacheIndex];
}
int &indexValue = *pIndexValue;
bool bIndexValid = (indexValue >= iLayerIndexBaseValue);
// Check index
if(!bIndexValid)
{
// Update index
indexValue = vertexCount;
// Allocate new vertex
vertices[vertexCount++] = tri.p[j];
}
// Allocate new index
indices[indexCount++] = indexValue;
}
}
}
}
if( ( x & 31 ) == 31 )
{
RenderLoading( 4 );
}
}
assert( vertexCount <= c_iMaxTerrainVertices );
assert( indexCount <= c_iMaxTerrainIndices );
D3DVERTEXELEMENT9 decl[] =
{
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
{0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},
{0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
{0, 32, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0},
D3DDECL_END()
};
assert(vertexCount != 0);
g_d3d_device->CreateVertexDeclaration(decl, &vertexDecl);
g_d3d_device->CreateVertexBuffer(sizeof(TerrainVertex) * vertexCount, D3DUSAGE_WRITEONLY, 0, D3DPOOL_MANAGED, &vertexBuffer, NULL);
g_d3d_device->CreateIndexBuffer(sizeof(int) * indexCount, D3DUSAGE_WRITEONLY, D3DFMT_INDEX32, D3DPOOL_MANAGED, &indexBuffer, NULL);
TerrainVertex* vertex;
int* index;
vertexBuffer->Lock(0, 0, (void**)&vertex, 0);
indexBuffer->Lock(0, 0, (void**)&index, 0);
for (int i = 0; i < vertexCount; ++i)
{
vertex[i].pos = vertices[i];
vertex[i].col = D3DXCOLOR(0xFFFFFFFF);
vertex[i].tex = D3DXVECTOR2(vertices[i].x, vertices[i].z);
vertex[i].normal = GetNormal(vertices[i], pIsoSurface); // D3DXVECTOR3(0, 0, 0); // GetNormal(vertices[i]);
}
mymemcpy(index, indices, sizeof(int) * indexCount);
/* for (int i = 0; i < indexCount; i+=3)
{
int iVertex1 = index[i];
int iVertex2 = index[i + 1];
int iVertex3 = index[i + 2];
D3DXVECTOR3 vNormal;
D3DXVECTOR3 vDelta1 = vertex[iVertex2].pos - vertex[iVertex1].pos;
D3DXVECTOR3 vDelta2 = vertex[iVertex3].pos - vertex[iVertex1].pos;
D3DXVec3Cross(&vNormal, &vDelta1, &vDelta2);
vertex[iVertex1].normal += vNormal;
vertex[iVertex2].normal += vNormal;
vertex[iVertex3].normal += vNormal;
}
for (int i = 0; i < vertexCount; ++i)
D3DXVec3Normalize(&vertex[i].normal, &vertex[i].normal);
*/
indexBuffer->Unlock();
vertexBuffer->Unlock();
g_pTextures[TI_Wave].Unlock();
}
void TerrainGrid::Render()
{
g_d3d_device->SetStreamSource(0, vertexBuffer, 0, sizeof(TerrainVertex));
g_d3d_device->SetFVF(NULL);
g_d3d_device->SetVertexDeclaration(vertexDecl);
g_d3d_device->SetIndices(indexBuffer);
g_d3d_device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, vertexCount, 0, indexCount / 3);
}

View File

@@ -0,0 +1,51 @@
#pragma once
#include <d3dx9.h>
extern IDirect3DDevice9* g_d3d_device;
class TerrainGrid
{
public:
typedef float (TerrainGrid::*iso_surface_function)(const D3DXVECTOR3&);
void Init( int StepsXZ, int StepsY, iso_surface_function pIsoSurface );
void Render();
float IsoSurfaceIsle(const D3DXVECTOR3& pos);
float IsoSurfaceCave(const D3DXVECTOR3& pos);
float IsoSurfaceCaveGround(const D3DXVECTOR3& pos);
private:
typedef struct
{
D3DXVECTOR3 p[3];
} TRIANGLE;
typedef struct
{
D3DXVECTOR3 p[8];
float val[8];
} GRIDCELL;
float PerlinNoise_2D(float x, float y, float scale);
D3DXVECTOR3 VertexInterp(float isolevel, D3DXVECTOR3 p1, D3DXVECTOR3 p2, float valp1, float valp2);
int Polygonise(GRIDCELL grid, float isolevel, TRIANGLE* triangles);
D3DXVECTOR3 GetNormal(D3DXVECTOR3 input, iso_surface_function pIsoSurface);
D3DLOCKED_BOX noiseLock;
int vertexCount;
int indexCount;
IDirect3DVertexDeclaration9* vertexDecl;
IDirect3DIndexBuffer9* indexBuffer;
IDirect3DVertexBuffer9* vertexBuffer;
};
struct TerrainVertex
{
D3DXVECTOR3 pos;
D3DXVECTOR3 normal;
D3DXVECTOR2 tex;
D3DCOLOR col;
};

View File

@@ -0,0 +1,54 @@
/***********************************************************************************/
/** \file TextFileReader.h
** \brief Header File zur Klasse TextFileReader
*************************************************************************************
** Autor: Christian Roesch
*************************************************************************************
** _tut nichts_
**
*//*********************************************************************************/
#ifndef _TextFileReader_H
#define _TextFileReader_H
// includes
#include <vector>
#include <string>
// Klassen-Deklaration
namespace FrameWork
{
/***********************************************************************************/
/** \brief TextFileReader _tut nichts_
*************************************************************************************
** Genau genommen _tut dies nichts_
**
*//*********************************************************************************/
class TextFileReader
{
public:
bool read( std::string strFileName );
bool append( std::string FileName );
std::vector <std::string>& getFileLines();
int getLineCount();
void clear();
protected:
private:
std::vector <std::string> m_vecLines;
};
}
#endif//_TextFileReader_H
class FrameWork::TextFileReader;
/************************************************************************************
** Ende der Datei: TextFileReader.h
************************************************************************************/

View File

@@ -0,0 +1,506 @@
#include "intrin.h"
#include "defines.h"
#include "Texture.h"
#include "Random.h"
#include "globals.h"
#include "rotmat.h"
void Texture::Init()
{
m_iSizeX= -1;
m_iSizeY= -1;
m_iSizeZ= -1;
m_iMipLevel= -1;
m_pTexture= NULL;
m_d3dlb.pBits= NULL;
m_d3dlb.RowPitch= -1;
m_d3dlb.SlicePitch= -1;
}
void Texture::DeInit()
{
Release();
}
void Texture::Create( int iSizeX,
int iSizeY,
int iSizeZ,
int iMipLevel )
{
Release();
m_iSizeX= iSizeX;
m_iSizeY= iSizeY;
m_iSizeZ= iSizeZ;
m_iMipLevel= iMipLevel;
if(m_iSizeZ > 1)
{
g_d3d_device->CreateVolumeTexture(
m_iSizeX,
m_iSizeY,
m_iSizeZ,
m_iMipLevel,
0,
D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED,
(IDirect3DVolumeTexture9**)&m_pTexture,
NULL );
}
else
{
m_iSizeZ = 1;
g_d3d_device->CreateTexture(
m_iSizeX,
m_iSizeY,
m_iMipLevel,
0,
D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED,
(IDirect3DTexture9**)&m_pTexture,
NULL );
}
}
void Texture::Release()
{
Unlock();
if( m_pTexture != NULL )
{
m_pTexture->Release();
m_pTexture= NULL;
}
m_iSizeX= -1;
m_iSizeY= -1;
m_iSizeZ= -1;
m_iMipLevel= -1;
m_d3dlb.pBits= NULL;
m_d3dlb.RowPitch= -1;
m_d3dlb.SlicePitch= -1;
}
void Texture::Lock()
{
if(m_iSizeZ > 1)
{
((IDirect3DVolumeTexture9*)m_pTexture)->LockBox( 0, &m_d3dlb, 0, 0 );
}
else
{
D3DLOCKED_RECT d3dlr;
((IDirect3DTexture9*)m_pTexture)->LockRect( 0, &d3dlr, 0, 0 );
m_d3dlb.pBits = d3dlr.pBits;
m_d3dlb.RowPitch = d3dlr.Pitch;
m_d3dlb.SlicePitch = 0;
}
}
void Texture::Unlock()
{
if( m_d3dlb.pBits == NULL )
{
return;
}
if(m_iSizeZ > 1)
{
((IDirect3DVolumeTexture9*)m_pTexture)->UnlockBox( 0 );
}
else
{
((IDirect3DTexture9*)m_pTexture)->UnlockRect( 0 );
}
m_d3dlb.pBits= NULL;
m_d3dlb.RowPitch= -1;
m_d3dlb.SlicePitch= -1;
}
const D3DLOCKED_BOX& Texture::GetData() const
{
return m_d3dlb;
};
void Texture::PrepareRandomTexture()
{
RandomGenerator rg;
rg.setSeed( 1024 );
for( int i= 0; i < 1024; ++i )
{
rg.genFloat();
}
Lock();
for( int iZ= 0; iZ < m_iSizeZ; ++iZ )
{
for( int iY= 0; iY < m_iSizeY; ++iY )
{
DWORD* pData= (DWORD*)((BYTE*)m_d3dlb.pBits + iY * m_d3dlb.RowPitch + iZ * m_d3dlb.SlicePitch );
for( int iX= 0; iX < m_iSizeX; ++iX )
{
rg.genFloat();
*pData++ = rg.getLastTempValue();
}
}
}
Unlock();
// Generate mip maps
D3DXFilterTexture(m_pTexture, NULL, 0, D3DX_DEFAULT);
}
#ifdef EXTRACODE
#include <fstream>
#endif
void Texture::PrepareRotMatrixFromFile()
{
#ifdef EXTRACODE
Release();
D3DXCreateTextureFromFile(
g_d3d_device,
"64k_pre/rotationalMatrix32.png",
(IDirect3DTexture9**)&m_pTexture );
m_iSizeX= 32;
m_iSizeY= 32;
m_iSizeZ = 1;
m_iMipLevel= 1;
Lock();
std::ofstream ofs( "64k_pre/rotMat.txt" );
for( int iY= 0; iY < m_iSizeY; ++iY )
{
DWORD* pData= (DWORD*)((BYTE*)m_d3dlb.pBits + iY * m_d3dlb.RowPitch );
for( int iX= 0; iX < m_iSizeX; ++iX )
{
//rg.genFloat();
//*pData++ = rg.getLastTempValue();
DWORD dw= *pData++;
ofs << dw << "," << "\n";
}
}
Unlock();
#endif
}
void Texture::PrepareTexGenRenderStates(IDirect3DBaseTexture9 *pInputTexture)
{
g_d3d_device->SetRenderState( D3DRS_LIGHTING, FALSE );
g_d3d_device->SetRenderState( D3DRS_ZENABLE, FALSE );
g_d3d_device->SetRenderState( D3DRS_MULTISAMPLEANTIALIAS, FALSE );
g_d3d_device->SetRenderState( D3DRS_ALPHATESTENABLE, FALSE );
g_d3d_device->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
g_d3d_device->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
g_d3d_device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_d3d_device->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
// sampler2D randomSampler : register(s0);
g_d3d_device->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
g_d3d_device->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
g_d3d_device->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
g_d3d_device->SetSamplerState( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP );
g_d3d_device->SetSamplerState( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP );
g_d3d_device->SetTexture( 0, g_pTextures[ TI_Random ].GetPointer() );
// sampler2D randomCubeSampler : register(s1);
g_d3d_device->SetSamplerState( 1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
g_d3d_device->SetSamplerState( 1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
g_d3d_device->SetSamplerState( 1, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
g_d3d_device->SetSamplerState( 1, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP );
g_d3d_device->SetSamplerState( 1, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP );
g_d3d_device->SetSamplerState( 1, D3DSAMP_ADDRESSW, D3DTADDRESS_WRAP );
g_d3d_device->SetTexture( 1, g_pTextures[ TI_RandomCube ].GetPointer() );
// sampler2D ditherSampler : register(s2);
g_d3d_device->SetSamplerState( 2, D3DSAMP_MINFILTER, D3DTEXF_POINT );
g_d3d_device->SetSamplerState( 2, D3DSAMP_MAGFILTER, D3DTEXF_POINT );
g_d3d_device->SetSamplerState( 2, D3DSAMP_MIPFILTER, D3DTEXF_POINT );
g_d3d_device->SetSamplerState( 2, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP );
g_d3d_device->SetSamplerState( 2, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP );
g_d3d_device->SetTexture( 2, g_pTextures[ TI_RotMatrix ].GetPointer() );
// sampler2D inputSampler : register(s3);
g_d3d_device->SetSamplerState( 3, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
g_d3d_device->SetSamplerState( 3, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
g_d3d_device->SetSamplerState( 3, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
g_d3d_device->SetSamplerState( 3, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP );
g_d3d_device->SetSamplerState( 3, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP );
g_d3d_device->SetTexture( 3, pInputTexture );
}
void Texture::PrepareShaderTexture(int iShader1, int iShader2, int iShader3, int iShader4)
{
const int iMaxShaderCount = 4;
int shaders[iMaxShaderCount] = { iShader1, iShader2, iShader3, iShader4 };
IDirect3DTexture9 *pIntermediate = NULL;
IDirect3DSurface9 *pIntermediateSurface = NULL;
IDirect3DSurface9 *pIntermediateData = NULL;
// Create intermediate texture target
g_d3d_device->CreateTexture( m_iSizeX,
m_iSizeY,
1,
D3DUSAGE_RENDERTARGET,
D3DFMT_A8R8G8B8,
D3DPOOL_DEFAULT,
&(pIntermediate),
NULL);
pIntermediate->GetSurfaceLevel(0, &pIntermediateSurface);
// Create system-memory surface
g_d3d_device->CreateOffscreenPlainSurface( m_iSizeX,
m_iSizeY,
D3DFMT_A8R8G8B8,
D3DPOOL_SYSTEMMEM,
&(pIntermediateData),
NULL);
IDirect3DSurface9 *pColorSurface = NULL;
IDirect3DSurface9 *pDepthStencilSurface = NULL;
g_d3d_device->BeginScene();
// Get targets
g_d3d_device->GetRenderTarget(0, &pColorSurface);
g_d3d_device->GetDepthStencilSurface(&pDepthStencilSurface);
for(int i = 0; i < iMaxShaderCount; i++)
{
int iShader = shaders[i];
if(iShader < 0)
continue;
// Set intermediate target & state
g_d3d_device->SetRenderTarget(0, pIntermediateSurface);
g_d3d_device->SetDepthStencilSurface(NULL);
PrepareTexGenRenderStates(m_pTexture);
Shader::SetResolution(m_iSizeX, m_iSizeY);
// Generate texture
g_FullScreenQuad.m_iUsedShader[0] = iShader;
g_FullScreenQuad.Render();
// Copy data
g_d3d_device->GetRenderTargetData(pIntermediateSurface, pIntermediateData);
D3DLOCKED_RECT intermediateRect;
// Lock surfaces
pIntermediateData->LockRect(&intermediateRect, NULL, D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_READONLY);
Lock();
// Copy data to destination surface
mymemcpy(m_d3dlb.pBits, intermediateRect.pBits, m_d3dlb.RowPitch * m_iSizeY);
// Unlock surfaces
Unlock();
pIntermediateData->UnlockRect();
// Generate mip maps
D3DXFilterTexture(m_pTexture, NULL, 0, D3DX_DEFAULT);
}
// Reset targets
g_d3d_device->SetRenderTarget(0, pColorSurface);
g_d3d_device->SetDepthStencilSurface(pDepthStencilSurface);
g_d3d_device->EndScene();
g_d3d_device->Present(NULL, NULL, NULL, NULL);
// Release
if(pColorSurface)
pColorSurface->Release();
if(pDepthStencilSurface)
pDepthStencilSurface->Release();
pIntermediateSurface->Release();
pIntermediate->Release();
pIntermediateData->Release();
}
void Texture::PrepareRotMatrix()
{
Lock();
int iPos= 0;
for( int iY= 0; iY < m_iSizeY; ++iY )
{
DWORD* pData= (DWORD*)((BYTE*)m_d3dlb.pBits + iY * m_d3dlb.RowPitch );
for( int iX= 0; iX < m_iSizeX; ++iX )
{
*pData++ = dwRotMatData[ iPos++ ];
}
}
Unlock();
}
void Texture::PrepareSpecTexture()
{
g_pTextures[ TI_LightSpec1D ].Create( 256, 1, 1, 1 );
g_pTextures[ TI_LightSpec1D ].Lock();
float fVal= 255.0f;
for( int i= 0; i <= 255; ++i )
{
int iV= (int)fVal;
((DWORD*)(g_pTextures[ TI_LightSpec1D ].m_d3dlb.pBits))[ 255 - i ]=
0xff << 24 |
( iV & 0xff ) << 16 |
( iV & 0xff ) << 8 |
( iV & 0xff );
fVal*= 0.925f;
}
//unlock
g_pTextures[ TI_LightSpec1D ].Unlock();
}
void Texture::Prepare1DTextures()
{
PrepareSpecTexture();
int iTexIndex= TI_First1D;
static const unsigned char pucDataTest[]=
{
1, // Groesse == 8
255, 255, 255,
7,
255, 255, 255,
0,
16, // Groesse == 128
32, 32, 64,
64,
120, 120, 128,
63,
255, 251, 208,
0,
16, // Groesse == 128
255, 255, 255,
4,
192, 192, 192,
4,
145, 145, 145,
4,
108, 108, 108,
4,
81, 81, 81,
8,
45, 45, 45,
16,
14, 14, 14,
16,
4, 4, 4,
71,
0, 0, 0,
0,
16, // Groesse == 128
80, 0, 165,
16,
38, 3, 238,
18,
0, 183, 195,
12,
0, 217, 110,
18,
1, 232,0,
18,
152, 216,0,
12,
229, 200,0 ,
18,
255, 62,0 ,
15,
225, 18,0 ,
0,
0
};
const unsigned char* pData= pucDataTest;
int ColorIn[ 3 ];
int ColorOut[ 3 ];
while( *pData != 0 )
{
//create Texture
int iTexSize= *pData * 8;
pData++;
/*int iMips= 1;
while( 2 << iMips <= iTexSize )
{
iMips++;
}*/
g_pTextures[ iTexIndex ].Create( iTexSize, 1, 1, 1 );
g_pTextures[ iTexIndex ].Lock();
int iX= 0;
ColorIn[ 0 ]= *pData++;
ColorIn[ 1 ]= *pData++;
ColorIn[ 2 ]= *pData++;
//set Texture Data
while( true )
{
int iLength= *pData;
pData++;
if( iLength == 0 )
{
break;
}
ColorOut[ 0 ]= *pData++;
ColorOut[ 1 ]= *pData++;
ColorOut[ 2 ]= *pData++;
//lerp colors
for( int i= 0; i <= iLength; ++i )
{
int iA= iLength - i;
int iR= ( ColorOut[ 0 ] * i + ColorIn[ 0 ] * iA ) / iLength;
int iG= ( ColorOut[ 1 ] * i + ColorIn[ 1 ] * iA ) / iLength;
int iB= ( ColorOut[ 2 ] * i + ColorIn[ 2 ] * iA ) / iLength;
assert( iX < g_pTextures[ iTexIndex ].m_iSizeX );
((DWORD*)(g_pTextures[ iTexIndex ].m_d3dlb.pBits))[ iX ]=
0xff << 24 |
( iR & 0xff ) << 16 |
( iG & 0xff ) << 8 |
( iB & 0xff );
++iX;
}
--iX;
ColorIn[ 0 ]= ColorOut[ 0 ];
ColorIn[ 1 ]= ColorOut[ 1 ];
ColorIn[ 2 ]= ColorOut[ 2 ];
}
//unlock
g_pTextures[ iTexIndex ].Unlock();
iTexIndex++;
}
}

View File

@@ -0,0 +1,83 @@
#pragma once
/***********************************************************************************/
/** \file Texture.h
** \brief Header File zur Klasse Texture
*************************************************************************************
** Autor: Christian Roesch
*************************************************************************************
** _tut nichts_
**
*//*********************************************************************************/
#ifndef _Texture_H
#define _Texture_H
// includes
#include <d3dx9.h>
#include <cassert>
// Klassen-Deklaration
extern IDirect3DDevice9* g_d3d_device;
/***********************************************************************************/
/** \brief Texture _tut nichts_
*************************************************************************************
** Genau genommen _tut dies nichts_
**
*//*********************************************************************************/
class Texture
{
public:
void Init();
void DeInit();
void Create( int m_iSizeX,
int m_iSizeY,
int m_iSizeZ,
int m_iMipLevel );
void Release();
void Lock();
void Unlock();
const D3DLOCKED_BOX& GetData() const;
IDirect3DBaseTexture9* GetPointer()
{
return m_pTexture;
}
void PrepareRandomTexture();
void PrepareRotMatrixFromFile();
void PrepareRotMatrix();
void PrepareShaderTexture(int iShader1, int iShader2 = -1, int iShader3 = -1, int iShader4 = -1);
static void Prepare1DTextures();
private:
static void PrepareSpecTexture();
static void PrepareTexGenRenderStates(IDirect3DBaseTexture9 *pInputTexture);
int m_iSizeX;
int m_iSizeY;
int m_iSizeZ;
int m_iMipLevel;
IDirect3DBaseTexture9* m_pTexture;
D3DLOCKED_BOX m_d3dlb;
};
#endif//_Texture_H
class Texture;
/************************************************************************************
** Ende der Datei: Texture.h
************************************************************************************/

View File

@@ -0,0 +1,43 @@
#pragma once
struct SVUMeter
{
const static int m_iBufferLength= 441;
float m_fVUData[ m_iBufferLength ];
int m_iLastPos;
SVUMeter()
{
m_iLastPos= 0;
for( int i= 0; i < m_iBufferLength; ++i )
{
m_fVUData[ i ]= 0.0f;
}
}
void Set( int iPos,
float fVal )
{
iPos= iPos % m_iBufferLength;
while( true )
{
m_fVUData[ m_iLastPos ]= fVal;
if( m_iLastPos != iPos )
{
m_iLastPos++;
m_iLastPos= m_iLastPos % m_iBufferLength;
}
else
{
break;
}
}
}
float Get( int iPos )
{
iPos= iPos % m_iBufferLength;
return m_fVUData[ iPos ];
}
};

View File

@@ -0,0 +1,84 @@
#include "defines.h"
#include "Water.h"
#include "shader.h"
#include "globals.h"
#include "intrin.h"
void Water::Init()
{
}
void Water::Update(const D3DXMATRIX &mView, const D3DXMATRIX &mProj)
{
// Mirror reflection
D3DXMATRIX mMirror;
D3DXMatrixIdentity(&mMirror);
mMirror._22 = -1.0f;
mMirror._42 = 2.0f * m_fWaterLevel;
m_ViewMatrix = mMirror * mView;
// Extract new view position
m_ViewPos.x = -(m_ViewMatrix._41 * m_ViewMatrix._11 + m_ViewMatrix._42 * m_ViewMatrix._12 + m_ViewMatrix._43 * m_ViewMatrix._13);
m_ViewPos.y = -(m_ViewMatrix._41 * m_ViewMatrix._21 + m_ViewMatrix._42 * m_ViewMatrix._22 + m_ViewMatrix._43 * m_ViewMatrix._23);
m_ViewPos.z = -(m_ViewMatrix._41 * m_ViewMatrix._31 + m_ViewMatrix._42 * m_ViewMatrix._32 + m_ViewMatrix._43 * m_ViewMatrix._33);
// Extract camera direction
m_ViewDir.x = m_ViewMatrix._13;
m_ViewDir.y = m_ViewMatrix._23;
m_ViewDir.z = m_ViewMatrix._33;
float fEyeHeight = -(mView._41 * mView._21 + mView._42 * mView._22 + mView._43 * mView._23);
float fReflectionClipHeight = m_fWaterLevel
- min(max(fEyeHeight - m_fWaterLevel, 0.0f), 64.0f) / 32.0f;
// Clip reflection
m_ProjMatrix = ObliqueProjectionMatrix(m_ViewMatrix, mProj,
D3DXPLANE(0.0f, -1.0f, 0.0f, fReflectionClipHeight));
}
/// Returns the sign of the given value
inline float Sign0(float v)
{
return (v > 0.0f) ? 1.0f : ((v < 0.0f) ? -1.0f : 0.0f);
}
// Computes a projection matrix that contains the given plane as near plane
D3DXMATRIX Water::ObliqueProjectionMatrix(const D3DXMATRIX &mView, const D3DXMATRIX &mProjection, const D3DXPLANE &clipPlane)
{
// Compute inverse transpose (orthogonal matrix)
D3DXMATRIX mViewInverseTranspose = mView;
mViewInverseTranspose._14 = -(mView._41 * mView._11 + mView._42 * mView._12 + mView._43 * mView._13);
mViewInverseTranspose._24 = -(mView._41 * mView._21 + mView._42 * mView._22 + mView._43 * mView._23);
mViewInverseTranspose._34 = -(mView._41 * mView._31 + mView._42 * mView._32 + mView._43 * mView._33);
mViewInverseTranspose._41 = mView._14;
mViewInverseTranspose._42 = mView._24;
mViewInverseTranspose._43 = mView._34;
// Transform plane to view space
D3DXPLANE viewClipPlane = -clipPlane;
D3DXPlaneTransform(&viewClipPlane, &viewClipPlane, &mViewInverseTranspose);
// Check clip plane orientation
if(viewClipPlane.d > -0.001f)
return mProjection;
// Compute view-space corner point
D3DXVECTOR4 vFarCorner = D3DXVECTOR4(
Sign0(viewClipPlane.a + mProjection._31) / mProjection._11,
Sign0(viewClipPlane.b + mProjection._32) / mProjection._22,
-1.0f,
(1.0f + mProjection._33) / mProjection._43 );
// Scale clip plane
D3DXPLANE projClipPlane = viewClipPlane * (1.0f / D3DXPlaneDot(&viewClipPlane, &vFarCorner));
// Modify projection matrix
return D3DXMATRIX(mProjection._11, mProjection._12, projClipPlane.a, mProjection._14,
mProjection._21, mProjection._22, projClipPlane.b, mProjection._24,
mProjection._31, mProjection._32, projClipPlane.c, mProjection._34,
mProjection._41, mProjection._42, projClipPlane.d, mProjection._44);
}

View File

@@ -0,0 +1,60 @@
#pragma once
/***********************************************************************************/
/** \file Water.h
** \brief Header File zur Klasse Water
*************************************************************************************
** Autor: Christian Roesch
*************************************************************************************
** _tut nichts_
**
*//*********************************************************************************/
#ifndef _WATER_H
#define _WATER_H
// includes
#include <d3dx9.h>
#include <cassert>
// Klassen-Deklaration
extern IDirect3DDevice9* g_d3d_device;
/***********************************************************************************/
/** \brief Water _tut nichts_
*************************************************************************************
** Genau genommen _tut dies nichts_
**
*//*********************************************************************************/
class Water
{
public:
float m_fWaterLevel;
static const int MaxSplitCount = 16;
void Init();
void Update(const D3DXMATRIX &mView, const D3DXMATRIX &mProj);
D3DXMATRIX m_ViewMatrix;
D3DXMATRIX m_ProjMatrix;
D3DXVECTOR3 m_ViewPos;
D3DXVECTOR3 m_ViewDir;
private:
/// Computes a projection matrix that contains the given plane as near plane
D3DXMATRIX ObliqueProjectionMatrix(const D3DXMATRIX &mView, const D3DXMATRIX &mProjection,
const D3DXPLANE &clipPlane);
};
#endif//_Water_H
class Water;
/************************************************************************************
** Ende der Datei: Water.h
************************************************************************************/

View File

@@ -0,0 +1,73 @@
#pragma once
struct SVertexBar
{
FLOAT x, y, z;
DWORD dwColor;
};
const DWORD c_dwFVFBar= D3DFVF_XYZ|D3DFVF_DIFFUSE;
SVertexBar g_VertBar[]=
{
{ -1.0f, -1.0f, 5.0f, 0xff000000 },
{ -1.0f, 1.0f, 5.0f, 0xff000000 },
{ 1.0f, -1.0f, 5.0f, 0xff000000 },
{ 1.0f, 1.0f,5.0f, 0xff000000 },
};
void RenderBars()
{
g_d3d_device->SetRenderState( D3DRS_LIGHTING, FALSE );
g_d3d_device->SetRenderState( D3DRS_ZENABLE, FALSE );
g_d3d_device->SetRenderState( D3DRS_ALPHATESTENABLE, FALSE );
g_d3d_device->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
g_d3d_device->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
g_d3d_device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE );
g_d3d_device->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
g_d3d_device->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
g_d3d_device->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
g_d3d_device->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
D3DXMATRIX mat;
D3DXMatrixOrthoLH(
&mat,
(float)c_iScreenSizeX,
-(float)c_iScreenSizeY,
1.0f,
8.0f );
g_d3d_device->SetTransform( D3DTS_PROJECTION, &mat );
D3DXMatrixIdentity( &mat );
g_d3d_device->SetTransform( D3DTS_VIEW, &mat );
g_d3d_device->SetTransform( D3DTS_WORLD, &mat );
float fBarHeight= (float)( c_iScreenSizeY - c_iRealScreenY ) * 0.5f;
for( int i= -1; i <= 1; i+= 2 )
{
g_VertBar[ 0 ].x= -(float)c_iScreenSizeX * 0.5f - 10.0f;
g_VertBar[ 0 ].y= (float)i * ( (float)c_iScreenSizeY * 0.5f + 10.0f );
g_VertBar[ 1 ].x= -(float)c_iScreenSizeX * 0.5f - 10.0f;
g_VertBar[ 1 ].y= (float)i * ( (float)c_iScreenSizeY * 0.5f - fBarHeight );
g_VertBar[ 2 ].x= (float)c_iScreenSizeX * 0.5f + 10.0f;
g_VertBar[ 2 ].y= (float)i * ( (float)c_iScreenSizeY * 0.5f + 10.0f );
g_VertBar[ 3 ].x= (float)c_iScreenSizeX * 0.5f + 10.0f;
g_VertBar[ 3 ].y= (float)i * ( (float)c_iScreenSizeY * 0.5f - fBarHeight );
g_d3d_device->SetFVF( c_dwFVFBar );
g_d3d_device->DrawPrimitiveUP(
D3DPT_TRIANGLESTRIP,
2,
g_VertBar,
sizeof( SVertexBar )
);
}
}

View File

@@ -0,0 +1,15 @@
1
98304 -1769472 256 535.946 -162.758 -727.05 0.528012 0.518 0 2.5 1 2 -1
229376 -2228224 512 446.024 -50.2737 -568.231 0.387012 0.173 0 2.5 1 2 -1
131072 -1769472 0 392.778 -23.105 -461.411 0.402012 -0.000999899 0 2.5 1 2 -1
131072 -1769472 0 359.845 -18.091 -380.603 0.387012 0.0140001 0 2.5 1 2 -1
131072 -1769472 64 328.781 -15.8439 -300.023 0.366012 -0.0609999 0 2.5 1 2 -1
131072 -1736704 0 305.205 -12.769 -220.326 0.309012 -0.0429999 0 2.5 1 2 -1
98304 -1736704 0 238.041 -11.8258 -200.246 -0.404988 -0.0429999 0 2.5 1 2 -1
65536 -1736704 0 179.447 -2.13206 -196.481 1.71301 -0.0609999 0 2.5 1 2 -1
65536 -1736704 0 130.192 -0.554431 -210.416 1.16401 0.0080001 0 2.5 1 2 -1
65536 -1736704 0 84.5052 -0.707465 -193.233 0.888011 0.0140001 0 2.5 1 2 -1
65536 -1736704 0 60.7442 0.801214 -182.173 0.687011 0.104 0 2.5 1 2 -1
65536 -1736704 0 20.8194 1.91127 -192.842 -0.590989 0.107 0 2.5 1 2 -1
65536 -1736704 0 4.27645 4.2192 -190.699 -1.04099 0.209 0 2.5 1 2 -1
65536 -1736704 0 -2.91621 5.65886 -191.777 -1.06799 0.209 0 2.5 1 2 -1

View File

@@ -0,0 +1,8 @@
2
32768 1673749 256 -619.057 4.12432 1159.72 -15.213 1.497 0 -0.0625 1 2 -1
65536 1687552 0 -610.353 5.47902 1143.59 -15.213 1.497 0 0.125 1 2 -1
65536 1687552 0 -600.624 6.99332 1125.57 -15.213 1.497 0 1.09375 1 2 -1
65536 1687552 0 -591.106 8.47477 1107.94 -15.213 1.497 0 1.8125 1 2 -1
65536 1687552 0 -579.935 9.3357 1092.42 -15.066 0.183 0 4.1875 1 2 -1
65536 1687552 0 -568.014 10.2545 1075.86 -15.066 0.0209998 0 13.8125 1 2 -1
65536 1687552 0 -551.998 11.4889 1053.62 -15.084 -0.0450002 0 13.8125 1 2 -1

View File

@@ -0,0 +1,9 @@
2
32768 -933888 0 -31.5672 7.26193 429.969 1.821 0.0079999 0 4.5 1 2 -1
32768 -933888 0 -27.9271 7.26193 415.726 1.929 -0.0250001 0 4.5625 1 2 -1
32768 -933888 0 -22.9083 7.26193 402.32 2.22 -0.142 0 4.5 1 2 -1
32768 -933888 0 -16.0532 7.26193 391.582 2.41201 -0.193 0 4.5 1 2 -1
32768 -933888 0 2.53725 7.26193 375.651 2.53201 -0.226 0 4.5 1 2 -1
32768 -933888 0 18.0491 7.26193 367.857 2.62201 -0.265 0 4.625 1 2 -1
32768 -933888 0 29.2024 7.26193 362.707 2.76601 -0.319 0 4.5 1 2 -1
32768 -933888 0 40.7302 7.26193 358.162 2.78401 -0.331 0 4.875 1 2 -1

View File

@@ -0,0 +1,9 @@
2
32768 -1152170 256 -388.809 97.9653 57.3876 4.293 0.451999 0 3.3125 1 2 -1
49152 -1152170 128 -332.951 71.5833 38.0275 4.47899 0.371 0 4.3125 1 2 -1
49152 -1127594 256 -298.146 60.2924 33.1761 4.59898 0.296 0 4.0625 1 2 -1
49152 -1078442 256 -254.353 48.0945 -16.025 4.73097 0.212 0 3.9375 1 2 -1
49152 -1029290 256 -209.076 42.4666 -83.6222 5.06696 0.134 0 3.8125 1 2 -1
49152 -980138 256 -155.226 30.4756 -152.27 5.45095 0.0559996 0 3.8125 1 2 -1
49152 -930986 256 -105.829 16.298 -201.189 5.80494 -0.0700004 0 3.5625 1 2 -1
49152 -881834 256 -70.6753 16.298 -216.448 5.90394 -0.0820004 0 3.8125 1 2 -1

View File

@@ -0,0 +1,17 @@
2
32768 -1736704 0 -124.892 57.3811 266.716 -2.676 0.344 0 3.5625 1 2 -1
49152 -1736704 0 -126.368 41.1807 209.292 -2.487 0.242 0 4.9375 1 2 -1
49152 -1736704 0 -93.4319 28.1445 171.427 -2.337 0.23 0 4.4375 1 2 -1
49152 -1736704 0 -41.8932 14.1238 137.163 -1.974 0.155 0 3.5625 1 2 -1
49152 -1736704 0 -1.6593 14.3062 125.151 -2.118 0.00199989 0 3.4375 1 2 -1
49152 -1736704 0 25.5644 17.9652 118.81 -2.922 0.107 0 3.4375 1 2 -1
49152 -1736704 0 48.192 23.0855 103.741 -3.918 -0.043 0 2.8125 1 2 -1
49152 -1736704 0 63.418 26.4446 89.5194 -4.443 -0.226 0 3.5625 1 2 -1
49152 -1736704 0 74.8424 29.3657 81.1522 -4.731 -0.112 0 3.5625 1 2 -1
49152 -1736704 0 90.7341 33.6623 70.0309 -5.06999 0.179 0 5.3125 1 2 -1
49152 -1736704 0 108.009 37.2439 59.4516 -5.10598 0.197 0 5.3125 1 2 -1
49152 -1736704 0 125.296 41.3295 45.3239 -5.27698 0.212 0 5.3125 1 2 -1
49152 -1736704 0 145.309 46.9206 21.5443 -5.31298 0.281 0 5.3125 1 2 -1
49152 -1736704 0 192.396 65.4099 -0.35717 -5.16599 0.371 0 5.4375 1 2 -1
49152 -1736704 0 245.39 101.996 -33.3431 -5.148 0.404 0 5.0625 1 2 -1
49152 -1736704 0 287.133 130.728 -86.5936 -5.304 0.392 0 3.5625 1 2 -1

View File

@@ -0,0 +1,9 @@
10
32768 1177374 256 -36.9555 -0.708456 -43.1076 -0.00599966 0.0560001 0 2.5 1 2 -1
32768 1196032 64 -36.8996 -1.19202 -34.4816 -0.00899966 0.0560001 0 2.5 1 2 -1
32768 1204224 64 -15.9377 -4.54803 -28.388 0.366 -0.000999904 0 2.5 1 2 -1
32768 1212416 64 7.26778 -4.84548 -32.6627 0.588 0.0860001 0 2.5 1 2 -1
32768 1220608 64 16.654 -6.1544 -31.7887 0.639 0.0650001 0 2.5 1 2 -1
32768 1228800 64 26.0385 -5.96161 -25.1148 0.786 0.0500001 0 2.5 1 2 -1
32768 1236992 64 34.2396 -6.66313 -17.5941 1.098 0.0230001 0 2.5 1 2 -1
32768 1245184 64 40.0844 -6.57907 -11.9354 1.335 0.0260001 0 2.5 1 2 -1

Some files were not shown because too many files have changed in this diff Show More