Skip to content

Commit 99ebfa7

Browse files
committed
tidyup
1 parent 4030eca commit 99ebfa7

7 files changed

Lines changed: 1 addition & 836 deletions

File tree

CathodeLib/CathodeLib.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@
4747
</ItemGroup>
4848

4949
<ItemGroup>
50-
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
5150
<PackageReference Include="System.Buffers" Version="4.5.1" />
5251
<PackageReference Include="System.Memory" Version="4.5.4" />
5352
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
5453
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
55-
<PackageReference Include="WindowsBase_Core.STW" Version="4.0.30319.1" />
5654
</ItemGroup>
5755

5856
<ItemGroup>

CathodeLib/Properties/Resources.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,6 @@
131131
<value>..\Resources\NodeDBs\entity_parameter_names.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
132132
</data>
133133
<data name="sound_names" type="System.Resources.ResXFileRef, System.Windows.Forms">
134-
<value>..\resources\sound_names.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
134+
<value>..\Resources\sound_names.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
135135
</data>
136136
</root>

CathodeLib/Scripts/CATHODE/Collisions.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System;
33
using System.Collections.Generic;
44
using System.IO;
5-
using System.Runtime.InteropServices;
65
using System.Linq;
76
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
87
using UnityEngine;
@@ -94,9 +93,6 @@ override protected bool LoadInternal()
9493
Entry1.Vertices = vertexes.GetRange(verIndex, verIndex + Entry1.VertexCount);
9594
}
9695
}
97-
98-
string dsfdsfds = "";
99-
10096
}
10197
return true;
10298
}

CathodeLib/Scripts/CATHODE/Models.cs

Lines changed: 0 additions & 252 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
using System.Collections.Generic;
44
using System.IO;
55
using System.Linq;
6-
using System.Runtime.InteropServices;
76
#if UNITY_EDITOR || UNITY_STANDALONE
87
using UnityEngine;
98
#else
109
using System.Numerics;
11-
using System.Windows.Media;
12-
using System.Windows.Media.Media3D;
1310
#endif
1411

1512
namespace CATHODE
@@ -455,255 +452,6 @@ override protected bool SaveInternal()
455452
}
456453
#endregion
457454

