Ok, so I create an object with an IDE defined mesh. I assign boneweights based on the position.x of each vertex.
Later, I instantiate the object, I then assign the boneweights to the mesh, however when I attempt to rotate the bones, they have nothing happens.
Here is the pertinent part of my project:
DUMMYWALL = Instantiate(DUMMYWALL,World.position,Quaternion.identity)as Transform;
Destroy(DUMMYWALL.gameObject.GetComponent<MeshRenderer>());
DUMMYWALL.gameObject.AddComponent<SkinnedMeshRenderer>();
//DUMMYWALL.localScale = Scale;
Transform[] WallBones = new Transform[2];
Matrix4x4[] WallBP = new Matrix4x4[2];
MeshFilter WallMeshFilter = DUMMYWALL.gameObject.GetComponent<MeshFilter>();
SkinnedMeshRenderer WallSMRenderer = DUMMYWALL.gameObject.GetComponent<SkinnedMeshRenderer>();
Vector3[] WallVerts = WallMeshFilter.mesh.vertices;
WallBW = new BoneWeight[WallVerts.Length];
for (int i = 0; i < WallVerts.Length; i++) {
WallBW*.boneIndex0 = 0;*
WallBW_.weight0 = Mathf.Abs(10WallVerts.x);
WallBW.boneIndex1 = 1;
WallBW.weight1 = (1f - (10Mathf.Abs(WallVerts*.x)));
}*_
* WallBones[0] = new GameObject(“Bone 0”).transform;*
* WallBones[0].localPosition = WallVerts[189];*
* WallBones[0].parent = DUMMYWALL;*
WallBP[0] = WallBones[0].worldToLocalMatrix * transform.localToWorldMatrix;
* WallBones[1] = new GameObject(“Bone 1”).transform;*
* WallBones[1].localPosition = WallVerts[2];*
* WallBones[1].parent = DUMMYWALL;*
WallBP[1] = WallBones[1].worldToLocalMatrix * transform.localToWorldMatrix;
* //Assign collections to DUMMYWALL*
* WallMeshFilter.mesh.boneWeights = WallBW;*
* WallMeshFilter.mesh.bindposes = WallBP;*
* WallSMRenderer.sharedMesh = WallMeshFilter.mesh;*
* WallSMRenderer.bones = WallBones;*
Transform southwall = (Transform)Instantiate(DUMMYWALL,(nCMfilter.mesh.vertices[0]*.99f),Quaternion.identity);
* southwall.name = “SouthWall”;*
* southwall.parent = nCGO.transform;*
_ southwall.localRotation = (Quaternion.LookRotation(Vector3.zero - southwall.transform.position) * away);
* MeshFilter SWMFilter = southwall.gameObject.GetComponent();
SkinnedMeshRenderer SWSMRenderer = southwall.gameObject.GetComponent();
Matrix4x4 WallBP = new Matrix4x4[2];
SWMFilter.mesh.boneWeights = WallBW;
SWSMRenderer.sharedMesh = SWMFilter.mesh;
SWSMRenderer.bones[0].localPosition = SWMFilter.mesh.vertices[189];
SWSMRenderer.bones[1].localPosition = SWMFilter.mesh.vertices[2];*_
I figured it out, I apparently have to set the weights of the instantiated mesh. Talk about a disgusting waste of processing.