Created
June 5, 2018 14:36
-
-
Save ronyx69/e69e5d0b0b4a28d6577a5afad1af3dcf to your computer and use it in GitHub Desktop.
Copy vertex paint from a prop to a vehicle sub mesh. Apply and save AnimUV params.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Anim UV Scripts | |
// Create scrolling or multi-frame animations for vehicle sub meshes. | |
// Run in asset editor and see effects in real time. | |
// AnimUV Params Mod is not required for using the scripts and saving the asset. | |
// It's only needed to load the data in-game. | |
// Animated faces must be vertex painted black! The rest reimains white. | |
// Shades of gray animate slower, don't use unless you know what you're doing. | |
// Google how to do vertex color painting in your 3d software of choice! | |
// for vehicles, vertex colors get generated and overwritten on import | |
// therefore you need to import the sub mesh as a prop, save, reload | |
// and then import the vehicle sub mesh, | |
// and copy the vertex paint from the prop to the vehicle sub mesh using this script: | |
var subMesh = 1; // vehicle sub mesh id, starting from 1 | |
var asset2 = PrefabCollection<PropInfo>.FindLoaded("filename.Asset Name_Data"); // CHANGE TO PROP NAME | |
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as VehicleInfo; | |
Color[] colors = new Color[asset2.m_mesh.vertices.Length]; | |
for (int i = 0; i < asset2.m_mesh.vertices.Length; i++) colors[i] = asset2.m_mesh.colors[i]; | |
asset.m_subMeshes[subMesh].m_subInfo.m_mesh.colors = colors; | |
// | |
// The LODs are not UV animated, they are like regular props. | |
// AnimUV Simplified Script (Vehicle Sub Mesh) | |
// Simple UV scrolling animation | |
var subMesh = 1; // Sub mesh id starting from 1 | |
var time = 2; // Length of animation loop in seconds. | |
var fps = 30; // Frames per second, more than 60 not recommended. | |
var sideways = false; // Set to true if you want horizontal UV scroll. | |
var reverse = false; // Set to true to reverse the scrolling direction. | |
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as VehicleInfo; | |
var shader = Shader.Find("Custom/Props/Prop/AnimUV"); | |
asset.m_subMeshes[subMesh].m_subInfo.m_material.shader = shader; | |
shader = Shader.Find("Custom/Props/Prop/Default"); | |
asset.m_subMeshes[subMesh].m_subInfo.m_lodMaterial.shader = shader; | |
var tx=0f; var ty=0f; | |
if(sideways==true) tx=1f/(fps*time); else ty=1f/(fps*time); | |
if(reverse==true) { tx=0-tx; ty=0-ty; } | |
var frames = 1f*fps*time; | |
var cycles = 60f/time; | |
var vec = new Vector4(tx, ty, frames, cycles); | |
asset.m_subMeshes[subMesh].m_subInfo.m_material.SetVector("_RollParams0", vec); | |
asset.m_subMeshes[subMesh].m_subInfo.m_mesh.name="AnimUV "+tx.ToString("R")+" "+ty.ToString("R")+" "+frames.ToString("R")+" "+ cycles.ToString("R"); | |
// AnimUV Advanced Script (Vehicle Sub Mesh) | |
// Full control over AnimUV paramaters | |
var subMesh = 1; // Sub mesh id starting from 1 | |
var tx = 0.05f; // X coordinate transform amount, 1f = full width of image | |
var ty = 0.1f; // Y coordinate transform amount, 1f = full height of image | |
var frames = 30f; // Amount of transforms per cycle. Amount of animation frames. | |
var cycles = 60f; // Animation cycles per minute. | |
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as VehicleInfo; | |
var shader = Shader.Find("Custom/Props/Prop/AnimUV"); | |
asset.m_subMeshes[subMesh].m_subInfo.m_material.shader = shader; | |
shader = Shader.Find("Custom/Props/Prop/Default"); | |
asset.m_subMeshes[subMesh].m_subInfo.m_lodMaterial.shader = shader; | |
var vec = new Vector4(tx, ty, frames, cycles); | |
asset.m_subMeshes[subMesh].m_subInfo.m_material.SetVector("_RollParams0", vec); | |
asset.m_subMeshes[subMesh].m_subInfo.m_mesh.name="AnimUV "+tx.ToString("R")+" "+ty.ToString("R")+" "+frames.ToString("R")+" "+ cycles.ToString("R"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment