void Awake() { //hitPoint = pointer.hitPoint; cloth = GetComponent <ObiClothBase>(); lastMousePos = hitPoint; // kick // trackedObj = GetComponent<SteamVR_TrackedObject>(); }
void Awake() { cloth = GetComponent <ObiClothBase>(); collider = GetComponent <MeshCollider>(); collider.enabled = false; lastMousePos = Input.mousePosition; }
protected virtual void Awake() { cloth = GetComponent <ObiClothBase>(); cloth.OnBlueprintLoaded += OnBlueprintLoaded; cloth.OnBlueprintUnloaded += OnBlueprintUnloaded; if (cloth.isLoaded) { OnBlueprintLoaded(cloth, cloth.sourceBlueprint); } }
void Awake() { //hitPoint = pointer.hitPoint; cloth = GetComponent <ObiClothBase>(); //if (GameObject.FindWithTag("right") != null) //{ right = GameObject.Find("RightController").GetComponent <VRTK_Pointer>(); //Debug.Log(right.gameObject.name); left = GameObject.Find("LeftController").GetComponent <VRTK_Pointer>(); //} //else //{ // Debug.Log("f**k?"); //} lastMousePos = hitPoint; // kick // trackedObj = GetComponent<SteamVR_TrackedObject>(); }
public override void UnloadBlueprint(ObiSolver solver) { int index = m_Solver.actors.IndexOf(this); if (index >= 0 && sourceBlueprint != null && clothBlueprintBase.deformableTriangles != null) { // remove triangles: solver.implementation.RemoveDeformableTriangles(clothBlueprintBase.deformableTriangles.Length / 3, trianglesOffset); // update all following actor's triangle offset: for (int i = index + 1; i < m_Solver.actors.Count; i++) { ObiClothBase clothActor = solver.actors[i] as ObiClothBase; if (clothActor != null) { clothActor.trianglesOffset -= clothBlueprintBase.deformableTriangles.Length / 3; } } } base.UnloadBlueprint(solver); }
void Awake() { cloth = GetComponent <ObiClothBase>(); //lastMousePos = Input.mousePosition; }
public void UpdateSkinning(ObiActor actor) { GetSlaveMeshIfNeeded(); ObiClothBase masterCloth = m_Master.GetComponent <ObiClothBase>(); if (skinMap.bound && slaveMesh != null && masterCloth.isLoaded) { Matrix4x4 s2l; if (gameObject == m_Master.gameObject) { s2l = m_Master.renderMatrix * masterCloth.solver.transform.localToWorldMatrix; } else { s2l = transform.worldToLocalMatrix * masterCloth.solver.transform.localToWorldMatrix; } Vector3[] slavePositions = slaveMesh.vertices; Vector3[] slaveNormals = slaveMesh.normals; Vector4[] slaveTangents = slaveMesh.tangents; for (int i = 0; i < skinMap.skinnedVertices.Count; ++i) { var data = skinMap.skinnedVertices[i]; int firstVertex = data.masterTriangleIndex; int t1 = masterCloth.clothBlueprintBase.deformableTriangles[firstVertex]; int t2 = masterCloth.clothBlueprintBase.deformableTriangles[firstVertex + 1]; int t3 = masterCloth.clothBlueprintBase.deformableTriangles[firstVertex + 2]; // get solver indices for each particle: int s1 = masterCloth.solverIndices[t1]; int s2 = masterCloth.solverIndices[t2]; int s3 = masterCloth.solverIndices[t3]; // get master particle positions/normals: Vector3 p1 = masterCloth.solver.renderablePositions[s1]; Vector3 p2 = masterCloth.solver.renderablePositions[s2]; Vector3 p3 = masterCloth.solver.renderablePositions[s3]; Vector3 n1 = masterCloth.solver.normals[s1]; Vector3 n2 = masterCloth.solver.normals[s2]; Vector3 n3 = masterCloth.solver.normals[s3]; Vector3 skinnedPos = ObiUtils.BarycentricInterpolation(p1, p2, p3, data.position.barycentricCoords) + ObiUtils.BarycentricInterpolation(n1, n2, n3, data.position.barycentricCoords) * data.position.height; Vector3 skinnedNormal = ObiUtils.BarycentricInterpolation(p1, p2, p3, data.normal.barycentricCoords) + ObiUtils.BarycentricInterpolation(n1, n2, n3, data.normal.barycentricCoords) * data.normal.height; Vector3 skinnedTangent = ObiUtils.BarycentricInterpolation(p1, p2, p3, data.tangent.barycentricCoords) + ObiUtils.BarycentricInterpolation(n1, n2, n3, data.tangent.barycentricCoords) * data.tangent.height; // update slave data arrays: slavePositions[data.slaveIndex] = s2l.MultiplyPoint3x4(skinnedPos); slaveNormals[data.slaveIndex] = s2l.MultiplyVector(skinnedNormal - skinnedPos); Vector3 tangent = s2l.MultiplyVector(skinnedTangent - skinnedPos); slaveTangents[data.slaveIndex] = new Vector4(tangent.x, tangent.y, tangent.z, slaveTangents[data.slaveIndex].w); } slaveMesh.vertices = slavePositions; slaveMesh.normals = slaveNormals; slaveMesh.tangents = slaveTangents; slaveMesh.RecalculateBounds(); } }