// Start is called before the first frame update. void Start() { myRb = GetComponent <PhysXRigidBody>(); meshstateTracker = FindObjectOfType <MeshstateTracker>(); deformableMeshes = new List <DeformableMesh>(GetComponentsInChildren <DeformableMesh>()); DeformableMesh.Subdivide(deformableMeshes[0].maxEdgeLength, deformableMeshes[0].GetMeshFilter().mesh); vertices = new List <Vector3>(deformableMeshes[0].GetMeshFilter().mesh.vertices); // Group similar vertices. meshGraph = meshstateTracker.GetMyMeshGraph(meshType); originalMesh = Instantiate(deformableMeshes[0].GetMeshFilter().mesh); collisionResolver = Instantiate(collisionResolver); resolverBody = collisionResolver.GetComponent <PhysXBody>(); resolverBody.position = new Vector3(0, 10000, 0); interfaceCar = GetComponent <InterfaceCarDrive4W>(); if (interfaceCar != null) { frWheel = interfaceCar.frontRightW; frWheelVertexGroup = NearestVertexTo(frWheel.transform.position); flWheel = interfaceCar.frontLeftW; flWheelVertexGroup = NearestVertexTo(flWheel.transform.position); rrWheel = interfaceCar.rearRightW; rrWheelVertexGroup = NearestVertexTo(rrWheel.transform.position); rlWheel = interfaceCar.rearLeftW; rlWheelVertexGroup = NearestVertexTo(rlWheel.transform.position); } teamId = GetComponent <NetworkPlayerVehicle>().teamId; }
public void Set(DeformableMesh deformable) { Vector3[] verts = deformable.GetVertsWS(); for (int v = 0; v < verts.Length; v++) { // check if in bounds Vector3 localV = LocalPoint(verts[v]); if (bounds.Contains(localV)) { // find vert's grid cell float weightingX, weightingY; //Debug.Log(localV.x); int x = PointToGrid(localV.x, out weightingX, cellsM1); int y = PointToGrid(localV.y, out weightingY, cellsM1); //Debug.Log("x: " + x + ", y: " + y); // deform if (x > -1 && x < cellsM1 && y > -1 && y < cellsM1) { localV += BilinearFilter(x, y, weightingX, weightingY); verts[v] = WorldPoint(localV); } } } deformable.SetVertsWS(verts); }
void LateStart() { // Split each mesh ready for deformations. DeformableMesh.Subdivide(maxEdgeLength, interceptorMeshFilter); interceptorMeshGraph = new MeshGraph(interceptorMeshFilter, groupRadius); System.GC.Collect(); Debug.Log("IanMeshDone"); //DeformableMesh.Subdivide(maxEdgeLength, aceMeshFilter); aceMeshGraph = new MeshGraph(aceMeshFilter, groupRadius); System.GC.Collect(); Debug.Log("AceMeshDone"); DeformableMesh.Subdivide(maxEdgeLength, bomberMeshFilter); bomberMeshGraph = new MeshGraph(bomberMeshFilter, groupRadius); System.GC.Collect(); Debug.Log("BomberMeshDone"); //DeformableMesh.Subdivide(maxEdgeLength, bikeMeshFilter); //bikeMeshGraph = new MeshGraph(bikeMeshFilter, groupRadius); //System.GC.Collect(); //Debug.Log("BikeMeshDone"); Debug.Log("Loading Main Menu..."); SceneManager.LoadScene("MainMenu"); //StartCoroutine(nameof(LoadMeshes)); }
// Use this for initialization void Start() { filter = GetComponent <MeshFilter>(); filter.mesh = GenerateMesh(); deformableMeshRef = GetComponent <DeformableMesh>(); deformableMeshRef.MeshRegenerated(); }
private void Start() { mInfo = GetComponent <MeshInfo>(); Collider c = GetComponent <Collider>(); minImpactDistance = Mathf.Min(c.bounds.extents.x, Mathf.Min(c.bounds.extents.y, c.bounds.extents.z)) * 2.0f; deformableMesh = GetComponent <DeformableMesh>(); defaultHitsToCut = hitsToCut; }
void Awake() { if (current == null) { current = this; } else { Destroy(gameObject); } planeGenerator = GetComponent <generatePlaneMesh> (); }
public override bool ApplyOperation() { if (base.ApplyOperation()) { DeformableMesh deformationScript = objectTransform.GetComponent <DeformableMesh>(); if (deformationScript != null) { deformationScript.Deform(impactVector, simplifiedVector); return(true); } } return(false); }
void HandleInput() { Ray inputRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(inputRay, out hit)) { DeformableMesh deformer = hit.collider.GetComponent <DeformableMesh>(); if (deformer) { Vector3 point = hit.point; point += hit.normal * forceOffset; deformer.AddDeformingForce(point, hit.normal, force, forceOffset); } } }
void Update() { if (Input.GetMouseButton(0)) { ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hitInfo)) { snow = hitInfo.collider.gameObject.GetComponent <DeformableMesh>(); if (snow) { Vector3 inputPosition = hitInfo.point; inputPosition += hitInfo.normal * 0.1f; snow.AddForce(inputPosition); } } } }
void Start() { deformableMesh = GetComponent <DeformableMesh>(); rigidBody = GetComponent <Rigidbody>(); }
public void RpcOnDeform(Vector3 impactVector, Vector3 simplifiedVector) { DeformableMesh deformableMesh = GetComponent <DeformableMesh>(); deformableMesh.Deform(impactVector, simplifiedVector); }
void OnCollisionEnter(Collision other) { _deformable = other.gameObject.GetComponent <DeformableMesh>(); }
void OnCollisionExit(Collision other) { _deformable = null; }
void Start() { planeDeformer = GetComponent <DeformableMesh> (); }