├── Assets
├── shader
├── PlayerModelStand
└── playermodelstand
├── PlayerAssets
├── Amogus.gtmodel
├── Lucy.gtmodel
├── Grimace.gtmodel
├── Skeleton.gtmodel
├── The Ape.gtmodel
├── Lar Gibbon.gtmodel
├── RobotMonke.gtmodel
├── The Chimp.gtmodel
├── WhiteGibbon.gtmodel
├── Beautifulboy.gtmodel
├── Buff Gorilla.gtmodel
├── HazmatGorilla.gtmodel
├── Toon Gorilla.gtmodel
├── Babbling Baboon.gtmodel
├── Kyle The Robot.gtmodel
├── Siamang Gibbon.gtmodel
├── WhiteCheekGibbon.gtmodel
├── character stump.gtmodel
└── Golden Tamarin Monkey.gtmodel
├── Directory.Build.targets
├── PluginInfo.cs
├── MakeRelease.ps1
├── Directory.Build.props
├── README.md
├── PlayerModel.sln
├── Scripts
├── PlayerModelButton.cs
├── PlayerModelAppearance.cs
├── FastIKFabric.cs
└── PlayerModelController.cs
├── LICENSE
├── PlayerModel.csproj
└── Plugin.cs
/Assets/shader:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/Assets/shader
--------------------------------------------------------------------------------
/Assets/PlayerModelStand:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/Assets/PlayerModelStand
--------------------------------------------------------------------------------
/Assets/playermodelstand:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/Assets/playermodelstand
--------------------------------------------------------------------------------
/PlayerAssets/Amogus.gtmodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/PlayerAssets/Amogus.gtmodel
--------------------------------------------------------------------------------
/PlayerAssets/Lucy.gtmodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/PlayerAssets/Lucy.gtmodel
--------------------------------------------------------------------------------
/PlayerAssets/Grimace.gtmodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/PlayerAssets/Grimace.gtmodel
--------------------------------------------------------------------------------
/PlayerAssets/Skeleton.gtmodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/PlayerAssets/Skeleton.gtmodel
--------------------------------------------------------------------------------
/PlayerAssets/The Ape.gtmodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/PlayerAssets/The Ape.gtmodel
--------------------------------------------------------------------------------
/PlayerAssets/Lar Gibbon.gtmodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/PlayerAssets/Lar Gibbon.gtmodel
--------------------------------------------------------------------------------
/PlayerAssets/RobotMonke.gtmodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/PlayerAssets/RobotMonke.gtmodel
--------------------------------------------------------------------------------
/PlayerAssets/The Chimp.gtmodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/PlayerAssets/The Chimp.gtmodel
--------------------------------------------------------------------------------
/PlayerAssets/WhiteGibbon.gtmodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/PlayerAssets/WhiteGibbon.gtmodel
--------------------------------------------------------------------------------
/PlayerAssets/Beautifulboy.gtmodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/PlayerAssets/Beautifulboy.gtmodel
--------------------------------------------------------------------------------
/PlayerAssets/Buff Gorilla.gtmodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/PlayerAssets/Buff Gorilla.gtmodel
--------------------------------------------------------------------------------
/PlayerAssets/HazmatGorilla.gtmodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/PlayerAssets/HazmatGorilla.gtmodel
--------------------------------------------------------------------------------
/PlayerAssets/Toon Gorilla.gtmodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/PlayerAssets/Toon Gorilla.gtmodel
--------------------------------------------------------------------------------
/PlayerAssets/Babbling Baboon.gtmodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/PlayerAssets/Babbling Baboon.gtmodel
--------------------------------------------------------------------------------
/PlayerAssets/Kyle The Robot.gtmodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/PlayerAssets/Kyle The Robot.gtmodel
--------------------------------------------------------------------------------
/PlayerAssets/Siamang Gibbon.gtmodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/PlayerAssets/Siamang Gibbon.gtmodel
--------------------------------------------------------------------------------
/PlayerAssets/WhiteCheekGibbon.gtmodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/PlayerAssets/WhiteCheekGibbon.gtmodel
--------------------------------------------------------------------------------
/PlayerAssets/character stump.gtmodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/PlayerAssets/character stump.gtmodel
--------------------------------------------------------------------------------
/PlayerAssets/Golden Tamarin Monkey.gtmodel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NachoEngine/PlayerModel/HEAD/PlayerAssets/Golden Tamarin Monkey.gtmodel
--------------------------------------------------------------------------------
/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/PluginInfo.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace PlayerModel
3 | {
4 | ///
5 | /// This class is used to provide information about your mod to BepInEx.
6 | ///
7 | class PluginInfo
8 | {
9 | public const string GUID = "com.nachoengine.playermodel";
10 | public const string Name = "PlayerModel";
11 | public const string Version = "1.2.9";
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/MakeRelease.ps1:
--------------------------------------------------------------------------------
1 | # Needs to be at least that version, or mmm can't read the archive
2 | #Requires -Modules @{ ModuleName="Microsoft.PowerShell.Archive"; ModuleVersion="1.2.3" }
3 | $MyInvocation.MyCommand.Path | Split-Path | Push-Location # Run from this script's directory
4 | $Name = (ls *.csproj).BaseName
5 | dotnet build -c Release
6 | mkdir BepInEx\plugins\$Name
7 | cp bin\Release\netstandard2.0\$Name.dll BepInEx\plugins\$Name\
8 | Compress-Archive .\BepInEx\ $Name-v
9 | rmdir .\BepInEx\ -Recurse
--------------------------------------------------------------------------------
/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | C:\Program Files (x86)\Steam\steamapps\common\Gorilla Tag
5 | $(GamePath)\Gorilla Tag_Data\Managed
6 | $(GamePath)\BepInEx\core
7 | $(GamePath)\BepInEx\plugins
8 |
9 |
10 | .\Libs
11 | .\Libs
12 | .\Libs
13 | 0
14 |
15 |
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PlayerModel
2 |
3 | PC Mod for GorillaTag
4 |
5 | This Mod allows you to change Player models!!
6 |
7 | ** This is client side only. It will still show the gorilla model for other players.**
8 |
9 | 
10 |
11 | FastIKFabric.cs by https://github.com/ditzel/SimpleIK (DON'T DOWNLOAD)
12 |
13 | ## Installation:
14 |
15 | - This mod requries Utilla, https://github.com/legoandmars/Utilla/releases, extract it into the Plugins folder
16 | - Download the [latest PlayerModel mod release] and extract it into the Plugins folder
17 | - All you need is to drag PlayerModel.dll in your Plugins folder. The mod will generate a PlayerModel/PlayerAssets folder to store playermodel files in. (.gtmodel)
18 | - D O N E
19 |
20 | [latest release of this mod]: https://github.com/NachoEngine/PlayerModelMod/releases
21 |
22 | ## PlayerModel Creators
23 |
24 | If you want to make your own playermodels:
25 | https://github.com/NachoEngine/GorillaPlayerModelModProject-Master
26 |
--------------------------------------------------------------------------------
/PlayerModel.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.32228.343
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlayerModel", "PlayerModel.csproj", "{F4729AD2-2925-4583-AFE3-BDD80240D65B}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {F4729AD2-2925-4583-AFE3-BDD80240D65B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {F4729AD2-2925-4583-AFE3-BDD80240D65B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {F4729AD2-2925-4583-AFE3-BDD80240D65B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {F4729AD2-2925-4583-AFE3-BDD80240D65B}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {70EBA368-1813-4EB7-BAA5-D56C89B56697}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/Scripts/PlayerModelButton.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace PlayerModel.Utils
4 | {
5 | public class PlayerModelButton : MonoBehaviour
6 | {
7 | public int button;
8 |
9 | public float debounceTime = 0.25f;
10 |
11 | public float touchTime;
12 |
13 | private bool pressedShow = true;
14 |
15 | public bool setColour = true;
16 | public Vector3 oldpos;
17 | public Vector3 pos;
18 |
19 | void Start()
20 | {
21 | gameObject.layer = 18;
22 | gameObject.AddComponent().isTrigger = true;
23 | oldpos = transform.localScale;
24 | pos = transform.localScale;
25 | }
26 |
27 | public void Press()
28 | {
29 | if (!enabled || !(touchTime + debounceTime < Time.time))
30 | {
31 | return;
32 | }
33 |
34 | touchTime = Time.time;
35 |
36 | Plugin.ButtonPress(button);
37 | }
38 |
39 | void Update()
40 | {
41 | transform.localScale = pos;
42 | if (!enabled || !(touchTime + debounceTime < Time.time))
43 | {
44 | if (setColour)
45 | gameObject.GetComponent().material.color = Color.red;
46 |
47 | pos = oldpos * 1.075f;
48 | pressedShow = false;
49 | }
50 | else
51 | {
52 | if (setColour)
53 | gameObject.GetComponent().material.color = Color.white;
54 |
55 | pos = oldpos;
56 | pressedShow = true;
57 | }
58 | }
59 |
60 | void OnTriggerEnter(Collider collider)
61 | {
62 | if (pressedShow)
63 | {
64 | if (!(collider.GetComponentInParent() != null))
65 | return;
66 |
67 | GorillaTriggerColliderHandIndicator component = collider.GetComponent();
68 | if (component != null)
69 | {
70 | GorillaTagger.Instance.offlineVRRig.PlayHandTapLocal(67, component.isLeftHand, 0.05f);
71 | GorillaTagger.Instance.StartVibration(component.isLeftHand, GorillaTagger.Instance.tapHapticStrength / 2f, GorillaTagger.Instance.tapHapticDuration);
72 | }
73 | }
74 | Press();
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/Scripts/PlayerModelAppearance.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using UnityEngine;
3 |
4 | namespace PlayerModel.Player
5 | {
6 | public class PlayerModelAppearance : MonoBehaviour
7 | {
8 | public static GameObject gorillabody;
9 | public static GameObject gorillaface;
10 | public static GameObject gorillachest;
11 |
12 | public static GameObject serverGameObject;
13 |
14 | static public void ShowOnlineRig()
15 | {
16 | GameObject clone_face = GameObject.Find("Player Objects/GorillaParent/GorillaVRRigs/Gorilla Player Networked(Clone)/rig/body/head/gorillaface");
17 | GameObject clone_body = GameObject.Find("Player Objects/GorillaParent/GorillaVRRigs/Gorilla Player Networked(Clone)/gorilla");
18 | GameObject clone_chest = GameObject.Find("Player Objects/GorillaParent/GorillaVRRigs/Gorilla Player Networked(Clone)/rig/body/gorillachest");
19 |
20 | clone_face.GetComponent().forceRenderingOff = false;
21 | clone_body.GetComponent().forceRenderingOff = false;
22 | clone_chest.GetComponent().forceRenderingOff = false;
23 | }
24 |
25 | static public void HideOnlineRig()
26 | {
27 | GameObject clone_face = GameObject.Find("Player Objects/GorillaParent/GorillaVRRigs/Gorilla Player Networked(Clone)/rig/body/head/gorillaface");
28 | GameObject clone_body = GameObject.Find("Player Objects/GorillaParent/GorillaVRRigs/Gorilla Player Networked(Clone)/gorilla");
29 | GameObject clone_chest = GameObject.Find("Player Objects/GorillaParent/GorillaVRRigs/Gorilla Player Networked(Clone)/rig/body/gorillachest");
30 |
31 | clone_face.GetComponent().forceRenderingOff = true;
32 | clone_body.GetComponent().forceRenderingOff = true;
33 | clone_chest.GetComponent().forceRenderingOff = true;
34 | }
35 | static public void HideOfflineRig()
36 | {
37 | //Debug.Log("hidding gorilla");
38 | int LayerCameraIgnore = LayerMask.NameToLayer("Bake");//hidden layer
39 |
40 | gorillaface.layer = LayerCameraIgnore;
41 | gorillabody.layer = LayerCameraIgnore;
42 | gorillachest.layer = LayerCameraIgnore;
43 |
44 | }
45 |
46 | static public void ShowOfflineRig()
47 | {
48 | //Debug.Log("showing gorilla");
49 | int LayerCameraShow = LayerMask.NameToLayer("Default");
50 |
51 |
52 | gorillaface.layer = LayerCameraShow;
53 |
54 | gorillabody.layer = LayerCameraShow;
55 |
56 | gorillachest.layer = LayerCameraShow;
57 |
58 | }
59 |
60 |
61 | static Color gorillacolor;
62 | static public bool flag1 = true;
63 | static public Renderer rendGorilla;
64 | static public Material mat;
65 |
66 | public static Color GetColor()
67 | {
68 | float r = PlayerPrefs.GetFloat("redValue");
69 | float g = PlayerPrefs.GetFloat("greenValue");
70 | float b = PlayerPrefs.GetFloat("blueValue");
71 | return new Color(r, g, b);
72 |
73 |
74 | }
75 | static public void AssignColor()
76 | {
77 | mat_index = PlayerModelController.gamemat_index;
78 | colormat_index = PlayerModelController.colormat_index;
79 |
80 | //Debug.Log("color assigned");
81 | if (colormat_index != mat_index || playermats[mat_index] == Plugin.player_main_material)
82 | //if color mat is not the same as game textures mat
83 | //or
84 | //if playermodel game textures mat is the main mat
85 | {
86 | if (playermats[colormat_index] != null)
87 | {
88 | playermats[colormat_index].color = GetColor();
89 | Plugin.playermodel.GetComponent().materials = playermats;
90 |
91 | }
92 |
93 | }
94 |
95 |
96 | }
97 |
98 | static public void ResetMaterial(GameObject playermodel)
99 | {
100 |
101 | mat_index = PlayerModelController.gamemat_index;
102 | colormat_index = PlayerModelController.colormat_index;
103 |
104 | if (playermats != null)
105 | {
106 | if (playermats[mat_index] != Plugin.player_main_material)
107 | {
108 | playermats[mat_index] = Plugin.player_main_material;
109 | //Debug.Log("reset mat");
110 | playermodel.GetComponent().materials = playermats;
111 | //Debug.Log(playermats);
112 | }
113 | }
114 | }
115 |
116 |
117 |
118 | public static int mat_index;
119 | public static int colormat_index;
120 | public static Material premat;
121 | public static Material[] playermats;//used to store reference of selected playermodel to assign back
122 |
123 |
124 | static public void AssignMaterial(GameObject playermodel)
125 | {
126 | mat_index = PlayerModelController.gamemat_index;
127 | colormat_index = PlayerModelController.colormat_index;
128 |
129 | if (gorillabody != null) //if in a lobby
130 | {
131 | if (gorillabody.GetComponent().material.name == "darkfur 1(Clone) (Instance)")//if not main mat
132 | {
133 | if (playermats[mat_index] != Plugin.player_main_material)
134 | {
135 | playermats[mat_index] = Plugin.player_main_material;
136 | //Debug.Log("Playermodel main mat assigned");
137 | }
138 |
139 | }
140 | else
141 | {
142 | playermats[mat_index] = gorillabody.GetComponent().material; //lava ice rockstones
143 | }
144 |
145 |
146 | }
147 | else
148 | {
149 | playermats[mat_index] = Plugin.player_main_material;
150 | }
151 | playermodel.GetComponent().materials = playermats;
152 |
153 |
154 |
155 |
156 |
157 | }
158 |
159 |
160 | }
161 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Creative Commons Legal Code
2 |
3 | CC0 1.0 Universal
4 |
5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12 | HEREUNDER.
13 |
14 | Statement of Purpose
15 |
16 | The laws of most jurisdictions throughout the world automatically confer
17 | exclusive Copyright and Related Rights (defined below) upon the creator
18 | and subsequent owner(s) (each and all, an "owner") of an original work of
19 | authorship and/or a database (each, a "Work").
20 |
21 | Certain owners wish to permanently relinquish those rights to a Work for
22 | the purpose of contributing to a commons of creative, cultural and
23 | scientific works ("Commons") that the public can reliably and without fear
24 | of later claims of infringement build upon, modify, incorporate in other
25 | works, reuse and redistribute as freely as possible in any form whatsoever
26 | and for any purposes, including without limitation commercial purposes.
27 | These owners may contribute to the Commons to promote the ideal of a free
28 | culture and the further production of creative, cultural and scientific
29 | works, or to gain reputation or greater distribution for their Work in
30 | part through the use and efforts of others.
31 |
32 | For these and/or other purposes and motivations, and without any
33 | expectation of additional consideration or compensation, the person
34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35 | is an owner of Copyright and Related Rights in the Work, voluntarily
36 | elects to apply CC0 to the Work and publicly distribute the Work under its
37 | terms, with knowledge of his or her Copyright and Related Rights in the
38 | Work and the meaning and intended legal effect of CC0 on those rights.
39 |
40 | 1. Copyright and Related Rights. A Work made available under CC0 may be
41 | protected by copyright and related or neighboring rights ("Copyright and
42 | Related Rights"). Copyright and Related Rights include, but are not
43 | limited to, the following:
44 |
45 | i. the right to reproduce, adapt, distribute, perform, display,
46 | communicate, and translate a Work;
47 | ii. moral rights retained by the original author(s) and/or performer(s);
48 | iii. publicity and privacy rights pertaining to a person's image or
49 | likeness depicted in a Work;
50 | iv. rights protecting against unfair competition in regards to a Work,
51 | subject to the limitations in paragraph 4(a), below;
52 | v. rights protecting the extraction, dissemination, use and reuse of data
53 | in a Work;
54 | vi. database rights (such as those arising under Directive 96/9/EC of the
55 | European Parliament and of the Council of 11 March 1996 on the legal
56 | protection of databases, and under any national implementation
57 | thereof, including any amended or successor version of such
58 | directive); and
59 | vii. other similar, equivalent or corresponding rights throughout the
60 | world based on applicable law or treaty, and any national
61 | implementations thereof.
62 |
63 | 2. Waiver. To the greatest extent permitted by, but not in contravention
64 | of, applicable law, Affirmer hereby overtly, fully, permanently,
65 | irrevocably and unconditionally waives, abandons, and surrenders all of
66 | Affirmer's Copyright and Related Rights and associated claims and causes
67 | of action, whether now known or unknown (including existing as well as
68 | future claims and causes of action), in the Work (i) in all territories
69 | worldwide, (ii) for the maximum duration provided by applicable law or
70 | treaty (including future time extensions), (iii) in any current or future
71 | medium and for any number of copies, and (iv) for any purpose whatsoever,
72 | including without limitation commercial, advertising or promotional
73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74 | member of the public at large and to the detriment of Affirmer's heirs and
75 | successors, fully intending that such Waiver shall not be subject to
76 | revocation, rescission, cancellation, termination, or any other legal or
77 | equitable action to disrupt the quiet enjoyment of the Work by the public
78 | as contemplated by Affirmer's express Statement of Purpose.
79 |
80 | 3. Public License Fallback. Should any part of the Waiver for any reason
81 | be judged legally invalid or ineffective under applicable law, then the
82 | Waiver shall be preserved to the maximum extent permitted taking into
83 | account Affirmer's express Statement of Purpose. In addition, to the
84 | extent the Waiver is so judged Affirmer hereby grants to each affected
85 | person a royalty-free, non transferable, non sublicensable, non exclusive,
86 | irrevocable and unconditional license to exercise Affirmer's Copyright and
87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the
88 | maximum duration provided by applicable law or treaty (including future
89 | time extensions), (iii) in any current or future medium and for any number
90 | of copies, and (iv) for any purpose whatsoever, including without
91 | limitation commercial, advertising or promotional purposes (the
92 | "License"). The License shall be deemed effective as of the date CC0 was
93 | applied by Affirmer to the Work. Should any part of the License for any
94 | reason be judged legally invalid or ineffective under applicable law, such
95 | partial invalidity or ineffectiveness shall not invalidate the remainder
96 | of the License, and in such case Affirmer hereby affirms that he or she
97 | will not (i) exercise any of his or her remaining Copyright and Related
98 | Rights in the Work or (ii) assert any associated claims and causes of
99 | action with respect to the Work, in either case contrary to Affirmer's
100 | express Statement of Purpose.
101 |
102 | 4. Limitations and Disclaimers.
103 |
104 | a. No trademark or patent rights held by Affirmer are waived, abandoned,
105 | surrendered, licensed or otherwise affected by this document.
106 | b. Affirmer offers the Work as-is and makes no representations or
107 | warranties of any kind concerning the Work, express, implied,
108 | statutory or otherwise, including without limitation warranties of
109 | title, merchantability, fitness for a particular purpose, non
110 | infringement, or the absence of latent or other defects, accuracy, or
111 | the present or absence of errors, whether or not discoverable, all to
112 | the greatest extent permissible under applicable law.
113 | c. Affirmer disclaims responsibility for clearing rights of other persons
114 | that may apply to the Work or any use thereof, including without
115 | limitation any person's Copyright and Related Rights in the Work.
116 | Further, Affirmer disclaims responsibility for obtaining any necessary
117 | consents, permissions or other rights required for any use of the
118 | Work.
119 | d. Affirmer understands and acknowledges that Creative Commons is not a
120 | party to this document and has no duty or obligation with respect to
121 | this CC0 or use of the Work.
122 |
--------------------------------------------------------------------------------
/Scripts/FastIKFabric.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace DitzelGames.FastIK
4 | {
5 | ///
6 | /// Fabrik IK Solver
7 | ///
8 | public class FastIKFabric : MonoBehaviour
9 | {
10 | ///
11 | /// Chain length of bones
12 | ///
13 | public int ChainLength = 2;
14 |
15 | ///
16 | /// Target the chain should bent to
17 | ///
18 | public Transform Target;
19 | public Transform Pole;
20 |
21 | ///
22 | /// Solver iterations per update
23 | ///
24 | [Header("Solver Parameters")]
25 | public int Iterations = 10;
26 |
27 | ///
28 | /// Distance when the solver stops
29 | ///
30 | public float Delta = 0.001f;
31 |
32 | ///
33 | /// Strength of going back to the start position.
34 | ///
35 | [Range(0, 1)]
36 | public float SnapBackStrength = 1f;
37 |
38 |
39 | protected float[] BonesLength; //Target to Origin
40 | protected float CompleteLength;
41 | protected Transform[] Bones;
42 | protected Vector3[] Positions;
43 | protected Vector3[] StartDirectionSucc;
44 | protected Quaternion[] StartRotationBone;
45 | protected Quaternion StartRotationTarget;
46 | protected Transform Root;
47 |
48 |
49 | // Start is called before the first frame update
50 | void Awake()
51 | {
52 | Init();
53 | }
54 |
55 | void Init()
56 | {
57 | //initial array
58 | Bones = new Transform[ChainLength + 1];
59 | Positions = new Vector3[ChainLength + 1];
60 | BonesLength = new float[ChainLength];
61 | StartDirectionSucc = new Vector3[ChainLength + 1];
62 | StartRotationBone = new Quaternion[ChainLength + 1];
63 |
64 | //find root
65 | Root = transform;
66 | for (var i = 0; i <= ChainLength; i++)
67 | {
68 | if (Root == null)
69 | throw new UnityException("The chain value is longer than the ancestor chain!");
70 | Root = Root.parent;
71 | }
72 |
73 | //init target
74 | if (Target == null)
75 | {
76 | Target = new GameObject(gameObject.name + " Target").transform;// + " Target"
77 | DontDestroyOnLoad(Target);
78 | SetPositionRootSpace(Target, GetPositionRootSpace(transform));
79 | }
80 | StartRotationTarget = GetRotationRootSpace(Target);
81 |
82 |
83 | //init data
84 | var current = transform;
85 | CompleteLength = 0;
86 | for (var i = Bones.Length - 1; i >= 0; i--)
87 | {
88 | Bones[i] = current;
89 | StartRotationBone[i] = GetRotationRootSpace(current);
90 |
91 | if (i == Bones.Length - 1)
92 | {
93 | //leaf
94 | StartDirectionSucc[i] = GetPositionRootSpace(Target) - GetPositionRootSpace(current);
95 | }
96 | else
97 | {
98 | //mid bone
99 | StartDirectionSucc[i] = GetPositionRootSpace(Bones[i + 1]) - GetPositionRootSpace(current);
100 | BonesLength[i] = StartDirectionSucc[i].magnitude;
101 | CompleteLength += BonesLength[i];
102 | }
103 |
104 | current = current.parent;
105 | }
106 |
107 |
108 |
109 | }
110 |
111 | // Update is called once per frame
112 | void LateUpdate()
113 | {
114 | ResolveIK();
115 | }
116 |
117 | private void ResolveIK()
118 | {
119 | if (Target == null)
120 | return;
121 |
122 | if (BonesLength.Length != ChainLength)
123 | Init();
124 |
125 | //Fabric
126 |
127 | // root
128 | // (bone0) (bonelen 0) (bone1) (bonelen 1) (bone2)...
129 | // x--------------------x--------------------x---...
130 |
131 | //get position
132 | for (int i = 0; i < Bones.Length; i++)
133 | Positions[i] = GetPositionRootSpace(Bones[i]);
134 |
135 | var targetPosition = GetPositionRootSpace(Target);
136 | var targetRotation = GetRotationRootSpace(Target);
137 |
138 | //1st is possible to reach?
139 | if ((targetPosition - GetPositionRootSpace(Bones[0])).sqrMagnitude >= CompleteLength * CompleteLength)
140 | {
141 | //just strech it
142 | var direction = (targetPosition - Positions[0]).normalized;
143 | //set everything after root
144 | for (int i = 1; i < Positions.Length; i++)
145 | Positions[i] = Positions[i - 1] + direction * BonesLength[i - 1];
146 | }
147 | else
148 | {
149 | for (int i = 0; i < Positions.Length - 1; i++)
150 | Positions[i + 1] = Vector3.Lerp(Positions[i + 1], Positions[i] + StartDirectionSucc[i], SnapBackStrength);
151 |
152 | for (int iteration = 0; iteration < Iterations; iteration++)
153 | {
154 | //https://www.youtube.com/watch?v=UNoX65PRehA
155 | //back
156 | for (int i = Positions.Length - 1; i > 0; i--)
157 | {
158 | if (i == Positions.Length - 1)
159 | Positions[i] = targetPosition; //set it to target
160 | else
161 | Positions[i] = Positions[i + 1] + (Positions[i] - Positions[i + 1]).normalized * BonesLength[i]; //set in line on distance
162 | }
163 |
164 | //forward
165 | for (int i = 1; i < Positions.Length; i++)
166 | Positions[i] = Positions[i - 1] + (Positions[i] - Positions[i - 1]).normalized * BonesLength[i - 1];
167 |
168 | //close enough?
169 | if ((Positions[Positions.Length - 1] - targetPosition).sqrMagnitude < Delta * Delta)
170 | break;
171 | }
172 | }
173 |
174 | //move towards pole
175 | if (Pole != null)
176 | {
177 | var polePosition = GetPositionRootSpace(Pole);
178 | for (int i = 1; i < Positions.Length - 1; i++)
179 | {
180 | var plane = new Plane(Positions[i + 1] - Positions[i - 1], Positions[i - 1]);
181 | var projectedPole = plane.ClosestPointOnPlane(polePosition);
182 | var projectedBone = plane.ClosestPointOnPlane(Positions[i]);
183 | var angle = Vector3.SignedAngle(projectedBone - Positions[i - 1], projectedPole - Positions[i - 1], plane.normal);
184 | Positions[i] = Quaternion.AngleAxis(angle, plane.normal) * (Positions[i] - Positions[i - 1]) + Positions[i - 1];
185 | }
186 | }
187 |
188 | //set position & rotation
189 | for (int i = 0; i < Positions.Length; i++)
190 | {
191 | if (i == Positions.Length - 1)
192 | SetRotationRootSpace(Bones[i], Quaternion.Inverse(targetRotation) * StartRotationTarget * Quaternion.Inverse(StartRotationBone[i]));
193 | else
194 | SetRotationRootSpace(Bones[i], Quaternion.FromToRotation(StartDirectionSucc[i], Positions[i + 1] - Positions[i]) * Quaternion.Inverse(StartRotationBone[i]));
195 | SetPositionRootSpace(Bones[i], Positions[i]);
196 | }
197 | }
198 |
199 | private Vector3 GetPositionRootSpace(Transform current)
200 | {
201 | if (Root == null)
202 | return current.position;
203 | else
204 | return Quaternion.Inverse(Root.rotation) * (current.position - Root.position);
205 | }
206 |
207 | private void SetPositionRootSpace(Transform current, Vector3 position)
208 | {
209 | if (Root == null)
210 | current.position = position;
211 | else
212 | current.position = Root.rotation * position + Root.position;
213 | }
214 |
215 | private Quaternion GetRotationRootSpace(Transform current)
216 | {
217 | //inverse(after) * before => rot: before -> after
218 | if (Root == null)
219 | return current.rotation;
220 | else
221 | return Quaternion.Inverse(current.rotation) * Root.rotation;
222 | }
223 |
224 | private void SetRotationRootSpace(Transform current, Quaternion rotation)
225 | {
226 | if (Root == null)
227 | current.rotation = rotation;
228 | else
229 | current.rotation = Root.rotation * rotation;
230 | }
231 |
232 | void OnDrawGizmos()
233 | {
234 | #if UNITY_EDITOR
235 | var current = this.transform;
236 | for (int i = 0; i < ChainLength && current != null && current.parent != null; i++)
237 | {
238 | var scale = Vector3.Distance(current.position, current.parent.position) * 0.1f;
239 | Handles.matrix = Matrix4x4.TRS(current.position, Quaternion.FromToRotation(Vector3.up, current.parent.position - current.position), new Vector3(scale, Vector3.Distance(current.parent.position, current.position), scale));
240 | Handles.color = Color.green;
241 | Handles.DrawWireCube(Vector3.up * 0.5f, Vector3.one);
242 | current = current.parent;
243 | }
244 | #endif
245 | }
246 |
247 | }
248 | }
--------------------------------------------------------------------------------
/PlayerModel.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\BepInEx\core\0Harmony.dll
56 |
57 |
58 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\Assembly-CSharp.dll
59 |
60 |
61 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\Assembly-CSharp-firstpass.dll
62 |
63 |
64 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\BakeryRuntimeAssembly.dll
65 |
66 |
67 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\BepInEx\core\BepInEx.dll
68 |
69 |
70 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\BepInEx\core\BepInEx.Harmony.dll
71 |
72 |
73 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\BepInEx\core\BepInEx.Preloader.dll
74 |
75 |
76 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\Cinemachine.dll
77 |
78 |
79 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\clipper_library.dll
80 |
81 |
82 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\BepInEx\core\HarmonyXInterop.dll
83 |
84 |
85 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\MeshBakerCore.dll
86 |
87 |
88 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\BepInEx\core\Mono.Cecil.dll
89 |
90 |
91 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\BepInEx\core\Mono.Cecil.Mdb.dll
92 |
93 |
94 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\BepInEx\core\Mono.Cecil.Pdb.dll
95 |
96 |
97 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\BepInEx\core\Mono.Cecil.Rocks.dll
98 |
99 |
100 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\Mono.Security.dll
101 |
102 |
103 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\BepInEx\core\MonoMod.RuntimeDetour.dll
104 |
105 |
106 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\BepInEx\core\MonoMod.Utils.dll
107 |
108 |
109 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\Oculus.Platform.dll
110 |
111 |
112 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\Oculus.VR.dll
113 |
114 |
115 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\Photon3Unity3D.dll
116 |
117 |
118 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\PhotonChat.dll
119 |
120 |
121 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\PhotonRealtime.dll
122 |
123 |
124 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\PhotonUnityNetworking.dll
125 |
126 |
127 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\PhotonUnityNetworking.Utilities.dll
128 |
129 |
130 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\PhotonVoice.dll
131 |
132 |
133 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\PhotonVoice.API.dll
134 |
135 |
136 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\PhotonVoice.PUN.dll
137 |
138 |
139 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\PlayFab.dll
140 |
141 |
142 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\SteamVR.dll
143 |
144 |
145 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\System.Configuration.dll
146 |
147 |
148 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\System.Diagnostics.StackTrace.dll
149 |
150 |
151 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\System.EnterpriseServices.dll
152 |
153 |
154 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\System.Globalization.Extensions.dll
155 |
156 |
157 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\System.ServiceModel.Internals.dll
158 |
159 |
160 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\System.Xml.XPath.XDocument.dll
161 |
162 |
163 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\Unity.Animation.Rigging.dll
164 |
165 |
166 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\Unity.Burst.dll
167 |
168 |
169 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\Unity.Burst.Unsafe.dll
170 |
171 |
172 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\Unity.InputSystem.dll
173 |
174 |
175 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\Unity.Mathematics.dll
176 |
177 |
178 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\Unity.Timeline.dll
179 |
180 |
181 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\Unity.XR.Interaction.Toolkit.dll
182 |
183 |
184 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.dll
185 |
186 |
187 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.AccessibilityModule.dll
188 |
189 |
190 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.AIModule.dll
191 |
192 |
193 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.AndroidJNIModule.dll
194 |
195 |
196 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.AnimationModule.dll
197 |
198 |
199 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.ARModule.dll
200 |
201 |
202 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.AssetBundleModule.dll
203 |
204 |
205 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.AudioModule.dll
206 |
207 |
208 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.ClothModule.dll
209 |
210 |
211 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.ClusterInputModule.dll
212 |
213 |
214 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.ClusterRendererModule.dll
215 |
216 |
217 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.CoreModule.dll
218 |
219 |
220 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.CrashReportingModule.dll
221 |
222 |
223 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.DirectorModule.dll
224 |
225 |
226 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.DSPGraphModule.dll
227 |
228 |
229 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.GameCenterModule.dll
230 |
231 |
232 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.GridModule.dll
233 |
234 |
235 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.HotReloadModule.dll
236 |
237 |
238 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.ImageConversionModule.dll
239 |
240 |
241 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.IMGUIModule.dll
242 |
243 |
244 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.InputLegacyModule.dll
245 |
246 |
247 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.InputModule.dll
248 |
249 |
250 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.JSONSerializeModule.dll
251 |
252 |
253 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.LocalizationModule.dll
254 |
255 |
256 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.ParticleSystemModule.dll
257 |
258 |
259 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.PerformanceReportingModule.dll
260 |
261 |
262 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.Physics2DModule.dll
263 |
264 |
265 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.PhysicsModule.dll
266 |
267 |
268 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.ProfilerModule.dll
269 |
270 |
271 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.ScreenCaptureModule.dll
272 |
273 |
274 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.SharedInternalsModule.dll
275 |
276 |
277 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.SpatialTracking.dll
278 |
279 |
280 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.SpriteMaskModule.dll
281 |
282 |
283 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.SpriteShapeModule.dll
284 |
285 |
286 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.StreamingModule.dll
287 |
288 |
289 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.SubstanceModule.dll
290 |
291 |
292 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.SubsystemsModule.dll
293 |
294 |
295 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.TerrainModule.dll
296 |
297 |
298 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.TerrainPhysicsModule.dll
299 |
300 |
301 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.TextCoreModule.dll
302 |
303 |
304 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.TextRenderingModule.dll
305 |
306 |
307 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.TilemapModule.dll
308 |
309 |
310 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.TLSModule.dll
311 |
312 |
313 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.UI.dll
314 |
315 |
316 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.UIElementsModule.dll
317 |
318 |
319 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.UIModule.dll
320 |
321 |
322 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.UmbraModule.dll
323 |
324 |
325 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.UNETModule.dll
326 |
327 |
328 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.UnityAnalyticsModule.dll
329 |
330 |
331 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.UnityConnectModule.dll
332 |
333 |
334 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.UnityTestProtocolModule.dll
335 |
336 |
337 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.UnityWebRequestAssetBundleModule.dll
338 |
339 |
340 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.UnityWebRequestAudioModule.dll
341 |
342 |
343 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.UnityWebRequestModule.dll
344 |
345 |
346 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.UnityWebRequestTextureModule.dll
347 |
348 |
349 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.UnityWebRequestWWWModule.dll
350 |
351 |
352 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.VehiclesModule.dll
353 |
354 |
355 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.VFXModule.dll
356 |
357 |
358 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.VideoModule.dll
359 |
360 |
361 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.VRModule.dll
362 |
363 |
364 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.WindModule.dll
365 |
366 |
367 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.XR.LegacyInputHelpers.dll
368 |
369 |
370 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\UnityEngine.XRModule.dll
371 |
372 |
373 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\BepInEx\Plugins\Utilla\Utilla.dll
374 |
375 |
376 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\Valve.Newtonsoft.Json.dll
377 |
378 |
379 | ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\Gorilla Tag_Data\Managed\websocket-sharp.dll
380 |
381 |
382 |
383 |
--------------------------------------------------------------------------------
/Scripts/PlayerModelController.cs:
--------------------------------------------------------------------------------
1 | using DitzelGames.FastIK;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using UnityEngine;
7 | using UnityEngine.UI;
8 | using UnityEngine.XR;
9 |
10 | namespace PlayerModel.Player
11 | {
12 | public class PlayerModelController : MonoBehaviour
13 | {
14 | List previewMats = new List();
15 | List playermodelMats = new List();
16 | static public GameObject misc_orb;
17 |
18 | static public string playermodel_head = "playermodel.head";
19 | static public string playermodel_torso = "playermodel.torso";
20 |
21 | static public string playermodel_lefthand = "playermodel.lefthand";
22 | static public string playermodel_righthand = "playermodel.righthand";
23 |
24 |
25 | static public string player_info_stream;
26 |
27 | static public string[] player_info;
28 |
29 | static public string playermodel_name;
30 | static public string playermodel_author;
31 |
32 | static public bool CustomColors;
33 | static public string colorMat;
34 |
35 | static public bool GameModeTextures;
36 | static public string gameMat;
37 |
38 | static public GameObject player_preview;
39 | static public string namegui;
40 |
41 | public static float rotationY = -60f;
42 | public static float localPositionY = 0.15f;
43 |
44 | public static int gamemat_index;
45 | public static int colormat_index;
46 |
47 | public static bool LipSync = false;
48 |
49 | static public void PreviewModel(int index)
50 | {
51 | if (player_preview != null)
52 | Destroy(player_preview);
53 |
54 | string path = Path.Combine(Plugin.playerpath, Plugin.fileName[index]);
55 | //Debug.Log(path);
56 |
57 | AssetBundle playerbundle = AssetBundle.LoadFromFile(path);
58 | GameObject assetplayer = playerbundle.LoadAsset("playermodel.ParentObject");
59 | if (playerbundle != null && assetplayer != null)
60 | {
61 | var parentAsset = Instantiate(assetplayer);
62 |
63 | playerbundle.Unload(false);
64 |
65 | player_info_stream = parentAsset.GetComponent().text;
66 | //Debug.Log(player_info_stream);
67 | player_info = player_info_stream.Split('$');
68 |
69 | parentAsset.GetComponent().enabled = false;
70 |
71 | playermodel_name = player_info[0];
72 | playermodel_author = player_info[1];
73 | player_body = parentAsset.transform.GetChild(0).gameObject.transform.Find("playermodel.body").gameObject;
74 | //Debug.Log(player_body.GetComponent().materials[0].name);
75 | Plugin.updateMaterialArray(player_body);
76 | //Debug.Log(player_body.GetComponent().materials[0].name);
77 | List material_list = player_body.GetComponent().materials.ToList();
78 | /*Debug.Log("Checking mats names after update:");
79 | for (int i = 0; i < material_list.Count; i++)
80 | {
81 | Debug.Log(material_list[i].name);
82 | }
83 | Debug.Log("Finished");*/
84 |
85 | Material[] material_array = material_list.ToArray();
86 |
87 | player_preview = new GameObject("playemodel.preview");
88 | Plugin.updateMaterialArray(player_preview);
89 |
90 | var meshFilter = player_preview.AddComponent();
91 | Mesh originalMesh = player_body.GetComponent().sharedMesh;
92 | meshFilter.mesh = originalMesh;
93 | MeshRenderer rend = player_preview.AddComponent();
94 | rend.materials = material_array;
95 | player_preview.transform.localScale = player_body.transform.localScale;
96 | pos = Plugin.misc_preview.transform.position;
97 | player_preview.transform.position = PlayerModel.Plugin.misc_preview.transform.position;
98 |
99 | Quaternion rot = Quaternion.Euler(-90f, -60f, 0f);
100 | player_preview.transform.rotation = rot;
101 |
102 | Plugin.model_text.text = playermodel_name.ToUpper(); ;
103 | Plugin.author_text.text = playermodel_author.ToUpper();
104 |
105 | //new playermodel info here:
106 | if (player_info.Length > 4) //bugs here manwefwefwefwewefwewefwewefwefwefwefwefwefwefwefwefwvrwgfsdvwfsdvwefacwefasf
107 | {
108 | Plugin.mat_preview[0] = null;
109 | Plugin.SetMainDisplayButtonMaterial(Plugin.mat_preview[0]);
110 | bool checkmat = true;
111 | bool gamemodetex = bool.Parse(player_info[3]); //if gamemodetextures are changable
112 | string gameMatname = player_info[5];
113 | //Debug.Log("gamemode texture material: "+ gameMatname);
114 |
115 | if (gamemodetex)//player_info[5] is the gameMat assigned material name
116 | {
117 | //Debug.Log("Mat Search start: " + gameMatname);
118 | for (int i = 0; i < material_array.Length; i++)//cycles mat list to match material name to assign gameMat changing
119 | {
120 |
121 | //Debug.Log(material_array[i].name);
122 | if (gameMatname == material_array[i].name || gameMatname + " (Instance)" == material_array[i].name)
123 | {
124 |
125 | Plugin.mat_preview[0] = material_array[i];
126 | Plugin.SetMainDisplayButtonMaterial(material_array[i]);
127 | checkmat = false;
128 | break;
129 | }
130 | //possible bug here: if the gameMatname isnt found in the preview material list, it would be assigned to mat_preview[0] etc
131 | //will make sure to have the text_info have the material name in the project, will add error logs in project
132 |
133 | }
134 | if (checkmat)
135 | {
136 | //Debug.LogError("Material Reference not Found: "+ gameMatname);
137 | }
138 | }
139 |
140 | if (player_info.Length == 7)
141 | {
142 | if (bool.Parse(player_info[6]))
143 | {
144 | //Debug.Log("This Playermodel has lipsync on");
145 | }
146 | }
147 |
148 | else
149 | {
150 | Plugin.mat_preview[0] = player_preview.GetComponent().material;
151 | Plugin.SetMainDisplayButtonMaterial(player_preview.GetComponent().material);
152 |
153 | }
154 | }
155 | else
156 | {
157 | Plugin.mat_preview[0] = player_preview.GetComponent().material;
158 | Plugin.SetMainDisplayButtonMaterial(player_preview.GetComponent().material);
159 |
160 | }
161 |
162 |
163 |
164 |
165 | player_preview.AddComponent();
166 |
167 | Destroy(parentAsset);
168 | }
169 | }
170 |
171 | public static Vector3 pos;
172 | static public GameObject player_body;
173 |
174 | static public void UnloadModel()
175 | {
176 |
177 | GameObject.Find("RightHandTriggerCollider").GetComponent().enabled = true;
178 | GameObject.Find("LeftHandTriggerCollider").GetComponent().enabled = true;
179 |
180 | GameObject playermodel = GameObject.Find("playermodel.ParentObject(Clone)");
181 | if (playermodel != null)
182 | {
183 | //Debug.Log("Unloading Playermodel");
184 | GameObject headbone = GameObject.Find(playermodel_head);
185 | GameObject HandRight = GameObject.Find(playermodel_lefthand);
186 | GameObject HandLeft = GameObject.Find(playermodel_righthand);
187 | GameObject offsetL = GameObject.Find("offsetL");
188 | GameObject offsetR = GameObject.Find("offsetR");
189 | GameObject root = GameObject.Find(playermodel_torso);
190 | GameObject LeftTarget = GameObject.Find("playermodel.lefthandpos" + " Target");
191 | GameObject RightTarget = GameObject.Find("playermodel.righthandpos" + " Target");
192 | GameObject poleR = GameObject.Find("poleR");
193 | GameObject poleL = GameObject.Find("poleL");
194 |
195 | digit_L.Clear();
196 | digit_R.Clear();
197 |
198 | Destroy(poleR);
199 | Destroy(poleL);
200 | Destroy(LeftTarget);
201 | Destroy(RightTarget);
202 | Destroy(root);
203 | Destroy(HandLeft);
204 | Destroy(offsetL);
205 | Destroy(offsetR);
206 | Destroy(HandRight);
207 | Destroy(headbone);
208 | Destroy(playermodel);
209 | }
210 | }
211 |
212 | public static GameObject offsetL;
213 | public static GameObject offsetR;
214 | public static GameObject HandLeft;
215 | public static GameObject HandRight;
216 | public static GameObject root;
217 | public static GameObject headbone;
218 | public static GameObject headtarget;
219 | public static GameObject poleR;
220 | public static GameObject poleL;
221 |
222 | public static List digit_R = new List();
223 | public static List digit_L = new List();
224 |
225 | public VRRig rig;
226 |
227 | public static Quaternion headoffset;
228 | static public void LoadModel(int index)
229 | {
230 | //Debug.Log("Loading Playermodel: "+index);
231 | LipSync = false;
232 |
233 | AssetBundle playerbundle = AssetBundle.LoadFromFile(Path.Combine(PlayerModel.Plugin.playerpath, PlayerModel.Plugin.fileName[index]));
234 | if (playerbundle != null)
235 | {
236 | GameObject assetplayer = playerbundle.LoadAsset("playermodel.ParentObject");
237 | if (assetplayer != null)
238 | {
239 | var parentAsset = Instantiate(assetplayer);
240 |
241 | playerbundle.Unload(false);
242 |
243 | GameObject playermodel = GameObject.Find("playermodel.body");
244 |
245 | Plugin.updateMaterialArray(playermodel);
246 |
247 | player_info_stream = parentAsset.GetComponent().text;
248 | //Debug.Log(player_info_stream);
249 | player_info = player_info_stream.Split('$');
250 |
251 | parentAsset.GetComponent().enabled = false;
252 | //Debug.Log(player_info[0]);
253 | CustomColors = bool.Parse(player_info[2]);
254 |
255 | GameModeTextures = bool.Parse(player_info[3]);
256 |
257 | offsetL = new GameObject("offsetL");
258 | offsetR = new GameObject("offsetR");
259 |
260 | HandLeft = GameObject.Find(playermodel_lefthand);
261 |
262 | HandRight = GameObject.Find(playermodel_righthand);
263 |
264 | root = GameObject.Find(playermodel_torso);
265 |
266 | headbone = GameObject.Find(playermodel_head);
267 | headtarget = GameObject.Find("Player Objects/Local VRRig/Local Gorilla Player/rig/body/head");
268 |
269 |
270 | PlayerModelAppearance.playermats = playermodel.GetComponent().materials;
271 | foreach(Material mat in PlayerModelAppearance.playermats){
272 | //Debug.Log("New Material: " + mat + " -- " + "Shader: " + mat.shader.name);
273 | }
274 | //Debug.Log("PlayerModel Info Length: "+ player_info.Length);
275 | if (player_info.Length > 4)//new version of PlayerModel V2
276 | {
277 |
278 | colorMat = player_info[4];
279 | //Debug.Log("Color Material: " + colorMat);
280 | gameMat = player_info[5];
281 | //Debug.Log("GameMode Material: " + gameMat);
282 |
283 | for (int i = 0; i < PlayerModelAppearance.playermats.Length; i++)
284 | {
285 | //find Color Material
286 | if (colorMat == PlayerModelAppearance.playermats[i].name)
287 | {
288 | colormat_index = i;
289 | //Debug.Log("Assigned Color material to: "+ i +" " + PlayerModelAppearance.playermats[i]);
290 | }
291 |
292 | //find GameTexture material
293 | if (gameMat == PlayerModelAppearance.playermats[i].name)
294 | {
295 | Plugin.player_main_material = PlayerModelAppearance.playermats[i];
296 | gamemat_index = i;
297 | //Debug.Log("Assigned Main mat: "+ Plugin.player_main_material + " to: " + i + " " + PlayerModelAppearance.playermats[i]);
298 | }
299 | }
300 |
301 | if (player_info.Length == 7) //PlayerModel v3
302 | {
303 | modelVersion = 2;
304 | //Debug.Log("playermodel v3 lipsync");
305 | if (bool.Parse(player_info[6]))
306 | {
307 | LipSync = true;
308 | }
309 | }
310 | }
311 | else
312 | {//PlayerModel V1
313 | gamemat_index = 0;
314 | colormat_index = 0;
315 | Plugin.player_main_material = PlayerModelAppearance.playermats[0]; //saves playermodel material
316 |
317 | }
318 |
319 |
320 | }
321 | }
322 | }
323 |
324 | public static int modelVersion;
325 | static public void AssignModel()
326 | {
327 | // Debug.Log("Start playermodel assigning");
328 | if (player_info.Length > 4)
329 | {
330 | modelVersion = 1;
331 | }
332 | else
333 | {
334 | modelVersion = 0;
335 | }
336 | //Debug.Log("Model Version: " + modelVersion);
337 |
338 | GameObject hand_l = GameObject.Find("Player Objects/Local VRRig/Local Gorilla Player/rig/body/shoulder.L/upper_arm.L/forearm.L/hand.L");
339 | //Debug.Log(hand_l);
340 | GameObject hand_r = GameObject.Find("Player Objects/Local VRRig/Local Gorilla Player/rig/body/shoulder.R/upper_arm.R/forearm.R/hand.R");
341 | // Debug.Log(hand_r);
342 | GameObject bodyrig = GameObject.Find("Player Objects/Local VRRig/Local Gorilla Player/rig/body");
343 | //Debug.Log(bodyrig);
344 | //Debug.Log("CHECK1");
345 | offsetL.transform.SetParent(hand_l.transform, false);
346 |
347 | offsetR.transform.SetParent(hand_r.transform, false);
348 |
349 | poleR = new GameObject("poleR");
350 | poleR.transform.SetParent(root.transform, false);
351 | poleL = new GameObject("poleL");
352 | poleL.transform.SetParent(root.transform, false);
353 | //Debug.Log("check1-2");
354 | poleL.transform.localPosition = new Vector3(-5f, -5f, -10);
355 | poleR.transform.localPosition = new Vector3(5f, -5f, -10);
356 | //Debug.Log("check2");
357 | GameObject lefthandpos = new GameObject("playermodel.lefthandpos");
358 | GameObject righthandpos = new GameObject("playermodel.righthandpos");
359 | //Debug.Log("check3");
360 | GameObject lefthandparent = HandLeft.transform.parent.gameObject;
361 | GameObject righthandparent = HandRight.transform.parent.gameObject;
362 | //Debug.Log("check4");
363 | lefthandpos.transform.SetParent(lefthandparent.transform, false);
364 | righthandpos.transform.SetParent(righthandparent.transform, false);
365 |
366 | lefthandpos.transform.SetPositionAndRotation(HandLeft.transform.position, HandLeft.transform.rotation);
367 | righthandpos.transform.SetPositionAndRotation(HandRight.transform.position, HandRight.transform.rotation);
368 |
369 | HandLeft.transform.SetPositionAndRotation(hand_l.transform.position, hand_l.transform.rotation);
370 | HandRight.transform.SetPositionAndRotation(hand_r.transform.position, hand_r.transform.rotation);
371 |
372 | Quaternion rotL = Quaternion.Euler(HandLeft.transform.localRotation.eulerAngles.x, HandLeft.transform.localRotation.eulerAngles.y, HandLeft.transform.localRotation.eulerAngles.z + 20f);
373 | Quaternion rotR = Quaternion.Euler(HandRight.transform.localRotation.eulerAngles.x, HandRight.transform.localRotation.eulerAngles.y, HandRight.transform.localRotation.eulerAngles.z - 20f);
374 |
375 | HandLeft.transform.position = hand_l.transform.position;
376 | HandRight.transform.position = hand_r.transform.position;
377 |
378 | HandLeft.transform.localRotation = rotL;
379 | HandRight.transform.localRotation = rotR;
380 |
381 | HandLeft.transform.SetParent(hand_l.transform, true);
382 | HandRight.transform.SetParent(hand_r.transform, true);
383 |
384 | //get each digit on each hand (parent bone of each digit)
385 |
386 | if (modelVersion > 0)
387 | {
388 | assignDigit(HandLeft, digit_L);
389 | assignDigit(HandRight, digit_R);
390 | root.AddComponent();
391 | }
392 |
393 | HandLeft = lefthandpos;
394 | HandRight = righthandpos;
395 |
396 | HandLeft.AddComponent();
397 | HandLeft.GetComponent().Target = offsetL.transform;
398 | HandLeft.GetComponent().Pole = poleL.transform;
399 |
400 | HandRight.AddComponent();
401 | HandRight.GetComponent().Target = offsetR.transform;
402 | HandRight.GetComponent().Pole = poleR.transform;
403 | root.transform.SetParent(bodyrig.transform, false);
404 | root.transform.localRotation = Quaternion.Euler(0f, 0.0f, 0.0f);
405 |
406 | headbone.transform.localRotation = headtarget.transform.localRotation;
407 | headoffset = headtarget.transform.localRotation;
408 | headbone.transform.SetParent(headtarget.transform, true);
409 | headbone.transform.localRotation = Quaternion.Euler(headoffset.x - 8, headoffset.y, headoffset.z);
410 | headbone.transform.localPosition = new Vector3(0, 0, 0);
411 | if (player_info.Length == 7)
412 | {
413 | //Debug.Log("scaling for v3 model");
414 | Vector3 scale = new Vector3(100, 100, 100);
415 | root.transform.localScale = scale;
416 | headbone.transform.localScale = scale;
417 | }
418 |
419 | }
420 | static public void assignDigit(GameObject hand, List digits)
421 | {
422 | List local = new List();
423 |
424 | foreach (Transform fingies in hand.transform)
425 | {
426 | local.Add(fingies.gameObject);
427 | }
428 | int index = 0;
429 | int mid = 0;
430 | int thumb = 0;
431 | //reorder list to index, middle, thumb
432 | for (int i = 0; i < hand.transform.childCount; i++)
433 | {
434 | if (hand.transform.GetChild(i).name.Contains("index"))
435 | {
436 | index = i;
437 | }
438 | if (hand.transform.GetChild(i).name.Contains("middle"))
439 | {
440 | mid = i;
441 | }
442 | if (hand.transform.GetChild(i).name.Contains("thumb"))
443 | {
444 | thumb = i;
445 | }
446 | }
447 |
448 | digits.Add(hand.transform.GetChild(index).gameObject);
449 | digits.Add(hand.transform.GetChild(mid).gameObject);
450 | digits.Add(hand.transform.GetChild(thumb).gameObject);
451 | }
452 | float currentTime;
453 |
454 |
455 | public class SpinYouBaboon : MonoBehaviour
456 | {
457 | float to;
458 | void Update()
459 | {
460 | to = Mathf.Lerp(to, localPositionY, 0.35f * 0.1f * Time.deltaTime);
461 | transform.rotation = Quaternion.Euler(-90f, rotationY, 0);
462 | transform.position = pos + new Vector3(0, to, 0);
463 | }
464 | }
465 |
466 | public class fingermovement : MonoBehaviour
467 | {
468 | float remapvalue = -75.0f; //degrees
469 | public float rightGrip;
470 | public float rightTrigger;
471 | public bool rightSecondary;
472 |
473 | public float leftGrip;
474 | public float leftTrigger;
475 | public bool leftSecondary;
476 |
477 |
478 |
479 | List objs = new List();
480 |
481 | bool ready = false;
482 |
483 |
484 | void Start()
485 | {
486 | //Debug.Log("add smoothing script");
487 | for (int i = 0; i < digit_L.Count; i++)
488 | {
489 | digit_L[i].AddComponent();
490 | digit_R[i].AddComponent();
491 | objs.Add(digit_L[i]);
492 |
493 | }
494 | for (int i = 0; i < digit_L.Count; i++)
495 | {
496 | objs.Add(digit_R[i]);
497 |
498 | }
499 |
500 | for (int i = 0; i < objs.Count; i++)
501 | {
502 | ResetTransforms(objs[i]);
503 | ResetTransforms(objs[i].transform.GetChild(0).gameObject);
504 | ResetTransforms(objs[i].transform.GetChild(0).GetChild(0).GetChild(0).gameObject);
505 | }
506 |
507 | ready = true;
508 | }
509 | void Update()
510 | {
511 | if (ready)
512 | {
513 | leftGrip = ControllerInputPoller.instance.leftControllerGripFloat;
514 | leftTrigger = ControllerInputPoller.instance.leftControllerIndexFloat;
515 | leftSecondary = ControllerInputPoller.instance.leftControllerPrimaryButton;
516 |
517 | rightGrip = ControllerInputPoller.instance.rightControllerGripFloat;
518 | rightTrigger = ControllerInputPoller.instance.rightControllerIndexFloat;
519 | rightSecondary = ControllerInputPoller.instance.rightControllerPrimaryButton;
520 |
521 | digit_L[0].GetComponent().input = leftTrigger;
522 | digit_L[1].GetComponent().input = leftGrip;
523 | digit_L[2].GetComponent().input = Convert.ToSingle(leftSecondary);
524 |
525 | digit_R[0].GetComponent().input = rightTrigger;
526 | digit_R[1].GetComponent().input = rightGrip;
527 | digit_R[2].GetComponent().input = Convert.ToSingle(rightSecondary);
528 |
529 |
530 | //Debug.Log(Convert.ToSingle(leftSecondary));
531 | fingermove(digit_L[0], digit_L[0].GetComponent().avg);
532 | fingermove(digit_L[1], digit_L[1].GetComponent().avg);
533 | fingermove(digit_L[2], digit_L[2].GetComponent().avg);
534 |
535 | fingermove(digit_R[0], digit_R[0].GetComponent().avg);
536 | fingermove(digit_R[1], digit_R[1].GetComponent().avg);
537 | fingermove(digit_R[2], digit_R[2].GetComponent().avg);
538 | }
539 |
540 | }
541 |
542 | void fingermove(GameObject parent, float input)//parent digit bone, float value from vr controller input (0.0->1.0)
543 | {
544 | float angle = Remap(input, remapvalue);//converts normalize value to relative angle to bone
545 | float angle2 = Remap(input, remapvalue);
546 | Vector3 localAngle = parent.transform.localEulerAngles;
547 |
548 | parent.transform.localEulerAngles = new Vector3(angle, localAngle.y, localAngle.z);//parent bone
549 |
550 | Vector3 localangle1 = parent.transform.GetChild(0).GetChild(0).localEulerAngles;
551 |
552 | parent.transform.GetChild(0).GetChild(0).localEulerAngles = new Vector3(angle2, localangle1.y, localangle1.z);//middle bone
553 |
554 | Vector3 localangle2 = parent.transform.GetChild(0).GetChild(0).GetChild(0).localEulerAngles;
555 |
556 | parent.transform.GetChild(0).GetChild(0).GetChild(0).localEulerAngles = new Vector3(angle2, localangle2.y, localangle2.z);//end bone
557 |
558 | }
559 |
560 | float Remap(float source, float targetTo)
561 | {
562 |
563 | float sourceTo = 1;
564 | float sourceFrom = 0;
565 | float targetFrom = 0;
566 | return targetFrom + (source - sourceFrom) * (targetTo - targetFrom) / (sourceTo - sourceFrom);
567 | }
568 | void ResetTransforms(GameObject obj)
569 | {
570 | GameObject newParent = new GameObject();
571 | newParent.name = "newParent_" + obj.name;
572 | newParent.transform.SetParent(obj.transform.parent, false);
573 | newParent.transform.SetPositionAndRotation(obj.transform.position, obj.transform.rotation);
574 | newParent.transform.localScale = obj.transform.localScale;
575 | obj.transform.SetParent(newParent.transform, true);
576 | }
577 |
578 | }
579 |
580 | public class smoothing : MonoBehaviour
581 | {
582 |
583 | const int samples = 3;
584 | float[] readings = new float[samples];
585 | int index = 0;
586 | float total = 0;
587 | public float avg = 0;
588 |
589 | public float input;
590 |
591 | void Start()
592 | {
593 | for (int i = 0; i < readings.Length; i++)
594 | {
595 | readings[i] = 0;
596 | }
597 | }
598 |
599 | void Update()
600 | {
601 | total -= readings[index];
602 | readings[index] = input;
603 | total += readings[index];
604 | index++;
605 |
606 | if (index >= samples)
607 | {
608 | index = 0;
609 | }
610 |
611 | avg = total / samples;
612 | }
613 | }
614 |
615 | }
616 |
617 | }
--------------------------------------------------------------------------------
/Plugin.cs:
--------------------------------------------------------------------------------
1 | using BepInEx;
2 | using Photon.Pun;
3 | using PlayerModel.Player;
4 | using PlayerModel.Utils;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Linq;
9 | using System.Reflection;
10 | using UnityEngine;
11 | using UnityEngine.Audio;
12 | using UnityEngine.InputSystem;
13 | using UnityEngine.UI;
14 | using UnityEngine.Rendering;
15 |
16 |
17 |
18 | namespace PlayerModel
19 | {
20 | ///
21 | /// This is your mod's main class.
22 | ///
23 |
24 | [BepInPlugin(PluginInfo.GUID, PluginInfo.Name, PluginInfo.Version)]
25 | [BepInDependency("org.legoandmars.gorillatag.utilla", "1.6.10")]
26 |
27 | public class Plugin : BaseUnityPlugin
28 | {
29 | static public Texture texture_;
30 | static public AudioClip _audioClip;
31 | static public bool _useMic = true;
32 | static public string _selectedDevice;
33 | static public AudioMixerGroup _mixerGroupMic;
34 | static public bool Cheaking = true;
35 |
36 |
37 | string rootPath;
38 | public static string textSavePath;
39 | public static string playerpath;
40 | public static string[] files;
41 | public static string[] fileName;
42 | public static string[] page;
43 | public static List materials = new List();
44 | public static Material defMat;
45 | public static Material matalpha;
46 |
47 | public static Shader UberShader = Shader.Find("GorillaTag/UberShader");
48 | public static Shader unlitShader;
49 | //public static Shader UberShader = Shader.Find("Gorilla/Standard (GT)");
50 |
51 | public static Material updateMaterial(Material oldmat)
52 | {
53 |
54 | if (oldmat.shader == UberShader)
55 | {
56 | //Debug.Log("has same material");
57 | return oldmat;
58 | }
59 | //Debug.Log("---- " + oldmat.shader.name);
60 |
61 | string color_ = "";
62 | string tex_ = "";
63 | Material newmat = new Material(UberShader);
64 |
65 | newmat.shaderKeywords = new string[]
66 | {
67 | "_USE_TEXTURE"
68 | };
69 | newmat.name = oldmat.name;
70 | //Debug.Log("Old Name: " + oldmat.name);
71 | //Debug.Log("new Name: " + newmat.name);
72 | /*if(oldmat.shader.name == "Standard")
73 | {
74 | color_ = "_Color";
75 | tex_ = "tex_";
76 | }*/
77 |
78 | newmat.SetFloat("_Cull",2f);
79 | if (newmat.HasFloat("_Cull"))
80 | {
81 | newmat.SetFloat("_Cull", 2f);
82 | // Debug.Log("Cull property set");
83 | }
84 | else
85 | {
86 | //Debug.LogError("Cull property missing");
87 | }
88 |
89 | color_ = "_Color";
90 | tex_ = "_MainTex";
91 |
92 | if (oldmat.shader.name == "Custom/playermodel_new" || oldmat.shader.name == "Custom/playermodel")
93 | {
94 | //Debug.Log("#######################################PlayerModel Shader");
95 | color_ = "_Color";
96 | tex_ = "_texture";
97 | }
98 |
99 | if (oldmat.HasProperty(color_))
100 | {
101 | newmat.color = oldmat.GetColor(color_);
102 | }
103 | else
104 | {
105 | //Debug.Log("color: "+color_ +" prop missing");
106 | }
107 | if (oldmat.HasProperty(tex_))
108 | {
109 |
110 | //Debug.Log("Copying texture: " + oldmat.GetTexture(tex_).name);
111 | Texture texture = oldmat.GetTexture(tex_);
112 |
113 | //newmat.SetTexture("_MainTex", oldmat.GetTexture(tex_));
114 | if (texture != null)
115 | {
116 | texture_ = texture;
117 |
118 | //newmat.SetTexture("_MainTex", oldmat.GetTexture(tex_));
119 | newmat.mainTexture = texture_;
120 |
121 | }
122 | else
123 | {
124 |
125 | //Debug.LogError(tex_ + " property is null");
126 | }
127 |
128 |
129 |
130 | }
131 | else
132 | {
133 | //Debug.Log("texture: "+ tex_+" prop missing");
134 | }
135 | //Debug.Log("new Name (Before Return: " + newmat.name);
136 | return newmat;
137 | }
138 |
139 | public static Vector4 Vector4(Color c)
140 | {
141 | Vector4 color_v = new Vector4(c.r, c.g, c.b, c.a);
142 | return color_v;
143 | }
144 | //private ClientScript clientScript;
145 |
146 | void Awake()
147 | {
148 | Utilla.Events.GameInitialized += OnGameInitialized;
149 | }
150 | public static void updateMaterialArray(GameObject obj)
151 | {
152 | //Debug.Log(obj);
153 | Renderer rend = obj.GetComponent();
154 | if (rend != null)
155 | {
156 |
157 | Material[] updatedMaterials = new Material[rend.materials.Length];
158 |
159 | for (int j = 0; j < updatedMaterials.Length; j++)
160 | {
161 |
162 | updatedMaterials[j] = updateMaterial(rend.materials[j]);
163 | //Debug.Log("Updated New Material: " + updatedMaterials[j]);
164 | //Debug.Log(updatedMaterials[j].name + " #" + j);
165 | }
166 | //Debug.Log("before update function: " + updatedMaterials[0].name);
167 | rend.materials = updatedMaterials;
168 |
169 | for(int i=0; i().material;
195 | // Debug.Log("Gorilla Cull Mode: " + gt_mat.GetFloat("_Cull"));
196 | rootPath = Directory.GetCurrentDirectory();
197 |
198 | playerpath = Path.Combine(rootPath, "BepInEx", "Plugins", "PlayerModel", "PlayerAssets");
199 | textSavePath = Path.Combine(rootPath, "BepInEx", "Plugins", "PlayerModel", textfilename);
200 | //preload gtmodels to PlayerAssets folder
201 | if (!Directory.Exists(playerpath))
202 | {
203 | //stores list of all embeded files from dll
204 | List embededmodels = Assembly.GetExecutingAssembly().GetManifestResourceNames().ToList();
205 |
206 | //removes not gtmodels from list
207 | string type = ".gtmodel";
208 | for (int i = 0; i < embededmodels.Count; i++)
209 | {
210 |
211 | if (!embededmodels[i].EndsWith(type))
212 | {
213 | embededmodels.Remove(embededmodels[i]);
214 | }
215 | }
216 |
217 | Directory.CreateDirectory(playerpath);
218 | //stores embeded models to folder
219 | foreach (String model in embededmodels)
220 | {
221 | //Debug.Log(model);
222 |
223 | string filename = model.Replace("PlayerModel.PlayerAssets.", "");
224 | MemoryStream ms = new MemoryStream(); // buffer for file bytes
225 | using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(model)) // open resource
226 | {
227 | stream.CopyTo(ms); // copy to buffer
228 | byte[] bb = ms.ToArray(); // need array to save
229 | File.WriteAllBytes(playerpath + @"\" + filename, bb); // save byte array to file
230 |
231 | }
232 | }
233 |
234 | }
235 |
236 | files = Directory.GetFiles(playerpath, "*.gtmodel");//cant Path.GetFileName - cant convert string[] to string
237 |
238 | fileName = new string[files.Length]; //creating new array with same length as files array
239 |
240 | for (int i = 0; i < fileName.Length; i++)
241 | {
242 | fileName[i] = Path.GetFileName(files[i]); //getting file names from directories
243 | //Debug.Log(fileName[i]);
244 | }
245 | //Debug.Log("Loading MISC");
246 | Stream str = Assembly.GetExecutingAssembly().GetManifestResourceStream("PlayerModel.Assets.playermodelstand");
247 | AssetBundle bundle = AssetBundle.LoadFromStream(str);
248 | GameObject asset = bundle.LoadAsset("misc");
249 | var localasset = Instantiate(asset);
250 |
251 | DontDestroyOnLoad(localasset);
252 |
253 | GameObject misc = localasset.transform.GetChild(0).gameObject;
254 | //Debug.Log("MISC Loaded");
255 | //Debug.Log(misc.name);
256 |
257 | for (int i = 0; i < misc.transform.childCount; i++)
258 | {
259 | //Debug.Log(misc.transform.GetChild(i));
260 |
261 | GameObject child = misc.transform.GetChild(i).gameObject;
262 | updateMaterialArray(child);
263 |
264 | }
265 | //Debug.Log("misc mat updated");
266 | misc.transform.position = new Vector3(-53.3f, 16.216f, -124.6f);
267 | misc.transform.localRotation = Quaternion.Euler(0f, -60f, 0f);
268 |
269 | //misc.transform.position = new Vector3(-66.54f, 11.3f, -82.55f);
270 | //misc.transform.localRotation = Quaternion.Euler(0f, 90f, 0f);
271 | //Debug.Log("MISC Child");
272 | SelectButton = misc.transform.Find("misc.selector").gameObject;
273 | //Debug.Log("MISC selectbutton");
274 | SelectButton.AddComponent().button = 1;
275 | //Debug.Log("MISC select add");
276 | RightButton = misc.transform.Find("misc.rightpage").gameObject;
277 | RightButton.AddComponent().button = 2;
278 |
279 | LeftButton = misc.transform.Find("misc.leftpage").gameObject;
280 | LeftButton.AddComponent().button = 3;
281 | //Debug.Log("Buttons Loaded");
282 | GameObject canvasText = misc.transform.Find("Canvas").gameObject;
283 |
284 | GameObject modelText = canvasText.transform.Find("model.text").gameObject;
285 | GameObject authorText = canvasText.transform.Find("author.text").gameObject;
286 | GameObject versionText = canvasText.transform.Find("version.text").gameObject;
287 |
288 | versionText.GetComponent().text = "V" + PluginInfo.Version;
289 |
290 | model_text = modelText.GetComponent();
291 | author_text = authorText.GetComponent();
292 |
293 | misc_preview = GameObject.Find("misc.preview");
294 |
295 | misc_orbs = new GameObject[4];
296 | misc_orbs[0] = GameObject.Find("misc.fur");
297 | misc_orbs[1] = GameObject.Find("misc.lava");
298 | misc_orbs[2] = GameObject.Find("misc.rock");
299 | misc_orbs[3] = GameObject.Find("misc.ice");
300 |
301 | for (int i = 0; i < misc_orbs.Length; i++)
302 | {
303 | misc_orbs[i].AddComponent().button = 4 + i;
304 | misc_orbs[i].GetComponent().setColour = false;
305 |
306 | }
307 |
308 | materials.Add(Resources.Load($"objects/equipment/materials/" + "bluealive"));
309 |
310 | defMat = Resources.Load("objects/treeroom/materials/lightfur");
311 |
312 | mat_preview = new Material[misc_orbs.Length];
313 |
314 | for (int i = 0; i < mat_preview.Length; i++)
315 | {
316 | mat_preview[i] = misc_orbs[i].GetComponent().material;
317 |
318 | }
319 |
320 | GameObject left_empty = GameObject.CreatePrimitive(PrimitiveType.Sphere);
321 | GameObject right_empty = GameObject.CreatePrimitive(PrimitiveType.Sphere);
322 | //for hand placement
323 | left_empty.GetComponent().enabled = false;
324 | right_empty.GetComponent().enabled = false;
325 |
326 | left_empty.transform.localScale = new Vector3(.03f, .5f, .03f);
327 | right_empty.transform.localScale = new Vector3(.03f, .5f, .03f);
328 |
329 |
330 |
331 | if (File.Exists(textSavePath))
332 | {
333 | string[] defaultdata = readFromText(textSavePath);
334 |
335 | //Debug.Log("Checking Default PlayerModel Data");
336 | //Debug.Log(defaultdata[1]);
337 | if (defaultdata[1] == Convert.ToString(0))//If IsGorilla
338 | {
339 | PlayerModelController.PreviewModel(Convert.ToInt32(defaultdata[0]));
340 | if (defaultdata[2] == model_text.text)//matching playermodel name
341 | {
342 | //Debug.Log("Loading Default PlayerModel");
343 | playerIndex = Convert.ToInt32(defaultdata[0]);
344 | PlayerModelController.PreviewModel(playerIndex);
345 | IsGorilla = false;
346 | assignedIndex = playerIndex;
347 |
348 | }
349 |
350 | }
351 | else
352 | {
353 | //Debug.Log("Loading as Gorilla");
354 | playerIndex = 0;
355 | PlayerModelController.PreviewModel(0);
356 | IsGorilla = true;
357 | }
358 |
359 | }
360 | STARTPLAYERMOD = true;
361 | //Debug.Log("PlayerModel Ready");
362 |
363 | Stream str_shader = Assembly.GetExecutingAssembly().GetManifestResourceStream("PlayerModel.Assets.shader");
364 | AssetBundle bundle_shader = AssetBundle.LoadFromStream(str_shader);
365 | GameObject asset_shader = bundle_shader.LoadAsset("Sphere");
366 | var localasset_shader = Instantiate(asset_shader);
367 |
368 | GameObject shader_sphere = localasset_shader;
369 | shader_sphere.transform.position = new Vector3(-66.54f, 12f, -84f);
370 | shader_sphere.transform.localScale = new Vector3(0.2f,0.2f,0.2f);
371 | shader_sphere.SetActive(false);
372 | }
373 |
374 |
375 | public static AudioSource _audioSource;
376 | public static bool vflag = true;
377 | public static GameObject voiceprefab;
378 | public static AudioMixer _audioMixer;
379 |
380 | public static GameObject voiceObject;
381 |
382 | public static int clipPosition;
383 |
384 | public static void restartMic()
385 | {
386 | _audioSource.Stop();
387 | _audioSource.clip = null;
388 | _audioSource.clip = Microphone.Start(_selectedDevice, true, 5, AudioSettings.outputSampleRate);
389 | _audioSource.Play();
390 | }
391 | static public void LipSyncStart()
392 | {
393 | if (_useMic)
394 | {
395 | if (Microphone.devices.Length > 0)
396 | {
397 | voiceObject = new GameObject();
398 | _audioSource = voiceObject.AddComponent();
399 |
400 | _selectedDevice = Microphone.devices[0].ToString();
401 | //Debug.Log(_selectedDevice);
402 | _audioSource.clip = Microphone.Start(_selectedDevice, true, 5, AudioSettings.outputSampleRate);
403 |
404 | _audioSource.spatialBlend = 1f;
405 | _audioSource.minDistance = 0f;
406 | _audioSource.maxDistance = 1f;
407 | _audioSource.playOnAwake = true;
408 | _audioSource.loop = true;
409 | _audioSource.Play();
410 |
411 | voiceObject = GameObject.CreatePrimitive(PrimitiveType.Sphere);
412 | voiceObject.GetComponent().enabled = false;
413 | voiceObject.GetComponent().enabled = false;
414 | voiceObject.transform.position = new Vector3(-66, 12, -82);
415 |
416 | }
417 | else
418 | {
419 | _useMic = false;
420 |
421 | }
422 | }
423 | }
424 | public static GameObject mouth;
425 | public static int sampleWindow = 64;
426 |
427 | public static float loudnessSensitivity = 100;
428 | public static float threshold = 0.2f;
429 |
430 | public static AudioClip MicClip;
431 | public static float GetLoudnessFromMic()
432 | {
433 | return AudioClipLoudness(Microphone.GetPosition(Microphone.devices[0]), _audioSource.clip);
434 | }
435 | static public float AudioClipLoudness(int clipPosition, AudioClip clip)
436 | {
437 | int startPosition = clipPosition - sampleWindow;
438 |
439 | if (startPosition < 0)
440 | return 0;
441 |
442 | float[] waveData = new float[sampleWindow];
443 | clip.GetData(waveData, startPosition);
444 |
445 |
446 |
447 | float totalLoudness = 0;
448 |
449 | for (int i = 0; i < sampleWindow; i++)
450 | {
451 | totalLoudness += Mathf.Abs(waveData[i]);
452 |
453 | }
454 |
455 | return totalLoudness / sampleWindow;
456 | }
457 |
458 | static string textfilename = "PlayerModelDefault.pmdefault";
459 | static string split = ",";
460 | public static void writeToText(int index_, int IsGorilla_, string name)
461 | {
462 |
463 | string text = index_ + split + IsGorilla_ + split + name;
464 | File.WriteAllText(textSavePath, text);
465 | }
466 |
467 | public static string[] readFromText(string path)
468 | {
469 |
470 | string text = File.ReadAllText(textSavePath);
471 | string[] strings = text.Split(',');
472 |
473 |
474 | return strings;
475 |
476 | }
477 | static public Material[] mat_preview;
478 | static public GameObject[] misc_orbs;
479 | static public int mat_index;
480 | static public Text model_text;
481 | static public Text author_text;
482 | static public GameObject misc_preview;
483 | static public Material player_main_material;
484 | static public GameObject SelectButton;
485 | static public GameObject RightButton;
486 | static public GameObject LeftButton;
487 |
488 | static public bool nachotext = false;
489 | static public bool IsGorilla = true;
490 | static public int playerIndex = 0;
491 | static public GameObject playermodel;
492 | static public GameObject clone_body;
493 | static public bool selectflag = false;
494 | static public bool leftflag = false;
495 | static public bool rightflag = false;
496 | static public bool clone_body_flag = false;
497 | static public bool flag_inroom = true;
498 | static public bool STARTPLAYERMOD = false;
499 | static public int assignedIndex = 0;// index of array,
500 |
501 | public static void SetMainDisplayButtonMaterial(Material material)
502 | {
503 | //Debug.Log("input material" + material.shader + ", " + material.name);
504 | //Debug.Log("orb mat is now: " + misc_orbs[0].GetComponent().material.shader);
505 | misc_orbs[0].GetComponent().material = material;
506 |
507 |
508 | }
509 | public static void ButtonPress(int button)
510 | {
511 | switch (button)
512 | {
513 |
514 | case 1:
515 | //Debug.Log("Selector Button Pressed");
516 | if (nachotext == false)
517 | {
518 | Destroy(GameObject.Find("nachoengine_playermodelmod"));
519 | nachotext = true;
520 | }
521 |
522 | if (IsGorilla == true)//switching from gorilla to playermodel
523 | {
524 | while (playermodel == null)
525 | {
526 | PlayerModelController.LoadModel(playerIndex);
527 | playermodel = GameObject.Find("playermodel.body");
528 |
529 | }
530 | assignedIndex = playerIndex;
531 | IsGorilla = false;
532 | PlayerModelController.AssignModel();
533 |
534 | }
535 | else//playermodel is assaigned, and spressed select button
536 | {
537 |
538 | if (assignedIndex == playerIndex)//playermodel to gorilla
539 | {
540 | //Debug.Log("PlayerModel to Gorilla");
541 | PlayerModelController.UnloadModel();
542 | IsGorilla = true;
543 | player_main_material = null;
544 | }
545 | else//playermodel to playermodel
546 | {
547 | //Debug.Log("PlayerModel to PlayerModel");
548 | PlayerModelController.UnloadModel();
549 | player_main_material = null;
550 |
551 |
552 | assignedIndex = playerIndex;
553 |
554 |
555 | }
556 | }
557 | //writeToText(assignedIndex, Convert.ToInt32(IsGorilla));
558 | writeToText(assignedIndex, Convert.ToInt32(IsGorilla), model_text.text);
559 |
560 | break;
561 | case 2:
562 | playerIndex++; //righjt
563 | //Debug.Log("Right");
564 |
565 | if (playerIndex > fileName.Length - 1)
566 | playerIndex = 0;
567 | PlayerModelController.PreviewModel(playerIndex);
568 |
569 | break;
570 | case 3:
571 | playerIndex--;
572 | //Debug.Log("Left");
573 | if (playerIndex < 0)
574 | playerIndex = fileName.Length - 1;//10 items but starts from 0 so 0 to 9 = 10 items
575 | PlayerModelController.PreviewModel(playerIndex);
576 |
577 | break;
578 | case 4:
579 | PlayerModelController.player_preview.GetComponent().material = mat_preview[0];
580 |
581 | break;
582 | case 5:
583 | PlayerModelController.player_preview.GetComponent().material = mat_preview[1];
584 |
585 | break;
586 | case 6:
587 | PlayerModelController.player_preview.GetComponent().material = mat_preview[2];
588 |
589 | break;
590 | case 7:
591 | PlayerModelController.player_preview.GetComponent().material = mat_preview[3];
592 |
593 | break;
594 | }
595 | }
596 |
597 | public float currentTime = 0;
598 |
599 |
600 |
601 | public float voiceDelay = 1;
602 | public const int samples = 10;
603 |
604 | float[] readings = new float[samples];
605 | int readIndex = 0;
606 | float total = 0;
607 | public float avg = 0;
608 |
609 | public void voiceSmoothing()
610 | {
611 |
612 | total -= readings[readIndex];
613 |
614 | readings[readIndex] = loudness;
615 | // add the reading to the total:
616 | total = total + readings[readIndex];
617 | // advance to the next position in the array:
618 | readIndex++;
619 |
620 | // if we're at the end of the array...
621 | if (readIndex >= samples)
622 | {
623 | // ...wrap around to the beginning:
624 |
625 | readIndex = 0;
626 | }
627 |
628 | // calculate the average:
629 | avg = total / samples;
630 |
631 | }
632 | public static float loudness;
633 |
634 | public float LipSyncWeight = 0;
635 |
636 | public bool LipSyncFlag = true;
637 |
638 | public bool InRoom = false;
639 |
640 |
641 | bool flagcode = false;
642 | private void Update()
643 | {
644 |
645 | if (!STARTPLAYERMOD)
646 | {
647 | return;
648 | }
649 |
650 | if (Time.time > currentTime)
651 | {
652 | currentTime = Time.time + 1;
653 |
654 | if (PlayerModelController.localPositionY == 1f)
655 | {
656 | PlayerModelController.localPositionY = -1f;
657 | }
658 | else
659 | {
660 | PlayerModelController.localPositionY = 1f;
661 | }
662 | }
663 |
664 |
665 |
666 | PlayerModelController.rotationY -= 0.2f;
667 |
668 | /*loudness = GetLoudnessFromMic() * loudnessSensitivity;
669 |
670 | voiceSmoothing();
671 |
672 | if (avg < threshold)
673 | avg = 0;
674 |
675 | Vector3 minScale = new Vector3(.1f, .1f, .1f);
676 | Vector3 maxScale = new Vector3(1f, 1f, 1f);
677 |
678 | voiceObject.transform.localScale = Vector3.Lerp(minScale, maxScale, avg);
679 |
680 | LipSyncWeight = Mathf.Lerp(0, 100, avg);
681 | */
682 |
683 | if (Keyboard.current.jKey.wasPressedThisFrame)
684 | SelectButton.GetComponent().Press();
685 |
686 | if (Keyboard.current.hKey.wasPressedThisFrame)
687 | LeftButton.GetComponent().Press();
688 |
689 | if (Keyboard.current.kKey.wasPressedThisFrame)
690 | RightButton.GetComponent().Press();
691 |
692 |
693 | //Debug.Log(IsGorilla);
694 |
695 | /*if (GorillaParent.instance.vrrigs.Count >= 1)
696 | {
697 | if (Time.time > voiceDelay)
698 | {
699 |
700 | voiceDelay += 1;
701 | Debug.Log("new time " + voiceDelay);
702 | restartMic();
703 |
704 |
705 | }
706 |
707 | }
708 | else
709 | {
710 | if (!LipSyncFlag)
711 | {
712 |
713 | restartMic();
714 | LipSyncFlag = true;
715 | Debug.Log("Mic Restart");
716 | }
717 | }*/
718 | if (!IsGorilla)
719 | {
720 | playermodel = GameObject.Find("playermodel.body");
721 | if (playermodel == null)
722 | {
723 | PlayerModelController.LoadModel(playerIndex);
724 | PlayerModelController.AssignModel();
725 | }
726 | }
727 |
728 |
729 |
730 |
731 | if (PhotonNetwork.InRoom)
732 | {
733 |
734 | if (IsGorilla == true)//in a room, is gorilla model
735 | {
736 |
737 | PlayerModelAppearance.ShowOfflineRig();
738 | //PlayerModelAppearance.ShowOnlineRig();
739 | flag_inroom = true;
740 | PlayerModelAppearance.flag1 = true;
741 |
742 | clone_body = null;
743 | }
744 | else//in a room, is playermodel
745 | {
746 | if (playermodel != null)
747 | {
748 |
749 | PlayerModelAppearance.HideOfflineRig();
750 | //PlayerModelAppearance.HideOnlineRig();
751 |
752 | if (PlayerModelController.CustomColors)
753 | PlayerModelAppearance.AssignColor();
754 |
755 | if (PlayerModelController.GameModeTextures)
756 |
757 | PlayerModelAppearance.AssignMaterial(playermodel);
758 |
759 | if (PlayerModelController.LipSync)
760 | {
761 | playermodel.GetComponent().SetBlendShapeWeight(0, LipSyncWeight);
762 | }
763 | }
764 |
765 |
766 |
767 | }
768 | }
769 | else if (!PhotonNetwork.InRoom)
770 | {
771 |
772 |
773 | flag_inroom = false;
774 | clone_body = null;
775 | if (IsGorilla == true)//not in a room, is gorilla model
776 | {
777 |
778 | PlayerModelAppearance.flag1 = true;
779 | PlayerModelAppearance.ShowOfflineRig();
780 |
781 | }
782 | else//not in a room, is playermodel
783 | {
784 | playermodel = GameObject.Find("playermodel.body");
785 | if (playermodel != null)
786 | {
787 |
788 | PlayerModelAppearance.ResetMaterial(playermodel);
789 | PlayerModelAppearance.HideOfflineRig();
790 |
791 |
792 |
793 | //if (PlayerModelController.CustomColors)
794 | //PlayerModelAppearance.AssignColor();
795 |
796 | //PlayerModelAppearance.AssignMaterial(playermodel);
797 |
798 | if (PlayerModelController.LipSync)
799 | {
800 | playermodel.GetComponent().SetBlendShapeWeight(0, LipSyncWeight);
801 | }
802 |
803 | }
804 |
805 | }
806 |
807 | }
808 |
809 | }//fixedupdate
810 | }
811 | }
812 |
--------------------------------------------------------------------------------