public override void Init(GPUSkinning gpuSkinning) { base.Init(gpuSkinning); newLodMesh = new Mesh(); newLodMesh.vertices = lodMesh.vertices; newLodMesh.uv = lodMesh.uv; newLodMesh.triangles = lodMesh.triangles; newLodMesh.tangents = GPUSkinningUtil.ExtractBoneWeights(lodMesh); additionalVertexStreames = new GPUSkinning_AdditionalVertexStreames(newLodMesh); // Bounding Sphere lodBoundingSpheres = new BoundingSphere[gpuSkinning.model.spawnObjects.Length]; for (int i = 0; i < lodBoundingSpheres.Length; ++i) { lodBoundingSpheres[i] = new BoundingSphere(gpuSkinning.model.spawnObjects[i].transform.position, 1f); } // Culling Group lodCullingGroup = new CullingGroup(); lodCullingGroup.targetCamera = Camera.main; lodCullingGroup.SetBoundingSpheres(lodBoundingSpheres); lodCullingGroup.SetBoundingSphereCount(lodBoundingSpheres.Length); lodCullingGroup.SetBoundingDistances(new float[] { 10, 15, 25, 40 }); lodCullingGroup.SetDistanceReferencePoint(Camera.main.transform); lodCullingGroup.onStateChanged = OnLodCullingGroupOnStateChangedHandler; newLodMesh.UploadMeshData(true); }
public override void Destroy() { base.Destroy(); if (matricesTex != null) { Object.Destroy(matricesTex); matricesTex = null; } if (additionalVertexStreames != null) { additionalVertexStreames.Destroy(); additionalVertexStreames = null; } hierarchyMatrices = null; }
public override void Destroy() { base.Destroy(); if (newLodMesh != null) { Object.Destroy(newLodMesh); newLodMesh = null; } if (additionalVertexStreames != null) { additionalVertexStreames.Destroy(); additionalVertexStreames = null; } if (lodCullingGroup != null) { lodCullingGroup.Dispose(); lodCullingGroup = null; } lodBoundingSpheres = null; }
public override void Init(GPUSkinning gpuSkinning) { base.Init(gpuSkinning); if (IsMatricesTextureSupported()) { shaderPropID_MatricesTex = Shader.PropertyToID("_MatricesTex"); shaderPropID_MatricesTexSize = Shader.PropertyToID("_MatricesTexSize"); shaderPropID_AnimLength = Shader.PropertyToID("_AnimLength"); shaderPropID_AnimFPS = Shader.PropertyToID("_AnimFPS"); shaderPropID_NumPixelsPerFrame = Shader.PropertyToID("_NumPixelsPerFrame"); matricesTex = new Texture2D(matricesTexWidth, matricesTexHeight, TextureFormat.RGBAHalf, false); matricesTex.name = "_MatricesTex"; matricesTex.filterMode = FilterMode.Point; additionalVertexStreames = new GPUSkinning_AdditionalVertexStreames(gpuSkinning.model.newMesh); BakeAnimationsToTexture(); } }