458-
#region ACCESSORS
459-
/* Get a mesh from the models PAK as a usable mesh format */
460-
461-
// TODO: Move these to extension classes that can be included separate to the library to remove external library dependencies in cathodelib
462-
463-
#if UNITY_EDITOR || UNITY_STANDALONE
464-
public Mesh GetMesh(CS2.Component.LOD.Submesh submesh)
465-
#else
466-
public Model3DGroup GetMesh(CS2.Component.LOD.Submesh submesh)
467-
#endif
468-
{
469-
#if UNITY_EDITOR || UNITY_STANDALONE
470-
Mesh mesh = new Mesh();
471-
#else
472-
Model3DGroup mesh = new Model3DGroup();
473-
#endif
474-
475-
#if UNITY_EDITOR || UNITY_STANDALONE
476-
List<UInt16> indices = new List<UInt16>();
477-
List<Vector3> vertices = new List<Vector3>();
478-
List<Vector3> normals = new List<Vector3>();
479-
List<Vector4> tangents = new List<Vector4>();
480-
List<Vector2> uv0 = new List<Vector2>();
481-
List<Vector2> uv1 = new List<Vector2>();
482-
List<Vector2> uv2 = new List<Vector2>();
483-
List<Vector2> uv3 = new List<Vector2>();
484-
List<Vector2> uv7 = new List<Vector2>();
485-
#else
486-
Int32Collection indices = new Int32Collection();
487-
Point3DCollection vertices = new Point3DCollection();
488-
Vector3DCollection normals = new Vector3DCollection();
489-
List<Vector4> tangents = new List<Vector4>();
490-
PointCollection uv0 = new PointCollection();
491-
PointCollection uv1 = new PointCollection();
492-
PointCollection uv2 = new PointCollection();
493-
PointCollection uv3 = new PointCollection();
494-
PointCollection uv7 = new PointCollection();
495-
#endif
496-
497-
//TODO: implement skeleton lookup for the indexes
498-
List<Vector4> boneIndex = new List<Vector4>(); //The indexes of 4 bones that affect each vertex
499-
List<Vector4> boneWeight = new List<Vector4>(); //The weights for each bone
500-
501-
if (submesh.content.Length == 0)
502-
return mesh;
503-
504-
using (BinaryReader reader = new BinaryReader(new MemoryStream(submesh.content)))
505-
{
506-
for (int i = 0; i < submesh.VertexFormat.Elements.Count; ++i)
507-
{
508-
if (i == submesh.VertexFormat.Elements.Count - 1)
509-
{
510-
//TODO: should probably verify VariableType here -----> maybe use the new case i've put in below?
511-
for (int x = 0; x < submesh.IndexCount; x++)
512-
indices.Add(reader.ReadUInt16());
513-
514-
continue;
515-
}
516-
517-
for (int x = 0; x < submesh.VertexCount; ++x)
518-
{
519-
for (int y = 0; y < submesh.VertexFormat.Elements[i].Count; ++y)
520-
{
521-
AlienVBF.Element format = submesh.VertexFormat.Elements[i][y];
522-
switch (format.VariableType)
523-
{
524-
//case VBFE_InputType.AlienVertexInputType_u16:
525-
// {
526-
// for (int z = 0; z < submesh.IndexCount; z++)
527-
// indices.Add(reader.ReadUInt16());
528-
// }
529-
// break;
530-
531-
case VBFE_InputType.VECTOR3:
532-
{
533-
#if UNITY_EDITOR || UNITY_STANDALONE
534-
Vector3 v = new Vector3(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32());
535-
#else
536-
Vector3D v = new Vector3D(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
537-
#endif
538-
switch (format.ShaderSlot)
539-
{
540-
case VBFE_InputSlot.NORMAL:
541-
normals.Add(v);
542-
break;
543-
case VBFE_InputSlot.TANGENT:
544-
#if UNITY_EDITOR || UNITY_STANDALONE
545-
tangents.Add(new Vector4((float)v.x, (float)v.y, (float)v.z, 0));
546-
#else
547-
tangents.Add(new Vector4((float)v.X, (float)v.Y, (float)v.Z, 0));
548-
#endif
549-
break;
550-
case VBFE_InputSlot.UV:
551-
//TODO: 3D UVW
552-
break;
553-
};
554-
break;
555-
}
556-
case VBFE_InputType.INT32:
557-
{
558-
int v = reader.ReadInt32();
559-
switch (format.ShaderSlot)
560-
{
561-
case VBFE_InputSlot.COLOUR:
562-
//??
563-
break;
564-
}
565-
break;
566-
}
567-
case VBFE_InputType.VECTOR4_BYTE:
568-
{
569-
Vector4 v = new Vector4(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), reader.ReadByte());
570-
switch (format.ShaderSlot)
571-
{
572-
case VBFE_InputSlot.BONE_INDICES:
573-
boneIndex.Add(v);
574-
break;
575-
}
576-
break;
577-
}
578-
case VBFE_InputType.VECTOR4_BYTE_DIV255:
579-
{
580-
Vector4 v = new Vector4(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), reader.ReadByte());
581-
v /= 255.0f;
582-
switch (format.ShaderSlot)
583-
{
584-
#if UNITY_EDITOR || UNITY_STANDALONE
585-
case VBFE_InputSlot.BONE_WEIGHTS:
586-
boneWeight.Add(v / (v.x + v.y + v.z + v.w));
587-
break;
588-
case VBFE_InputSlot.UV:
589-
uv2.Add(new Vector2(v.x, v.y));
590-
uv3.Add(new Vector2(v.z, v.w));
591-
break;
592-
#else
593-
case VBFE_InputSlot.BONE_WEIGHTS:
594-
boneWeight.Add(v / (v.X + v.Y + v.Z + v.W));
595-
break;
596-
case VBFE_InputSlot.UV:
597-
uv2.Add(new System.Windows.Point(v.X, v.Y));
598-
uv3.Add(new System.Windows.Point(v.Z, v.W));
599-
break;
600-
#endif
601-
}
602-
break;
603-
}
604-
case VBFE_InputType.VECTOR2_INT16_DIV2048:
605-
{
606-
#if UNITY_EDITOR || UNITY_STANDALONE
607-
Vector2 v = new Vector2(reader.ReadInt16(), reader.ReadInt16());
608-
v /= 2048.0f;
609-
#else
610-
System.Windows.Point v = new System.Windows.Point(reader.ReadInt16() / 2048.0f, reader.ReadInt16() / 2048.0f);
611-
#endif
612-
switch (format.ShaderSlot)
613-
{
614-
case VBFE_InputSlot.UV:
615-
if (format.VariantIndex == 0) uv0.Add(v);
616-
else if (format.VariantIndex == 1)
617-
{
618-
// TODO: We can figure this out based on AlienVBFE.
619-
//Material->Material.Flags |= Material_HasTexCoord1;
620-
uv1.Add(v);
621-
}
622-
else if (format.VariantIndex == 2) uv2.Add(v);
623-
else if (format.VariantIndex == 3) uv3.Add(v);
624-
else if (format.VariantIndex == 7) uv7.Add(v);
625-
break;
626-
}
627-
break;
628-
}
629-
case VBFE_InputType.VECTOR4_INT16_DIVMAX:
630-
{
631-
Vector4 v = new Vector4(reader.ReadInt16(), reader.ReadInt16(), reader.ReadInt16(), reader.ReadInt16());
632-
v /= (float)Int16.MaxValue;
633-
switch (format.ShaderSlot)
634-
{
635-
case VBFE_InputSlot.VERTEX:
636-
#if UNITY_EDITOR || UNITY_STANDALONE
637-
vertices.Add(v);
638-
#else
639-
vertices.Add(new Point3D(v.X, v.Y, v.Z));
640-
#endif
641-
break;
642-
}
643-
break;
644-
}
645-
case VBFE_InputType.VECTOR4_BYTE_NORM:
646-
{
647-
Vector4 v = new Vector4(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), reader.ReadByte());
648-
v /= (float)byte.MaxValue - 0.5f;
649-
v = Vector4.Normalize(v);
650-
switch (format.ShaderSlot)
651-
{
652-
case VBFE_InputSlot.NORMAL:
653-
#if UNITY_EDITOR || UNITY_STANDALONE
654-
normals.Add(v);
655-
#else
656-
normals.Add(new Vector3D(v.X, v.Y, v.Z));
657-
#endif
658-
break;
659-
case VBFE_InputSlot.TANGENT:
660-
break;
661-
case VBFE_InputSlot.BITANGENT:
662-
break;
663-
}
664-
break;
665-
}
666-
}
667-
}
668-
}
669-
Utilities.Align(reader, 16);
670-
}
671-
}
672-
673-
if (vertices.Count == 0) return mesh;
674-
675-
#if UNITY_EDITOR || UNITY_STANDALONE
676-
mesh.SetVertices(vertices);
677-
mesh.SetNormals(normals);
678-
mesh.SetIndices(indices, MeshTopology.Triangles, 0); //0??
679-
mesh.SetTangents(tangents);
680-
mesh.SetUVs(0, uv0);
681-
mesh.SetUVs(1, uv1);
682-
mesh.SetUVs(2, uv2);
683-
mesh.SetUVs(3, uv3);
684-
mesh.SetUVs(7, uv7);
685-
//mesh.SetBoneWeights(InBoneWeights.ToArray());
686-
mesh.RecalculateBounds();
687-
mesh.RecalculateNormals();
688-
mesh.RecalculateTangents();
689-
#else
690-
mesh.Children.Add(new GeometryModel3D
691-
{
692-
Geometry = new MeshGeometry3D
693-
{
694-
Positions = vertices,
695-
TriangleIndices = indices,
696-
Normals = normals,
697-
TextureCoordinates = uv0,
698-
},
699-
Material = new DiffuseMaterial(new SolidColorBrush(Color.FromRgb(255, 255, 0))),
700-
BackMaterial = new DiffuseMaterial(new SolidColorBrush(Color.FromRgb(255, 255, 0)))
701-
});
702-
#endif
703-
return mesh;
704-
}
705-
#endregion
706-
707455
#region HELPERS
708456
/* Find a model that contains a given submesh */
709457
public CS2 FindModelForSubmesh(CS2.Component.LOD.Submesh submesh)

0 commit comments

Comments
 (0)