Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
leezer3 committed Mar 30, 2023
2 parents 84b35c5 + b629720 commit 1b8011c
Show file tree
Hide file tree
Showing 50 changed files with 755 additions and 2,745 deletions.
23 changes: 18 additions & 5 deletions Building.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ This file is a WIP set of instructions for building openBVE from source.

#### When to use .NET Framework

- Visual Studio 2017 or later, x86 or x64
- .NET Framework 4.7.2 or later, x86 or x64
- Visual Studio 2017 or later
- .NET Framework 4.7.2 or later

#### When to use Mono

- Mono 5.20.1 or later, x86 or x64
- Mono 5.20.1 or later
- NuGet client 2.16 or later

### Linux

- Mono 5.20.1 or later, x86 or x64
- Mono 5.20.1 or later
- NuGet client 2.16 or later
- OpenAL
- GNU Make
Expand Down Expand Up @@ -50,6 +50,19 @@ echo -e '#!/bin/sh\nexec /usr/bin/mono /usr/local/lib/nuget.exe "$@"' | sudo tee
sudo chmod 755 /usr/local/bin/nuget
```

### Required Mono Components

NOTE: Depending on the install type you select, Mono will not install all components by default. These are required:

- mono-runtime
- libmono-corlib4.5-cil
- libmono-system-drawing4.0-cil
- libmono-system-windows-forms4.0-cil
- libmono-system4.0-cil
- libmono-system-xml-linq4.0-cil
- libmono-i18n4.0-all
- libmono-microsoft-csharp4.0-cil

#### Required Additional System Libraries

- libusb-1.0
Expand All @@ -59,7 +72,7 @@ sudo chmod 755 /usr/local/bin/nuget

### Mac

- Mono 5.20.1 or later, x86 only
- Mono 5.20.1 or later
- NuGet client 2.16 or later
- OpenAL
- GNU Make
Expand Down
2 changes: 1 addition & 1 deletion assets/Shaders/default.frag
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ out vec4 fragColor;

void main(void)
{
vec4 finalColor = vec4(oColor.rgb, 1.0) * texture(uTexture, oUv);
vec4 finalColor = vec4(oColor.rgb, 1.0) * texture(uTexture, oUv); // NOTE: only want the RGB of the color, A is passed in as part of opacity

if((uMaterialFlags & 1) == 0 && (uMaterialFlags & 4) == 0)
{
Expand Down
78 changes: 36 additions & 42 deletions source/AssimpParser/Wavefront/ObjFileMtlImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,19 +252,15 @@ private void Load(string[] lines)
// Loads a color definition
private void GetColorRGBA(ref Color128 color)
{
//Debug.Assert(color != null);

float r = 0, g = 0, b = 0;
GetFloat(out r);
color.R = r;
GetFloat(out color.R);

// we have to check if color is default 0 with only one token
if (!IsLineEnd(DataIt))
{
try
{
GetFloat(out g);
GetFloat(out b);
GetFloat(out color.G);
GetFloat(out color.B);
}
catch
{
Expand All @@ -276,8 +272,6 @@ private void GetColorRGBA(ref Color128 color)
*/
}
}
color.G = g;
color.B = b;
}

// Loads a single float value.
Expand All @@ -291,60 +285,60 @@ private void GetFloatValue(out float result)
// Gets a texture name from data.
private void GetTexture()
{
int clampIndex = -1;
int clampIndex;

if (String.Compare(Buffer, DataIt, DiffuseTexture, 0, DiffuseTexture.Length, StringComparison.OrdinalIgnoreCase) == 0)
if (string.Compare(Buffer, DataIt, DiffuseTexture, 0, DiffuseTexture.Length, StringComparison.OrdinalIgnoreCase) == 0)
{
// Diffuse texture
clampIndex = (int)Material.TextureType.TextureDiffuseType;
GetTextureOptionAndName(clampIndex, ref Model.CurrentMaterial.Texture);
}
else if (String.Compare(Buffer, DataIt, AmbientTexture, 0, AmbientTexture.Length, StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Compare(Buffer, DataIt, AmbientTexture, 0, AmbientTexture.Length, StringComparison.OrdinalIgnoreCase) == 0)
{
// Ambient texture
clampIndex = (int)Material.TextureType.TextureAmbientType;
GetTextureOptionAndName(clampIndex, ref Model.CurrentMaterial.TextureAmbient);
}
else if (String.Compare(Buffer, DataIt, SpecularTexture, 0, SpecularTexture.Length, StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Compare(Buffer, DataIt, SpecularTexture, 0, SpecularTexture.Length, StringComparison.OrdinalIgnoreCase) == 0)
{
// Specular texture
clampIndex = (int)Material.TextureType.TextureSpecularType;
GetTextureOptionAndName(clampIndex, ref Model.CurrentMaterial.TextureSpecular);
}
else if (String.Compare(Buffer, DataIt, OpacityTexture, 0, OpacityTexture.Length, StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Compare(Buffer, DataIt, OpacityTexture, 0, OpacityTexture.Length, StringComparison.OrdinalIgnoreCase) == 0)
{
// Opacity texture
clampIndex = (int)Material.TextureType.TextureOpacityType;
GetTextureOptionAndName(clampIndex, ref Model.CurrentMaterial.TextureOpacity);
}
else if (String.Compare(Buffer, DataIt, EmissiveTexture1, 0, EmissiveTexture1.Length, StringComparison.OrdinalIgnoreCase) == 0
|| String.Compare(Buffer, DataIt, EmissiveTexture2, 0, EmissiveTexture2.Length, StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Compare(Buffer, DataIt, EmissiveTexture1, 0, EmissiveTexture1.Length, StringComparison.OrdinalIgnoreCase) == 0
|| string.Compare(Buffer, DataIt, EmissiveTexture2, 0, EmissiveTexture2.Length, StringComparison.OrdinalIgnoreCase) == 0)
{
// Emissive texture
clampIndex = (int)Material.TextureType.TextureEmissiveType;
GetTextureOptionAndName(clampIndex, ref Model.CurrentMaterial.TextureEmissive);
}
else if (String.Compare(Buffer, DataIt, BumpTexture1, 0, BumpTexture1.Length, StringComparison.OrdinalIgnoreCase) == 0
|| String.Compare(Buffer, DataIt, BumpTexture2, 0, BumpTexture2.Length, StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Compare(Buffer, DataIt, BumpTexture1, 0, BumpTexture1.Length, StringComparison.OrdinalIgnoreCase) == 0
|| string.Compare(Buffer, DataIt, BumpTexture2, 0, BumpTexture2.Length, StringComparison.OrdinalIgnoreCase) == 0)
{
// Bump texture
clampIndex = (int)Material.TextureType.TextureBumpType;
GetTextureOptionAndName(clampIndex, ref Model.CurrentMaterial.TextureBump);
}
else if (String.Compare(Buffer, DataIt, NormalTexture, 0, NormalTexture.Length, StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Compare(Buffer, DataIt, NormalTexture, 0, NormalTexture.Length, StringComparison.OrdinalIgnoreCase) == 0)
{
// Normal map
clampIndex = (int)Material.TextureType.TextureNormalType;
GetTextureOptionAndName(clampIndex, ref Model.CurrentMaterial.TextureNormal);
}
else if (String.Compare(Buffer, DataIt, ReflectionTexture, 0, ReflectionTexture.Length, StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Compare(Buffer, DataIt, ReflectionTexture, 0, ReflectionTexture.Length, StringComparison.OrdinalIgnoreCase) == 0)
{
// Reflection texture(s)
// Do nothing here
return;
}
else if (String.Compare(Buffer, DataIt, DisplacementTexture1, 0, DisplacementTexture1.Length, StringComparison.OrdinalIgnoreCase) == 0
|| String.Compare(Buffer, DataIt, DisplacementTexture2, 0, DisplacementTexture2.Length, StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Compare(Buffer, DataIt, DisplacementTexture1, 0, DisplacementTexture1.Length, StringComparison.OrdinalIgnoreCase) == 0
|| string.Compare(Buffer, DataIt, DisplacementTexture2, 0, DisplacementTexture2.Length, StringComparison.OrdinalIgnoreCase) == 0)
{
// Displacement texture
clampIndex = (int)Material.TextureType.TextureDispType;
Expand Down Expand Up @@ -390,60 +384,60 @@ private void GetTextureOptionAndName(int clampIndex, ref string result)
//skip option key and value
int skipToken = 1;

if (String.Compare(Buffer, DataIt, ClampOption, 0, ClampOption.Length, StringComparison.OrdinalIgnoreCase) == 0)
if (string.Compare(Buffer, DataIt, ClampOption, 0, ClampOption.Length, StringComparison.OrdinalIgnoreCase) == 0)
{
DataIt = GetNextToken(DataIt, DataEnd);
string tmp;
CopyNextWord(out tmp);
if (String.Compare(tmp, 0, "on", 0, 2, StringComparison.OrdinalIgnoreCase) == 0)
if (string.Compare(tmp, 0, "on", 0, 2, StringComparison.OrdinalIgnoreCase) == 0)
{
clamp = true;
}

skipToken = 2;
}
else if (String.Compare(Buffer, DataIt, TypeOption, 0, TypeOption.Length, StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Compare(Buffer, DataIt, TypeOption, 0, TypeOption.Length, StringComparison.OrdinalIgnoreCase) == 0)
{
DataIt = GetNextToken(DataIt, DataEnd);
string tmp;
CopyNextWord(out tmp);
if (String.Compare(tmp, 0, "cube_top", 0, 8, StringComparison.OrdinalIgnoreCase) == 0)
if (string.Compare(tmp, 0, "cube_top", 0, 8, StringComparison.OrdinalIgnoreCase) == 0)
{
clampIndex = (int)Material.TextureType.TextureReflectionCubeTopType;
GetTextureName(ref Model.CurrentMaterial.TextureReflection[0]);
already = true;
}
else if (String.Compare(tmp, 0, "cube_bottom", 0, 11, StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Compare(tmp, 0, "cube_bottom", 0, 11, StringComparison.OrdinalIgnoreCase) == 0)
{
clampIndex = (int)Material.TextureType.TextureReflectionCubeBottomType;
GetTextureName(ref Model.CurrentMaterial.TextureReflection[1]);
already = true;
}
else if (String.Compare(tmp, 0, "cube_front", 0, 10, StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Compare(tmp, 0, "cube_front", 0, 10, StringComparison.OrdinalIgnoreCase) == 0)
{
clampIndex = (int)Material.TextureType.TextureReflectionCubeFrontType;
GetTextureName(ref Model.CurrentMaterial.TextureReflection[2]);
already = true;
}
else if (String.Compare(tmp, 0, "cube_back", 0, 9, StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Compare(tmp, 0, "cube_back", 0, 9, StringComparison.OrdinalIgnoreCase) == 0)
{
clampIndex = (int)Material.TextureType.TextureReflectionCubeBackType;
GetTextureName(ref Model.CurrentMaterial.TextureReflection[3]);
already = true;
}
else if (String.Compare(tmp, 0, "cube_left", 0, 9, StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Compare(tmp, 0, "cube_left", 0, 9, StringComparison.OrdinalIgnoreCase) == 0)
{
clampIndex = (int)Material.TextureType.TextureReflectionCubeLeftType;
GetTextureName(ref Model.CurrentMaterial.TextureReflection[4]);
already = true;
}
else if (String.Compare(tmp, 0, "cube_right", 0, 10, StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Compare(tmp, 0, "cube_right", 0, 10, StringComparison.OrdinalIgnoreCase) == 0)
{
clampIndex = (int)Material.TextureType.TextureReflectionCubeRightType;
GetTextureName(ref Model.CurrentMaterial.TextureReflection[5]);
already = true;
}
else if (String.Compare(tmp, 0, "sphere", 0, 6, StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Compare(tmp, 0, "sphere", 0, 6, StringComparison.OrdinalIgnoreCase) == 0)
{
clampIndex = (int)Material.TextureType.TextureReflectionSphereType;
GetTextureName(ref Model.CurrentMaterial.TextureReflection[0]);
Expand All @@ -452,22 +446,22 @@ private void GetTextureOptionAndName(int clampIndex, ref string result)

skipToken = 2;
}
else if (String.Compare(Buffer, DataIt, BlendUOption, 0, BlendUOption.Length, StringComparison.OrdinalIgnoreCase) == 0
|| String.Compare(Buffer, DataIt, BlendVOption, 0, BlendVOption.Length, StringComparison.OrdinalIgnoreCase) == 0
|| String.Compare(Buffer, DataIt, BoostOption, 0, BoostOption.Length, StringComparison.OrdinalIgnoreCase) == 0
|| String.Compare(Buffer, DataIt, ResolutionOption, 0, ResolutionOption.Length, StringComparison.OrdinalIgnoreCase) == 0
|| String.Compare(Buffer, DataIt, BumpOption, 0, BumpOption.Length, StringComparison.OrdinalIgnoreCase) == 0
|| String.Compare(Buffer, DataIt, ChannelOption, 0, ChannelOption.Length, StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Compare(Buffer, DataIt, BlendUOption, 0, BlendUOption.Length, StringComparison.OrdinalIgnoreCase) == 0
|| string.Compare(Buffer, DataIt, BlendVOption, 0, BlendVOption.Length, StringComparison.OrdinalIgnoreCase) == 0
|| string.Compare(Buffer, DataIt, BoostOption, 0, BoostOption.Length, StringComparison.OrdinalIgnoreCase) == 0
|| string.Compare(Buffer, DataIt, ResolutionOption, 0, ResolutionOption.Length, StringComparison.OrdinalIgnoreCase) == 0
|| string.Compare(Buffer, DataIt, BumpOption, 0, BumpOption.Length, StringComparison.OrdinalIgnoreCase) == 0
|| string.Compare(Buffer, DataIt, ChannelOption, 0, ChannelOption.Length, StringComparison.OrdinalIgnoreCase) == 0)
{
skipToken = 2;
}
else if (String.Compare(Buffer, DataIt, ModifyMapOption, 0, ModifyMapOption.Length, StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Compare(Buffer, DataIt, ModifyMapOption, 0, ModifyMapOption.Length, StringComparison.OrdinalIgnoreCase) == 0)
{
skipToken = 3;
}
else if (String.Compare(Buffer, DataIt, OffsetOption, 0, OffsetOption.Length, StringComparison.OrdinalIgnoreCase) == 0
|| String.Compare(Buffer, DataIt, ScaleOption, 0, ScaleOption.Length, StringComparison.OrdinalIgnoreCase) == 0
|| String.Compare(Buffer, DataIt, TurbulenceOption, 0, TurbulenceOption.Length, StringComparison.OrdinalIgnoreCase) == 0)
else if (string.Compare(Buffer, DataIt, OffsetOption, 0, OffsetOption.Length, StringComparison.OrdinalIgnoreCase) == 0
|| string.Compare(Buffer, DataIt, ScaleOption, 0, ScaleOption.Length, StringComparison.OrdinalIgnoreCase) == 0
|| string.Compare(Buffer, DataIt, TurbulenceOption, 0, TurbulenceOption.Length, StringComparison.OrdinalIgnoreCase) == 0)
{
skipToken = 4;
}
Expand Down
10 changes: 1 addition & 9 deletions source/AssimpParser/Wavefront/ObjFileParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
using System.Diagnostics;
using System.Globalization;
using System.IO;
using OpenBveApi.Interface;
using OpenBveApi.Math;
using OpenBveApi.Objects;

Expand Down Expand Up @@ -530,14 +529,7 @@ protected void GetFace(PrimitiveType type)
}

// Set active material, if one set
if (Model.CurrentMaterial != null)
{
face.Material = Model.CurrentMaterial;
}
else
{
face.Material = Model.DefaultMaterial;
}
face.Material = Model.CurrentMaterial ?? Model.DefaultMaterial;

// Create a default object, if nothing is there
if (Model.Current == null)
Expand Down
29 changes: 25 additions & 4 deletions source/AssimpParser/X/XFileHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,29 +109,45 @@ public TexEntry(string name, bool isNormalMap = false)
public class Material
{
public string Name;
public bool IsReference; // if true, mName holds a name by which the actual material can be found in the material list
public readonly bool IsReference; // if true, mName holds a name by which the actual material can be found in the material list
public Color128 Diffuse;
public float SpecularExponent;
public Color128 Specular;
public Color128 Emissive;
public List<TexEntry> Textures = new List<TexEntry>();

public uint SceneIndex; // the index under which it was stored in the scene's material list

public Material(bool isReference)
{
IsReference = isReference;
}
}

/** Helper structure to represent a bone weight */
public class BoneWeight
{
public uint Vertex;
public readonly uint Vertex;
public float Weight;

public BoneWeight(uint vertex)
{
Vertex = vertex;
}

}

/** Helper structure to represent a bone in a mesh */
public class Bone
{
public string Name;
public readonly string Name;
public List<BoneWeight> Weights = new List<BoneWeight>();
public Matrix4D OffsetMatrix;

public Bone(string name)
{
Name = name;
}
}

/** Helper structure to represent an XFile mesh */
Expand Down Expand Up @@ -190,8 +206,13 @@ public class AnimBone
/** Helper structure to represent an animation set in a XFile */
public class Animation
{
public string Name;
public readonly string Name;
public List<AnimBone> Anims = new List<AnimBone>();

public Animation(string name)
{
Name = name;
}
}

/** Helper structure analogue to aiScene */
Expand Down
Loading

0 comments on commit 1b8011c

Please sign in to comment.