├── .gitignore ├── BuildTools ├── BuildTools.csproj ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── CHANGELOG.txt ├── COPYING ├── COPYING.LESSER ├── LICENSE.txt ├── MCS.sln ├── MCS_Core ├── Character │ ├── MCSCharacter.cs │ ├── MCSCharacterModel.cs │ └── MCSCharacterSchematic.cs ├── Constants.cs ├── ContentLibrary │ ├── AssetCreator.cs │ ├── ContentLibrary.cs │ ├── ContentLibrarySO.cs │ ├── MCSObjectLoader.cs │ ├── MCSResourceManager.cs │ ├── MonDeserializer.cs │ └── RuntimeTextureLoader.cs ├── CoreServices │ ├── AlphaInjectionManager.cs │ ├── CSBoneService.cs │ ├── CSBoneService │ │ ├── BoneUtility.cs │ │ └── GeometryTransferUtility.cs │ └── CSInjectionMask.cs ├── Costuming │ ├── CIattachmentPoint.cs │ ├── CIbody.cs │ ├── CIclothing.cs │ ├── CIhair.cs │ ├── CIprop.cs │ ├── CostumeItem.cs │ └── CostumeModel.cs ├── Foundations │ ├── ContentPack.cs │ ├── ContentPackModel.cs │ ├── CoreMesh.cs │ ├── CoreMeshMetaData.cs │ ├── CoreMetaData.cs │ ├── CoreMorphs.cs │ ├── MorphGroup.cs │ └── MorphGroupService.cs ├── Item │ ├── MCSClothing.cs │ ├── MCSFigure.cs │ ├── MCSHair.cs │ ├── MCSItem.cs │ ├── MCSItemModel.cs │ ├── MCSItemSchematic.cs │ ├── MCSMesh.cs │ ├── MCSProp.cs │ └── MCSProperty.cs ├── MCSCharacterManager.cs ├── MCS_Core.csproj ├── Properties │ └── AssemblyInfo.cs ├── Services │ └── StreamingMorphs.cs ├── Utilities │ ├── AssetSchematicImporter.cs │ ├── BlendShapes.cs │ ├── ConvertWeldedMeshMorph.cs │ ├── EnumHelper.cs │ ├── Extensions │ │ └── Extensions.cs │ ├── KeyValueFloat.cs │ └── TextureUtilities.cs ├── Utility │ ├── Event │ │ ├── ILazyFixedUpdate.cs │ │ ├── ILazyLateUpdate.cs │ │ └── ILazyUpdate.cs │ ├── MCSResourceConverter.cs │ ├── Schematic │ │ ├── AssetDependency.cs │ │ ├── AssetSchematic.cs │ │ ├── AssetSchematicUtility.cs │ │ ├── Base │ │ │ ├── OriginAndDescription.cs │ │ │ ├── Path.cs │ │ │ ├── Physical.cs │ │ │ ├── Stream.cs │ │ │ ├── StreamAndPath.cs │ │ │ ├── StructureAndPhysics.cs │ │ │ ├── TypeAndFunction.cs │ │ │ └── VersionAndControl.cs │ │ ├── Enum │ │ │ ├── EmptyClass.cs │ │ │ └── Enumeration.cs │ │ └── Structure │ │ │ ├── ItemStructure.cs │ │ │ ├── MaterialStructure.cs │ │ │ └── MorphStructure.cs │ └── Serialize │ │ └── ISerializable.cs └── _Experimental │ ├── AttachmentPointSystem │ ├── APLayout.cs │ ├── MCSAttachmentPointConfiguration.cs │ └── SinglePropDefaultLayout.cs │ └── JCTs │ ├── Expand.cs │ ├── JCTTransition.cs │ └── Profiler.cs ├── MCS_Importer ├── AssetManager │ ├── ImportUtilities.cs │ └── TextureLoader.cs ├── Importer │ ├── AssetDependencyImporter.cs │ ├── DarwinPrototypeImporter.cs │ ├── JCTImportUtility.cs │ └── MCSCustomImporter.cs ├── MCS_Importer.csproj └── Properties │ └── AssemblyInfo.cs ├── MCS_Utilities ├── KDTree │ └── KDTree.cs ├── MCSConstants.cs ├── MCSResource.cs ├── MCS_Utilities.csproj ├── Morph │ └── Morph.cs ├── MorphExtraction │ ├── Compression.cs │ ├── Foundations │ │ └── MorphExtraction_Structs.cs │ └── MorphExtraction.cs ├── Paths.cs └── Properties │ └── AssemblyInfo.cs ├── README.md ├── Scripts ├── AttachmentPoints │ ├── SinglePropDefaultLayoutExample.cs │ └── SpiralPropLayout.cs ├── Editor │ ├── CIClothingEditor.cs │ ├── ContentLibrarySOEditor.cs │ ├── MCSCharacterManagerEditor.cs │ ├── MCSDebugInfo.cs │ ├── MCSMorphEditor.cs │ ├── MCSResourceEditor.cs │ ├── MaterialImporter.cs │ └── SearchableWindow.cs ├── Samples │ ├── AttachDetachClothing.cs │ ├── DisableAllClothing.cs │ ├── DriveMorph.cs │ ├── HairRandomizer.cs │ └── SetMaterials.cs └── Scripts.csproj ├── Shaders ├── AlphaCombiner.shader ├── EyeAndLash.shader ├── Hair │ ├── Editor.meta │ ├── Editor │ │ ├── HairShaderGUI.cs │ │ └── HairShaderGUI.cs.meta │ ├── EmptyClass.cs │ ├── EmptyClass.cs.meta │ ├── HairRenderer.cs │ ├── HairRenderer.cs.meta │ ├── Hair_UnityStandardCore.cginc │ ├── Hair_UnityStandardCore.cginc.meta │ ├── Hair_UnityStandardInput.cginc │ ├── Hair_UnityStandardInput.cginc.meta │ ├── Hair_Universal.shader │ ├── Hair_Universal.shader.meta │ ├── Hair_Universal_GL2.shader │ ├── Hair_Universal_GL2.shader.meta │ ├── Hair_setup.cginc │ └── Hair_setup.cginc.meta ├── Skin │ ├── BaseShader.shader │ ├── BaseShader.shader.meta │ ├── Editor.meta │ ├── Editor │ │ ├── VolundMultiStandardShaderGUI.cs │ │ └── VolundMultiStandardShaderGUI.cs.meta │ ├── NormalShader.shader │ ├── NormalShader.shader.meta │ ├── Volund_StandardSpecularCharacter.shader │ ├── Volund_StandardSpecularCharacter.shader.meta │ ├── Volund_StandardSpecularCharacter_GL2.shader │ ├── Volund_StandardSpecularCharacter_GL2.shader.meta │ ├── Volund_UnityStandardCore.cginc │ ├── Volund_UnityStandardCore.cginc.meta │ ├── Volund_UnityStandardCore_Legacy.cginc │ ├── Volund_UnityStandardCore_Legacy.cginc.meta │ ├── Volund_UnityStandardInput.cginc │ └── Volund_UnityStandardInput.cginc.meta ├── Standard │ ├── Standard-2pass-doublesided-half depth.shader │ ├── Standard-2pass-doublesided-half depth.shader.meta │ ├── Standard-2pass-doublesided.shader │ ├── Standard-2pass-doublesided.shader.meta │ ├── Standard-doublesided.shader │ ├── Standard-doublesided.shader.meta │ ├── StandardSpecular-doublesided.shader │ └── StandardSpecular-doublesided.shader.meta └── UniqueShadow │ ├── UniqueShadow.cs │ ├── UniqueShadow.cs.meta │ ├── UniqueShadowSun.cs │ ├── UniqueShadowSun.cs.meta │ ├── UniqueShadow_DepthOnly.shader │ ├── UniqueShadow_DepthOnly.shader.meta │ ├── UniqueShadow_ShadowSample.cginc │ └── UniqueShadow_ShadowSample.cginc.meta └── VENDORS.md /.gitignore: -------------------------------------------------------------------------------- 1 | bin/* 2 | build/* 3 | obj/ 4 | 5 | *.pidb 6 | *.userprefs 7 | *.swp 8 | *.DS_Store 9 | *.nib 10 | *.suo 11 | *.user 12 | *.pfx 13 | *.tmp 14 | .vs/ 15 | .vscode/ 16 | 17 | #include your own references, do not track these in git 18 | UnityEngine.dll 19 | UnityEditor.dll 20 | UnityDLLs/ 21 | -------------------------------------------------------------------------------- /BuildTools/BuildTools.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | {5489E763-5FE2-45FF-B295-20DD8C9312E2} 7 | Exe 8 | BuildTools 9 | BuildTools 10 | False 11 | v3.5 12 | 1.7 13 | 14 | 15 | True 16 | full 17 | False 18 | ..\build\BuildTools 19 | DEBUG; 20 | prompt 21 | 4 22 | True 23 | 24 | 25 | none 26 | True 27 | ..\build\BuildTools 28 | prompt 29 | 4 30 | True 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /BuildTools/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle ("BuildTools")] 8 | [assembly: AssemblyDescription ("")] 9 | [assembly: AssemblyConfiguration ("")] 10 | [assembly: AssemblyCompany ("")] 11 | [assembly: AssemblyProduct ("")] 12 | [assembly: AssemblyCopyright ("macleod")] 13 | [assembly: AssemblyTrademark ("")] 14 | [assembly: AssemblyCulture ("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion ("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | -------------------------------------------------------------------------------- /CHANGELOG.txt: -------------------------------------------------------------------------------- 1 | 1.7.0 2 | Released as open source under LGPLv3 3 | Misc cleanup of codebase 4 | Renamed project as simply MCS 5 | 6 | 1.6.6 7 | Added support for custom MR path location 8 | 9 | 1.6.5 10 | Fixes issue with boundary calculation for ON_ATTACH intervals 11 | 12 | 1.6.4 13 | Prepping work for windows universal support (not quite ready yet) 14 | Adds support for clearing blendshapes when CharacterManager.Start is called (on by default) 15 | Added OnPreLODChange and OnPostLODChange events (these are fired during the lod value in CharacterManager changes) 16 | Improved check for figure testing when importing assets 17 | Fixed a rare issue with normal texture importing when creating a material 18 | Added fix to allow Wii U builds to work properly 19 | Improved error handling when bad mon file exception occurs 20 | Fixed issue where duplicate bone names in figure bone hierarchy could cause error when attaching or removing clothing, props, and hair 21 | Added support for running JCT at edit time (note, this should only be used in very specific cases, it will ruin your bone state data), off by default 22 | Added support for auto closing the jaw (under CharacterManager -> Advanced) 23 | 24 | 1.6.3 25 | Adds support for automatic recalculation of mesh boundaries, frequency choices are never, on attach, on morph 26 | Resolves missing morph groups from character inspector 27 | Fixed error with head overlay material check when null 28 | Fixed serialization issue with prefabs for materials, LODs, and morphs 29 | Fixed issue with Alpha Injection when using prefabed figures 30 | Fixed problems and errors with prop attachment and usage 31 | Improved several eye morph qualities at lower LODs 32 | 33 | 1.6.2 34 | Resolved issue with content packs where parent and child had identical names and caused syncing issues 35 | Added support to remove unlinked content packs that were free floating to Editor 36 | Improved visual layout of Editor component 37 | Added support for detecting flawed CoreMesh and ContentPack assets 38 | Fixed misc hair attachment 39 | Added support for Overlay texture and color linked from CIHair to paint cap texture on head 40 | Fixed prop attachment in Editor 41 | Shows prop names instead of ID in Editor 42 | -------------------------------------------------------------------------------- /MCS_Core/Character/MCSCharacter.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using MCS; 6 | 7 | using MCS.Utility.Event; 8 | using MCS.Utility.Serialize; 9 | 10 | namespace MCS.Character 11 | { 12 | /* 13 | public class MCSCharacter : MonoBehaviour, IlazyUpdate, IlazyLateUpdate, ISerializable 14 | { 15 | 16 | public event AfterLazyUpdate OnAfterLazyUpdate; 17 | public event BeforeLazyUpdate OnBeforeLazyUpdate; 18 | public event BeforeLazyLateUpdate OnBeforeLazyLateUpdate; 19 | public event AfterLazyLateUpdate OnAfterLazyLateUpdate; 20 | 21 | bool needs_lazy_update = false; 22 | bool needs_lazy_late_update = false; 23 | 24 | 25 | public void Update() 26 | { 27 | if (needs_lazy_update) 28 | { 29 | if (OnBeforeLazyUpdate != null) 30 | OnBeforeLazyUpdate(); 31 | //do some processing 32 | if (OnAfterLazyUpdate != null) 33 | OnAfterLazyUpdate(); 34 | } 35 | } 36 | 37 | public void LateUpdate() 38 | { 39 | if (needs_lazy_late_update) 40 | { 41 | if (OnBeforeLazyLateUpdate != null) 42 | OnBeforeLazyLateUpdate(); 43 | //do some processing 44 | if (OnAfterLazyLateUpdate != null) 45 | OnAfterLazyLateUpdate(); 46 | } 47 | } 48 | 49 | public void SerializeStateToJson() 50 | { 51 | 52 | } 53 | 54 | public void DeserializeStateFromJson() 55 | { 56 | 57 | } 58 | 59 | } 60 | */ 61 | } 62 | -------------------------------------------------------------------------------- /MCS_Core/Character/MCSCharacterModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | namespace MCS.Character 4 | { 5 | public class MCSCharacterModel : MonoBehaviour 6 | { 7 | public MCSCharacterSchematic schematic; 8 | 9 | } 10 | 11 | } 12 | 13 | -------------------------------------------------------------------------------- /MCS_Core/Character/MCSCharacterSchematic.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace MCS.Character 3 | { 4 | public class MCSCharacterSchematic 5 | { 6 | public MCSCharacterSchematic() 7 | { 8 | } 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /MCS_Core/Constants.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System; 4 | using System.ComponentModel; 5 | using System.Reflection; 6 | 7 | namespace MCS.CONSTANTS 8 | { 9 | public enum POLARIZED_OPTION 10 | { 11 | NONE, 12 | POSITIVE, 13 | NEGATIVE 14 | } 15 | 16 | /// 17 | /// Determines the type of Importer available for the Import_DLL 18 | /// 19 | public enum IMPORTER_TYPE 20 | { 21 | LEGACY, 22 | ASSETSCHEMATIC, 23 | KEYVALUE 24 | } 25 | /// 26 | /// Enums for the different types of Blendshapes or Morphs available 27 | /// for the MCS Figures. The Enums roughly correspond to the prefix 28 | /// of the localName of the Morph. 29 | /// 30 | public enum BLENDSHAPE_TYPE 31 | { 32 | [Description("Full Body Morph")] 33 | FBM, // BODY GROUP 34 | [Description("Full Head Morph")] 35 | FHM, // HEAD GROUP 36 | [Description("Partial Body Morph")] 37 | PBM, // BODY GROUP 38 | [Description("Partial Head Morph")] 39 | PHM, // HEAD GROUP 40 | [Description("Morph Control Morph")] 41 | MCM, // HIDE DO NOT DISPLAY 42 | [Description("Joint Center Morph")] 43 | JCM, // HIDE DO NOT DISPLAY 44 | [Description("Vocal Shape Morph")] 45 | VSM, // PHONEME GROUP 46 | [Description("Proportion Morph")] 47 | SCL, // PROPORTION GROUP 48 | [Description("Morph Group")] 49 | CTRL, // IGNORE 50 | [Description("Complete Body Morph")] 51 | CBM, // custom morphs made by us 52 | [Description("Miscellaneous Morphs")] 53 | MSC // custom morphs made by us 54 | } 55 | 56 | /// 57 | /// Enum to distinguish the different types of meshes we deal with 58 | /// Body, Hair, Cloth or Prop. 59 | /// 60 | public enum MESH_TYPE 61 | { 62 | [Description("Body Mesh")] 63 | BODY, 64 | [Description("Hair Mesh")] 65 | HAIR, 66 | [Description("Clothing Mesh")] 67 | CLOTH, 68 | [Description("Prop Mesh")] 69 | PROP, 70 | [Description("UNNKOWN")] 71 | UNKNOWN, 72 | } 73 | 74 | /// 75 | /// Enum to distinguish between visible and hidden meshes. 76 | /// 77 | public enum VISIBILITY { Hidden, Visible } 78 | 79 | /// 80 | /// These are the material slots (or uv maps) that we care about on a figure. We use these slot identifiers specifically for alpha injection in 1.5 so that we can produce 2 separate alpha injection maps (one for head and one for body) 81 | /// 82 | public enum MATERIAL_SLOT 83 | { 84 | [Description("This is the uv map for the head of a figure")] 85 | HEAD, 86 | [Description("This is the uv map for the body of a figure")] 87 | BODY, 88 | [Description("This is the uv map for the eyes and lash of a figure")] 89 | EYEANDLASH, 90 | [Description("This is a uv map for an unknown region, we can ignore it")] 91 | UNKNOWN, 92 | } 93 | 94 | /// 95 | /// Enum used by the CharacterManager to determine how frequently 96 | /// the bounding box of a CostumeItem is recalculated. 97 | /// 98 | public enum COSTUME_BOUNDS_UPDATE_FREQUENCY { 99 | [Description("Automatically recalculate bounds of a mesh when attached to the figure")] 100 | ON_ATTACH, 101 | [Description("Automatically recalcualte bounds of a mesh whenever the figure is morphed")] 102 | ON_MORPH, 103 | [Description("Never recalculate mesh boundaries")] 104 | NEVER 105 | } 106 | 107 | } 108 | 109 | 110 | 111 | public static class EnumHelper 112 | { 113 | 114 | /* 115 | /// 116 | /// Retrieve the description on the enum, e.g. 117 | /// [Description("Bright Pink")] 118 | /// BrightPink = 2, 119 | /// Then when you pass in the enum, it will retrieve the description 120 | /// 121 | /// The Enumeration 122 | /// A string representing the friendly name 123 | public static string GetDescription (Enum en) 124 | { 125 | Type type = en.GetType (); 126 | MemberInfo[] memInfo = type.GetMember (en.ToString ()); 127 | 128 | if (memInfo != null && memInfo.Length > 0) { 129 | object[] attrs = memInfo [0].GetCustomAttributes (typeof(DescriptionAttribute), false); 130 | if (attrs != null && attrs.Length > 0) 131 | return ((DescriptionAttribute)attrs [0]).Description; 132 | } 133 | return en.ToString (); 134 | } 135 | */ 136 | 137 | //we cast string to enum of type by the grace of stack overflow : http://stackoverflow.com/questions/13970257/casting-string-to-enum 138 | public static T ParseEnum(string value) 139 | { 140 | //we should always have "unkown" be the first value for an enum so we can add a default here, and use a simplified default chekck 141 | //rather than a potential red error, weird null, undefined, etc 142 | return (T)Enum.Parse(typeof(T), value, ignoreCase: true); 143 | } 144 | 145 | } 146 | -------------------------------------------------------------------------------- /MCS_Core/ContentLibrary/ContentLibrary.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using MCS.FOUNDATIONS; 5 | using System.Linq; 6 | using MCS; 7 | using MCS.Item; 8 | using M3D_DLL; 9 | 10 | using MCS.Utility.Schematic; 11 | using System.IO; 12 | 13 | namespace MCS.CONTENTLIBRARY 14 | { 15 | public class ContentLibrary : MonoBehaviour 16 | { 17 | private ContentLibrarySO so; 18 | 19 | private MCSResourceManager ResourceManager(){ 20 | return GetComponent (); 21 | } 22 | 23 | public ContentLibrarySO GetContentLibrary(){ 24 | if (so == null) { 25 | so = (ContentLibrarySO)Resources.Load ("ContentLibrarySO"); 26 | } 27 | return so; 28 | } 29 | 30 | //pass in an id and get a coreMeshData in return 31 | public AssetSchematic GetItemData(string id){ 32 | AssetSchematic result = GetContentLibrary ().AssetSchematicList.Where(x => x.origin_and_description.mcs_id == id).SingleOrDefault (); 33 | return result; 34 | } 35 | 36 | /// 37 | /// Loads the game object. It looks first in the object cache, then in the resources folder on disk, 38 | /// then in the unity disk cache, and finally it will stream it if the url is present. 39 | /// 40 | /// The GameObject. 41 | /// Identifier. 42 | public MCSObjectLoader LoadMCSGameObject(string id){ 43 | return ResourceManager ().LoadAnyType (GetItemData (id)); 44 | } 45 | 46 | public MCSObjectLoader LoadGameObjectFromUrl(string id){ 47 | return ResourceManager ().LoadFromUrl (GetItemData (id)); 48 | } 49 | 50 | public GameObject LoadGameObjectFromResources(string id){ 51 | return ResourceManager ().LoadPrefabFromResources (GetItemData (id)); 52 | } 53 | 54 | public GameObject LoadGameObjectFromObjectCache(string id){ 55 | return (GameObject )ResourceManager ().GetObjectCache () [id]; 56 | } 57 | 58 | public AssetSchematic[] GetMyCompatibilities(string Id){ 59 | List schematics = new List (); 60 | foreach (string id in GetItemData(Id).version_and_control.compatibilities) { 61 | schematics.Add (GetItemData (id)); 62 | } 63 | return schematics.ToArray (); 64 | } 65 | 66 | //Not really sure what to name this... :( -Ben 67 | public AssetSchematic[] GetCompatibilitiesWithMeInIt(string Id){ 68 | return GetContentLibrary ().AssetSchematicList.Where(x => x.version_and_control.compatibilities.Contains (Id)).ToArray(); 69 | } 70 | 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /MCS_Core/ContentLibrary/ContentLibrarySO.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections.Generic; 3 | using MCS.FOUNDATIONS; 4 | using System.Linq; 5 | using MCS.Item; 6 | 7 | using MCS.Utility.Schematic; 8 | using MCS.Utility.Schematic.Enumeration; 9 | 10 | namespace MCS.CONTENTLIBRARY 11 | { 12 | public class ContentLibrarySO : ScriptableObject 13 | { 14 | public List AssetSchematicList; 15 | 16 | public Dictionary importerDependencies = new Dictionary(); 17 | public HashSet importerSeenPaths = new HashSet(); 18 | 19 | public bool refreshOnComplete = false; 20 | 21 | public void ClearDependencies() 22 | { 23 | importerDependencies.Clear(); 24 | } 25 | 26 | public void UpsertItem(AssetSchematic data) 27 | { 28 | if (AssetSchematicList == null) { 29 | AssetSchematicList = new List (); 30 | } 31 | 32 | if (AssetSchematicList.Select (x => x.origin_and_description.mcs_id == data.origin_and_description.mcs_id) == null) { 33 | //does not exist 34 | AssetSchematicList.Add (data); 35 | 36 | } else { 37 | //exists already 38 | AssetSchematicList.RemoveAll(x => x.origin_and_description.mcs_id == data.origin_and_description.mcs_id); 39 | AssetSchematicList.Add (data); 40 | } 41 | 42 | } 43 | 44 | public void DeleteItem(AssetSchematic data) 45 | { 46 | AssetSchematicList.RemoveAll(x => x.origin_and_description.mcs_id == data.origin_and_description.mcs_id); 47 | } 48 | 49 | public void DeleteAll() 50 | { 51 | if (AssetSchematicList != null) { 52 | AssetSchematicList.Clear (); 53 | } 54 | 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /MCS_Core/ContentLibrary/MCSObjectLoader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace M3D_DLL 5 | { 6 | public class MCSObjectLoader 7 | { 8 | public float progress; 9 | 10 | public void Complete(object obj, float timeToLoad){ 11 | MCSGameObjectEventAgs args = new MCSGameObjectEventAgs (); 12 | args.MCSObject = obj; 13 | args.TimeToLoadInMilliseconds = timeToLoad; 14 | DownloadComplete (args); 15 | } 16 | 17 | protected virtual void DownloadComplete(MCSGameObjectEventAgs e) 18 | { 19 | EventHandler handler = OnDownloadComplete; 20 | if (handler != null) { 21 | handler (this, e); 22 | } 23 | } 24 | 25 | public event EventHandler OnDownloadComplete; 26 | } 27 | 28 | public class MCSGameObjectEventAgs : EventArgs 29 | { 30 | public object MCSObject { get; set; } 31 | public float TimeToLoadInMilliseconds { get; set; } 32 | } 33 | 34 | } 35 | 36 | -------------------------------------------------------------------------------- /MCS_Core/ContentLibrary/MonDeserializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MCS.FOUNDATIONS; 3 | using UnityEngine; 4 | using System.IO; 5 | using MCS.Item; 6 | 7 | using MCS.Utility.Schematic; 8 | 9 | namespace M3D_DLL 10 | { 11 | public class MonDeserializer 12 | { 13 | 14 | /// 15 | /// Deserializes the mon file. Path needs to be within the assets folder 16 | /// 17 | /// The mon file. 18 | /// Path. 19 | public AssetSchematic[] DeserializeMonFile(string path){ 20 | 21 | string revisedPath = path.Replace ("Assets", ""); 22 | 23 | string result = ""; 24 | 25 | try 26 | { 27 | string streamPath = Application.dataPath + revisedPath; 28 | using (FileStream fs = new FileStream(streamPath,FileMode.Open)) 29 | { 30 | using (StreamReader sr = new StreamReader(fs)) 31 | { 32 | string line; 33 | 34 | while ((line = sr.ReadLine()) != null) 35 | { 36 | result += line; 37 | } 38 | } 39 | } 40 | } 41 | catch(Exception e) 42 | { 43 | Debug.LogError("Caught exception while processing mon file: " + path); 44 | Debug.LogException(e); 45 | } 46 | 47 | AssetSchematic[] schematics = null; 48 | if (result != null) { 49 | 50 | //try a multi one first 51 | try 52 | { 53 | schematics = AssetSchematic.CreateArrayFromJSON(result); 54 | if (schematics != null && schematics.Length <= 0) 55 | { 56 | schematics = null; 57 | } 58 | } catch(Exception e) 59 | { 60 | Debug.Log("Exception caught while processing schematic."); 61 | Debug.LogException(e); 62 | } 63 | 64 | 65 | if (schematics == null) 66 | { 67 | //try a single one 68 | try 69 | { 70 | AssetSchematic schematic = AssetSchematic.CreateFromJSON(result); 71 | schematics = new AssetSchematic[1]; 72 | schematics[0] = schematic; 73 | } 74 | catch (Exception e) 75 | { 76 | UnityEngine.Debug.LogError("Unable to parse mon file: " + path); 77 | UnityEngine.Debug.LogException(e); 78 | } 79 | } 80 | } 81 | return schematics; 82 | } 83 | } 84 | } 85 | 86 | -------------------------------------------------------------------------------- /MCS_Core/ContentLibrary/RuntimeTextureLoader.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class RuntimeTextureLoader 5 | { 6 | public Texture2D LoadFromByteArray(byte[] textureByteArray){ 7 | Texture2D tex = new Texture2D(2, 2); 8 | tex.LoadImage(textureByteArray); 9 | return tex; 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /MCS_Core/CoreServices/CSBoneService/BoneUtility.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Mono Runtime Version: 4.0.30319.1 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | // ------------------------------------------------------------------------------ 10 | using System; 11 | using System.Collections; 12 | using System.Collections.Generic; 13 | using UnityEngine; 14 | using System.Text.RegularExpressions; 15 | 16 | using MCS.UTILITIES.EXTENSIONS; 17 | using MCS.FOUNDATIONS; 18 | using MCS.CONSTANTS; 19 | using MCS.COSTUMING; 20 | 21 | namespace MCS.CORESERVICES 22 | { 23 | internal class BoneUtility 24 | { 25 | 26 | //white space then digit not preceeded by a whitespace (clean will convert these matched to "") 27 | //private static Regex _boneNameStripper = new Regex(@"(\s(?<=\s)\d+)?",RegexOptions.Compiled); 28 | private static Regex _boneNameStripper = new Regex(@"(\s(?<=\s)\d+)?"); 29 | private static string replacement = ""; 30 | 31 | //optimizes gc so we don't need to use so many regex replacements and string creation 32 | private static Dictionary _boneRemapCache = new Dictionary(); 33 | 34 | /// 35 | /// Remaps the bone structure from a given Transform, returning a new array of bones. 36 | /// 37 | /// An array of bone Transforms 38 | /// Reference geometry bones. 39 | /// Destination bones. 40 | public static Transform[] RemapBones (Transform[] reference_geometry_bones, Transform reference_root_bone, BoneUtility.BoneMap destination_bones, Transform destination_root_bone) 41 | { 42 | for(int i = 0; i < reference_geometry_bones.Length; i++) { 43 | BoneUtility.cleanAllBoneNames(reference_geometry_bones[i]); 44 | } 45 | 46 | var new_bones = new Transform[reference_geometry_bones.Length]; 47 | for (var index = 0; index < reference_geometry_bones.Length; index++) { 48 | new_bones[index] = DictionaryExtensions.Find (destination_bones, reference_geometry_bones[index].name); 49 | } 50 | 51 | return new_bones; 52 | } 53 | 54 | 55 | 56 | /// 57 | /// Cleans up all bone names recursively in children of the given Transform, using the regular expression provided. 58 | /// 59 | /// Bone. 60 | /// The regular expression to match or prelace 61 | public static void cleanAllBoneNames (Transform bone) 62 | { 63 | //do nothing, there is no space 64 | int pos = bone.name.IndexOf(" "); 65 | if(pos < 0) 66 | { 67 | return; 68 | } 69 | 70 | string replacementName; 71 | 72 | if(_boneRemapCache.TryGetValue(bone.name,out replacementName)){ 73 | bone.name = replacementName; 74 | return; 75 | } 76 | 77 | replacementName = _boneNameStripper.Replace (bone.name, replacement); 78 | _boneRemapCache[bone.name] = replacementName; 79 | bone.name = replacementName; 80 | } 81 | 82 | 83 | 84 | /// 85 | /// Return a string array of all bone names in a given boneMap 86 | /// 87 | /// The array of bone names. 88 | /// Bone map. 89 | public static string[] getAllBonesNames (BoneUtility.BoneMap bone_map) 90 | { 91 | string[] result = new string[bone_map.Keys.Count]; 92 | bone_map.Keys.CopyTo (result, 0); 93 | 94 | return result; 95 | } 96 | 97 | 98 | 99 | /// 100 | /// The BoneMap class of type Dictionary 101 | /// 102 | public class BoneMap : Dictionary 103 | { 104 | /// 105 | /// Initializes a new instance of the class given a Transform 106 | /// 107 | /// Transform. 108 | public BoneMap (Transform transform) 109 | { 110 | Traverse (transform); 111 | } 112 | 113 | 114 | 115 | /// 116 | /// Internal method to traverse a transform and it's children, looking for bones. 117 | /// 118 | /// Transform. 119 | private void Traverse (Transform transform) 120 | { 121 | //short circuit if we already have this entry 122 | if (ContainsKey(transform.name)) 123 | { 124 | UnityEngine.Debug.LogWarning("Duplicate bone map found: " + transform.name + ", please report this to customer service"); 125 | return; 126 | } 127 | Add (transform.name, transform); 128 | // Debug.Log(transform.name+":"+transform.name.Length); 129 | foreach (Transform child in transform) { 130 | //don't traverse if we think this is an "item" 131 | GameObject cGO = child.gameObject; 132 | if ( 133 | cGO == null 134 | || cGO.GetComponent() != null 135 | || cGO.GetComponent() != null 136 | || cGO.GetComponent() != null 137 | ){ 138 | continue; 139 | } 140 | Traverse (child); 141 | } 142 | } 143 | 144 | } 145 | 146 | 147 | 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /MCS_Core/CoreServices/CSBoneService/GeometryTransferUtility.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Mono Runtime Version: 4.0.30319.1 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | // ------------------------------------------------------------------------------ 10 | using System; 11 | using System.Collections; 12 | using System.Collections.Generic; 13 | using UnityEngine; 14 | 15 | using MCS.FOUNDATIONS; 16 | using MCS.CONSTANTS; 17 | using MCS.COSTUMING; 18 | 19 | namespace MCS.CORESERVICES 20 | { 21 | internal static class GeometryTransferUtility 22 | { 23 | /// 24 | /// Attaches a clone of the costume item to given CIbody figure. 25 | /// Send the GameObject of a costumeItem here, and we'll clone it, bind it and return the result 26 | /// 27 | /// The cloned GameObject of the costume_item 28 | /// Costume_item. 29 | /// Figure. 30 | public static GameObject CloneAndAttachCostumeItemToFigure (GameObject costume_item, BoneUtility.BoneMap figure_bone_map, CIbody figure, Transform root_bone) 31 | { 32 | // instatiate copy 33 | GameObject clone = GameObject.Instantiate (costume_item); 34 | clone.name = costume_item.name; 35 | 36 | // use the basic Attachment method 37 | GeometryTransferUtility.AttachCostumeItemToFigure (clone, figure_bone_map, figure, root_bone); 38 | 39 | // return the cloned costume_item GameObject 40 | return clone; 41 | } 42 | 43 | 44 | 45 | /// 46 | /// Attachs the costume_item to the given CIbody figure. 47 | /// 48 | /// The GameObject costume_item 49 | /// Costume item. 50 | /// Figure bone map. 51 | /// Figure. 52 | /// Root bone. 53 | /// Unneccesary return of parameter GameObject as both are the same GameObject 54 | public static GameObject AttachCostumeItemToFigure(GameObject costume_item, BoneUtility.BoneMap figure_bone_map, CIbody figure, Transform root_bone) 55 | { 56 | // add to figure 57 | costume_item.transform.parent = figure.transform; 58 | 59 | // does not need "costume_item = " as BindGeometryToTransform alters the costume_item GameObject anyway 60 | costume_item = BindGeometryToTransform (costume_item, figure.transform); 61 | 62 | // need figure bones for targeting 63 | // BoneMap body_bones = new BoneMap(transform); 64 | 65 | // go through each coremesh and rebind bones n what not 66 | CoreMesh[] meshes = costume_item.GetComponentsInChildren (true); 67 | foreach (CoreMesh mesh in meshes) { 68 | if (mesh.meshType == MESH_TYPE.PROP) 69 | { 70 | continue; 71 | } 72 | 73 | /* 74 | if(mesh.skinnedMeshRenderer.rootBone.name != "hip") 75 | { 76 | Transform[] bones = mesh.skinnedMeshRenderer.bones; 77 | foreach(Transform bone in bones) 78 | { 79 | if(bone.name == "hip") 80 | { 81 | UnityEngine.Debug.Log("Re-assigned hip bone as root"); 82 | mesh.skinnedMeshRenderer.rootBone = bone; 83 | break; 84 | } 85 | } 86 | } 87 | */ 88 | 89 | mesh.skinnedMeshRenderer.bones = BoneUtility.RemapBones (mesh.skinnedMeshRenderer.bones, mesh.skinnedMeshRenderer.rootBone, figure_bone_map, root_bone); 90 | //UnityEngine.Debug.Log("Remapped: " + mesh.name + " bones: " + mesh.skinnedMeshRenderer.bones.Length + " root: " + mesh.skinnedMeshRenderer.rootBone.name); 91 | mesh.skinnedMeshRenderer.rootBone = root_bone; 92 | } 93 | 94 | return costume_item; 95 | } 96 | 97 | 98 | 99 | /// 100 | /// Binds the reference Geometry to a given Transform, matching position, rotation, and scale. 101 | /// 102 | /// The reference Geometry GameObject 103 | /// Reference geometry. 104 | /// Destination transform. 105 | /// Unneccesary return of parameter GameObject as both are the same GameObject 106 | public static GameObject BindGeometryToTransform (GameObject referenceGeometry, Transform destination_transform) 107 | { 108 | referenceGeometry.transform.parent = destination_transform; 109 | referenceGeometry.transform.localPosition = referenceGeometry.transform.localPosition; 110 | referenceGeometry.transform.localRotation = referenceGeometry.transform.localRotation; 111 | referenceGeometry.transform.localScale = referenceGeometry.transform.localScale; 112 | return referenceGeometry; 113 | } 114 | 115 | 116 | 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /MCS_Core/CoreServices/CSInjectionMask.cs: -------------------------------------------------------------------------------- 1 | //using UnityEngine; 2 | //using System.Collections; 3 | // 4 | //namespace MCS.CORESERVICES 5 | //{ 6 | // [HideInInspector] 7 | // internal class CSInjectionMask : MonoBehaviour 8 | // { 9 | // public Texture2D injection_map; 10 | // public CSAlphaInjection injection_manager; 11 | // public bool has_registered = false; 12 | // private bool isQuitting = false; 13 | // 14 | // IEnumerator fetchAlphaInjector () 15 | // { 16 | // yield return new WaitForSeconds (0.01f); 17 | // injection_manager = transform.root.gameObject.GetComponentInChildren (); 18 | // if (injection_manager == null) 19 | // BindToFigure (); 20 | // else 21 | // registerWithAlphaInjector (); 22 | // } 23 | // 24 | // void registerWithAlphaInjector () 25 | // { 26 | // injection_manager.AddAndActivateMask (injection_map); 27 | // } 28 | // 29 | // //if the clothing, or you just added it to a figure, you can call this to get it to inject alphas n what not. 30 | // public void BindToFigure () 31 | // { 32 | // StartCoroutine (fetchAlphaInjector ()); 33 | // } 34 | // 35 | // void OnEnable () 36 | // { 37 | // if (injection_manager == null) 38 | // BindToFigure (); 39 | // else if (has_registered == false) 40 | // registerWithAlphaInjector (); 41 | // } 42 | // 43 | // void OnApplicationQuit () 44 | // { 45 | // isQuitting = true; 46 | // } 47 | // 48 | // void OnDisable () 49 | // { 50 | // if (injection_manager != null && !isQuitting) 51 | // injection_manager.RemoveAndDeactivateMask (injection_map); 52 | // } 53 | // } 54 | //} 55 | // 56 | -------------------------------------------------------------------------------- /MCS_Core/Costuming/CIbody.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using MCS.CONSTANTS; 5 | using MCS.FOUNDATIONS; 6 | 7 | namespace MCS.COSTUMING 8 | { 9 | /// 10 | /// The CIbody class contains information on an idividual body item. 11 | /// Inheriting from CostumeItem, which in turn is a MonoBehaviour; making this class a Component class. 12 | /// 13 | public class CIbody : CostumeItem 14 | { 15 | /// 16 | /// The backup texture. 17 | /// 18 | public Texture2D backupTexture; 19 | 20 | 21 | 22 | /// 23 | /// Adds a given CoreMesh reference to the interal LOD list. 24 | /// 25 | /// The CoreMesh reference to add. 26 | override public void AddCoreMeshToLODlist (CoreMesh cm) 27 | { 28 | if (backupTexture == null) 29 | backupTexture = cm.skinnedMeshRenderer.sharedMaterial.mainTexture as Texture2D; 30 | base.AddCoreMeshToLODlist (cm); 31 | } 32 | 33 | /// 34 | /// Returns the Material in the specified MATERIAL_SLOT 35 | /// 36 | public Material GetActiveMaterialInSlot(MATERIAL_SLOT querySlot) 37 | { 38 | SkinnedMeshRenderer smr = GetSkinnedMeshRenderer(); 39 | /* 40 | //this causes a problem at runtime where all the mats are wrong 41 | Material[] materials; 42 | if (Application.isPlaying) 43 | { 44 | materials = smr.materials; 45 | } else 46 | { 47 | materials = smr.sharedMaterials; 48 | } 49 | */ 50 | Material[] materials = smr.sharedMaterials; 51 | 52 | for(int i = 0; i < materials.Length; i++) 53 | { 54 | if(materials[i] == null) 55 | { 56 | continue; 57 | } 58 | string name = materials[i].name.ToLower(); 59 | MATERIAL_SLOT slot = MATERIAL_SLOT.UNKNOWN; 60 | 61 | if (name.Contains("head")) 62 | { 63 | slot = MATERIAL_SLOT.HEAD; 64 | } else if (name.Contains("body")) 65 | { 66 | slot = MATERIAL_SLOT.BODY; 67 | } else if (name.Contains("genesis2")) 68 | { 69 | slot = MATERIAL_SLOT.BODY; 70 | } else if (name.Contains("eyeandlash")){ 71 | slot = MATERIAL_SLOT.EYEANDLASH; 72 | } 73 | 74 | if (querySlot.Equals(slot)) 75 | { 76 | return materials[i]; 77 | } 78 | } 79 | 80 | return null; 81 | } 82 | 83 | 84 | 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /MCS_Core/Costuming/CIclothing.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using MCS.CONSTANTS; 6 | using MCS.FOUNDATIONS; 7 | 8 | namespace MCS.COSTUMING 9 | { 10 | /// 11 | /// 12 | /// The CIclothing class contains information on an idividual clothing item. 13 | /// Inheriting from CostumeItem, which in turn is a MonoBehaviour; making this class a Component class. 14 | /// 15 | /// 16 | /// Use CharacterManager GetClothingByID to get a reference to a specific CIClothing attached to a figure. 17 | /// Use CharacterManager GetVisibleClothing to get a List that contains all visible hair on the figure. 18 | /// 19 | /// 20 | /// The DLL takes care of attaching this MonoBehaviour as a component to clothing items that are attached to 21 | /// an MCS Figure either in Editor or through the API via the CharacterManager. 22 | /// 23 | /// For attaching clothing at runtime see and 24 | /// 25 | [Serializable] 26 | public class CIclothing : CostumeItem, ISerializationCallbackReceiver 27 | { 28 | 29 | 30 | /// 31 | /// The alpha mask texture for this clothing item. 32 | /// 33 | [Obsolete("This property is deprecated and you should now use alphaMasks, this is only here for pre 1.5 assets")] 34 | public Texture2D alphaMask; 35 | 36 | /// 37 | /// The alpha mask texture (injection mask) for the head, this will frequently be null as many clothing items do not need to affect any part of the head 38 | /// 39 | public Dictionary alphaMasks = new Dictionary(); 40 | 41 | [SerializeField] 42 | private List _alphaMasksKeys = new List(); 43 | [SerializeField] 44 | private List _alphaMasksVals = new List(); 45 | 46 | 47 | 48 | #region serialization helpers 49 | //pack anything up for serialization if we need 50 | public void OnBeforeSerialize() 51 | { 52 | _alphaMasksKeys.Clear(); 53 | _alphaMasksVals.Clear(); 54 | foreach (MATERIAL_SLOT slot in alphaMasks.Keys) 55 | { 56 | Texture2D value = alphaMasks[slot]; 57 | _alphaMasksKeys.Add(slot); 58 | _alphaMasksVals.Add(value); 59 | } 60 | } 61 | 62 | //regenerate all the fields we couldn't deserialize automatically 63 | public void OnAfterDeserialize() 64 | { 65 | alphaMasks.Clear(); 66 | for (int i = 0; i < _alphaMasksKeys.Count;i++) 67 | { 68 | MATERIAL_SLOT slot = _alphaMasksKeys[i]; 69 | Texture2D tex = _alphaMasksVals[i]; 70 | alphaMasks[slot] = tex; 71 | } 72 | } 73 | #endregion 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /MCS_Core/Costuming/CIprop.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using MCS.CONSTANTS; 5 | using MCS.FOUNDATIONS; 6 | 7 | namespace MCS.COSTUMING 8 | { 9 | /// 10 | /// 11 | /// The CIprop class contains information on an idividual prop. 12 | /// Inheriting from CostumeItem, which in turn is a MonoBehaviour; making this class a Component class. 13 | /// 14 | /// 15 | /// Use CharacterManager GetLoadedPropByName to get a reference to a specific CIProp attached to a figure. 16 | /// Use CharacterManager GetAllLoadedProps or GetAllAttachedProps to get a List that contains all loaded or all attached props on the figure. 17 | /// 18 | /// 19 | /// The DLL takes care of attaching this MonoBehaviour as a component to hairs that are attached to 20 | /// an MCS Figure either in Editor or through the API via the CharacterManager. 21 | /// 22 | /// 23 | /// GameObjects with a CIProp component that are added to an MCS Figure through the CharacterManager will not be visible until they are added to 24 | /// a CIAttachementPoint on the figure. 25 | /// 26 | /// For attaching hair at runtime see 27 | /// 28 | [ExecuteInEditMode] 29 | public class CIprop : CostumeItem 30 | { 31 | /// 32 | /// the initial position for this prop. 33 | /// 34 | public Vector3 basePosition; 35 | 36 | 37 | 38 | /// 39 | /// The initial rotation for this prop. 40 | /// 41 | public Vector3 baseRotation; 42 | 43 | 44 | 45 | /// 46 | /// Overridden MonoBehaviour Awake event 47 | /// 48 | public override void Awake () 49 | { 50 | initProp (); 51 | } 52 | 53 | 54 | 55 | /// 56 | /// Overridden MonoBehaviour Start event 57 | /// 58 | public override void Start () 59 | { 60 | initProp (); 61 | } 62 | 63 | 64 | 65 | /// 66 | /// Internal method, called on instance creation and start. 67 | /// 68 | void initProp () 69 | { 70 | // Debug.Log ("INIT PROP"); 71 | if (LODlist == null) 72 | LODlist = new List (); 73 | 74 | if (LODlist.Count <= 0) { 75 | CoreMesh[] meshes = gameObject.GetComponentsInChildren(); 76 | foreach (CoreMesh mesh in meshes) { 77 | AddCoreMeshToLODlist (mesh); 78 | } 79 | } 80 | } 81 | 82 | 83 | 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /MCS_Core/Foundations/ContentPack.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections.Generic; 3 | 4 | using MCS; 5 | using MCS.COSTUMING; 6 | 7 | [System.Serializable] 8 | /// 9 | /// Content Pack definition class. Every ContentPack 10 | /// 11 | /// A ContentPack represents an attachable unit in the MCS Ecosystem. 12 | /// ContentPacks consist of 0 or more GameObjects. These GameObjects will 13 | /// be attached to an MCSFigure when the ContentPack is added to that figure's 14 | /// CharacterManager. In order for the GameObjects to attach correctly they should 15 | /// have a CostumeItem component (CIHair, CIClothing, CIProp) attached. 16 | /// 17 | /// A ContentPack can be added to the CharacterManager of a figure 18 | /// by calling the manager's AddContentPack method. 19 | /// A ContentPack can be removed from the CharacterManager of an MCS 20 | /// Figure by calling the manager's RemoveContentPack method. 21 | /// 22 | public class ContentPack 23 | { 24 | /// 25 | /// The name of the content pack. 26 | /// If this ContentPack is constructed using the 2 argument 27 | /// constructor the name will be set to the name of the 28 | /// root GameObject passed to the constructor. 29 | /// 30 | public string name; 31 | 32 | 33 | 34 | /// 35 | /// The root GameObject for the ContentPack. 36 | /// If this ContentPack is constructed using the 2 argument constructor 37 | /// this will be the root of the GameObject passed to the constructor. 38 | /// 39 | public GameObject RootGameObject; 40 | 41 | 42 | 43 | /// 44 | /// CIclothing array of any clothing items in this content pack. 45 | /// 46 | public CIclothing[] availableClothing; 47 | 48 | 49 | 50 | /// 51 | /// CIhair array of any hair items in this content pack. 52 | /// 53 | public CIhair[] availableHair; 54 | 55 | 56 | 57 | /// 58 | /// CIprop array of any prop items in this content pack. 59 | /// 60 | public CIprop[] availableProps; 61 | 62 | /// 63 | /// All items exist in here 64 | /// 65 | public CostumeItem[] availableItems; 66 | 67 | 68 | 69 | /// 70 | /// Initializes a new, empty instance of the class. 71 | /// 72 | /// This constructor does not initialize public class members and they 73 | /// are left to their default values. 74 | /// These should be initialized prior to access. This can be done with 75 | /// setupWithGameObject 76 | /// 77 | public ContentPack () 78 | { 79 | } 80 | 81 | 82 | 83 | /// 84 | /// Initializes a new instance of the class. 85 | /// 86 | /// The ContentPack is initialized with the provided game object. 87 | /// See 88 | /// 89 | /// Object. 90 | public ContentPack (GameObject obj, bool clone = false) 91 | { 92 | setupWithGameObject (obj,clone); 93 | } 94 | 95 | 96 | 97 | /// 98 | /// Attempts to initializes this ContentPack with data gleamed from the given root GameObject. 99 | /// 100 | /// The root GameObject must have at least one CostumeItem component in it's children otherwise 101 | /// initializing the ContentPack will fail with an Exception. 102 | /// 103 | /// If successful references to the CostumeItems in the GameObject will be stored in the appropriate 104 | /// public Arrays of this ContentPack. 105 | /// 106 | /// 107 | /// Root GameObject to be used for initializing this ContentPack. Should have 108 | /// at least one child with a CostumeItem component. 109 | /// 110 | /// 111 | /// Optional bool. If true the root obj will be cloned and the clone will be used to initialize this ContentPack. 112 | /// 113 | public void setupWithGameObject (GameObject obj,bool clone=false) 114 | { 115 | if (clone) 116 | { 117 | GameObject cloneObj = GameObject.Instantiate(obj); 118 | cloneObj.name = obj.name; 119 | obj = cloneObj; 120 | } 121 | 122 | name = obj.name; 123 | RootGameObject = obj; 124 | availableClothing = obj.GetComponentsInChildren (true); 125 | availableHair = obj.GetComponentsInChildren (true); 126 | availableProps = obj.GetComponentsInChildren (true); 127 | availableItems = obj.GetComponentsInChildren(true); 128 | 129 | if( 130 | (availableClothing == null || availableClothing.Length <=0) 131 | && (availableHair == null || availableHair.Length <= 0) 132 | && (availableProps == null || availableProps.Length <= 0) 133 | ) 134 | { 135 | UnityEngine.Debug.LogError("Could not locate any clothing, hair, or props in content pack, aborting object: " + obj.name); 136 | throw new System.Exception("Invalid content pack"); 137 | } 138 | } 139 | 140 | 141 | 142 | } 143 | -------------------------------------------------------------------------------- /MCS_Core/Foundations/CoreMetaData.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System; 4 | using System.Collections.Generic; 5 | using MCS.CONSTANTS; 6 | using MCS.UTILITIES; 7 | using MCS.Utility.Schematic; 8 | using MCS.Utility.Schematic.Enumeration; 9 | 10 | namespace MCS.FOUNDATIONS 11 | { 12 | //should only go at the ITEM level? 13 | public class CoreMetaData : MonoBehaviour 14 | { 15 | //essential functional data 16 | public string item_id;//gonna change the damn reference again. shame. shame. 17 | public string collection_id; 18 | public HierarchyRank rank;//unneeded if this is always at the item level 19 | public PrimaryFunction function; 20 | public ItemSchematic schematic; 21 | public ItemCompatibilities compatibilities; 22 | //version info 23 | public float collection_version; 24 | public float item_version; 25 | public float mcs_version; 26 | //changeable 27 | public string item_name;//we could use existing "name" or override, but unity assigns this for its referencing, so lets avoid it 28 | public string collection_name; 29 | 30 | 31 | //during the import process unity gives us these arrays per gameobject - they are our metatadata from fbx 32 | public void PopulateValuesFromImportArrays(string[] names, object[] values){ 33 | //sweet. got the good stuff 34 | for (int i = 0; i < names.Length; i++) { 35 | 36 | //our placeholder values - make sure you dont use a previous parsed bad value!!! 37 | string name = names [i]; 38 | string string_value; 39 | float float_value; 40 | 41 | switch(name){ 42 | 43 | case "hierarchy_rank": 44 | string_value = values [i].ToString (); 45 | this.rank = MCS.Utilities.EnumHelper.ParseEnum (string_value); 46 | break; 47 | case "primary_function": 48 | string_value = values [i].ToString (); 49 | this.function = MCS.Utilities.EnumHelper.ParseEnum(string_value); 50 | break; 51 | case "collection_version": 52 | float_value = float.Parse (values [i].ToString ()); 53 | this.collection_version = float_value; 54 | break; 55 | case "item_version": 56 | float_value = float.Parse (values [i].ToString ()); 57 | this.item_version = float_value; 58 | break; 59 | case "mcs_version": 60 | float_value = float.Parse (values [i].ToString ()); 61 | this.mcs_version = float_value; 62 | break; 63 | case "item_id": 64 | string_value = values [i].ToString (); 65 | this.item_id = string_value; 66 | break; 67 | case "collection_id": 68 | string_value = values [i].ToString (); 69 | this.collection_id = string_value; 70 | break; 71 | case "item_name": 72 | string_value = values [i].ToString (); 73 | this.item_name = string_value; 74 | break; 75 | case "collection_name": 76 | string_value = values [i].ToString (); 77 | this.collection_name = string_value; 78 | break; 79 | case "geometries": 80 | string_value = values [i].ToString ();//json bundle 81 | this.schematic = ItemSchematic.CreateFromJSON (string_value); 82 | break; 83 | case "compatibilities": 84 | string_value = values [i].ToString ();//json bundle 85 | Debug.Log ("FOUND IT: " + string_value); 86 | this.compatibilities = ItemCompatibilities.CreateFromJSON (string_value); 87 | break; 88 | 89 | } 90 | } 91 | 92 | } 93 | } 94 | 95 | //items have optional parts, they can use or not use whatever parts as they wish... does this hold up to the test of time? 96 | [Serializable] 97 | public class ItemSchematic{ 98 | public string[] lods =null;//geometries that we toggle on and off 99 | public string[] active = null;//always active 100 | public string[] cap = null;//cap for hair - we could just use always active 101 | //if we go down this route, we'll eventually have a ton of things, like particles, bullets, 102 | //but... things will be explicit. sorda. 103 | public static ItemSchematic CreateFromJSON(string jsonString) 104 | { 105 | return JsonUtility.FromJson(jsonString); 106 | } 107 | } 108 | [Serializable] 109 | public class ItemCompatibilities{ 110 | public string[] figures = null;//geometries that we toggle on and off 111 | public static ItemCompatibilities CreateFromJSON(string jsonString) 112 | { 113 | return JsonUtility.FromJson(jsonString); 114 | } 115 | } 116 | //public enum HierarchyRank{ 117 | // unkown, 118 | // collection, 119 | // item, 120 | // geometry, 121 | // skeleton 122 | //} 123 | //public enum PrimaryFunction{ 124 | // unkown, 125 | // figure, 126 | // hair, 127 | // prop, 128 | // soft_wearable, 129 | // rigid_wearable, 130 | // appendage 131 | //} 132 | 133 | 134 | } 135 | 136 | -------------------------------------------------------------------------------- /MCS_Core/Foundations/MorphGroup.cs: -------------------------------------------------------------------------------- 1 | using MCS.FOUNDATIONS; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace MCS.FOUNDATIONS 8 | { 9 | /// 10 | /// A group of morphs tracked by their LocalName. 11 | /// Used to organize Morphs in the editor script 12 | /// into convenient groups. 13 | /// 14 | public class MorphGroup 15 | { 16 | /// 17 | /// A sub that is a child of this MorphGroup. 18 | /// 19 | public Dictionary SubGroups; 20 | /// 21 | /// List of Morph Names that are direct children of this MorphGroup 22 | /// 23 | public Dictionary Morphs; 24 | /// 25 | /// True if this MorphGroup is currently open in the Unity Editor. 26 | /// 27 | public bool IsOpenInEditor; 28 | /// 29 | /// Key to key off of 30 | /// 31 | public string Key; 32 | 33 | public MorphGroup(string key) 34 | { 35 | SubGroups = new Dictionary(); 36 | Morphs = new Dictionary(); 37 | Key = key; 38 | IsOpenInEditor = false; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /MCS_Core/Foundations/MorphGroupService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | using UnityEngine; 7 | 8 | namespace MCS.FOUNDATIONS 9 | { 10 | /// 11 | /// In charge of handling s for the editor script. 12 | /// 13 | public class MorphGroupService 14 | { 15 | private static Dictionary morphGroups = new Dictionary(); 16 | 17 | public static void GenerateMorphGroupsFromFile(string name) 18 | { 19 | var assetpath = getAssetPath(name); 20 | var filePath = GetFilePath(assetpath); 21 | if (MorphGroupFileExists(assetpath)) 22 | { 23 | morphGroups[name] = new MorphGroup(name); 24 | var fileData = File.ReadAllText(filePath); 25 | var lines = fileData.Split("\n"[0]); 26 | GenerateSubgroupsFromLines(lines, name); 27 | } 28 | } 29 | 30 | public static MorphGroup GetMorphGroups(string name) 31 | { 32 | MorphGroup group = null; 33 | if (!morphGroups.ContainsKey(name)) 34 | { 35 | var assetpath = getAssetPath(name); 36 | GenerateMorphGroupsFromFile(name); 37 | } 38 | group = morphGroups[name]; 39 | return group; 40 | } 41 | 42 | public static bool MorphGroupFileExists(string assetpath) 43 | { 44 | var filePath = GetFilePath(assetpath); 45 | return File.Exists(filePath); 46 | } 47 | 48 | private static string GetFilePath(string assetpath) 49 | { 50 | return assetpath.Substring(0, assetpath.LastIndexOf("/")) + "/MorphGroups.csv"; 51 | } 52 | 53 | private static string getAssetPath(string name) 54 | { 55 | return Application.dataPath + "/MCS/Content/" + name + "/Figure/" + name + "/"; 56 | } 57 | 58 | private static void GenerateSubgroupsFromLines(string[] lines, string gameObjectName) 59 | { 60 | foreach (var line in lines) 61 | { 62 | var lineHasMultipleGroups = line.Contains('"'); 63 | if (lineHasMultipleGroups) 64 | { 65 | GenerateMultipleSubgroupsFromLine(line, gameObjectName); 66 | } 67 | else 68 | { 69 | GenerateSubgroupFromLine(line, gameObjectName); 70 | } 71 | } 72 | } 73 | 74 | private static void GenerateSubgroupFromLine(string line, string gameObjectName) 75 | { 76 | var lineData = line.Trim().Split(','); 77 | var key = lineData[0]; 78 | var display = lineData[1]; 79 | var groupHierarchy = lineData[2].Trim().Split('/'); 80 | var group = GetGroup(groupHierarchy, gameObjectName); 81 | group.Morphs[key] = display; 82 | } 83 | 84 | private static void GenerateMultipleSubgroupsFromLine(string line, string gameObjectName) 85 | { 86 | var lineData = line.Trim().Split('"'); 87 | var keyAndDisplay = lineData[0].Split(','); 88 | var key = keyAndDisplay[0]; 89 | var display = keyAndDisplay[1]; 90 | var groups = lineData[1].Split(','); 91 | foreach (var groupName in groups) 92 | { 93 | var groupHierarchy = groupName.Trim().Split('/'); 94 | var group = GetGroup(groupHierarchy, gameObjectName); 95 | group.Morphs[key] = display; 96 | } 97 | } 98 | 99 | private static MorphGroup GetGroup(string[] groupHierarchy, string gameObjectName) 100 | { 101 | var currentGroup = morphGroups[gameObjectName]; 102 | while (groupHierarchy.Length > 0) 103 | { 104 | var groupName = groupHierarchy[0]; 105 | if (!currentGroup.SubGroups.ContainsKey(groupName)) 106 | { 107 | currentGroup.SubGroups[groupName] = new MorphGroup(groupName); 108 | } 109 | currentGroup = currentGroup.SubGroups[groupName]; 110 | groupHierarchy = groupHierarchy.Skip(1).ToArray(); 111 | } 112 | return currentGroup; 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /MCS_Core/Item/MCSClothing.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using MCS.Item; 4 | namespace MCS.Item 5 | { 6 | public class MCSClothing : MCSItem 7 | { 8 | 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /MCS_Core/Item/MCSFigure.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using MCS.Item; 4 | namespace MCS.Item 5 | { 6 | public class MCSFigure : MCSItem 7 | { 8 | 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /MCS_Core/Item/MCSHair.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using MCS.Item; 4 | namespace MCS.Item 5 | { 6 | public class MCSHair : MCSItem 7 | { 8 | 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /MCS_Core/Item/MCSItem.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using MCS; 6 | 7 | using MCS.Utility.Event; 8 | using MCS.Utility.Serialize; 9 | 10 | namespace MCS.Item 11 | { 12 | 13 | public class MCSItem : MonoBehaviour, IlazyUpdate, IlazyLateUpdate, ISerializable 14 | { 15 | 16 | public event AfterLazyUpdate OnAfterLazyUpdate; 17 | public event BeforeLazyUpdate OnBeforeLazyUpdate; 18 | public event BeforeLazyLateUpdate OnBeforeLazyLateUpdate; 19 | public event AfterLazyLateUpdate OnAfterLazyLateUpdate; 20 | 21 | //bool needs_lazy_update = false; 22 | //bool needs_lazy_late_update = false; 23 | 24 | /* 25 | public void Update() 26 | { 27 | if (needs_lazy_update) 28 | { 29 | if (OnBeforeLazyUpdate != null) 30 | OnBeforeLazyUpdate(); 31 | //do some processing 32 | if (OnAfterLazyUpdate != null) 33 | OnAfterLazyUpdate(); 34 | } 35 | Debug.Log("Item getting updated..."); 36 | } 37 | 38 | public void LateUpdate() 39 | { 40 | if (needs_lazy_late_update) 41 | { 42 | if (OnBeforeLazyLateUpdate != null) 43 | OnBeforeLazyLateUpdate(); 44 | //do some processing 45 | if (OnAfterLazyLateUpdate != null) 46 | OnAfterLazyLateUpdate(); 47 | } 48 | 49 | } 50 | */ 51 | public void SerializeStateToJson() 52 | { 53 | 54 | } 55 | 56 | public void DeserializeStateFromJson() 57 | { 58 | 59 | } 60 | 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /MCS_Core/Item/MCSItemModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using MCS.Utility.Schematic; 4 | using MCS.Utility.Schematic.Enumeration; 5 | namespace MCS.Item 6 | { 7 | public class MCSItemModel : MonoBehaviour 8 | { 9 | //our actual schematic, helpers functions for convenience below 10 | public AssetSchematic schematic; 11 | 12 | 13 | //pull out things for easy access here 14 | public string item_id 15 | { 16 | get 17 | { 18 | return this.schematic.origin_and_description.mcs_id; 19 | } 20 | set 21 | { 22 | this.schematic.origin_and_description.mcs_id = value; 23 | } 24 | } 25 | public string item_name 26 | { 27 | get 28 | { 29 | return this.schematic.origin_and_description.name; 30 | } 31 | set 32 | { 33 | this.schematic.origin_and_description.name = value; 34 | } 35 | } 36 | //public float mass 37 | //{ 38 | // get 39 | // { 40 | // return this.schematic.structure_and_physics.mass; 41 | // } 42 | // set 43 | // { 44 | // this.schematic.structure_and_physics.mass = value; 45 | // } 46 | //} 47 | public HierarchyRank hierarchy_rank 48 | { 49 | get 50 | { 51 | return this.schematic.type_and_function.hierarchy_rank; 52 | } 53 | set 54 | { 55 | this.schematic.type_and_function.hierarchy_rank = value; 56 | } 57 | } 58 | public PrimaryFunction primary_function 59 | { 60 | get 61 | { 62 | return this.schematic.type_and_function.primary_function; 63 | } 64 | set 65 | { 66 | this.schematic.type_and_function.primary_function = value; 67 | } 68 | } 69 | 70 | public ItemFunction item_function 71 | { 72 | get 73 | { 74 | return this.schematic.type_and_function.item_function; 75 | } 76 | set 77 | { 78 | this.schematic.type_and_function.item_function = value; 79 | } 80 | } 81 | 82 | // Used in Artist Tools 83 | public void InitializeItem() 84 | { 85 | schematic = new AssetSchematic(); 86 | schematic.InitializeSchematic(); 87 | } 88 | 89 | } 90 | 91 | } 92 | 93 | -------------------------------------------------------------------------------- /MCS_Core/Item/MCSItemSchematic.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace MCS.Item 3 | { 4 | } 5 | 6 | -------------------------------------------------------------------------------- /MCS_Core/Item/MCSMesh.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using MCS.FOUNDATIONS; 6 | using MCS.CONSTANTS; 7 | using MCS.UTILITIES; 8 | 9 | namespace MCS.Item 10 | { 11 | [ExecuteInEditMode] 12 | public class MCSMesh : MonoBehaviour 13 | { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /MCS_Core/Item/MCSProp.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using MCS.Item; 4 | namespace MCS.Item 5 | { 6 | public class MCSProp : MCSItem 7 | { 8 | 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /MCS_Core/Item/MCSProperty.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using UnityEngine; 7 | 8 | namespace MCS.Item 9 | { 10 | 11 | //This gets attached to all interesting fbx nodes if a key "MCS_ID" is found, which will be saved to GUID inside the component 12 | // we don't show it in the inspector by default as this is specific to how artist tools exports fbx nodes 13 | [HideInInspector] 14 | public class MCSProperty : MonoBehaviour 15 | { 16 | public string mcs_id; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /MCS_Core/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle ("M3D_DLL")] 8 | [assembly: AssemblyDescription ("")] 9 | [assembly: AssemblyConfiguration ("")] 10 | [assembly: AssemblyCompany ("")] 11 | [assembly: AssemblyProduct ("")] 12 | [assembly: AssemblyCopyright("MCS")] 13 | [assembly: AssemblyTrademark ("")] 14 | [assembly: AssemblyCulture ("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("1.7.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | -------------------------------------------------------------------------------- /MCS_Core/Utilities/BlendShapes.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System; 4 | using System.Text.RegularExpressions; 5 | 6 | namespace MCS.UTILITIES{ 7 | /// 8 | /// Utility class for formatting BlendShape display names. 9 | /// 10 | public static class BlendShapes { 11 | 12 | /// 13 | /// Converts a DisplayName string to a correctly formatted label. 14 | /// 15 | /// The formatted label string. 16 | /// The DisplayName string to format. 17 | public static string convertBlendshapeIDToLabel (string ID) 18 | { 19 | 20 | string prefix = ID.Substring (0, 3); 21 | 22 | string new_suffix = ""; 23 | switch (prefix) { 24 | 25 | case "CTR": 26 | new_suffix = "(Complete)"; 27 | break; 28 | case "FHM": 29 | new_suffix = "(Head)"; 30 | break; 31 | case "FBM": 32 | new_suffix = "(Body)"; 33 | break; 34 | case "PHM": 35 | new_suffix = "(Head)"; 36 | break; 37 | case "PBM": 38 | new_suffix = "(Body)"; 39 | break; 40 | case "CBM": 41 | new_suffix = "(Complete)"; 42 | break; 43 | case "SCL": 44 | new_suffix = "(Proportion)"; 45 | break; 46 | case "VSM": 47 | new_suffix = "(Phoneme)"; 48 | break; 49 | 50 | } 51 | string label = ID; 52 | if (string.IsNullOrEmpty (new_suffix) == false) 53 | label = ID.Substring (3); 54 | if (ID.StartsWith ("CTRL")) 55 | label = ID.Substring (4); 56 | label = properSpacing (label); 57 | if (ID.StartsWith ("VSM")) 58 | label = VSMformat (label); 59 | //return string.Format("{0} {1}", label, new_suffix); 60 | return string.Format ("{0}", label); 61 | } 62 | 63 | 64 | 65 | /// 66 | /// Internal method to ensure correct spacing of a given string. 67 | /// 68 | /// A correctly spaced string. 69 | /// The string to work with 70 | private static string properSpacing (string instr) 71 | { 72 | var r = new Regex (@" 73 | (?<=[A-Z])(?=[A-Z][a-z]) | 74 | (?<=[^A-Z])(?=[A-Z]) | 75 | (?<=[A-Za-z])(?=[^A-Za-z])", RegexOptions.IgnorePatternWhitespace); 76 | 77 | return r.Replace (instr, " "); 78 | } 79 | 80 | 81 | 82 | /// 83 | /// Internal method to correctly format a VSM label. 84 | /// 85 | /// The formatted string. 86 | /// The string to format. 87 | private static string VSMformat (string unformattedVSM) 88 | { 89 | string retstr = ""; 90 | char tempchr = ' '; 91 | if (unformattedVSM.Length == 1) { 92 | tempchr = unformattedVSM [0]; 93 | retstr = "\"" + tempchr + Char.ToLower (tempchr) + Char.ToLower (tempchr) + "...\""; 94 | } 95 | 96 | if (unformattedVSM.Length > 1) { 97 | retstr += unformattedVSM [0]; 98 | for (int i = 1; i < unformattedVSM.Length; i++) { 99 | tempchr = Char.ToLower (unformattedVSM [i]); 100 | retstr += tempchr; 101 | } 102 | retstr = "\"" + retstr + tempchr + "...\""; 103 | } 104 | return retstr; 105 | } 106 | 107 | 108 | 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /MCS_Core/Utilities/EnumHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MCS.Utilities 4 | { 5 | public static class EnumHelper 6 | { 7 | //we cast string to enum of type by the grace of stack overflow : http://stackoverflow.com/questions/13970257/casting-string-to-enum 8 | public static T ParseEnum(string value) 9 | { 10 | //we should always have "unkown" be the first value for an enum so we can add a default here, and sue a simplified default chekck 11 | //rather than a potential red error, weird null, undefined, etc 12 | return (T)Enum.Parse(typeof(T), value, ignoreCase: true); 13 | } 14 | 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /MCS_Core/Utilities/Extensions/Extensions.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | namespace MCS.UTILITIES.EXTENSIONS 6 | { 7 | /// 8 | /// Dictionary extension class. 9 | /// 10 | public class DictionaryExtensions 11 | { 12 | /// 13 | /// Find method extension for Dictionary class. Returns the TValue if found, or the default for type TValue if not found. 14 | /// 15 | /// A value of type TValue 16 | /// The TKey,TValue Dictionary to inspect. 17 | /// The key to find, of type TKey. 18 | /// The type of TKey. 19 | /// The type f TValue 20 | public static TValue Find(Dictionary source, TKey key) 21 | { 22 | TValue value; 23 | source.TryGetValue(key, out value); 24 | return value; 25 | } 26 | } 27 | 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /MCS_Core/Utilities/KeyValueFloat.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace MCS.UTILITIES 5 | { 6 | /// 7 | /// Simple string and float data pair class, without constructor. 8 | /// 9 | [System.Serializable] 10 | public class KeyValueFloat 11 | { 12 | /// 13 | /// string field key. 14 | /// 15 | public string key; 16 | 17 | /// 18 | /// float field value. 19 | /// 20 | public float value; 21 | } 22 | 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /MCS_Core/Utility/Event/ILazyFixedUpdate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace MCS.Utility.Event 3 | { 4 | public delegate void BeforeLazyFixedUpdate(); 5 | public delegate void AfterLazyFixedUpdate(); 6 | 7 | interface IlazyFixedUpdate 8 | { 9 | event BeforeLazyFixedUpdate OnBeforeLazyFixedUpdate; 10 | event AfterLazyFixedUpdate OnAfterLazyFixedUpdate; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /MCS_Core/Utility/Event/ILazyLateUpdate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace MCS.Utility.Event 3 | { 4 | public delegate void BeforeLazyLateUpdate(); 5 | public delegate void AfterLazyLateUpdate(); 6 | 7 | interface IlazyLateUpdate 8 | { 9 | event BeforeLazyLateUpdate OnBeforeLazyLateUpdate; 10 | event AfterLazyLateUpdate OnAfterLazyLateUpdate; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /MCS_Core/Utility/Event/ILazyUpdate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace MCS.Utility.Event 3 | { 4 | public delegate void BeforeLazyUpdate(); 5 | public delegate void AfterLazyUpdate(); 6 | 7 | interface IlazyUpdate 8 | { 9 | event BeforeLazyUpdate OnBeforeLazyUpdate; 10 | event AfterLazyUpdate OnAfterLazyUpdate; 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /MCS_Core/Utility/MCSResourceConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using MCS; 7 | using MCS_Utilities.MorphExtraction; 8 | using MCS.FOUNDATIONS; 9 | using MCS.SERVICES; 10 | 11 | 12 | namespace MCS.Utility 13 | { 14 | public static class MCSResourceConverter 15 | { 16 | [Obsolete("Please switch to MorphData")] 17 | public static MCS_Utilities.MorphExtraction.Structs.BlendshapeState UncompressedToBlendshapeState(ref byte[] bytes) 18 | { 19 | return StreamingMorphs.ConvertBytesToBlendshapeState(ref bytes); 20 | } 21 | [Obsolete("Please switch to MorphData")] 22 | public static MCS_Utilities.MorphExtraction.Structs.BlendshapeState CompressedToBlendshapeState(ref byte[] bytes) 23 | { 24 | return StreamingMorphs.DecompressAndConvertBytesToBlendshapeState(ref bytes); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /MCS_Core/Utility/Schematic/AssetSchematicUtility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | using UnityEngine; 5 | using MCS.Utility.Schematic.Base; 6 | using MCS.Utility.Schematic.Enumeration; 7 | using MCS.Utility.Schematic.Structure; 8 | 9 | namespace MCS.Utility.Schematic 10 | { 11 | public static class AssetSchematicUtility 12 | { 13 | 14 | public static List GetValidMetadataKeys() 15 | { 16 | List classList = new List 17 | { 18 | typeof(MCS.Utility.Schematic.AssetSchematic), 19 | typeof(MCS.Utility.Schematic.Base.OriginAndDescription), 20 | typeof(MCS.Utility.Schematic.Base.StreamAndPath), 21 | typeof(MCS.Utility.Schematic.Base.StructureAndPhysics), 22 | typeof(MCS.Utility.Schematic.Base.TypeAndFunction), 23 | typeof(MCS.Utility.Schematic.Base.VersionAndControl), 24 | typeof(MCS.Utility.Schematic.Structure.ItemStructure), 25 | typeof(MCS.Utility.Schematic.Structure.MaterialStructure), 26 | typeof(MCS.Utility.Schematic.Structure.MorphStructure) 27 | }; 28 | List MetaDataList = new List(); 29 | BindingFlags bindingFlags = BindingFlags.Public | 30 | BindingFlags.NonPublic | 31 | BindingFlags.Instance | 32 | BindingFlags.Static; 33 | 34 | foreach (System.Type a in classList) 35 | foreach (FieldInfo field in a.GetFields(bindingFlags)) 36 | MetaDataList.Add(field.Name); 37 | 38 | return MetaDataList; 39 | } 40 | 41 | public static Color ConvertColorStringToColor(string raw) 42 | { 43 | if (String.IsNullOrEmpty(raw)) 44 | { 45 | return Color.clear; 46 | } 47 | 48 | string[] tints = raw.Split (','); 49 | float inR = float.Parse(tints[0]); 50 | float inG = float.Parse(tints[1]); 51 | float inB = float.Parse(tints[2]); 52 | float inA = (tints.Length > 3 ? float.Parse(tints[3]) : 255f); //default to fully visible 53 | 54 | float r, g, b, a; 55 | 56 | if(inR <= 1f && inG <= 1f && inB <= 1f) 57 | { 58 | //1,0.8,0.5,0.1 59 | r = inR; 60 | g = inG; 61 | b = inB; 62 | a = (inA >= 255f ? 1f : inA); //clamp it if it's set to 255 63 | } 64 | else 65 | { 66 | //255,200,120,10 67 | r = (inR / 255); 68 | g = (inG / 255); 69 | b = (inB / 255); 70 | a = (inA / 255); 71 | } 72 | 73 | 74 | Color c = new Color (r, g, b, a); 75 | //UnityEngine.Debug.Log("Color: " + c); 76 | return c; 77 | } 78 | } 79 | } 80 | 81 | -------------------------------------------------------------------------------- /MCS_Core/Utility/Schematic/Base/OriginAndDescription.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MCS.Utility.Schematic.Enumeration; 3 | using UnityEngine; 4 | 5 | 6 | namespace MCS.Utility.Schematic.Base 7 | { 8 | [Serializable] 9 | public class OriginAndDescription : ISerializationCallbackReceiver 10 | { 11 | #region Origin 12 | public string mcs_id; 13 | public string name; 14 | public string vendor_id; 15 | public string vendor_name; 16 | public string collection_id; 17 | public string collection_name; 18 | #region Artist Tools Specific. 19 | [NonSerialized] 20 | public Guid mcs_id_guid; 21 | [NonSerialized] 22 | public Guid parent_id_guid; 23 | public string parent_id; 24 | public int child_count; 25 | #endregion 26 | #endregion 27 | #region Description 28 | 29 | [SerializeField] 30 | [HideInInspector] 31 | private string gender_enum; 32 | [ATEditable] 33 | [ATListView(typeof(Gender))] 34 | public Gender gender; 35 | 36 | [SerializeField] 37 | [HideInInspector] 38 | private string category_enum; 39 | [ATEditable] 40 | [ATListView(typeof(Category))] 41 | public Category category; 42 | 43 | [ATEditable] 44 | [ATInputText] 45 | public string[] tags; 46 | [ATEditable] 47 | [ATInputText] 48 | public string description; 49 | #endregion 50 | 51 | #region ISerializationCallbackReceiver implementation 52 | 53 | public void OnBeforeSerialize() 54 | { 55 | if (String.IsNullOrEmpty(mcs_id) && (mcs_id_guid != Guid.Empty)) 56 | { 57 | mcs_id = mcs_id_guid.ToString(); 58 | } 59 | if (String.IsNullOrEmpty(parent_id) && (parent_id_guid != Guid.Empty)) 60 | { 61 | parent_id = parent_id_guid.ToString(); 62 | } 63 | gender_enum = gender.ToString (); 64 | category_enum = category.ToString (); 65 | } 66 | 67 | public void OnAfterDeserialize () 68 | { 69 | if (!String.IsNullOrEmpty(mcs_id)) 70 | mcs_id_guid = new Guid(mcs_id); 71 | if (!String.IsNullOrEmpty(parent_id)) 72 | parent_id_guid = new Guid(parent_id); 73 | 74 | if (gender_enum != null) { 75 | gender = (Gender)Enum.Parse (typeof(Gender), gender_enum); 76 | } 77 | if (category_enum != null) { 78 | category = (Category)Enum.Parse (typeof(Category), category_enum); 79 | } 80 | } 81 | 82 | #endregion 83 | } 84 | } 85 | 86 | -------------------------------------------------------------------------------- /MCS_Core/Utility/Schematic/Base/Path.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MCS.Utility.Schematic.Base 4 | { 5 | public class Path 6 | { 7 | public string root_path; 8 | public string source_path; 9 | public string generated_path; 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /MCS_Core/Utility/Schematic/Base/Physical.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MCS.Utility.Schematic.Enumeration; 3 | namespace MCS.Utility.Schematic.Base 4 | { 5 | public class Physical 6 | { 7 | public float mass; 8 | public float volume; 9 | public float density; 10 | public PhysicalSubstance substance; 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /MCS_Core/Utility/Schematic/Base/Stream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace MCS.Utility.Schematic.Base 3 | { 4 | public class Stream 5 | { 6 | public string image_thumbnail; 7 | public string interactive_thumbnail; 8 | public string url; 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /MCS_Core/Utility/Schematic/Base/StreamAndPath.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace MCS.Utility.Schematic.Base 3 | { 4 | [Serializable] 5 | public class StreamAndPath 6 | { 7 | #region Stream 8 | public string image_thumbnail; 9 | public string interactive_thumbnail; 10 | public string url; 11 | #endregion 12 | #region Path 13 | public string root_path; 14 | public string source_path; 15 | public string generated_path; 16 | #endregion 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /MCS_Core/Utility/Schematic/Base/StructureAndPhysics.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MCS.Utility.Schematic.Structure; 3 | using MCS.Utility.Schematic.Enumeration; 4 | using UnityEngine; 5 | 6 | 7 | namespace MCS.Utility.Schematic.Base 8 | { 9 | [Serializable] 10 | public class StructureAndPhysics : ISerializationCallbackReceiver 11 | { 12 | 13 | public StructureAndPhysics(){ 14 | item_structure = new ItemStructure (); 15 | material_structure = new MaterialStructure (); 16 | morph_structure = new MorphStructure (); 17 | } 18 | 19 | #region Structure 20 | public ItemStructure item_structure; 21 | public MaterialStructure material_structure; 22 | public MorphStructure morph_structure; 23 | #endregion 24 | 25 | #region Physics 26 | //public float mass; 27 | //public float volume; 28 | //[ATEditable] 29 | //[ATInputSlider] 30 | //public float density; 31 | 32 | //[SerializeField] 33 | //[HideInInspector] 34 | //private string substance_enum; 35 | //[ATListView(typeof(PhysicalSubstance))] 36 | //[ATEditable] 37 | //public PhysicalSubstance substance; 38 | #endregion 39 | 40 | #region ISerializationCallbackReceiver implementation 41 | 42 | public void OnBeforeSerialize () 43 | { 44 | //substance_enum = substance.ToString (); 45 | } 46 | 47 | public void OnAfterDeserialize () 48 | { 49 | //if (substance_enum != null) { 50 | // substance = (PhysicalSubstance)Enum.Parse (typeof(PhysicalSubstance), substance_enum); 51 | //} 52 | } 53 | 54 | #endregion 55 | } 56 | } 57 | 58 | -------------------------------------------------------------------------------- /MCS_Core/Utility/Schematic/Base/TypeAndFunction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MCS.Utility.Schematic.Enumeration; 3 | using System.Diagnostics; 4 | using UnityEngine; 5 | 6 | 7 | namespace MCS.Utility.Schematic.Base 8 | { 9 | [Serializable] 10 | public class TypeAndFunction : ISerializationCallbackReceiver 11 | { 12 | #region Type 13 | 14 | [SerializeField] 15 | [HideInInspector] 16 | private string primary_function_enum; 17 | [ATEditable] 18 | [ATListView(typeof(PrimaryFunction))] 19 | public PrimaryFunction primary_function; 20 | 21 | [SerializeField] 22 | [HideInInspector] 23 | private string hierarchy_rank_enum; 24 | [ATEditable] 25 | [ATListView(typeof(HierarchyRank))] 26 | public HierarchyRank hierarchy_rank; 27 | 28 | [SerializeField] 29 | [HideInInspector] 30 | private string artisttools_function_enum; 31 | public ArtistToolsFunction artisttools_function; 32 | 33 | #endregion 34 | #region Function 35 | [SerializeField] 36 | [HideInInspector] 37 | private string item_function_enum; 38 | [ATEditable] 39 | [ATListView(typeof(ItemFunction))] 40 | public ItemFunction item_function; 41 | 42 | [SerializeField] 43 | [HideInInspector] 44 | private string material_function_enum; 45 | [ATEditable] 46 | [ATListView(typeof(MaterialFunction))] 47 | public MaterialFunction material_function; 48 | 49 | [SerializeField] 50 | [HideInInspector] 51 | private string morph_function_enum; 52 | [ATEditable] 53 | [ATListView(typeof(MorphFunction))] 54 | public MorphFunction morph_function; 55 | 56 | [SerializeField] 57 | [HideInInspector] 58 | private string animation_function_enum; 59 | [ATEditable] 60 | [ATListView(typeof(AnimationFunction))] 61 | public AnimationFunction animation_function; 62 | #endregion 63 | 64 | #region ISerializationCallbackReceiver implementation 65 | 66 | public void OnBeforeSerialize () 67 | { 68 | primary_function_enum = primary_function.ToString (); 69 | hierarchy_rank_enum = hierarchy_rank.ToString (); 70 | item_function_enum = item_function.ToString (); 71 | material_function_enum = material_function.ToString (); 72 | morph_function_enum = morph_function.ToString (); 73 | animation_function_enum = animation_function.ToString (); 74 | artisttools_function_enum = artisttools_function.ToString(); 75 | } 76 | 77 | public void OnAfterDeserialize () 78 | { 79 | if (primary_function_enum != null) { 80 | primary_function = (PrimaryFunction)Enum.Parse (typeof(PrimaryFunction), primary_function_enum); 81 | } 82 | if (hierarchy_rank_enum != null) { 83 | hierarchy_rank = (HierarchyRank)Enum.Parse (typeof(HierarchyRank), hierarchy_rank_enum); 84 | } 85 | if (item_function_enum != null) { 86 | item_function = (ItemFunction)Enum.Parse (typeof(ItemFunction), item_function_enum); 87 | } 88 | if (material_function_enum != null) { 89 | material_function = (MaterialFunction)Enum.Parse (typeof(MaterialFunction), material_function_enum); 90 | } 91 | if (morph_function_enum != null) { 92 | morph_function = (MorphFunction)Enum.Parse (typeof(MorphFunction), morph_function_enum); 93 | } 94 | if (animation_function_enum != null) { 95 | animation_function = (AnimationFunction)Enum.Parse (typeof(AnimationFunction), animation_function_enum); 96 | } 97 | if (artisttools_function_enum != null) 98 | { 99 | artisttools_function = (ArtistToolsFunction)Enum.Parse(typeof(ArtistToolsFunction), artisttools_function_enum); 100 | } 101 | } 102 | 103 | #endregion 104 | 105 | 106 | } 107 | } 108 | 109 | -------------------------------------------------------------------------------- /MCS_Core/Utility/Schematic/Base/VersionAndControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace MCS.Utility.Schematic.Base 3 | { 4 | [Serializable] 5 | public class VersionAndControl 6 | { 7 | #region Version 8 | public float mcs_version; 9 | public float mcs_revision; 10 | public float collection_version; 11 | public float item_version; 12 | #endregion 13 | #region Control 14 | [ATEditable] 15 | [ATInputText] 16 | public string[] compatibilities; 17 | #endregion 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /MCS_Core/Utility/Schematic/Enum/EmptyClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace MCS.Utility.Schematic.Enumeration 3 | { 4 | //public enum HierarchyRank{ 5 | // unkown, 6 | // collection, 7 | // item, 8 | // geometry, 9 | // skeleton 10 | //} 11 | //public enum PrimaryFunction{ 12 | // unkown, 13 | // figure, 14 | // hair, 15 | // prop, 16 | // soft_wearable, 17 | // rigid_wearable, 18 | // appendage 19 | //} 20 | 21 | 22 | } 23 | 24 | -------------------------------------------------------------------------------- /MCS_Core/Utility/Schematic/Enum/Enumeration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.ComponentModel; 4 | using System.Runtime.Serialization; 5 | 6 | namespace MCS.Utility.Schematic.Enumeration 7 | { 8 | public enum HierarchyRank 9 | { 10 | unknown, 11 | collection, 12 | item, 13 | geometry, 14 | skeleton 15 | } 16 | public enum ArtistToolsFunction 17 | { 18 | unknown, 19 | item, 20 | model, 21 | geometry, 22 | skeleton, 23 | material, 24 | skin, 25 | morph, 26 | animation 27 | } 28 | public enum PrimaryFunction 29 | { 30 | unknown, 31 | item, 32 | material, 33 | morph, 34 | animation 35 | } 36 | public enum ItemFunction 37 | { 38 | unknown, 39 | figure, 40 | hair, 41 | prop, 42 | soft_wearable, 43 | rigid_wearable, 44 | appendage 45 | } 46 | public enum MaterialFunction 47 | { 48 | unknown, 49 | basic, 50 | decal, 51 | damage, 52 | morph 53 | } 54 | public enum MorphFunction 55 | { 56 | unknown, 57 | blendshape, 58 | jct 59 | } 60 | public enum AnimationFunction 61 | { 62 | unknown 63 | } 64 | public enum PhysicalSubstance 65 | { 66 | unknown, 67 | cotton, 68 | marble, 69 | wood, 70 | aluminum, 71 | steal, 72 | bone 73 | } 74 | public enum Gender 75 | { 76 | unknown, 77 | none, 78 | female, 79 | male 80 | } 81 | public enum Category 82 | { 83 | unknown, 84 | scifi, 85 | fantasy, 86 | modern, 87 | horror 88 | } 89 | 90 | public static class EnumHelpers 91 | { 92 | 93 | public static T GetAttributeOfType(this Enum enumVal) where T : System.Attribute 94 | { 95 | var type = enumVal.GetType(); 96 | var memInfo = type.GetMember(enumVal.ToString()); 97 | var attributes = memInfo[0].GetCustomAttributes(typeof(T), false); 98 | return (attributes.Length > 0) ? (T)attributes[0] : null; 99 | } 100 | 101 | 102 | public static string GetDesc(this Enum enumValue) 103 | { 104 | var attribute = enumValue.GetAttributeOfType(); 105 | 106 | return attribute == null ? String.Empty : attribute.Description; 107 | } 108 | 109 | 110 | public static T GetEnum(string description) 111 | { 112 | var type = typeof(T); 113 | if (!type.IsEnum) throw new InvalidOperationException(); 114 | foreach (var field in type.GetFields()) 115 | { 116 | var attribute = Attribute.GetCustomAttribute(field, 117 | typeof(DescriptionAttribute)) as DescriptionAttribute; 118 | if (attribute != null) 119 | { 120 | if (attribute.Description == description) 121 | return (T)field.GetValue(null); 122 | } 123 | else 124 | { 125 | if (field.Name == description) 126 | return (T)field.GetValue(null); 127 | } 128 | } 129 | throw new ArgumentException("Not found.", "description"); 130 | // or return default(T); 131 | } 132 | } 133 | 134 | } 135 | 136 | 137 | -------------------------------------------------------------------------------- /MCS_Core/Utility/Schematic/Structure/ItemStructure.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | namespace MCS.Utility.Schematic.Structure 4 | { 5 | //items have optional parts, they can use or not use whatever parts as they wish... does this hold up to the test of time? 6 | [Serializable] 7 | public class ItemStructure 8 | { 9 | public string[] lods = null;//geometries that we toggle on and off 10 | public string[] persistent = null;//always active 11 | public string[] cap = null;//cap for hair - we could just use always active 12 | //if we go down this route, we'll eventually have a ton of things, like particles, bullets, 13 | //but... things will be explicit. sorda. 14 | public string[] assigned_materials = null; // list of materials associated with the item. 15 | public string[] alpha_masks = null; // List of Alpha Masks required by each item. They should be in the order defined by the array below. 16 | public string[] alpha_masks_key = null; // List of Alpha Mask keys - HEAD, BODY, EYES. 17 | 18 | public string overlay = null; //a texture to apply to the figure's skin 19 | public string overlay_color = null; //a tint color for the overlay 20 | 21 | public string[] morph_resouces = null; 22 | public static ItemStructure CreateFromJSON(string jsonString) 23 | { 24 | return JsonUtility.FromJson(jsonString); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /MCS_Core/Utility/Schematic/Structure/MaterialStructure.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | namespace MCS.Utility.Schematic.Structure 4 | { 5 | //this is the data for the textures we support 6 | [Serializable] 7 | public class MaterialStructure 8 | { 9 | //{ 10 | // "albedo":"images/albedo.jpg", 11 | // "tint":"255,200,120", 12 | // "metal":"images/metal.jpg", 13 | // "smoothness":"images/smoothness.jpg", 14 | // "emission":"images/emission.jpg", 15 | // "emission_modifier":1.0, 16 | // "normal":"images/normal.jpg", 17 | // "normal_modifier":1.0, 18 | // "transparency":"images/transparency.jpg", 19 | // "transparency_mode":"cutout" 20 | //} 21 | public string shader; 22 | 23 | public string albedo; 24 | public string albedo_tint; 25 | public string metal; 26 | public string specular; 27 | public string smoothness_channel; 28 | public float metallic_value; 29 | public float smoothness_value; 30 | public string normal; 31 | public float normal_value; 32 | public string detail_normal; 33 | public float detail_normal_value; 34 | public string height; 35 | public string transparency; 36 | public string transparency_mode; 37 | public float transparency_value; 38 | public string emission; //image map 39 | public string emission_value; //color r,g,b 40 | public string emission_color; //Artist Tools uses this as the rgb value for emission 41 | public string global_illumination; 42 | public string detail; 43 | public string occlusion; //ambient occlusion map, Standard Shader: _OcclusionMap 44 | public float occlusion_value; //Standard shader: _OcclusionStrength 45 | public float tile_x; 46 | public float tile_y; 47 | public float offset_x; 48 | public float offset_y; 49 | public string tint; //TODO: this should probably automagically get converted into a color (r,g,b) as a number from 0-255 50 | 51 | public string[] shader_keywords = null; //eg: _ALPHATEST_ON 52 | public string[] shader_tags = null; //eg: RenderType=TransparentCutout 53 | public string[] shader_properties = null; //eg: "int:_SrcBlend=1","float:_Range=2.0","color:_Col=127,255,3,0.5" 54 | public int render_queue = -2; //-1+ are valid ranges 55 | 56 | public string[] textures = null;//list of textures on disk 57 | public static MaterialStructure CreateFromJSON(string jsonString) 58 | { 59 | return JsonUtility.FromJson(jsonString); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /MCS_Core/Utility/Schematic/Structure/MorphStructure.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System; 4 | 5 | namespace MCS.Utility.Schematic.Structure 6 | { 7 | [Serializable] 8 | public class MorphStructure 9 | { 10 | public string[] lodMorphObjectNames = null; 11 | public string[] lodMorphLocations = null; 12 | } 13 | } 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /MCS_Core/Utility/Serialize/ISerializable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace MCS.Utility.Serialize 3 | { 4 | public delegate void SerializeToJson(); 5 | public delegate void DeserializeFromJson(); 6 | 7 | interface ISerializable 8 | { 9 | void SerializeStateToJson(); 10 | void DeserializeStateFromJson(); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /MCS_Core/_Experimental/AttachmentPointSystem/APLayout.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using MCS.COSTUMING; 4 | 5 | [System.Serializable] 6 | /// 7 | /// Attachment Point layout base class inherits from MonoBehaviour 8 | /// 9 | public class APLayout : MonoBehaviour 10 | { 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | public APLayout () 15 | { 16 | } 17 | 18 | 19 | 20 | /// 21 | /// Overrideable event - Unknown use. 22 | /// 23 | /// ap. 24 | /// Unusual for an event to be able to return a value. 25 | virtual public int OnNeedMaximumVisibleItems (CIattachmentPoint ap) 26 | { 27 | return 0; 28 | } 29 | 30 | 31 | 32 | /// 33 | /// Overrideable event - absolute local position 34 | /// 35 | /// Ap. 36 | /// Unusual for an event to be able to return a value. 37 | virtual public Vector3 OnPositionForAttachmentPoint (CIattachmentPoint ap) 38 | { 39 | return new Vector3(); 40 | } 41 | 42 | 43 | 44 | /// 45 | /// Overrideable event - absolute local rotation 46 | /// 47 | /// Ap. 48 | /// Unusual for an event to be able to return a value. 49 | virtual public Vector3 OnRotationForAttachmentPoint (CIattachmentPoint ap) 50 | { 51 | return new Vector3(); 52 | } 53 | 54 | 55 | 56 | /// 57 | /// Overrideable event - absolute positional offset to localPosition 58 | /// 59 | /// The GameObject Item. 60 | /// The index. 61 | /// Unusual for an event to be able to return a value. 62 | virtual public Vector3 OnPositionForItemByIndex (GameObject item, int index) 63 | { 64 | return new Vector3(); 65 | } 66 | 67 | 68 | 69 | /// 70 | /// Overrideable event - absolute rotational offset to localRotation 71 | /// 72 | /// The GameObject Item. 73 | /// The index 74 | /// Unusual for an event to be able to return a value. 75 | virtual public Vector3 OnRotationForItemByIndex (GameObject item, int index) 76 | { 77 | return new Vector3(); 78 | } 79 | 80 | 81 | 82 | } 83 | -------------------------------------------------------------------------------- /MCS_Core/_Experimental/AttachmentPointSystem/MCSAttachmentPointConfiguration.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | /// 6 | /// AttachmentPointConfiguration class. Inherits from ScriptableObject 7 | /// 8 | public class MCSAttachmentPointConfiguration : ScriptableObject 9 | { 10 | /// 11 | /// List of AttachmentPoint presets. 12 | /// 13 | public List attachmentPointPresets; 14 | 15 | 16 | 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | public MCSAttachmentPointConfiguration () 21 | { 22 | if (attachmentPointPresets == null) 23 | attachmentPointPresets = new List (); 24 | } 25 | 26 | 27 | 28 | /// 29 | /// AttachmentPoint preset class, contains all the data for a single Attachment Point 30 | /// 31 | [System.Serializable] 32 | public class AttachmentPointPreset 33 | { 34 | [SerializeField]public string targetBone; 35 | public Vector3 positionOffset; 36 | public Vector3 rotationOffset; 37 | public bool autoMirror = true; 38 | public string layoutClassName; 39 | } 40 | 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /MCS_Core/_Experimental/AttachmentPointSystem/SinglePropDefaultLayout.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using MCS.COSTUMING; 4 | 5 | /// 6 | /// Default Layout class for a single Attachment Point. Inherits from APLayout. 7 | /// 8 | public class SinglePropDefaultLayout : APLayout 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | public SinglePropDefaultLayout () 14 | { 15 | } 16 | 17 | 18 | 19 | /// 20 | /// Overridden event. 21 | /// 22 | /// ap. 23 | /// Unusual for an event to be able to return a value. 24 | override public int OnNeedMaximumVisibleItems (CIattachmentPoint ap) 25 | { 26 | return 1; 27 | } 28 | 29 | 30 | 31 | /// 32 | /// Overridden event - absolute local position 33 | /// 34 | /// Ap. 35 | /// Unusual for an event to be able to return a value. 36 | override public Vector3 OnPositionForAttachmentPoint (CIattachmentPoint ap) 37 | { 38 | return ap.transform.localPosition; 39 | } 40 | 41 | 42 | 43 | /// 44 | /// Overridden event - absolute local rotation 45 | /// 46 | /// Ap. 47 | /// Unusual for an event to be able to return a value. 48 | override public Vector3 OnRotationForAttachmentPoint (CIattachmentPoint ap) 49 | { 50 | return ap.transform.localEulerAngles; 51 | } 52 | 53 | 54 | 55 | /// 56 | /// Overridden event - absolute positional offset to localPosition 57 | /// 58 | /// The GameObject Item. 59 | /// The index. 60 | /// Unusual for an event to be able to return a value. 61 | override public Vector3 OnPositionForItemByIndex (GameObject item, int index) 62 | { 63 | return item.transform.localPosition; 64 | } 65 | 66 | 67 | 68 | /// 69 | /// Overridden event - absolute rotational offset to localRotation 70 | /// 71 | /// The GameObject Item. 72 | /// The index 73 | /// Unusual for an event to be able to return a value. 74 | override public Vector3 OnRotationForItemByIndex (GameObject item, int index) 75 | { 76 | return item.transform.localEulerAngles; 77 | } 78 | 79 | 80 | 81 | } 82 | -------------------------------------------------------------------------------- /MCS_Core/_Experimental/JCTs/Expand.cs: -------------------------------------------------------------------------------- 1 | //using UnityEngine; 2 | //using System.Collections.Generic; 3 | // 4 | //[ExecuteInEditMode] 5 | //public class Expand : MonoBehaviour 6 | //{ 7 | // public float m_expand; 8 | // private float m_lastExpand; 9 | // 10 | // SkinnedMeshRenderer m_meshRender; 11 | // 12 | // private SkinnedMeshRenderer MeshRender 13 | // { 14 | // get 15 | // { 16 | // if (m_meshRender) 17 | // return m_meshRender; 18 | // SkinnedMeshRenderer meshRender = transform.GetComponentInChildren(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer; 19 | // m_meshRender = meshRender; 20 | // return meshRender; 21 | // } 22 | // } 23 | // 24 | // void Awake() 25 | // { 26 | // } 27 | // 28 | // 29 | // void Update() 30 | // { 31 | // if (m_expand != m_lastExpand) 32 | // { 33 | // SkinnedMeshRenderer meshRender = MeshRender; 34 | // Mesh mesh = meshRender.sharedMesh; 35 | // 36 | // Vector3[] vertices = mesh.vertices; 37 | // Vector3[] normals = mesh.normals; 38 | // Vector3[] deltas = null; 39 | // 40 | // if (deltas == null || deltas.Length == 0) 41 | // deltas = new Vector3[vertices.Length]; 42 | // 43 | // for(int i = 0; i < deltas.Length; i++) 44 | // deltas[i] = normals[i] * m_lastExpand * 0.001f; 45 | // 46 | // for(int i = 0; i < deltas.Length; i++) 47 | // vertices[i] -= deltas[i]; 48 | // 49 | // for(int i = 0; i < deltas.Length; i++) 50 | // deltas[i] = normals[i] * m_expand * 0.001f; 51 | // 52 | // for(int i = 0; i < deltas.Length; i++) 53 | // vertices[i] += deltas[i]; 54 | // 55 | // mesh.vertices = vertices; 56 | // m_lastExpand = m_expand; 57 | // } 58 | // } 59 | //} 60 | // 61 | -------------------------------------------------------------------------------- /MCS_Core/_Experimental/JCTs/Profiler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | //using System.Collections.Generic; 3 | //using UnityEngine; 4 | // 5 | //public class Profiler 6 | //{ 7 | // public static Profiler FPS = new Profiler(); 8 | // public static Profiler Paint0 = new Profiler(); 9 | // public static Profiler Paint1 = new Profiler(); 10 | // public static Profiler Paint2 = new Profiler(); 11 | // public static Profiler Project0 = new Profiler(); 12 | // public static Profiler Project1 = new Profiler(); 13 | // float m_start; 14 | // float m_stop; 15 | // float m_duration; 16 | // 17 | // 18 | // public void reset() { 19 | // m_duration = 0; 20 | // } 21 | // 22 | // public void start() { 23 | // reset(); 24 | // m_start = Time.realtimeSinceStartup; 25 | // } 26 | // 27 | // public void stop() 28 | // { 29 | // m_stop = Time.realtimeSinceStartup; 30 | // m_duration += (m_stop - m_start); 31 | // } 32 | // 33 | // public void cont() { 34 | // m_start = Time.realtimeSinceStartup; 35 | // } 36 | // 37 | // public float Duration { 38 | // get { 39 | // return m_duration*1000; 40 | // } 41 | // } 42 | // 43 | // public int DurationMCS { 44 | // get { 45 | // return (int)(m_duration*10000); 46 | // } 47 | // } 48 | //} 49 | // 50 | -------------------------------------------------------------------------------- /MCS_Importer/MCS_Importer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {3981EBB4-7CD9-49DA-A3A4-2E971D77EF06} 7 | Library 8 | M3DIMPORT_DLL 9 | v3.5 10 | 1.7 11 | 12 | 13 | True 14 | full 15 | False 16 | ..\build\Debug 17 | DEBUG; 18 | prompt 19 | 4 20 | False 21 | MCS_Importer 22 | 23 | 24 | True 25 | full 26 | False 27 | ..\build\Debug 28 | DEBUG;UNITY_TARGET_GTE_5_5; 29 | prompt 30 | 4 31 | False 32 | M3DIMPORT_DLL 33 | 34 | 35 | True 36 | ..\build\Release 37 | prompt 38 | 4 39 | False 40 | none 41 | M3DIMPORT_DLL 42 | 43 | 44 | OnBuildSuccess 45 | 46 | 47 | 48 | 49 | 50 | ..\UnityDlls\5.5\UnityEngine.dll 51 | 52 | 53 | ..\UnityDlls\5.5\UnityEditor.dll 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | ..\..\..\..\..\..\..\Applications\Unity\Hub\Editor\2017.4\Unity.app\Contents\Managed\UnityEditor.dll 66 | 67 | 68 | ..\..\..\..\..\..\..\Applications\Unity\Hub\Editor\2017.4\Unity.app\Contents\Managed\UnityEngine.dll 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | {BB0EB3B1-241F-46BC-812A-1BAD99734ED7} 84 | MCS_Utilities 85 | 86 | 87 | {862CB436-4E0A-4AE6-BDF4-1A636878817B} 88 | MCS_Core 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /MCS_Importer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle ("M3DIMPORT_DLL")] 8 | [assembly: AssemblyDescription ("")] 9 | [assembly: AssemblyConfiguration ("")] 10 | [assembly: AssemblyCompany ("")] 11 | [assembly: AssemblyProduct ("")] 12 | [assembly: AssemblyCopyright("MCS")] 13 | [assembly: AssemblyTrademark ("")] 14 | [assembly: AssemblyCulture ("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion("1.0.*")] 21 | 22 | // The following attributes are used to specify the signing key for the assembly, 23 | // if desired. See the Mono documentation for more information about signing. 24 | 25 | //[assembly: AssemblyDelaySign(false)] 26 | //[assembly: AssemblyKeyFile("")] 27 | 28 | -------------------------------------------------------------------------------- /MCS_Utilities/MCSConstants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace MCS_Utilities 7 | { 8 | class MCSConstants 9 | { 10 | public const int LATEST_MAJOR_VERSION = 2; 11 | public const int LATEST_MINOR_VERSION = 0; 12 | public const int MR_MAGIC_NUMBER = 1618775168; //used to uniquely identify .mr files 13 | 14 | //the packed file contains the header, which we'll parse, and the body after, we don't have to read the body, we can fseek the file 15 | public const string HEAD_STOP = "\u0002M3DResourceBody\0002"; 16 | public const int MAX_HEADER_LENGTH = 1024 * 1024 * 10; //up to X bytes for a header 17 | public const int MAX_BYTES_PER_CHUNK = 8096;//1024; 18 | 19 | public const int SIZE_OF_FLOAT = sizeof(float); 20 | public const int SIZE_OF_INT = sizeof(int); 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /MCS_Utilities/MCS_Utilities.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {BB0EB3B1-241F-46BC-812A-1BAD99734ED7} 8 | Library 9 | Properties 10 | MCS_Utilities 11 | MCS_Utilities 12 | v3.5 13 | 512 14 | 15 | 16 | 1.7 17 | 18 | 19 | true 20 | full 21 | false 22 | ..\build\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | ..\build\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | ..\..\..\..\OMC_Morph3D\Assets\MCS\Code\Plugins\ICSharpCode.SharpZipLib.dll 44 | 45 | 46 | ..\..\..\..\..\..\..\Applications\Unity\Hub\Editor\2017.4\Unity.app\Contents\Managed\UnityEditor.dll 47 | 48 | 49 | ..\..\..\..\..\..\..\Applications\Unity\Hub\Editor\2017.4\Unity.app\Contents\Managed\UnityEngine.dll 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 72 | 73 | -------------------------------------------------------------------------------- /MCS_Utilities/Paths.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Text.RegularExpressions; 4 | 5 | namespace MCS_Utilities 6 | { 7 | public class Paths 8 | { 9 | //Convert Assets/MajorTom/Outgoing/AlphaInjection/foo.png to ./AlphaInjection/foo.png 10 | // used specifically for mon file generation so we can replace "./" with the parent dir of the .mon file 11 | public static string RelativeTo(string baseDir, string filePath) 12 | { 13 | UnityEngine.Debug.Log("Orig: " + baseDir + " => " + filePath); 14 | if (String.IsNullOrEmpty(filePath)) 15 | { 16 | return filePath; 17 | } 18 | 19 | baseDir = baseDir.Replace(@"\", @"/"); 20 | filePath = filePath.Replace(@"\", @"/"); 21 | filePath = filePath.Replace(baseDir, "").TrimStart('/'); 22 | filePath = @"./" + filePath; 23 | UnityEngine.Debug.Log("Out: " + filePath); 24 | 25 | return filePath; 26 | } 27 | 28 | //convert /foo/bar/car to /foo/bar 29 | public static string ConvertFileToDir(string filePath) 30 | { 31 | filePath = filePath.Replace(@"\", "/"); 32 | int pos = filePath.LastIndexOf('/'); 33 | if (pos >= 0) 34 | { 35 | return filePath.Substring(0, pos); 36 | } 37 | throw new Exception("Could not detect dir"); 38 | } 39 | 40 | public static string GetFileNameFromFullPath(string filePath,bool stripExtension = false) 41 | { 42 | filePath = filePath.Replace(@"\", "/"); 43 | int pos = filePath.LastIndexOf('/'); 44 | if (pos >= 0) 45 | { 46 | string result = filePath.Substring(pos+1); 47 | if (stripExtension) 48 | { 49 | int posExt = result.LastIndexOf('.'); 50 | if (posExt >= 0) 51 | { 52 | result = result.Substring(0, posExt); 53 | } 54 | } 55 | 56 | return result; 57 | } 58 | throw new Exception("Could not detect dir"); 59 | } 60 | 61 | public static string ConvertRelativeToAbsolute(string baseDir, string filePath) 62 | { 63 | if (String.IsNullOrEmpty(filePath) || String.IsNullOrEmpty(baseDir)) 64 | { 65 | return filePath; 66 | } 67 | 68 | /* 69 | if (!filePath.StartsWith(@"./")) 70 | { 71 | return filePath; 72 | } 73 | */ 74 | 75 | baseDir = baseDir.Replace(@"\", @"/"); 76 | filePath = filePath.Replace(@"\", @"/"); 77 | 78 | if (filePath.StartsWith(@"./")) 79 | { 80 | filePath = filePath.Replace("./", baseDir + "/"); 81 | } else 82 | { 83 | //it doesn't start with a "./" let's assume we would not combine it first, then we would combine it as the default 84 | if (!File.Exists(filePath)) 85 | { 86 | filePath = baseDir.TrimEnd('/') + @"/" + filePath; 87 | } 88 | 89 | } 90 | return filePath; 91 | } 92 | 93 | protected static Regex nameScrub = new Regex("[^a-zA-Z0-9_-]+"); 94 | public static string ScrubKey(string src) 95 | { 96 | src = src.Replace(" ", "_"); 97 | src = nameScrub.Replace(src, ""); 98 | return src; 99 | } 100 | 101 | protected static Regex directoryScrub = new Regex(@"[^a-zA-Z0-9-._/]+"); 102 | public static string ScrubPath(string src) 103 | { 104 | src = src.Replace("\\", "/"); 105 | src = src.Replace(" ", "_"); 106 | src = directoryScrub.Replace(src, ""); 107 | return src; 108 | } 109 | 110 | //Attempts to delete a directory recursively multiple times catching exceptions up to X times 111 | public static void TryDirectoryDelete(string dirPath, int attemptCount = 0) 112 | { 113 | int maxAttempts = 10; 114 | 115 | //delete the loose files which we don't need anymore 116 | if (!Directory.Exists(dirPath)) 117 | { 118 | return; 119 | } 120 | 121 | try 122 | { 123 | Directory.Delete(dirPath, true); 124 | } 125 | catch (Exception e) 126 | { 127 | //if we're below our attempts, try again 128 | if (attemptCount < maxAttempts) 129 | { 130 | //wait 10 ms and try again 131 | System.Threading.Thread.Sleep(10); 132 | TryDirectoryDelete(dirPath, attemptCount++); 133 | } 134 | else 135 | { 136 | UnityEngine.Debug.LogError("Max attempts at deleting directory: " + dirPath + " Check to see if you're exceeding path name limits!"); 137 | UnityEngine.Debug.LogException(e); 138 | throw; 139 | } 140 | } 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /MCS_Utilities/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("MCS_Utilities")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("MCS_Utilities")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("bb0eb3b1-241f-46bc-812a-1bad99734ed7")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MCS 2 | This project is used to power the Avatar system known as MCS. 3 | 4 | ## Copyright 5 | Copyright 2015-2019 by the MCS authors and Daz 3D released under LGPLv3. 6 | 7 | ## License and Usage 8 | This library, MCS, and all of it's original supporting code and tools are licensed under the LGPLv3 as viewed here: https://opensource.org/licenses/lgpl-3.0.html 9 | 10 | MCS is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 11 | 12 | MCS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public License along with MCS. If not, see . 15 | 16 | ## Compiling 17 | For ease of use there is a Visual Studio solution file MCS.sln provided which has projects inside. 18 | 19 | 1. Copy or reference your UnityEngine.dll and UnityEditor.dll (these are inside your unity install directory) 20 | 2. Build MCS_Utilities 21 | 3. Build MCS_Importer 22 | 4. Build_MCS_Core 23 | 24 | Or you can build the individual folders with the Mono or Microsoft compiler (`mcs.exe` or `csc.exe`). You will need to build the folders in the order above and include references to them as you build the next one. 25 | 26 | 27 | ## Installing 28 | This library is designed to be built as a series of managed dlls and then copied into your project. You can also copy the source files directly into your project. For ease of use please see the releases section on github for a `.unitypackage` which will take care of installing the dlls, shaders, and supporting editor scripts automatically for you. 29 | 30 | You can also look at the BuildTools program which will copy the appropriate files into a structure suitable for your Unity project. 31 | 32 | ### Folder Structure 33 | Managed plugins will exist at `Assets/MCS/Code/Plugins` including the 3rd party vendor plugin `ICSharpCode.SharpZipLib.dll` 34 | 35 | Loose scripts will exist at `Assets/MCS/Code/Scripts` in their respective folders 36 | 37 | Shaders will exist at `Assets/MCS/Resources/Shaders` 38 | 39 | Content, including the base figures, will exist at `Assets/MCS/Content/[PRODUCTNAME]` and `/Assets/StreamingAssets/[VENDORNAME]` 40 | 41 | ## Support 42 | This project is only minimially supported now, however, we are accepting pull requests and would consider having someone externally help contribute or maintain this project. If you are interested in assiting please email jjanzer at make taffi dot com. 43 | 44 | ## Legacy Assets 45 | Please note that your existing assets will not work unless you move them into the `Assets/MCS` and update their `.mon` files to point to these new paths. If you would like to use this latest code version with legacy assets you will need to find and replace any `M3D` references with `MCS`. These references will be found in the following file types: `.mon`, `.fbx`, `.json`, and `.mr`. Be careful if you replace those strings as `fbx` and `mr` are binary files, so you should ensure you use a binary safe tool and not a string based tool. We have converted most of these assest to the new name which you can access via one of the links below. 46 | 47 | ### Previously Purchased Assets on the MCS Store 48 | If you've purchased existing assets on the non-unity store in the past you may be able to download them via: [mcsdownload.com](https://mcsdownload.com) with your legacy username and paasword. 49 | 50 | *Note*: this download site will expire July 2019, so if you'd like to download your assets and haven't done so yet, please do so before then. 51 | 52 | ### Purchasing New Assets 53 | If you wanted to buy an asset but never purchased it you can find a assets for purchase at [daz3d](https://daz3d.com/shop). 54 | 55 | ## Contributors 56 | The current maintainer of MCS is Jesse Janzer. In the past the following people have contributed development towards this project: Jesse Janzer, Ben Hesson, Bruce Stagbrook de Claimont, Abhishek Tripathi, Jesse Gomez, and Ian King. -------------------------------------------------------------------------------- /Scripts/AttachmentPoints/SinglePropDefaultLayoutExample.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using MCS.COSTUMING; 4 | 5 | 6 | public class SinglePropDefaultLayoutExample : APLayout { 7 | 8 | public SinglePropDefaultLayoutExample(){ 9 | 10 | } 11 | 12 | override public int OnNeedMaximumVisibleItems(CIattachmentPoint ap) 13 | { 14 | return 1; 15 | } 16 | override public Vector3 OnPositionForAttachmentPoint (CIattachmentPoint ap){ 17 | return new Vector3(); 18 | } 19 | override public Vector3 OnRotationForAttachmentPoint (CIattachmentPoint ap){ 20 | return new Vector3(); 21 | } 22 | 23 | override public Vector3 OnPositionForItemByIndex (GameObject item, int index){ 24 | return new Vector3(); 25 | } 26 | override public Vector3 OnRotationForItemByIndex (GameObject item, int index){ 27 | return new Vector3(); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Scripts/AttachmentPoints/SpiralPropLayout.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using MCS.COSTUMING; 4 | 5 | 6 | public class SpiralPropLayout : APLayout { 7 | 8 | int starting_angle = -45; 9 | int angle_spacing = 15; 10 | 11 | override public int OnNeedMaximumVisibleItems(CIattachmentPoint ap){ 12 | return 6; 13 | } 14 | override public Vector3 OnPositionForAttachmentPoint (CIattachmentPoint ap){ 15 | return new Vector3(); 16 | } 17 | override public Vector3 OnRotationForAttachmentPoint (CIattachmentPoint ap){ 18 | return new Vector3(); 19 | } 20 | 21 | override public Vector3 OnPositionForItemByIndex (GameObject item, int index){ 22 | return new Vector3(); 23 | } 24 | override public Vector3 OnRotationForItemByIndex (GameObject item, int index){ 25 | return new Vector3(0f,0f,starting_angle + (index*angle_spacing)); 26 | } 27 | 28 | public Vector3 OnPositionOffsetForItemByIndex (GameObject item, int index){ 29 | return new Vector3(); 30 | } 31 | public Vector3 OnRotationOffsetForItemByIndex (GameObject item, int index){ 32 | return new Vector3(0f,0f,starting_angle + (index*angle_spacing)); 33 | } 34 | 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Scripts/Editor/ContentLibrarySOEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System.Collections; 4 | using System.Linq; 5 | using MCS.CONTENTLIBRARY; 6 | 7 | [CustomEditor (typeof(ContentLibrarySO))] 8 | public class ContentLibrarySOEditor : Editor 9 | { 10 | 11 | protected bool[] showItemData = null; 12 | protected bool[] compatibilities = null; 13 | 14 | //changed the name of this so it doesn't get used at the moment. Will fix this later - Ben 15 | // public void OnInspectorGUI () 16 | // { 17 | // EditorGUILayout.Space (); 18 | // 19 | // ContentLibrarySO data; 20 | // data = (ContentLibrarySO)target; 21 | // if (data.AssetSchematicList != null) { 22 | // 23 | // if (showItemData == null || showItemData.Length != data.AssetSchematicList.Count) { 24 | // showItemData = new bool[data.AssetSchematicList.Count]; 25 | // } 26 | // 27 | // if (compatibilities == null || compatibilities.Length != data.AssetSchematicList.Count) { 28 | // compatibilities = new bool[data.AssetSchematicList.Count]; 29 | // } 30 | // 31 | // EditorGUILayout.BeginVertical(); 32 | // 33 | // for (int i = 0; i < showItemData.Length; i++) { 34 | // showItemData [i] = EditorGUILayout.Foldout (showItemData [i], data.AssetSchematicList [i].item_name); 35 | // if (showItemData [i]) { 36 | // EditorGUI.indentLevel++; 37 | // 38 | // EditorGUILayout.LabelField("item id: " + data.AssetSchematicList [i].item_id); 39 | // EditorGUILayout.LabelField("item version: " + data.AssetSchematicList [i].item_version); 40 | // EditorGUILayout.LabelField("collection id: " + data.AssetSchematicList [i].collection_id); 41 | // EditorGUILayout.LabelField("collection name: " + data.AssetSchematicList [i].collection_name); 42 | // EditorGUILayout.LabelField("collection version: " + data.AssetSchematicList [i].collection_version); 43 | // EditorGUILayout.LabelField("rank: " + data.AssetSchematicList [i].hierarchy_rank.ToString()); 44 | // EditorGUILayout.LabelField("function: " + data.AssetSchematicList [i].function.ToString()); 45 | // EditorGUILayout.LabelField("mcs version: " + data.AssetSchematicList [i].mcs_version); 46 | // 47 | // if (data.AssetSchematicList [i].mon_file_path != "") { 48 | // EditorGUILayout.LabelField("mon path: " + data.AssetSchematicList [i].mon_file_path); 49 | // } 50 | // if(data.AssetSchematicList [i].donor_file_path != "" && data.AssetSchematicList [i].donor_file_path != null){ 51 | // EditorGUILayout.LabelField("donor path: " + data.AssetSchematicList [i].donor_file_path); 52 | // } 53 | // if (data.AssetSchematicList [i].prefab_path != "") { 54 | // EditorGUILayout.LabelField("prefab path: " + data.AssetSchematicList [i].prefab_path); 55 | // } 56 | // 57 | // if (data.AssetSchematicList [i].compatibilities != null && data.AssetSchematicList [i].compatibilities.Length > 0) { 58 | // 59 | // compatibilities[i] = EditorGUILayout.Foldout (compatibilities[i], "compatibilities:"); 60 | // if (compatibilities [i]) { 61 | // EditorGUI.indentLevel++; 62 | // for (int j = 0; j < data.AssetSchematicList [i].compatibilities.Length; j++) { 63 | // EditorGUILayout.LabelField(data.AssetSchematicList [i].compatibilities[j]); 64 | // } 65 | // EditorGUI.indentLevel--; 66 | // } 67 | // 68 | // } 69 | // 70 | // 71 | // EditorGUILayout.Space (); 72 | // EditorGUI.indentLevel--; 73 | // } 74 | // } 75 | // 76 | // EditorGUILayout.EndVertical(); 77 | // } 78 | // 79 | // 80 | // 81 | // 82 | // 83 | // } 84 | } 85 | 86 | -------------------------------------------------------------------------------- /Scripts/Editor/MCSDebugInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using UnityEditor; 4 | using UnityEngine; 5 | using MCS; 6 | using System.Collections; 7 | using System.Text; 8 | using System.Diagnostics; 9 | 10 | namespace AssemblyCSharpEditor 11 | { 12 | public class MCSDebugInfo : Editor 13 | { 14 | 15 | private static StreamWriter sr; 16 | private const string MCS_LOG_PATH = "Assets/MCS/~Logs/"; 17 | private const string DLL_PATH = "Assets/MCS/scripts/Plugins/"; 18 | 19 | [MenuItem("MCS/Generate Debug Info")] 20 | public static void GenerateMorphDebugInfo() 21 | { 22 | string directory = string.Format (MCS_LOG_PATH + "MCS Debug Log {0:yyyy-MM-dd_hh-mm-ss-tt}", DateTime.Now); 23 | string filename = "Log.txt"; 24 | 25 | Directory.CreateDirectory (directory); 26 | sr = File.CreateText (directory + "/" + filename); 27 | 28 | UnityEngine.Debug.Log ("Generated MCS Log in " + MCS_LOG_PATH + ". Delete after sending to MCS"); 29 | 30 | //Application.CaptureScreenshot(directory + "/Screenshot.png"); 31 | 32 | //Check the platform it is on 33 | sr.WriteLine ("Application Platform: " + Application.platform); 34 | 35 | //Check Unity version 36 | sr.WriteLine("Unity Version: " + Application.unityVersion); 37 | 38 | //Check dll version of M3D_Dll and M3DIMPORT_DLL 39 | if (File.Exists (DLL_PATH + "M3D_DLL.dll")) { 40 | FileVersionInfo m3d = FileVersionInfo.GetVersionInfo(DLL_PATH + "M3D_DLL.dll"); 41 | sr.WriteLine ("M3D_DLL.dll version: " + m3d.FileVersion.ToString ()); 42 | } 43 | if (File.Exists (DLL_PATH + "M3DIMPORT_DLL.dll")) { 44 | FileVersionInfo m3dimport = FileVersionInfo.GetVersionInfo(DLL_PATH + "M3DIMPORT_DLL.dll"); 45 | sr.WriteLine ("M3DIMPORT_DLL.dll version: " + m3dimport.FileVersion.ToString ()); 46 | } 47 | 48 | //Check if it is playing 49 | sr.WriteLine ("Is Application Playing: " + Application.isPlaying); 50 | 51 | sr.WriteLine (""); 52 | 53 | //Write out number of gameobjects with a MCSCharacterManager attached 54 | MCSCharacterManager[] characterManagerObjects = FindObjectsOfType (typeof(MCSCharacterManager)) as MCSCharacterManager[]; 55 | sr.WriteLine ("Gameobjects with MCSCharacterManager: " + characterManagerObjects.Length); 56 | 57 | foreach (MCSCharacterManager obj in characterManagerObjects) { 58 | 59 | //Check current lod level 60 | sr.WriteLine ( obj.gameObject.name + " current LOD level: " + obj.currentLODLevel); 61 | 62 | //Check blendshape levels 63 | foreach (MCS.FOUNDATIONS.Morph morph in obj.coreMorphs.morphStateGroups["All"]) { 64 | if (morph.value > 0) { 65 | sr.WriteLine ( obj.gameObject.name + " blend shape " + morph.name + ": " + morph.value); 66 | } 67 | } 68 | 69 | //Check if it has an animation controller 70 | Animator anim = obj.gameObject.GetComponent (); 71 | if (anim != null) { 72 | if (anim.runtimeAnimatorController != null) { 73 | sr.WriteLine ( obj.gameObject.name + " has Animator Controller: " + anim.runtimeAnimatorController.name); 74 | } else { 75 | sr.WriteLine ( obj.gameObject.name + " does NOT have an animation controller"); 76 | } 77 | } 78 | 79 | //Check content packs 80 | foreach (ContentPack cp in obj.GetAllContentPacks()) { 81 | sr.WriteLine ( obj.gameObject.name + "content pack: " + cp.name); 82 | } 83 | 84 | //Get children info 85 | sr.WriteLine (obj.gameObject.name + " children:"); 86 | FindChildren (obj.gameObject); 87 | } 88 | sr.Close (); 89 | 90 | } 91 | 92 | 93 | private static void FindChildren(GameObject obj){ 94 | 95 | StringBuilder sb = new StringBuilder (); 96 | 97 | //check if gameobject is active 98 | sb.Append ("\t" + obj.name + " active: " + obj.activeSelf.ToString ()); 99 | 100 | //check for a skinned mesh renderer 101 | SkinnedMeshRenderer smr = obj.GetComponent (); 102 | if (smr != null) { 103 | 104 | //check if the skinned mesh renderer is enabled 105 | sb.Append (" SkinnedMeshRender Enabled: " + smr.enabled); 106 | 107 | Renderer rend = obj.GetComponent (); 108 | if (rend != null) { 109 | foreach(Material mat in rend.sharedMaterials){ 110 | sb.Append (System.Environment.NewLine); 111 | 112 | //print out the material name and then the shader name 113 | sb.Append("\t\t" + mat.name + " " + mat.shader.name); 114 | } 115 | } 116 | } 117 | 118 | sr.WriteLine (sb.ToString()); 119 | 120 | foreach (Transform child in obj.transform) { 121 | 122 | //stop at the hip object 123 | if (obj.name == "hip") { 124 | return; 125 | } 126 | FindChildren (child.gameObject); 127 | } 128 | } 129 | 130 | } 131 | } 132 | 133 | -------------------------------------------------------------------------------- /Scripts/Editor/MCSMorphEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System.Collections; 4 | using MCS_Utilities; 5 | 6 | using MCS; 7 | using MCS.SERVICES; 8 | using MCS.FOUNDATIONS; 9 | using MCS_Utilities.Morph; 10 | 11 | [CustomEditor(typeof(MCSMorphFileWrapper))] 12 | public class MCSMorphEditor : Editor 13 | { 14 | 15 | 16 | protected Vector2 scrollDeltaVertsPos; 17 | protected Vector2 scrollDeltaNormalsPos; 18 | 19 | public override void OnInspectorGUI() 20 | { 21 | MCSMorphFileWrapper wrapper = (MCSMorphFileWrapper)target; 22 | 23 | GUILayout.Label("File: " + wrapper.fileName); 24 | 25 | try 26 | { 27 | byte[] bytes = System.IO.File.ReadAllBytes(wrapper.fileName); 28 | MorphData morphData = MorphData.ConvertBytesToMorphData(bytes); 29 | GUILayout.Label("Morph: " + morphData.name); 30 | GUILayout.Label("Mesh: " + morphData.meshName); 31 | 32 | int i = 0; 33 | GUILayout.Label("Delta Vertices: " + (morphData.blendshapeData.deltaVertices != null ? morphData.blendshapeData.deltaVertices.Length.ToString() : "null")); 34 | if (morphData.blendshapeData.deltaVertices != null) 35 | { 36 | scrollDeltaVertsPos = EditorGUILayout.BeginScrollView(scrollDeltaVertsPos, GUILayout.Height(400)); 37 | foreach (Vector3 v in morphData.blendshapeData.deltaVertices) 38 | { 39 | EditorGUILayout.BeginHorizontal(); 40 | EditorGUILayout.LabelField(i.ToString(), GUILayout.Width(50)); 41 | EditorGUILayout.Vector3Field("",v);//, GUILayout.Width(300)); 42 | EditorGUILayout.EndHorizontal(); 43 | 44 | i++; 45 | } 46 | EditorGUILayout.EndScrollView(); 47 | } 48 | 49 | 50 | GUILayout.Label("Delta Normals: " + (morphData.blendshapeData.deltaNormals != null ? morphData.blendshapeData.deltaNormals.Length.ToString() : "null")); 51 | if (morphData.blendshapeData.deltaNormals != null) 52 | { 53 | scrollDeltaNormalsPos = EditorGUILayout.BeginScrollView(scrollDeltaNormalsPos, GUILayout.Height(400)); 54 | i = 0; 55 | foreach (Vector3 v in morphData.blendshapeData.deltaNormals) 56 | { 57 | EditorGUILayout.BeginHorizontal(); 58 | EditorGUILayout.Vector3Field(i.ToString(), v);//, GUILayout.Width(300)); 59 | EditorGUILayout.EndHorizontal(); 60 | 61 | i++; 62 | } 63 | EditorGUILayout.EndScrollView(); 64 | } 65 | 66 | } 67 | catch 68 | { 69 | GUIStyle style = new GUIStyle(); 70 | style.normal.textColor = Color.red; 71 | GUILayout.Label("Can't parse morph file, it appears corrupted."); 72 | } 73 | } 74 | } 75 | 76 | 77 | 78 | [InitializeOnLoad] 79 | public class MCSMorphFileGlobal 80 | { 81 | private static MCSMorphFileWrapper wrapper = null; 82 | private static bool selectionChanged = false; 83 | 84 | static MCSMorphFileGlobal() 85 | { 86 | Selection.selectionChanged += SelectionChanged; 87 | EditorApplication.update += Update; 88 | } 89 | 90 | private static void SelectionChanged() 91 | { 92 | selectionChanged = true; 93 | // can't do the wrapper stuff here. it does not work 94 | // when you Selection.activeObject = wrapper 95 | // so do it in Update 96 | } 97 | 98 | private static void Update() 99 | { 100 | if (selectionChanged == false) return; 101 | 102 | selectionChanged = false; 103 | if (Selection.activeObject != wrapper) 104 | { 105 | if (Selection.objects.Length > 1) 106 | { 107 | //they have multiple files selected 108 | return; 109 | } 110 | 111 | Object[] objects = Selection.objects; 112 | int[] instanceIds = new int[objects.Length + 1]; 113 | Object[] newObjects = new Object[objects.Length + 1]; 114 | 115 | for (int i = 0; i < objects.Length; i++) 116 | { 117 | newObjects[i] = objects[i]; 118 | instanceIds[i] = objects[i].GetInstanceID(); 119 | } 120 | 121 | string fn = AssetDatabase.GetAssetPath(Selection.activeInstanceID); 122 | if (fn.ToLower().EndsWith(".morph")) 123 | { 124 | if (wrapper == null) 125 | { 126 | wrapper = ScriptableObject.CreateInstance(); 127 | wrapper.hideFlags = HideFlags.DontSave; 128 | } 129 | newObjects[objects.Length] = wrapper; 130 | instanceIds[objects.Length] = wrapper.GetInstanceID(); 131 | 132 | wrapper.fileName = fn; 133 | Selection.activeObject = wrapper; 134 | } 135 | } 136 | } 137 | } 138 | 139 | public class MCSMorphFileWrapper : ScriptableObject 140 | { 141 | [System.NonSerialized] 142 | public string fileName; // path is relative to Assets/ 143 | } 144 | -------------------------------------------------------------------------------- /Scripts/Editor/MCSResourceEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System.Collections; 4 | using MCS_Utilities; 5 | 6 | [CustomEditor(typeof(MCSResourceFileWrapper))] 7 | public class MCSResourceEditor : Editor { 8 | public override void OnInspectorGUI() 9 | { 10 | MCSResourceFileWrapper wrapper = (MCSResourceFileWrapper)target; 11 | 12 | GUILayout.Label(wrapper.fileName); 13 | 14 | try 15 | { 16 | MCSResource mr = new MCSResource(); 17 | mr.Read(wrapper.fileName); 18 | EditorGUILayout.BeginHorizontal(); 19 | GUILayout.Label("" + mr.header.Keys.Length + " entries"); 20 | EditorGUILayout.EndHorizontal(); 21 | 22 | EditorGUILayout.BeginHorizontal(); 23 | EditorGUILayout.LabelField("File",GUILayout.Width(250)); 24 | EditorGUILayout.LabelField("Size",GUILayout.Width(100)); 25 | EditorGUILayout.EndHorizontal(); 26 | for (int i = 0; i < mr.header.Keys.Length; i++) 27 | { 28 | EditorGUILayout.BeginHorizontal(); 29 | EditorGUILayout.TextField(mr.header.Keys[i],GUILayout.Width(250)); 30 | float kB = ((float)mr.header.Lengths[i]) / 1024f; 31 | EditorGUILayout.TextField(kB.ToString("F2") + "kB",GUILayout.Width(100)); 32 | bool export = GUILayout.Button("Export",GUILayout.Width(100)); 33 | if (export) 34 | { 35 | mr.UnpackResource(mr.header.Keys[i]); 36 | AssetDatabase.Refresh(); 37 | } 38 | EditorGUILayout.EndHorizontal(); 39 | } 40 | 41 | } catch 42 | { 43 | GUIStyle style = new GUIStyle(); 44 | style.normal.textColor = Color.red; 45 | GUILayout.Label("Can't parse resource file, it appears corrupted."); 46 | } 47 | } 48 | } 49 | 50 | 51 | 52 | [InitializeOnLoad] 53 | public class MCSResourceFileGlobal 54 | { 55 | private static MCSResourceFileWrapper wrapper = null; 56 | private static bool selectionChanged = false; 57 | 58 | static MCSResourceFileGlobal() 59 | { 60 | Selection.selectionChanged += SelectionChanged; 61 | EditorApplication.update += Update; 62 | } 63 | 64 | private static void SelectionChanged() 65 | { 66 | selectionChanged = true; 67 | // can't do the wrapper stuff here. it does not work 68 | // when you Selection.activeObject = wrapper 69 | // so do it in Update 70 | } 71 | 72 | private static void Update() 73 | { 74 | if (selectionChanged == false) return; 75 | 76 | selectionChanged = false; 77 | if (Selection.activeObject != wrapper) 78 | { 79 | if (Selection.objects.Length > 1) 80 | { 81 | //they have multiple files selected 82 | return; 83 | } 84 | 85 | Object[] objects = Selection.objects; 86 | int[] instanceIds = new int[objects.Length + 1]; 87 | Object[] newObjects = new Object[objects.Length + 1]; 88 | 89 | for(int i = 0; i < objects.Length; i++) 90 | { 91 | newObjects[i] = objects[i]; 92 | instanceIds[i] = objects[i].GetInstanceID(); 93 | } 94 | 95 | string fn = AssetDatabase.GetAssetPath(Selection.activeInstanceID); 96 | if (fn.ToLower().EndsWith(".mr")) 97 | { 98 | if (wrapper == null) 99 | { 100 | wrapper = ScriptableObject.CreateInstance(); 101 | wrapper.hideFlags = HideFlags.DontSave; 102 | } 103 | newObjects[objects.Length] = wrapper; 104 | instanceIds[objects.Length] = wrapper.GetInstanceID(); 105 | 106 | wrapper.fileName = fn; 107 | Selection.activeObject = wrapper; 108 | } 109 | } 110 | } 111 | } 112 | 113 | // M3DResourceFileWrapper.cs 114 | public class MCSResourceFileWrapper : ScriptableObject 115 | { 116 | [System.NonSerialized] 117 | public string fileName; // path is relative to Assets/ 118 | } 119 | -------------------------------------------------------------------------------- /Scripts/Editor/SearchableWindow.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | public class SearchableWindow : EditorWindow 5 | { 6 | private static SearchableWindow windowInstance; 7 | private static Vector2 _scroll; 8 | public delegate void SetResult(string newResult); 9 | 10 | private SetResult action; 11 | private string[] options; 12 | 13 | private string searchString = ""; 14 | 15 | public static void Init (SetResult action, string[] options) 16 | { 17 | if(SearchableWindow.windowInstance != null) 18 | SearchableWindow.windowInstance.Close(); 19 | 20 | windowInstance = EditorWindow.GetWindow (true, "Search Window", true); 21 | windowInstance.action = action; 22 | windowInstance.options = options; 23 | } 24 | 25 | void OnGUI () 26 | { 27 | EditorGUILayout.Space(); 28 | 29 | GUILayout.BeginHorizontal(GUI.skin.FindStyle("Toolbar")); 30 | searchString = GUILayout.TextField(searchString, GUI.skin.FindStyle("ToolbarSeachTextField")); 31 | if (GUILayout.Button("", GUI.skin.FindStyle("ToolbarSeachCancelButton"))) 32 | { 33 | searchString = ""; 34 | GUI.FocusControl(null); 35 | } 36 | GUILayout.EndHorizontal(); 37 | 38 | _scroll = EditorGUILayout.BeginScrollView(_scroll); 39 | EditorGUILayout.Space(); 40 | foreach(string option in options) 41 | { 42 | if(searchString != "" && option.IndexOf(searchString, System.StringComparison.OrdinalIgnoreCase) < 0) 43 | continue; 44 | GUILayout.BeginHorizontal(); 45 | 46 | string display = option; 47 | 48 | int pos = option.LastIndexOf("|"); 49 | if (pos >= 0) 50 | { 51 | display = option.Substring(0, pos); 52 | } 53 | 54 | EditorGUILayout.LabelField(display); 55 | if(GUILayout.Button("Select", GUILayout.Width(75))) 56 | { 57 | UnityEngine.Debug.Log("Selected: " + option); 58 | action(option); 59 | windowInstance.Close(); 60 | } 61 | GUILayout.FlexibleSpace(); 62 | GUILayout.EndHorizontal(); 63 | } 64 | EditorGUILayout.EndScrollView(); 65 | } 66 | 67 | void OnDestroy() 68 | { 69 | windowInstance = null; 70 | } 71 | 72 | void OnEnable() 73 | { 74 | windowInstance = this; 75 | } 76 | 77 | void OnInspectorUpdate() 78 | { 79 | Repaint(); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Scripts/Samples/AttachDetachClothing.cs: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * For reference only 3 | * Copyright MCS 2017 All Rights Reserved 4 | ***************************************************************/ 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | using UnityEngine; 8 | using MCS.COSTUMING; 9 | using MCS; 10 | 11 | /// 12 | /// Component class that can be attached to the root of an MCS figure. 13 | /// The component listens for input from the mouse 14 | /// and attaches or detaches clothing on click. 15 | /// 16 | public class AttachDetachClothing : MonoBehaviour 17 | { 18 | 19 | /// 20 | /// Array of CIclothing components or their GameObjects that we want to attach at runtime. 21 | /// This array must be populated in the Editor. 22 | /// 23 | public CIclothing[] clothing; 24 | 25 | //We will construct a ContentPack from the array of clothing 26 | private ContentPack cp; 27 | 28 | //Tracks whether the ContentPack cp is attached to our figure. 29 | private bool isAttached; 30 | 31 | //Reference to the CharacterManager component on our MCS Figure for convenenience. 32 | private MCSCharacterManager m_CharacterManager; 33 | 34 | // Use this for initialization 35 | void Start() 36 | { 37 | //Cnstruct an empty gameobject that we'll use to hold each of our CIclothing items clothing. 38 | GameObject go = new GameObject(); 39 | //Give the GameObject a name 40 | go.name = "Root"; 41 | //Disable it so we don't see it 42 | go.SetActive(false); 43 | 44 | //Loop through the array and set each GameObject in the array 45 | //As a child of our empty GameObject go 46 | for (int i = 0; i < clothing.Length; i++) 47 | { 48 | //Make sure element is no null 49 | if (clothing[i] == null) 50 | { 51 | continue; 52 | } 53 | //Instantiate the prefab references as GameObjects at the origin 54 | GameObject cloth = Instantiate(clothing[i].gameObject, new Vector3(0, 0, 0), Quaternion.identity) as GameObject; 55 | 56 | cloth.transform.SetParent(go.transform); 57 | } 58 | 59 | //We can now construct a single ContentPack that contains all of the clothing items in clothing. 60 | //The optional boolean parameter in the constructor allows us to clone the GameObject. It is 61 | //false by default. 62 | cp = new ContentPack(go); 63 | 64 | //Obtain a reference to the MCS figure's CharacterManager Component 65 | m_CharacterManager = GetComponent(); 66 | 67 | //Start out unattached 68 | isAttached = false; 69 | } 70 | 71 | // Update is called once per frame 72 | void Update() 73 | { 74 | 75 | //If the left mouse button was released 76 | if (Input.GetMouseButtonUp(0)) 77 | { 78 | //If the ContentPack is attached 79 | if (isAttached) 80 | { 81 | //Remove it and update our isAttached 82 | m_CharacterManager.RemoveContentPack(cp); 83 | isAttached = false; 84 | /* 85 | * Note the call to RemoveContentPack can be at times expensive if the GameObject is also destroyed. 86 | * It may be faster to toggle the visibility of the individual CIclothing items in the empty GameObject 87 | */ 88 | 89 | } 90 | else 91 | { 92 | //Otherwise add the ContetnPack to the CharacterManager 93 | m_CharacterManager.AddContentPack(cp); 94 | isAttached = true; 95 | 96 | } 97 | } 98 | } 99 | 100 | 101 | } 102 | -------------------------------------------------------------------------------- /Scripts/Samples/DisableAllClothing.cs: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * For reference only 3 | * Copyright MCS 2017 All Rights Reserved 4 | ***************************************************************/ 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using UnityEngine; 10 | using MCS; 11 | using MCS.COSTUMING; 12 | 13 | /// 14 | /// Component class that can be attached to an MCS figure. The Monobehavior uses the CharacterManager 15 | /// to disable all clothing attached to the CharacterManager on start. 16 | /// 17 | class DisableAllClothing : MonoBehaviour 18 | { 19 | 20 | //Use this for initializations 21 | public void Start() 22 | { 23 | //Get a reference to the CharacterManager component 24 | MCSCharacterManager m_CharacterManager = GetComponent(); 25 | 26 | //This call will update 27 | m_CharacterManager.DetectAttachedClothing(); 28 | //Iterate through each attached clothing item 29 | foreach (CIclothing item in m_CharacterManager.GetAllClothing()) 30 | { 31 | //Set the item's visibility to false. 32 | item.SetVisibility(false); 33 | } 34 | } 35 | 36 | //Update is called once per frame 37 | public void Update() 38 | { 39 | 40 | } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /Scripts/Samples/DriveMorph.cs: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * For reference only 3 | * Copyright MCS 2017 All Rights Reserved 4 | ***************************************************************/ 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | using UnityEngine; 8 | using MCS.FOUNDATIONS; 9 | using MCS; 10 | 11 | /// 12 | /// Component class to be attached to an MCS Figure. Attempts to drive the given 13 | /// Blendshape linearly from 0 to the given value over the period of 5 seconds. 14 | /// 15 | public class DriveMorph : MonoBehaviour 16 | { 17 | 18 | /// 19 | /// The localName of the morph we want to drive e.g. "FBMHeavy" 20 | /// 21 | public string MorphName; 22 | /// 23 | /// Maximum value of the morph we want to drive. 24 | /// Between 0 and 100 25 | /// 26 | public float MaxMorphValue; 27 | 28 | /// 29 | /// Read Only reference to the Morph that we will be driving 30 | /// 31 | private Morph morph; 32 | 33 | /// 34 | /// Did the user supplied MorphName map to a valid Morph? 35 | /// 36 | private bool exists; 37 | 38 | /// 39 | /// Reference to the CharacterManager 40 | /// 41 | private MCSCharacterManager m_CharacterManager; 42 | 43 | 44 | // Use this for initialization 45 | void Start() 46 | { 47 | //Get a reference to the CharacterManager 48 | m_CharacterManager = GetComponent(); 49 | 50 | /* 51 | * Attempt to get the Morph from the "User" supplied MorphName 52 | /* We access the CoreMorphs member of the CharacterManager. 53 | * From there we can get the morphLookup Dictionary that maps all possible MorphNames to their Morphs. 54 | */ 55 | exists = m_CharacterManager.coreMorphs.morphLookup.TryGetValue(MorphName, out morph); 56 | 57 | // Set the Morph (or blenddshape) value to 0 so we can drive starting from 0. 58 | m_CharacterManager.SetBlendshapeValue(morph.name, 0); 59 | 60 | 61 | } 62 | 63 | // Update is called once per frame 64 | void Update() 65 | { 66 | //If the blendshape name supplied by the user doesn't exist, we're done. 67 | if (!exists) 68 | { 69 | return; 70 | } 71 | 72 | //Calculate the delta for the morph value for this call to update 73 | float delta = (MaxMorphValue / 5) * Time.deltaTime; 74 | 75 | /* 76 | * Set the blendshape value to the current value + delta, or MaxMorphValue if the value is already there. 77 | * This could be optimized without the ternary expression so that unecessary code is not run. 78 | */ 79 | m_CharacterManager.SetBlendshapeValue(morph.name, 80 | morph.value >= MaxMorphValue ? MaxMorphValue : morph.value + delta); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Scripts/Samples/HairRandomizer.cs: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * For reference only 3 | * Copyright MCS 2017 All Rights Reserved 4 | ***************************************************************/ 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | using UnityEngine; 8 | using MCS; 9 | using MCS.COSTUMING; 10 | 11 | /// 12 | /// Component class that randomly selects and attaches a hair from a list of hair to an MCS figure. 13 | /// This component should be attached to an MCSFigure such as MCSMale or MCSFemale. 14 | /// The hair is chosen at start 15 | /// 16 | public class HairRandomizer : MonoBehaviour 17 | { 18 | /// 19 | /// Set in the Editor - an array of Hairs from which to choose. 20 | /// 21 | public CIhair[] Hairs; 22 | 23 | // Use this for initialization 24 | void Start() 25 | { 26 | //Check if Hairs is non empty 27 | if (Hairs.Length <= 0) 28 | { 29 | //If it's empty, we're done 30 | return; 31 | } 32 | 33 | //All of our logic is in the start method so we the reference to the CharacterManager can be local to the function. 34 | MCSCharacterManager m_CharacterManager = GetComponent(); 35 | 36 | //Detect any attached hair so we get the most recent list of hairs 37 | m_CharacterManager.DetectAttachedHair(); 38 | //Get all of the attached hair on the figure 39 | List attachedHairs = m_CharacterManager.GetAllHair(); 40 | //Iterate through each hair and disable it. 41 | foreach (CIhair hair in attachedHairs) 42 | { 43 | //Disable the hair 44 | hair.SetVisibility(false); 45 | } 46 | 47 | //Get a random valid index 48 | int rndIndex = Random.Range(0, Hairs.Length); 49 | //Instantiate as a GameObject (default at the origin) 50 | GameObject obj = Instantiate(Hairs[rndIndex].gameObject) as GameObject; 51 | //Create a ContentPack (without cloning) from obj. This is safe as obj is guaranteed to have a CostumeItem component class 52 | ContentPack cp = new ContentPack(obj, false); 53 | //Add the ContentPack to the figure 54 | m_CharacterManager.AddContentPack(cp); 55 | //Disable obj -- Could also destroy obj if space is needed 56 | obj.SetActive(false); 57 | } 58 | 59 | // Update is called once per frame 60 | void Update() 61 | { 62 | 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Scripts/Samples/SetMaterials.cs: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * For reference only 3 | * Copyright MCS 2017 All Rights Reserved 4 | ***************************************************************/ 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using UnityEngine; 9 | 10 | /// 11 | /// Component class that sets the Materials defined by the user as the Materials for 12 | /// each available LOD on an MCS figure. Should be attached to the root MCS Figure. 13 | /// 14 | /// Materials need to be set in the editor. Script does no checking for null references. 15 | /// Materials should use a MCS shader either StandardCharacterShader, or SkinDefferred 16 | /// Currently no checking to enforce this. 17 | /// 18 | public class SetMaterials : MonoBehaviour 19 | { 20 | /// 21 | /// A Material for the Head material slot. 22 | /// Should use either the MCS/VolundVariants/StandardCharacterShader or the 23 | /// MCS/SkinDeffered shader. 24 | /// 25 | public Material Mat_Head; 26 | /// 27 | /// A Material for the Body material slot. 28 | /// Should use either the MCS/VolundVariants/StandardCharacterShader or the 29 | /// MCS/SkinDeffered shader. 30 | /// 31 | public Material Mat_Body; 32 | /// 33 | /// A Material for the Eye and Lash material slot. 34 | /// Should use either the MCS/VolundVariants/StandardCharacterShader or the 35 | /// MCS/SkinDeffered shader. 36 | /// 37 | public Material Mat_EyeLash; 38 | 39 | public void Start() 40 | { 41 | //Loop through the Lods and set the materials 42 | //See FindLODS() below for how we find the LODs on the figure 43 | foreach (SkinnedMeshRenderer smr in FindLODS()) 44 | { 45 | //Create a new material array for the current LOD 46 | Material[] newMats = new Material[smr.materials.Length]; 47 | 48 | //LOD0 has a differnt material ordering so assign materials accordingly 49 | if (smr.name.EndsWith("ale_LOD0")) 50 | { 51 | //Assign Eye and Lash material 52 | newMats[0] = Mat_EyeLash; 53 | //Assign Body Material 54 | newMats[1] = Mat_Body; 55 | } 56 | else 57 | { 58 | //Assign body material 59 | newMats[0] = Mat_Body; 60 | //Assign eye and lash material 61 | newMats[1] = Mat_EyeLash; 62 | } 63 | //Assign head material 64 | newMats[2] = Mat_Head; 65 | 66 | //Assign the newMaterials array as the materials for the SkinnedMeshRenderer 67 | //We assign the entire array rather than individual materials because that is what Unity requires. 68 | smr.materials = newMats; 69 | } 70 | 71 | } 72 | 73 | /// 74 | /// Performs a smart breadth first search for the LODS of the figure 75 | /// and yields each one as it finds it. 76 | /// 77 | /// 78 | private IEnumerable FindLODS() 79 | { 80 | //Declare a transform curr that we'll use later 81 | Transform curr = null; 82 | //Loop through the chilren of the gameobject's transform until we find the transform we're looking for 83 | for (int i = 0; i < transform.childCount; i++) 84 | { 85 | //Get the current child 86 | curr = transform.GetChild(i); 87 | //if it's M3DMale or M3DFemale we're done 88 | if (curr.name.Equals("M3DMale") || curr.name.Equals("M3DFemale") 89 | || curr.name.Equals("MCSMale") || curr.name.Equals("MCSFemale")) 90 | { 91 | break; 92 | } 93 | } 94 | 95 | //If we've found the transform we're looking for curr will not be null 96 | //As long as this component is attached to the Root M3D figure curr will not be null 97 | if (!(curr == null)) 98 | { 99 | //Loop through curr's children. This is where we [should] find the LODs for hte figure. 100 | for (int i = 0; i < curr.childCount; i++) 101 | { 102 | //Get the current child 103 | Transform child = curr.GetChild(i); 104 | //If it is a LOD yield the SkinnedMeshRenderer component to the caller. 105 | if ( child.name.StartsWith("M3DMale_LOD") || child.name.StartsWith("M3DFemale_LOD") 106 | || child.name.StartsWith("MCSMale_LOD") || child.name.StartsWith("MCSFemale_LOD")) 107 | { 108 | yield return child.gameObject.GetComponent(); 109 | } 110 | } 111 | 112 | } 113 | 114 | 115 | } 116 | } 117 | 118 | -------------------------------------------------------------------------------- /Scripts/Scripts.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {938E0098-9E22-4AC1-86B6-EB3EEBB96DE0} 7 | Exe 8 | Scripts 9 | Scripts 10 | v3.5 11 | 1.7 12 | 13 | 14 | True 15 | full 16 | False 17 | bin\Debug 18 | DEBUG; 19 | prompt 20 | 4 21 | False 22 | 23 | 24 | none 25 | True 26 | bin\Release 27 | prompt 28 | 4 29 | False 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | {BB0EB3B1-241F-46BC-812A-1BAD99734ED7} 52 | MCS_Utilities 53 | 54 | 55 | {3981EBB4-7CD9-49DA-A3A4-2E971D77EF06} 56 | MCS_Importer 57 | 58 | 59 | {862CB436-4E0A-4AE6-BDF4-1A636878817B} 60 | MCS_Core 61 | 62 | 63 | 64 | 65 | 66 | ..\UnityDlls\5.3\UnityEditor.dll 67 | 68 | 69 | ..\UnityDlls\5.3\UnityEngine.dll 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /Shaders/AlphaCombiner.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | Shader "Unlit/AlphaCombiner" 4 | { 5 | Properties 6 | { 7 | _MainTex ("Texture", 2D) = "white" {} 8 | } 9 | SubShader 10 | { 11 | Tags { "Queue" = "Transparent" "RenderType"="Transparent" } 12 | LOD 100 13 | 14 | ZWrite Off 15 | Blend SrcAlpha OneMinusSrcAlpha 16 | 17 | Pass 18 | { 19 | CGPROGRAM 20 | 21 | #pragma vertex vert 22 | #pragma fragment frag 23 | #pragma target 2.0 24 | 25 | #include "UnityCG.cginc" 26 | 27 | struct appdata 28 | { 29 | float4 vertex : POSITION; 30 | float2 uv : TEXCOORD0; 31 | }; 32 | 33 | struct v2f 34 | { 35 | float2 uv : TEXCOORD0; 36 | float4 vertex : SV_POSITION; 37 | }; 38 | 39 | sampler2D _MainTex; 40 | float4 _MainTex_ST; 41 | 42 | v2f vert (appdata v) 43 | { 44 | v2f o; 45 | o.vertex = UnityObjectToClipPos(v.vertex); 46 | o.uv = TRANSFORM_TEX(v.uv, _MainTex); 47 | return o; 48 | } 49 | 50 | fixed4 frag (v2f i) : SV_Target 51 | { 52 | // sample the texture 53 | fixed4 col = tex2D(_MainTex, i.uv); 54 | 55 | float alpha = (col.r + col.g + col.b) / 3; 56 | col.a = 1 - alpha; 57 | 58 | return col; 59 | } 60 | ENDCG 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Shaders/EyeAndLash.shader: -------------------------------------------------------------------------------- 1 | Shader "MCS/EyeAndLash" { 2 | Properties { 3 | _Color ("Color", Color) = (1,1,1,1) 4 | _MainTex ("Albedo (RGB)", 2D) = "white" {} 5 | _Spread ("Spread", Range(0,128)) = 64 6 | } 7 | SubShader { 8 | Blend SrcAlpha OneMinusSrcAlpha 9 | ZWrite Off 10 | ZTest Less 11 | Tags { 12 | "IgnoreProjector" = "True" 13 | "Queue" = "Transparent" 14 | "RenderType"="Transparent" 15 | } 16 | 17 | LOD 200 18 | 19 | CGPROGRAM 20 | // Physically based Standard lighting model, and enable shadows on all light types 21 | #pragma surface surf EyeLight fullforwardshadows alpha:fade 22 | 23 | // Use shader model 3.0 target, to get nicer looking lighting 24 | #pragma target 3.0 25 | 26 | #include "UnityPBSLighting.cginc" 27 | 28 | sampler2D _MainTex; 29 | 30 | struct Input { 31 | float2 uv_MainTex; 32 | float3 viewDir; 33 | float3 lightDir; 34 | }; 35 | 36 | struct SurfOut { 37 | fixed3 Albedo; // base (diffuse or specular) color 38 | fixed3 Normal; // tangent space normal, if written 39 | half3 Emission; 40 | half Metallic; // 0=non-metal, 1=metal 41 | half Smoothness; // 0=rough, 1=smooth 42 | half Occlusion; // occlusion (default 1) 43 | fixed Alpha; // alpha for transparencies 44 | float3 lightDir; 45 | float3 viewDir; 46 | }; 47 | 48 | half _Spread; 49 | fixed4 _Color; 50 | 51 | //our custom light function that generates a highlight on the wet part of the eye 52 | half4 LightingEyeLight(SurfOut s, half3 lightDir, half3 viewDir, half atten) { 53 | half NdotL = dot(s.Normal, lightDir); 54 | half4 c; 55 | c.rgb = s.Albedo * _LightColor0.rgb * (NdotL * atten); 56 | c.a = s.Alpha; 57 | 58 | bool isEye = (s.Albedo.r + s.Albedo.g + s.Albedo.b ) > 2.7; 59 | 60 | //is this our eye or eyelash? 61 | if (isEye) { 62 | float3 halfAngle = normalize((normalize(lightDir) + normalize(viewDir))); 63 | half diff = max(0, dot(s.Normal, lightDir)); 64 | float nh = max(0, dot(s.Normal, halfAngle)); 65 | float rim = pow(nh, _Spread); 66 | if (rim > 0.5) { 67 | rim *= 1.5; 68 | } 69 | rim = saturate(rim); 70 | 71 | c.a = rim; 72 | } 73 | return c; 74 | } 75 | 76 | void surf (Input IN, inout SurfOut o) { 77 | fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; 78 | o.Albedo = c.rgb; 79 | o.Alpha = c.a; 80 | } 81 | ENDCG 82 | } 83 | FallBack "Diffuse" 84 | } 85 | -------------------------------------------------------------------------------- /Shaders/Hair/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b19490e311c518646b86556746d1ba79 3 | folderAsset: yes 4 | timeCreated: 1444336563 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shaders/Hair/Editor/HairShaderGUI.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 533e9f6d68a48294b87f6f89d8817b53 3 | timeCreated: 1432823189 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Shaders/Hair/EmptyClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace AssemblyCSharpEditor 4 | { 5 | public class EmptyClass 6 | { 7 | public EmptyClass () 8 | { 9 | } 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /Shaders/Hair/EmptyClass.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8709ead4560314391bf754cb24995861 3 | timeCreated: 1470350653 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Shaders/Hair/HairRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dd2968890be6eda4080e206094d11332 3 | timeCreated: 1424039794 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: -200 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Shaders/Hair/Hair_UnityStandardCore.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0cfa4cd13d905648a7c2b8be6f4c70d 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Shaders/Hair/Hair_UnityStandardInput.cginc: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_STANDARD_INPUT_INCLUDED 2 | #define UNITY_STANDARD_INPUT_INCLUDED 3 | 4 | // Volund Hair Rendering changes tagged begin-end-volund-hair 5 | 6 | #include "UnityCG.cginc" 7 | #include "UnityShaderVariables.cginc" 8 | #include "UnityStandardConfig.cginc" 9 | #include "UnityPBSLighting.cginc" // TBD: remove 10 | #include "UnityStandardUtils.cginc" 11 | 12 | //--------------------------------------- 13 | // Directional lightmaps & Parallax require tangent space too 14 | #if (_NORMALMAP || !DIRLIGHTMAP_OFF || _PARALLAXMAP) 15 | #define _TANGENT_TO_WORLD 1 16 | #endif 17 | 18 | #if (_DETAIL_MULX2 || _DETAIL_MUL || _DETAIL_ADD || _DETAIL_LERP) 19 | #define _DETAIL 1 20 | #endif 21 | 22 | //--------------------------------------- 23 | half4 _Color; 24 | half _Cutoff; 25 | 26 | sampler2D _MainTex; 27 | float4 _MainTex_ST; 28 | 29 | sampler2D _DetailAlbedoMap; 30 | float4 _DetailAlbedoMap_ST; 31 | 32 | sampler2D _BumpMap; 33 | half _BumpScale; 34 | 35 | sampler2D _DetailMask; 36 | sampler2D _DetailNormalMap; 37 | half _DetailNormalMapScale; 38 | 39 | sampler2D _SpecGlossMap; 40 | sampler2D _MetallicGlossMap; 41 | half _Metallic; 42 | half _Glossiness; 43 | 44 | sampler2D _OcclusionMap; 45 | half _OcclusionStrength; 46 | 47 | sampler2D _ParallaxMap; 48 | half _Parallax; 49 | half _UVSec; 50 | 51 | half4 _EmissionColor; 52 | sampler2D _EmissionMap; 53 | 54 | //------------------------------------------------------------------------------------- 55 | // Input functions 56 | 57 | struct VertexInput 58 | { 59 | float4 vertex : POSITION; 60 | half3 normal : NORMAL; 61 | float2 uv0 : TEXCOORD0; 62 | float2 uv1 : TEXCOORD1; 63 | #if defined(DYNAMICLIGHTMAP_ON) || defined(UNITY_PASS_META) 64 | float2 uv2 : TEXCOORD2; 65 | #endif 66 | #ifdef _TANGENT_TO_WORLD 67 | half4 tangent : TANGENT; 68 | #endif 69 | 70 | //begin-volund-hair: Bind vertex color attribute 71 | float4 color : COLOR; 72 | //end-volund-hair: 73 | }; 74 | 75 | float4 TexCoords(VertexInput v) 76 | { 77 | float4 texcoord; 78 | texcoord.xy = TRANSFORM_TEX(v.uv0, _MainTex); // Always source from uv0 79 | texcoord.zw = TRANSFORM_TEX(((_UVSec == 0) ? v.uv0 : v.uv1), _DetailAlbedoMap); 80 | return texcoord; 81 | } 82 | 83 | half DetailMask(float2 uv) 84 | { 85 | return tex2D (_DetailMask, uv).a; 86 | } 87 | 88 | half3 Albedo(float4 texcoords) 89 | { 90 | half3 albedo = _Color.rgb * tex2D (_MainTex, texcoords.xy).rgb; 91 | #if _DETAIL 92 | #if (SHADER_TARGET < 30) 93 | // SM20: instruction count limitation 94 | // SM20: no detail mask 95 | half mask = 1; 96 | #else 97 | half mask = DetailMask(texcoords.xy); 98 | #endif 99 | half3 detailAlbedo = tex2D (_DetailAlbedoMap, texcoords.zw).rgb; 100 | #if _DETAIL_MULX2 101 | albedo *= LerpWhiteTo (detailAlbedo * unity_ColorSpaceDouble.rgb, mask); 102 | #elif _DETAIL_MUL 103 | albedo *= LerpWhiteTo (detailAlbedo, mask); 104 | #elif _DETAIL_ADD 105 | albedo += detailAlbedo * mask; 106 | #elif _DETAIL_LERP 107 | albedo = lerp (albedo, detailAlbedo, mask); 108 | #endif 109 | #endif 110 | return albedo; 111 | } 112 | 113 | half Alpha(float2 uv) 114 | { 115 | return tex2D(_MainTex, uv).a * _Color.a; 116 | } 117 | 118 | half Occlusion(float2 uv) 119 | { 120 | #if (SHADER_TARGET < 30) 121 | // SM20: instruction count limitation 122 | // SM20: simpler occlusion 123 | return tex2D(_OcclusionMap, uv).g; 124 | #else 125 | half occ = tex2D(_OcclusionMap, uv).g; 126 | return LerpOneTo (occ, _OcclusionStrength); 127 | #endif 128 | } 129 | 130 | half4 SpecularGloss(float2 uv) 131 | { 132 | half4 sg; 133 | #ifdef _SPECGLOSSMAP 134 | sg = tex2D(_SpecGlossMap, uv.xy); 135 | #else 136 | sg = half4(_SpecColor.rgb, _Glossiness); 137 | #endif 138 | return sg; 139 | } 140 | 141 | half2 MetallicGloss(float2 uv) 142 | { 143 | half2 mg; 144 | #ifdef _METALLICGLOSSMAP 145 | mg = tex2D(_MetallicGlossMap, uv.xy).ra; 146 | #else 147 | mg = half2(_Metallic, _Glossiness); 148 | #endif 149 | return mg; 150 | } 151 | 152 | half3 Emission(float2 uv) 153 | { 154 | #ifndef _EMISSION 155 | return 0; 156 | #else 157 | return tex2D(_EmissionMap, uv).rgb * _EmissionColor.rgb; 158 | #endif 159 | } 160 | 161 | #ifdef _NORMALMAP 162 | half3 NormalInTangentSpace(float4 texcoords) 163 | { 164 | half3 normalTangent = UnpackScaleNormal(tex2D (_BumpMap, texcoords.xy), _BumpScale); 165 | // SM20: instruction count limitation 166 | // SM20: no detail normalmaps 167 | #if _DETAIL && !defined(SHADER_API_MOBILE) && (SHADER_TARGET >= 30) 168 | half mask = DetailMask(texcoords.xy); 169 | half3 detailNormalTangent = UnpackScaleNormal(tex2D (_DetailNormalMap, texcoords.zw), _DetailNormalMapScale); 170 | #if _DETAIL_LERP 171 | normalTangent = lerp( 172 | normalTangent, 173 | detailNormalTangent, 174 | mask); 175 | #else 176 | normalTangent = lerp( 177 | normalTangent, 178 | BlendNormals(normalTangent, detailNormalTangent), 179 | mask); 180 | #endif 181 | #endif 182 | return normalTangent; 183 | } 184 | #endif 185 | 186 | float4 Parallax (float4 texcoords, half3 viewDir) 187 | { 188 | #if !defined(_PARALLAXMAP) || (SHADER_TARGET < 30) 189 | // SM20: instruction count limitation 190 | // SM20: no parallax 191 | return texcoords; 192 | #else 193 | half h = tex2D (_ParallaxMap, texcoords.xy).g; 194 | float2 offset = ParallaxOffset1Step (h, _Parallax, viewDir); 195 | return float4(texcoords.xy + offset, texcoords.zw + offset); 196 | #endif 197 | } 198 | 199 | #endif // UNITY_STANDARD_INPUT_INCLUDED 200 | -------------------------------------------------------------------------------- /Shaders/Hair/Hair_UnityStandardInput.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8e3ef04cacfeab4393b32656997db66 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Shaders/Hair/Hair_Universal.shader: -------------------------------------------------------------------------------- 1 | Shader "Morph3D/Volund Variants/Standard Hair" 2 | { 3 | Properties 4 | { 5 | _Color("Color", Color) = (1,1,1,1) 6 | _MainTex("Albedo", 2D) = "white" {} 7 | 8 | _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 9 | 10 | _Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5 11 | _SpecColor("Specular", Color) = (0.2,0.2,0.2) 12 | _SpecGlossMap("Specular", 2D) = "white" {} 13 | 14 | _BumpScale("Scale", Float) = 1.0 15 | _BumpMap("Normal Map", 2D) = "bump" {} 16 | 17 | _Parallax ("Height Scale", Range (0.005, 0.08)) = 0.02 18 | _ParallaxMap ("Height Map", 2D) = "black" {} 19 | 20 | _OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0 21 | _OcclusionMap("Occlusion", 2D) = "white" {} 22 | 23 | _EmissionColor("Color", Color) = (0,0,0) 24 | _EmissionMap("Emission", 2D) = "white" {} 25 | 26 | _DetailMask("Detail Mask", 2D) = "white" {} 27 | 28 | _DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {} 29 | _DetailNormalMapScale("Scale", Float) = 1.0 30 | _DetailNormalMap("Normal Map", 2D) = "bump" {} 31 | 32 | [Enum(UV0,0,UV1,1)] _UVSec ("UV Set for secondary textures", Float) = 0 33 | 34 | _KKFlowMap("KK FlowMap", 2D) = "white" {} 35 | _KKReflectionSmoothness("KK Reflective Smoothness", Range(0.0, 1.0)) = 0.5 36 | _KKReflectionGrayScale("KK Reflective Gray Scale", Range(0.0, 48.0)) = 5.0 37 | _KKPrimarySpecularColor("KK Primary Specular Color", Color) = (1.0, 1.0, 1.0) 38 | _KKPrimarySpecularExponent("KK Primary Exponent", Range(1.0, 192.0)) = 64.0 39 | _KKPrimaryRootShift("KK Primary Root Shift", Range(-1.0, 1.0)) = 0.275 40 | _KKSecondarySpecularColor("KK Secondary Specular Color", Color) = (1.0, 1.0, 1.0) 41 | _KKSecondarySpecularExponent("KK Secondary Exponent", Range(1.0, 192.0)) = 48.0 42 | _KKSecondaryRootShift("KK Secondary Root Shift", Range(-1.0, 1.0)) = -0.040 43 | _KKSpecularMixDirectFactors("KK Spec Mix Direct Factors", Vector) = (0.15, 0.10, 0.05, 0) 44 | _KKSpecularMixIndirectFactors("KK Spec Mix Indirect Factors", Vector) = (0.75, 0.60, 0.15, 0) 45 | 46 | [HideInInspector] _SrcBlend ("__src", Float) = 5.0 47 | [HideInInspector] _DstBlend ("__dst", Float) = 10.0 48 | [HideInInspector] _ZWrite ("__zw", Float) = 1.0 49 | [HideInInspector] _ZTest ("__zt", Float) = 4.0 50 | [HideInInspector] _Cull ("__cull", Float) = 0.0 51 | } 52 | 53 | CGINCLUDE 54 | #define UNITY_SETUP_BRDF_INPUT SpecularSetup 55 | ENDCG 56 | 57 | SubShader 58 | { 59 | Tags { "Special"="Hair" "RenderType"="Transparent" "PerformanceChecks"="False" } 60 | 61 | // Low LOD level since there's no meaningful fallback. 62 | LOD 150 63 | 64 | // ------------------------------------------------------------------ 65 | // Base forward pass (directional light, emission, lightmaps, ...) 66 | Pass 67 | { 68 | Name "FORWARD" 69 | Tags { "LightMode" = "ForwardBase" } 70 | 71 | Blend [_SrcBlend] [_DstBlend] 72 | ZWrite [_ZWrite] 73 | ZTest [_ZTest] 74 | Cull [_Cull] 75 | 76 | CGPROGRAM 77 | #pragma target 3.5 78 | 79 | #pragma only_renderers d3d11 d3d9 opengl 80 | 81 | #pragma shader_feature _NORMALMAP 82 | #pragma multi_compile _ _ALPHATEST_ON 83 | #pragma multi_compile _ _ALPHABLEND_ON 84 | #pragma multi_compile _ _UNITY_5_4 85 | #pragma shader_feature _EMISSIONMAP 86 | #pragma shader_feature _SPECGLOSSMAP 87 | #pragma shader_feature ___ _DETAIL_MULX2 88 | //NEVER ON shader_feature _PARALLAXMAP 89 | 90 | #pragma multi_compile_fwdbase 91 | #pragma multi_compile_fog 92 | 93 | // Volund variants 94 | // (these debug variants should only be active in Editor, but there's currently no automatic 95 | // way of defining variants for editor-only) 96 | #pragma multi_compile DBG_NONE DBG_OCCLUSION DBG_GRAYMASK DBG_MASKEDALBEDO DBG_SPECULAR DBG_LIGHTING DBG_FLOW 97 | 98 | #pragma vertex vertForwardBase 99 | #pragma fragment fragForwardBase 100 | 101 | #include "Hair_setup.cginc" 102 | 103 | ENDCG 104 | } 105 | // ------------------------------------------------------------------ 106 | // Additive forward pass (one light per pass) 107 | Pass 108 | { 109 | Name "FORWARD_DELTA" 110 | Tags { "LightMode" = "ForwardAdd" } 111 | Blend [_SrcBlend] One 112 | ZWrite Off 113 | ZTest [_ZTest] 114 | Cull [_Cull] 115 | 116 | CGPROGRAM 117 | #pragma target 3.5 118 | 119 | #pragma only_renderers d3d11 d3d9 opengl 120 | 121 | #pragma shader_feature _NORMALMAP 122 | #pragma multi_compile _ _ALPHATEST_ON _ALPHABLEND_ON 123 | #pragma multi_compile _ _UNITY_5_4 124 | #pragma shader_feature _SPECGLOSSMAP 125 | #pragma shader_feature ___ _DETAIL_MULX2 126 | //NEVER ON shader_feature _PARALLAXMAP 127 | 128 | #pragma multi_compile_fwdadd_fullshadows 129 | #pragma multi_compile_fog 130 | 131 | // Volund variants 132 | #define DBG_NONE 133 | #define ADDITIVE_PASS 134 | 135 | #pragma vertex vertForwardAdd 136 | #pragma fragment fragForwardAdd 137 | 138 | #include "Hair_setup.cginc" 139 | 140 | ENDCG 141 | } 142 | // ------------------------------------------------------------------ 143 | // Shadow rendering pass 144 | Pass { 145 | Name "ShadowCaster" 146 | Tags { "LightMode" = "ShadowCaster" } 147 | 148 | ZWrite On ZTest LEqual 149 | 150 | CGPROGRAM 151 | #pragma target 3.5 152 | 153 | #pragma only_renderers d3d11 d3d9 opengl 154 | 155 | #define UNITY_BRDF_PBS BRDF1_Unity_PBS_KK 156 | 157 | #pragma multi_compile _ _ALPHATEST_ON _ALPHABLEND_ON 158 | #pragma multi_compile_shadowcaster 159 | #pragma multi_compile _ _UNITY_5_4 160 | 161 | #pragma vertex vertShadowCaster 162 | #pragma fragment fragShadowCaster 163 | 164 | #include "UnityStandardShadow.cginc" 165 | 166 | ENDCG 167 | } 168 | } 169 | 170 | FallBack "Morph3D/Volund Variants/Standard Hair Legacy" 171 | } 172 | 173 | -------------------------------------------------------------------------------- /Shaders/Hair/Hair_Universal.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dcae2dc1955704241a291fe478f50de8 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Shaders/Hair/Hair_Universal_GL2.shader: -------------------------------------------------------------------------------- 1 | Shader "Morph3D/Volund Variants/Standard Hair Legacy" 2 | { 3 | Properties 4 | { 5 | _Color("Color", Color) = (1,1,1,1) 6 | _MainTex("Albedo", 2D) = "white" {} 7 | 8 | _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 9 | 10 | _Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5 11 | _SpecColor("Specular", Color) = (0.2,0.2,0.2) 12 | _SpecGlossMap("Specular", 2D) = "white" {} 13 | 14 | _BumpScale("Scale", Float) = 1.0 15 | _BumpMap("Normal Map", 2D) = "bump" {} 16 | 17 | _Parallax ("Height Scale", Range (0.005, 0.08)) = 0.02 18 | _ParallaxMap ("Height Map", 2D) = "black" {} 19 | 20 | _OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0 21 | _OcclusionMap("Occlusion", 2D) = "white" {} 22 | 23 | _EmissionColor("Color", Color) = (0,0,0) 24 | _EmissionMap("Emission", 2D) = "white" {} 25 | 26 | _DetailMask("Detail Mask", 2D) = "white" {} 27 | 28 | _DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {} 29 | _DetailNormalMapScale("Scale", Float) = 1.0 30 | _DetailNormalMap("Normal Map", 2D) = "bump" {} 31 | 32 | [Enum(UV0,0,UV1,1)] _UVSec ("UV Set for secondary textures", Float) = 0 33 | 34 | _KKFlowMap("KK FlowMap", 2D) = "white" {} 35 | _KKReflectionSmoothness("KK Reflective Smoothness", Range(0.0, 1.0)) = 0.5 36 | _KKReflectionGrayScale("KK Reflective Gray Scale", Range(0.0, 48.0)) = 5.0 37 | _KKPrimarySpecularColor("KK Primary Specular Color", Color) = (1.0, 1.0, 1.0) 38 | _KKPrimarySpecularExponent("KK Primary Exponent", Range(1.0, 192.0)) = 64.0 39 | _KKPrimaryRootShift("KK Primary Root Shift", Range(-1.0, 1.0)) = 0.275 40 | _KKSecondarySpecularColor("KK Secondary Specular Color", Color) = (1.0, 1.0, 1.0) 41 | _KKSecondarySpecularExponent("KK Secondary Exponent", Range(1.0, 192.0)) = 48.0 42 | _KKSecondaryRootShift("KK Secondary Root Shift", Range(-1.0, 1.0)) = -0.040 43 | _KKSpecularMixDirectFactors("KK Spec Mix Direct Factors", Vector) = (0.15, 0.10, 0.05, 0) 44 | _KKSpecularMixIndirectFactors("KK Spec Mix Indirect Factors", Vector) = (0.75, 0.60, 0.15, 0) 45 | 46 | [HideInInspector] _SrcBlend ("__src", Float) = 5.0 47 | [HideInInspector] _DstBlend ("__dst", Float) = 10.0 48 | [HideInInspector] _ZWrite ("__zw", Float) = 1.0 49 | [HideInInspector] _ZTest ("__zt", Float) = 4.0 50 | [HideInInspector] _Cull ("__cull", Float) = 0.0 51 | } 52 | 53 | CGINCLUDE 54 | #define UNITY_SETUP_BRDF_INPUT SpecularSetup 55 | ENDCG 56 | 57 | SubShader 58 | { 59 | Tags { "Special"="Hair" "RenderType"="Transparent" "PerformanceChecks"="False" } 60 | 61 | // Low LOD level since there's no meaningful fallback. 62 | LOD 150 63 | 64 | // ------------------------------------------------------------------ 65 | // Base forward pass (directional light, emission, lightmaps, ...) 66 | Pass 67 | { 68 | Name "FORWARD" 69 | Tags { "LightMode" = "ForwardBase" } 70 | 71 | Blend [_SrcBlend] [_DstBlend] 72 | ZWrite [_ZWrite] 73 | ZTest [_ZTest] 74 | Cull [_Cull] 75 | 76 | CGPROGRAM 77 | #pragma target 2.5 78 | #pragma only_renderers d3d11 d3d9 opengl glcore gles gles3 metal 79 | 80 | #pragma shader_feature _NORMALMAP 81 | #pragma multi_compile _ _ALPHATEST_ON 82 | #pragma multi_compile _ _ALPHABLEND_ON 83 | #pragma multi_compile _ _UNITY_5_4 84 | #pragma shader_feature _EMISSIONMAP 85 | #pragma shader_feature _SPECGLOSSMAP 86 | #pragma shader_feature ___ _DETAIL_MULX2 87 | //NEVER ON shader_feature _PARALLAXMAP 88 | 89 | #pragma multi_compile_fwdbase 90 | #pragma multi_compile_fog 91 | 92 | // Volund variants 93 | // (these debug variants should only be active in Editor, but there's currently no automatic 94 | // way of defining variants for editor-only) 95 | #pragma multi_compile DBG_NONE DBG_OCCLUSION DBG_GRAYMASK DBG_MASKEDALBEDO DBG_SPECULAR DBG_LIGHTING DBG_FLOW 96 | 97 | #pragma vertex vertForwardBase 98 | #pragma fragment fragForwardBase 99 | 100 | #include "Hair_setup.cginc" 101 | 102 | ENDCG 103 | } 104 | // ------------------------------------------------------------------ 105 | // Additive forward pass (one light per pass) 106 | Pass 107 | { 108 | Name "FORWARD_DELTA" 109 | Tags { "LightMode" = "ForwardAdd" } 110 | Blend [_SrcBlend] One 111 | ZWrite Off 112 | ZTest [_ZTest] 113 | Cull [_Cull] 114 | 115 | CGPROGRAM 116 | #pragma target 2.5 117 | 118 | #pragma only_renderers d3d11 d3d9 opengl glcore gles gles3 metal 119 | 120 | #pragma shader_feature _NORMALMAP 121 | #pragma multi_compile _ _ALPHATEST_ON _ALPHABLEND_ON 122 | #pragma multi_compile _ _UNITY_5_4 123 | #pragma shader_feature _SPECGLOSSMAP 124 | #pragma shader_feature ___ _DETAIL_MULX2 125 | //NEVER ON shader_feature _PARALLAXMAP 126 | 127 | #pragma multi_compile_fwdadd_fullshadows 128 | #pragma multi_compile_fog 129 | 130 | // Volund variants 131 | #define DBG_NONE 132 | #define ADDITIVE_PASS 133 | 134 | #pragma vertex vertForwardAdd 135 | #pragma fragment fragForwardAdd 136 | 137 | #include "Hair_setup.cginc" 138 | 139 | ENDCG 140 | } 141 | // ------------------------------------------------------------------ 142 | // Shadow rendering pass 143 | Pass { 144 | Name "ShadowCaster" 145 | Tags { "LightMode" = "ShadowCaster" } 146 | 147 | ZWrite On ZTest LEqual 148 | 149 | CGPROGRAM 150 | #pragma target 2.5 151 | 152 | #pragma only_renderers d3d11 d3d9 opengl glcore gles gles3 metal 153 | 154 | #define UNITY_BRDF_PBS BRDF1_Unity_PBS_KK 155 | 156 | #pragma multi_compile _ _ALPHATEST_ON _ALPHABLEND_ON 157 | #pragma multi_compile_shadowcaster 158 | #pragma multi_compile _ _UNITY_5_4 159 | 160 | #pragma vertex vertShadowCaster 161 | #pragma fragment fragShadowCaster 162 | 163 | #include "UnityStandardShadow.cginc" 164 | 165 | ENDCG 166 | } 167 | } 168 | 169 | FallBack Off 170 | } 171 | 172 | -------------------------------------------------------------------------------- /Shaders/Hair/Hair_Universal_GL2.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5381f4d7a185049b28c55f9e654d07eb 3 | timeCreated: 1470350656 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shaders/Hair/Hair_setup.cginc: -------------------------------------------------------------------------------- 1 | #ifndef FILE_HAIR_SETUP_CGINC 2 | #define FILE_HAIR_SETUP_CGINC 3 | 4 | #include "Hair_UnityStandardInput.cginc" 5 | 6 | #include "UnityCG.cginc" 7 | #include "Lighting.cginc" 8 | 9 | sampler2D _KKFlowMap; 10 | half _KKReflectionSmoothness; 11 | half _KKReflectionGrayScale; 12 | half4 _KKPrimarySpecularColor; 13 | half _KKPrimarySpecularExponent; 14 | half _KKPrimaryRootShift; 15 | half4 _KKSecondarySpecularColor; 16 | half _KKSecondarySpecularExponent; 17 | half _KKSecondaryRootShift; 18 | half3 _KKSpecularMixDirectFactors; 19 | half3 _KKSpecularMixIndirectFactors; 20 | 21 | half KKDiffuseApprox(half3 normal, half3 lightDir) { 22 | return max(0.f, dot(normal, lightDir) * 0.75f + 0.25f); 23 | } 24 | 25 | half3 BRDF_Unity_KK_ish(half3 baseColor, half3 specColor, half reflectivity, half roughness, half3 normal, half3 normalVertex, half3 viewDir, UnityLight light, UnityIndirect indirect, half3 specGI, half3 tanDir1, half3 tanDir2, half occlusion, half atten) { 26 | half3 halfDir = normalize (light.dir + viewDir); 27 | half nl = light.ndotl; 28 | half nh = BlinnTerm (normal, halfDir); 29 | half sp = RoughnessToSpecPower (roughness); 30 | 31 | half diffuseTerm = nl; 32 | half specularTerm = pow(nh, sp); 33 | 34 | // Poor man's KK. Not physically correct. 35 | half th1 = dot(tanDir1, halfDir); 36 | half th2 = dot(tanDir2, halfDir); 37 | 38 | half3 kkSpecTermPrimary = pow(sqrt(1.f - th1 * th1), _KKPrimarySpecularExponent) * _KKPrimarySpecularColor.rgb; 39 | half3 kkSpecTermSecondary = pow(sqrt(1.f - th2 * th2), _KKSecondarySpecularExponent) * _KKSecondarySpecularColor.rgb; 40 | half3 kkSpecTermBlinn = specularTerm * specColor; 41 | 42 | half kkDirectFactor = min(1.f, Luminance(indirect.diffuse) + nl * atten); 43 | _KKSpecularMixDirectFactors *= kkDirectFactor; 44 | 45 | half3 kkSpecTermDirect = kkSpecTermPrimary * _KKSpecularMixDirectFactors.x 46 | + kkSpecTermSecondary * _KKSpecularMixDirectFactors.y 47 | + kkSpecTermBlinn * _KKSpecularMixDirectFactors.z; 48 | kkSpecTermDirect *= light.color; 49 | 50 | half3 kkSpecTermIndirect = kkSpecTermPrimary * _KKSpecularMixIndirectFactors.x 51 | + kkSpecTermSecondary * _KKSpecularMixIndirectFactors.y 52 | + kkSpecTermBlinn * _KKSpecularMixIndirectFactors.z; 53 | kkSpecTermIndirect *= specGI; 54 | 55 | #ifdef DBG_LIGHTING 56 | baseColor = 0.5f; 57 | #endif 58 | #ifdef DBG_SPECULAR 59 | baseColor = 0; 60 | #endif 61 | 62 | half3 diffuseColor = baseColor; 63 | half3 color = half3(0.f, 0.f, 0.f); 64 | color += baseColor * (indirect.diffuse + light.color * diffuseTerm); 65 | color += (kkSpecTermIndirect + kkSpecTermDirect) * occlusion; 66 | 67 | return color; 68 | } 69 | 70 | // We'll use this for now, but we're really just wasting performance 71 | // including a full PBS setup and then throwing most of it away. 72 | // 73 | // For the time being, this is a convenient way of keeping up with enlighten and material 74 | // setup changes, though. (We still need quite a few modifications to inject ourselves into it) 75 | #include "Hair_UnityStandardCore.cginc" 76 | 77 | #endif // FILE_HAIR_SETUP_CGINC 78 | -------------------------------------------------------------------------------- /Shaders/Hair/Hair_setup.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0074fdb10e515f46afe7ce69264b7ad 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Shaders/Skin/BaseShader.shader: -------------------------------------------------------------------------------- 1 | Shader "Custom/BaseShader" { 2 | Properties { 3 | _Color ("Color", Color) = (1,1,1,1) 4 | _MainTex ("Albedo (RGB)", 2D) = "white" {} 5 | _Glossiness ("Smoothness", Range(0,1)) = 0.5 6 | _Metallic ("Metallic", Range(0,1)) = 0.0 7 | } 8 | SubShader { 9 | Tags { "RenderType"="Opaque" } 10 | LOD 200 11 | 12 | CGPROGRAM 13 | // Physically based Standard lighting model, and enable shadows on all light types 14 | #pragma surface surf Standard fullforwardshadows 15 | 16 | // Use shader model 3.0 target, to get nicer looking lighting 17 | #pragma target 3.0 18 | 19 | sampler2D _MainTex; 20 | 21 | struct Input { 22 | float2 uv_MainTex; 23 | }; 24 | 25 | half _Glossiness; 26 | half _Metallic; 27 | fixed4 _Color; 28 | 29 | void surf (Input IN, inout SurfaceOutputStandard o) { 30 | // Albedo comes from a texture tinted by color 31 | fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; 32 | o.Albedo = c.rgb; 33 | // Metallic and smoothness come from slider variables 34 | o.Metallic = _Metallic; 35 | o.Smoothness = _Glossiness; 36 | o.Alpha = c.a; 37 | } 38 | ENDCG 39 | } 40 | FallBack "Diffuse" 41 | } 42 | -------------------------------------------------------------------------------- /Shaders/Skin/BaseShader.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cfacdd83a700f407aa3f16b999561f4a 3 | timeCreated: 1470424842 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shaders/Skin/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 54718ce59fd935b4784208f10d7e9ff3 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Shaders/Skin/Editor/VolundMultiStandardShaderGUI.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3411982f28b52934a8f75a7b4445c61d 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Shaders/Skin/NormalShader.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | Shader "Unlit/NormalShader" 4 | { 5 | Properties 6 | { 7 | _MainTex ("Texture", 2D) = "white" {} 8 | } 9 | SubShader 10 | { 11 | Tags { "RenderType"="Opaque" } 12 | LOD 100 13 | 14 | Pass 15 | { 16 | CGPROGRAM 17 | #pragma vertex vert 18 | #pragma fragment frag 19 | // make fog work 20 | #pragma multi_compile_fog 21 | 22 | #include "UnityCG.cginc" 23 | 24 | struct appdata 25 | { 26 | float4 vertex : POSITION; 27 | float2 uv : TEXCOORD0; 28 | }; 29 | 30 | struct v2f 31 | { 32 | float2 uv : TEXCOORD0; 33 | UNITY_FOG_COORDS(1) 34 | float4 vertex : SV_POSITION; 35 | }; 36 | 37 | sampler2D _MainTex; 38 | float4 _MainTex_ST; 39 | 40 | v2f vert (appdata v) 41 | { 42 | v2f o; 43 | o.vertex = UnityObjectToClipPos(v.vertex); 44 | o.uv = TRANSFORM_TEX(v.uv, _MainTex); 45 | UNITY_TRANSFER_FOG(o,o.vertex); 46 | return o; 47 | } 48 | 49 | fixed4 frag (v2f i) : SV_Target 50 | { 51 | // sample the texture 52 | fixed4 col = tex2D(_MainTex, i.uv); 53 | // apply fog 54 | UNITY_APPLY_FOG(i.fogCoord, col); 55 | return col; 56 | } 57 | ENDCG 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Shaders/Skin/NormalShader.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: baedc009bc5484cc798d2dc337e915a3 3 | timeCreated: 1470424863 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shaders/Skin/Volund_StandardSpecularCharacter.shader: -------------------------------------------------------------------------------- 1 | Shader "MCS/Volund Variants/Standard Character (Specular, Surface)" 2 | { 3 | Properties 4 | { 5 | _Color("Color", Color) = (1,1,1,1) 6 | _MainTex("Albedo", 2D) = "white" {} 7 | _AlphaTex("Alpha", 2D) = "white" {} 8 | 9 | _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 10 | 11 | _Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5 12 | _SpecColor("Specular", Color) = (0.2,0.2,0.2) 13 | _SpecGlossMap("Specular", 2D) = "white" {} 14 | 15 | _BumpScale("Scale", Float) = 1.0 16 | _BumpMap("Normal Map", 2D) = "bump" {} 17 | 18 | _Parallax ("Height Scale", Range (0.005, 0.08)) = 0.02 19 | _ParallaxMap ("Height Map", 2D) = "black" {} 20 | 21 | _OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0 22 | _OcclusionMap("Occlusion", 2D) = "white" {} 23 | 24 | _EmissionColor("Color", Color) = (0,0,0) 25 | _EmissionMap("Emission", 2D) = "white" {} 26 | 27 | _DetailMask("Detail Mask", 2D) = "white" {} 28 | 29 | _DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {} 30 | _DetailNormalMapScale("Scale", Float) = 1.0 31 | _DetailNormalMap("Normal Map", 2D) = "bump" {} 32 | 33 | [Enum(UV0,0,UV1,1)] _UVSec ("UV Set for secondary textures", Float) = 0 34 | 35 | // UI-only data 36 | [HideInInspector] _EmissionScaleUI("Scale", Float) = 0.0 37 | [HideInInspector] _EmissionColorUI("Color", Color) = (1,1,1) 38 | 39 | // Blending state 40 | [HideInInspector] _Mode ("__mode", Float) = 0.0 41 | [HideInInspector] _SrcBlend ("__src", Float) = 1.0 42 | [HideInInspector] _DstBlend ("__dst", Float) = 0.0 43 | [HideInInspector] _ZWrite ("__zw", Float) = 1.0 44 | 45 | // Volund properties 46 | [HideInInspector] _CullMode ("__cullmode", Float) = 2.0 47 | [HideInInspector] _SmoothnessInAlbedo ("__smoothnessinalbedo", Float) = 0.0 48 | _SmoothnessTweak1("Smoothness Scale", Range(0.0, 4.0)) = 1.0 49 | _SmoothnessTweak2("Smoothness Bias", Range(-1.0, 1.0)) = 0.0 50 | _SpecularMapColorTweak("Specular Color Tweak", Color) = (1,1,1,1) 51 | _PlaneReflectionBumpScale("Plane Reflection Bump Scale", Range(0.0, 1.0)) = 0.4 52 | _PlaneReflectionBumpClamp("Plane Reflection Bump Clamp", Range(0.0, 0.15)) = 0.05 53 | } 54 | 55 | CGINCLUDE 56 | #define UNITY_SETUP_BRDF_INPUT SpecularSetup 57 | #define USE_SMOOTHNESS_TWEAK 58 | ENDCG 59 | 60 | SubShader 61 | { 62 | Tags { 63 | "RenderType"="Opaque" 64 | "PerformanceChecks"="False" 65 | } 66 | LOD 300 67 | 68 | 69 | // ------------------------------------------------------------------ 70 | // Base forward pass (directional light, emission, lightmaps, ...) 71 | Pass 72 | { 73 | Name "FORWARD" 74 | Tags { "LightMode" = "ForwardBase" } 75 | 76 | Blend [_SrcBlend] [_DstBlend] 77 | ZWrite [_ZWrite] 78 | Cull [_CullMode] 79 | 80 | CGPROGRAM 81 | #pragma target 3.0 82 | //#pragma only_renderers d3d11 d3d9 opengl glcore 83 | 84 | // ------------------------------------- 85 | 86 | #pragma shader_feature _NORMALMAP 87 | #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON 88 | #pragma shader_feature _EMISSION 89 | #pragma shader_feature _SPECGLOSSMAP 90 | #pragma shader_feature ___ _DETAIL_MULX2 91 | #pragma shader_feature _AlphaTex; 92 | 93 | // Volund variants 94 | #pragma shader_feature SMOOTHNESS_IN_ALBEDO 95 | 96 | #pragma multi_compile_fwdbase nolightmap 97 | #pragma multi_compile_fog 98 | 99 | #pragma vertex vertForwardBase 100 | #pragma fragment fragForwardBase 101 | 102 | #include "Volund_UnityStandardCore.cginc" 103 | 104 | ENDCG 105 | } 106 | // ------------------------------------------------------------------ 107 | // Additive forward pass (one light per pass) 108 | Pass 109 | { 110 | Name "FORWARD_DELTA" 111 | Tags { "LightMode" = "ForwardAdd" } 112 | Blend [_SrcBlend] One 113 | Fog { Color (0,0,0,0) } // in additive pass fog should be black 114 | ZWrite Off 115 | ZTest LEqual 116 | Cull [_CullMode] 117 | 118 | CGPROGRAM 119 | #pragma target 3.0 120 | //#pragma only_renderers d3d11 d3d9 opengl glcore 121 | 122 | // ------------------------------------- 123 | 124 | 125 | #pragma shader_feature _NORMALMAP 126 | #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON 127 | #pragma shader_feature _SPECGLOSSMAP 128 | #pragma shader_feature ___ _DETAIL_MULX2 129 | 130 | 131 | // Volund variants 132 | #pragma shader_feature SMOOTHNESS_IN_ALBEDO 133 | 134 | #pragma multi_compile_fwdadd_fullshadows 135 | #pragma multi_compile_fog 136 | 137 | #pragma vertex vertForwardAdd 138 | #pragma fragment fragForwardAdd 139 | 140 | #include "Volund_UnityStandardCore.cginc" 141 | 142 | ENDCG 143 | } 144 | // ------------------------------------------------------------------ 145 | // Shadow rendering pass 146 | Pass { 147 | Name "ShadowCaster" 148 | Tags { "LightMode" = "ShadowCaster" } 149 | 150 | ZWrite On ZTest LEqual 151 | Cull [_CullMode] 152 | 153 | CGPROGRAM 154 | #pragma target 3.0 155 | //#pragma only_renderers d3d11 d3d9 opengl glcore 156 | 157 | // ------------------------------------- 158 | 159 | 160 | #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON 161 | #pragma multi_compile_shadowcaster 162 | 163 | #pragma vertex vertShadowCaster 164 | #pragma fragment fragShadowCaster 165 | 166 | #include "UnityStandardShadow.cginc" 167 | 168 | ENDCG 169 | } 170 | } 171 | 172 | FallBack "Morph3D/Volund Variants/Standard Character (Legacy)" 173 | CustomEditor "VolundMultiStandardShaderGUI" 174 | } 175 | -------------------------------------------------------------------------------- /Shaders/Skin/Volund_StandardSpecularCharacter.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b5f9959f7b6042c4eac31c2b58eb6cc2 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Shaders/Skin/Volund_StandardSpecularCharacter_GL2.shader: -------------------------------------------------------------------------------- 1 | Shader "MCS/Volund Variants/Standard Character (Legacy)" 2 | { 3 | Properties 4 | { 5 | _Color("Color", Color) = (1,1,1,1) 6 | _MainTex("Albedo", 2D) = "white" {} 7 | _AlphaTex("Alpha", 2D) = "white" {} 8 | 9 | _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5 10 | 11 | _Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5 12 | _SpecColor("Specular", Color) = (0.2,0.2,0.2) 13 | 14 | _SpecGlossMap("Specular", 2D) = "white" {} 15 | 16 | _BumpScale("Scale", Float) = 1.0 17 | _BumpMap("Normal Map", 2D) = "bump" {} 18 | 19 | _Parallax ("Height Scale", Range (0.005, 0.08)) = 0.02 20 | _ParallaxMap ("Height Map", 2D) = "black" {} 21 | 22 | _OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0 23 | _OcclusionMap("Occlusion", 2D) = "white" {} 24 | 25 | _EmissionColor("Color", Color) = (0,0,0) 26 | _EmissionMap("Emission", 2D) = "white" {} 27 | 28 | _DetailMask("Detail Mask", 2D) = "white" {} 29 | 30 | _DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {} 31 | _DetailNormalMapScale("Scale", Float) = 1.0 32 | _DetailNormalMap("Normal Map", 2D) = "bump" {} 33 | 34 | [Enum(UV0,0,UV1,1)] _UVSec ("UV Set for secondary textures", Float) = 0 35 | 36 | // UI-only data 37 | [HideInInspector] _EmissionScaleUI("Scale", Float) = 0.0 38 | [HideInInspector] _EmissionColorUI("Color", Color) = (1,1,1) 39 | 40 | // Blending state 41 | [HideInInspector] _Mode ("__mode", Float) = 0.0 42 | [HideInInspector] _SrcBlend ("__src", Float) = 1.0 43 | [HideInInspector] _DstBlend ("__dst", Float) = 0.0 44 | [HideInInspector] _ZWrite ("__zw", Float) = 1.0 45 | 46 | // Volund properties 47 | [HideInInspector] _CullMode ("__cullmode", Float) = 2.0 48 | [HideInInspector] _SmoothnessInAlbedo ("__smoothnessinalbedo", Float) = 0.0 49 | _SmoothnessTweak1("Smoothness Scale", Range(0.0, 4.0)) = 1.0 50 | _SmoothnessTweak2("Smoothness Bias", Range(-1.0, 1.0)) = 0.0 51 | _SpecularMapColorTweak("Specular Color Tweak", Color) = (1,1,1,1) 52 | _PlaneReflectionBumpScale("Plane Reflection Bump Scale", Range(0.0, 1.0)) = 0.4 53 | _PlaneReflectionBumpClamp("Plane Reflection Bump Clamp", Range(0.0, 0.15)) = 0.05 54 | } 55 | 56 | CGINCLUDE 57 | #define UNITY_SETUP_BRDF_INPUT SpecularSetup 58 | #define USE_SMOOTHNESS_TWEAK 59 | ENDCG 60 | 61 | SubShader 62 | { 63 | Tags { 64 | "RenderType"="Opaque" 65 | "PerformanceChecks"="False" 66 | } 67 | LOD 300 68 | 69 | 70 | // ------------------------------------------------------------------ 71 | // Base forward pass (directional light, emission, lightmaps, ...) 72 | Pass 73 | { 74 | Name "FORWARD" 75 | Tags { "LightMode" = "ForwardBase" } 76 | 77 | Blend [_SrcBlend] [_DstBlend] 78 | ZWrite [_ZWrite] 79 | Cull [_CullMode] 80 | 81 | CGPROGRAM 82 | #pragma target 3.5 83 | #pragma only_renderers d3d11 d3d9 opengl glcore gles gles3 84 | 85 | // ------------------------------------- 86 | 87 | #pragma shader_feature _NORMALMAP 88 | #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON 89 | #pragma shader_feature _EMISSION 90 | #pragma shader_feature _SPECGLOSSMAP 91 | //#pragma shader_feature ___ _DETAIL_MULX2 92 | #pragma shader_feature _AlphaTex; 93 | 94 | // Volund variants 95 | #pragma shader_feature SMOOTHNESS_IN_ALBEDO 96 | 97 | #pragma multi_compile_fwdbase nolightmap 98 | #pragma multi_compile_fog 99 | 100 | #pragma vertex vertForwardBase 101 | #pragma fragment fragForwardBase 102 | 103 | #include "Volund_UnityStandardCore_Legacy.cginc" 104 | 105 | 106 | ENDCG 107 | } 108 | 109 | 110 | // ------------------------------------------------------------------ 111 | // Additive forward pass (one light per pass) 112 | Pass 113 | { 114 | Name "FORWARD_DELTA" 115 | Tags { "LightMode" = "ForwardAdd" } 116 | Blend [_SrcBlend] One 117 | Fog { Color (0,0,0,0) } // in additive pass fog should be black 118 | ZWrite Off 119 | ZTest LEqual 120 | Cull [_CullMode] 121 | 122 | CGPROGRAM 123 | #pragma target 3.5 124 | #pragma only_renderers d3d11 d3d9 opengl glcore gles gles3 125 | 126 | // ------------------------------------- 127 | 128 | 129 | #pragma shader_feature _NORMALMAP 130 | #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON 131 | #pragma shader_feature _SPECGLOSSMAP 132 | #pragma shader_feature ___ _DETAIL_MULX2 133 | 134 | 135 | // Volund variants 136 | #pragma shader_feature SMOOTHNESS_IN_ALBEDO 137 | 138 | #pragma multi_compile_fwdadd_fullshadows 139 | #pragma multi_compile_fog 140 | 141 | #pragma vertex vertForwardAdd 142 | #pragma fragment fragForwardAdd 143 | 144 | #include "Volund_UnityStandardCore.cginc" 145 | 146 | ENDCG 147 | } 148 | // ------------------------------------------------------------------ 149 | // Shadow rendering pass 150 | Pass { 151 | Name "ShadowCaster" 152 | Tags { "LightMode" = "ShadowCaster" } 153 | 154 | ZWrite On ZTest LEqual 155 | Cull [_CullMode] 156 | 157 | CGPROGRAM 158 | #pragma target 3.5 159 | #pragma only_renderers d3d11 d3d9 opengl glcore gles gles3 160 | 161 | // ------------------------------------- 162 | 163 | 164 | #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON 165 | #pragma multi_compile_shadowcaster 166 | 167 | #pragma vertex vertShadowCaster 168 | #pragma fragment fragShadowCaster 169 | 170 | #include "UnityStandardShadow.cginc" 171 | 172 | ENDCG 173 | } 174 | } 175 | 176 | //FallBack "VertexLit" 177 | FallBack Off 178 | //CustomEditor "VolundMultiStandardShaderGUI" 179 | } 180 | -------------------------------------------------------------------------------- /Shaders/Skin/Volund_StandardSpecularCharacter_GL2.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8407a05bf8b1f477bbb985de22c843e5 3 | timeCreated: 1470417522 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shaders/Skin/Volund_UnityStandardCore.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bf7ad72260ce36a418162731903042af 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Shaders/Skin/Volund_UnityStandardCore_Legacy.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6a9e5a9f42f574a7ea481a790c5d89e7 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Shaders/Skin/Volund_UnityStandardInput.cginc: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_STANDARD_INPUT_INCLUDED 2 | #define UNITY_STANDARD_INPUT_INCLUDED 3 | 4 | #include "UnityCG.cginc" 5 | #include "UnityShaderVariables.cginc" 6 | #include "UnityStandardConfig.cginc" 7 | #include "UnityStandardUtils.cginc" 8 | #include "Lighting.cginc" 9 | 10 | // 11 | // Volund uniforms 12 | // 13 | uniform sampler2D _NormalAndOcclusion; 14 | uniform half _SmoothnessTweak1; 15 | uniform half _SmoothnessTweak2; 16 | uniform half4 _SpecularMapColorTweak; 17 | uniform float _CullMode; 18 | 19 | //MORPH3D uniforms 20 | uniform sampler2D _AlphaTex; 21 | 22 | //--------------------------------------- 23 | // Directional lightmaps & Parallax require tangent space too 24 | #if (_NORMALMAP || !DIRLIGHTMAP_OFF || _PARALLAXMAP) 25 | #define _TANGENT_TO_WORLD 1 26 | #endif 27 | 28 | #if (_DETAIL_MULX2 || _DETAIL_MUL || _DETAIL_ADD || _DETAIL_LERP) 29 | #define _DETAIL 1 30 | #endif 31 | 32 | //--------------------------------------- 33 | half4 _Color; 34 | half _Cutoff; 35 | 36 | sampler2D _MainTex; 37 | float4 _MainTex_ST; 38 | 39 | sampler2D _DetailAlbedoMap; 40 | float4 _DetailAlbedoMap_ST; 41 | 42 | sampler2D _BumpMap; 43 | half _BumpScale; 44 | 45 | sampler2D _DetailMask; 46 | sampler2D _DetailNormalMap; 47 | half _DetailNormalMapScale; 48 | 49 | sampler2D _SpecGlossMap; 50 | sampler2D _MetallicGlossMap; 51 | half _Metallic; 52 | half _Glossiness; 53 | 54 | sampler2D _OcclusionMap; 55 | half _OcclusionStrength; 56 | 57 | sampler2D _ParallaxMap; 58 | half _Parallax; 59 | half _UVSec; 60 | 61 | half4 _EmissionColor; 62 | sampler2D _EmissionMap; 63 | 64 | //------------------------------------------------------------------------------------- 65 | // Input functions 66 | 67 | struct VertexInput 68 | { 69 | float4 vertex : POSITION; 70 | half3 normal : NORMAL; 71 | float2 uv0 : TEXCOORD0; 72 | float2 uv1 : TEXCOORD1; 73 | #if defined(DYNAMICLIGHTMAP_ON) || defined(UNITY_PASS_META) 74 | float2 uv2 : TEXCOORD2; 75 | #endif 76 | #ifdef _TANGENT_TO_WORLD 77 | half4 tangent : TANGENT; 78 | #endif 79 | }; 80 | 81 | float4 TexCoords(VertexInput v) 82 | { 83 | float4 texcoord; 84 | texcoord.xy = TRANSFORM_TEX(v.uv0, _MainTex); // Always source from uv0 85 | texcoord.zw = TRANSFORM_TEX(((_UVSec == 0) ? v.uv0 : v.uv1), _DetailAlbedoMap); 86 | return texcoord; 87 | } 88 | 89 | half DetailMask(float2 uv) 90 | { 91 | return tex2D (_DetailMask, uv).a; 92 | } 93 | 94 | #ifdef SMOOTHNESS_IN_ALBEDO 95 | half3 Albedo(float4 texcoords, out half gloss) 96 | #else 97 | half3 Albedo(float4 texcoords) 98 | #endif 99 | { 100 | half4 albedoTex = tex2D (_MainTex, texcoords.xy); 101 | half3 albedo = _Color.rgb * albedoTex.rgb; 102 | 103 | #ifdef SMOOTHNESS_IN_ALBEDO 104 | gloss = albedoTex.a; 105 | 106 | #ifdef USE_SMOOTHNESS_TWEAK 107 | gloss = saturate(gloss * _SmoothnessTweak1 + _SmoothnessTweak2); 108 | #endif 109 | #endif 110 | 111 | #if _DETAIL 112 | #if (SHADER_TARGET < 30) 113 | // SM20: instruction count limitation 114 | // SM20: no detail mask 115 | half mask = 1; 116 | #else 117 | half mask = DetailMask(texcoords.xy); 118 | #endif 119 | half3 detailAlbedo = tex2D (_DetailAlbedoMap, texcoords.zw).rgb; 120 | #if _DETAIL_MULX2 121 | albedo *= LerpWhiteTo (detailAlbedo * unity_ColorSpaceDouble.rgb, mask); 122 | #elif _DETAIL_MUL 123 | albedo *= LerpWhiteTo (detailAlbedo, mask); 124 | #elif _DETAIL_ADD 125 | albedo += detailAlbedo * mask; 126 | #elif _DETAIL_LERP 127 | albedo = lerp (albedo, detailAlbedo, mask); 128 | #endif 129 | #endif 130 | return albedo; 131 | } 132 | 133 | half Alpha(float2 uv) 134 | { 135 | return tex2D(_AlphaTex, uv).r * _Color.a; 136 | } 137 | 138 | half Occlusion(float2 uv) 139 | { 140 | #if (SHADER_TARGET < 30) 141 | // SM20: instruction count limitation 142 | // SM20: simpler occlusion 143 | return tex2D(_OcclusionMap, uv).g; 144 | #else 145 | half occ = tex2D(_OcclusionMap, uv).g; 146 | return LerpOneTo (occ, _OcclusionStrength); 147 | #endif 148 | } 149 | 150 | half4 SpecularGloss(float2 uv) 151 | { 152 | half4 sg; 153 | #ifdef _SPECGLOSSMAP 154 | sg = tex2D(_SpecGlossMap, uv.xy); 155 | 156 | #ifdef USE_SMOOTHNESS_TWEAK 157 | sg *= _SpecularMapColorTweak; 158 | sg.a = saturate(sg.a * _SmoothnessTweak1 + _SmoothnessTweak2); 159 | #endif 160 | #else 161 | sg = half4(_SpecColor.rgb, _Glossiness); 162 | #endif 163 | return sg; 164 | } 165 | 166 | half2 MetallicGloss(float2 uv) 167 | { 168 | half2 mg; 169 | #ifdef _METALLICGLOSSMAP 170 | mg = tex2D(_MetallicGlossMap, uv.xy).ra; 171 | #else 172 | mg = half2(_Metallic, _Glossiness); 173 | #endif 174 | return mg; 175 | } 176 | 177 | half3 Emission(float2 uv) 178 | { 179 | #if !defined(_EMISSION) 180 | return 0; 181 | #else 182 | return tex2D(_EmissionMap, uv).rgb * _EmissionColor.rgb; 183 | #endif 184 | } 185 | 186 | #ifdef _NORMALMAP 187 | half3 NormalInTangentSpace(float4 texcoords) 188 | { 189 | half3 normalTangent = UnpackScaleNormal(tex2D (_BumpMap, texcoords.xy), _BumpScale); 190 | // SM20: instruction count limitation 191 | // SM20: no detail normalmaps 192 | #if _DETAIL && !defined(SHADER_API_MOBILE) && (SHADER_TARGET >= 30) 193 | half mask = DetailMask(texcoords.xy); 194 | half3 detailNormalTangent = UnpackScaleNormal(tex2D (_DetailNormalMap, texcoords.zw), _DetailNormalMapScale); 195 | #if _DETAIL_LERP 196 | normalTangent = lerp( 197 | normalTangent, 198 | detailNormalTangent, 199 | mask); 200 | #else 201 | normalTangent = lerp( 202 | normalTangent, 203 | BlendNormals(normalTangent, detailNormalTangent), 204 | mask); 205 | #endif 206 | #endif 207 | return normalTangent; 208 | } 209 | #endif 210 | 211 | float4 Parallax (float4 texcoords, half3 viewDir) 212 | { 213 | #if !defined(_PARALLAXMAP) || (SHADER_TARGET < 30) 214 | // SM20: instruction count limitation 215 | // SM20: no parallax 216 | return texcoords; 217 | #else 218 | half h = tex2D (_ParallaxMap, texcoords.xy).g; 219 | float2 offset = ParallaxOffset1Step (h, _Parallax, viewDir); 220 | return float4(texcoords.xy + offset, texcoords.zw + offset); 221 | #endif 222 | } 223 | 224 | #endif // UNITY_STANDARD_INPUT_INCLUDED 225 | -------------------------------------------------------------------------------- /Shaders/Skin/Volund_UnityStandardInput.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf56d65dc6838054780d7cf421d3de5d 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Shaders/Standard/Standard-2pass-doublesided-half depth.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 824a2be786ceb40ef8c7749caca0a9da 3 | timeCreated: 1433122783 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shaders/Standard/Standard-2pass-doublesided.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: daa07ac91d0cc44f38a7250d8bc72121 3 | timeCreated: 1433120641 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shaders/Standard/Standard-doublesided.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e9a234471563b4cb199c99b275ed7c10 3 | timeCreated: 1431454240 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shaders/Standard/StandardSpecular-doublesided.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8ac13f616c188443ca688ec5aa14e5b6 3 | timeCreated: 1431454239 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Shaders/UniqueShadow/UniqueShadow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d093dd1e5b70847d68dfc57c875eda27 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: 6 | - uniqueShadowUniversalShader: {fileID: 4800000, guid: 611709395ffc949c19a2120a1a4a9e73, 7 | type: 3} 8 | - uniqueShadowDepthShader: {fileID: 4800000, guid: 4cd1cc3fe24924d40bd04b92727549e0, 9 | type: 3} 10 | executionOrder: -100 11 | icon: {instanceID: 0} 12 | userData: 13 | assetBundleName: 14 | assetBundleVariant: 15 | -------------------------------------------------------------------------------- /Shaders/UniqueShadow/UniqueShadowSun.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class UniqueShadowSun : MonoBehaviour { 5 | public static Light instance; 6 | 7 | Light m_lightSource; 8 | 9 | void Awake() { 10 | m_lightSource = GetComponent(); 11 | if(!m_lightSource) 12 | Debug.LogErrorFormat("No light component found in UniqueShadowSun '{0}!", name); 13 | } 14 | 15 | void OnEnable() { 16 | if(instance) { 17 | Debug.LogErrorFormat("Not setting 'UniqueShadowSun.instance' because '{0}' is already active!", instance.name); 18 | return; 19 | } 20 | 21 | instance = m_lightSource; 22 | } 23 | 24 | void OnDisable() { 25 | if(instance == null) { 26 | Debug.LogErrorFormat("'UniqueShadowSun.instance' is already null when disabling '{0}'!", this.name); 27 | return; 28 | } 29 | 30 | if(instance != m_lightSource) { 31 | Debug.LogErrorFormat("Not UNsetting 'UniqueShadowSun.instance' because it points to someone else '{0}'!", instance.name); 32 | return; 33 | } 34 | 35 | instance = null; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Shaders/UniqueShadow/UniqueShadowSun.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8400a24544e29bb47bc8cf4c18eac599 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Shaders/UniqueShadow/UniqueShadow_DepthOnly.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | Shader "Hidden/Volund/Unique Shadow Depth Only" { 4 | 5 | CGINCLUDE 6 | #pragma only_renderers d3d11 d3d9 opengl 7 | #pragma fragmentoption ARB_precision_hint_fastest 8 | 9 | uniform float4 _MainTex_ST; 10 | uniform fixed _Cutoff; 11 | uniform sampler2D _MainTex; 12 | 13 | struct a2v { 14 | float4 vertex : POSITION; 15 | float2 uv : TEXCOORD0; 16 | }; 17 | 18 | struct v2f { 19 | float4 pos : SV_POSITION; 20 | half2 uv : TEXCOORD0; 21 | }; 22 | 23 | v2f vert(a2v v) { 24 | v2f o; 25 | o.pos = UnityObjectToClipPos(v.vertex); 26 | o.pos.z = max(UNITY_NEAR_CLIP_VALUE, o.pos.z); 27 | o.uv = v.uv * _MainTex_ST.xy + _MainTex_ST.zw; 28 | return o; 29 | } 30 | 31 | void HandleClip(half2 uv, fixed cutoff) { 32 | fixed a = tex2D(_MainTex, uv).a; 33 | clip(a - cutoff); 34 | } 35 | 36 | fixed4 frag(v2f i) : COLOR { 37 | #if defined(_ALPHATEST_ON) 38 | HandleClip(i.uv, _Cutoff); 39 | #endif 40 | return 0; 41 | } 42 | 43 | fixed4 fragT(v2f i) : COLOR { 44 | #if defined(_ALPHATEST_ON) 45 | HandleClip(i.uv, max(_Cutoff, 0.5f)); 46 | #else 47 | HandleClip(i.uv, 0.5f); 48 | #endif 49 | return 0; 50 | } 51 | ENDCG 52 | 53 | SubShader { 54 | Tags { "RenderType"="Opaque" } 55 | 56 | Cull Back 57 | ColorMask 0 58 | Offset 1, 0 59 | 60 | Pass { 61 | CGPROGRAM 62 | #pragma vertex vert 63 | #pragma fragment frag 64 | #pragma multi_compile _ _ALPHATEST_ON 65 | ENDCG 66 | } 67 | } 68 | 69 | SubShader { 70 | Tags { "RenderType"="Transparent" } 71 | 72 | Cull Off 73 | ColorMask 0 74 | Offset 1, 0 75 | 76 | Pass { 77 | CGPROGRAM 78 | #pragma vertex vert 79 | #pragma fragment fragT 80 | #pragma multi_compile _ _ALPHATEST_ON 81 | #define _ALPHABLEND_ON 82 | ENDCG 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Shaders/UniqueShadow/UniqueShadow_DepthOnly.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4cd1cc3fe24924d40bd04b92727549e0 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Shaders/UniqueShadow/UniqueShadow_ShadowSample.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: efbb1843b99424f4ea9edcbee8d06ba2 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /VENDORS.md: -------------------------------------------------------------------------------- 1 | # SharpZipLib 2 | 3 | http://icsharpcode.github.io/SharpZipLib/ 4 | 5 | ## SharpZipLib License 6 | 7 | ``` 8 | Copyright © 2000-2018 SharpZipLib Contributors 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | ``` 16 | --------------------------------------------------------------------------------