public CarCreationData(GameObject go, Mesh renderMesh, Mesh colliderMesh, CRBalltreeAsset btAsset, bool isRope) { gameObject_ = go; isRope_ = isRope; positionRotationCanBeUpdated_ = true; renderFingerprint_ = null; colliderFingerprint_ = null; btAsset_ = btAsset; if (renderMesh != null) { renderFingerprint_ = new byte[256]; CarGeometryUtils.CalculateFingerprint(renderMesh, renderFingerprint_); } if (colliderMesh != null) { colliderFingerprint_ = new byte[256]; CarGeometryUtils.CalculateFingerprint(colliderMesh, colliderFingerprint_); } position_ = go.transform.position; rotation_ = go.transform.rotation; lossyScale_ = go.transform.lossyScale; positionCollider_ = Vector3.zero; rotationCollider_ = Quaternion.identity; lossyScaleCollider_ = Vector3.one; Caronte_Fx_Body fxBody = go.GetComponent <Caronte_Fx_Body>(); if (fxBody != null) { colliderType_ = fxBody.ColliderType; hasValidCollider_ = fxBody.HasValidCollider(); if (colliderType_ == Caronte_Fx_Body.EColliderType.CustomGameObject) { GameObject goCollider = fxBody.GetColliderGameObject(); if (goCollider != null) { positionCollider_ = goCollider.transform.position; rotationCollider_ = goCollider.transform.rotation; lossyScaleCollider_ = goCollider.transform.lossyScale; } } } }
public Matrix4x4 GetCurrentMatrixLocalToWorld() { if (colliderType_ == Caronte_Fx_Body.EColliderType.CustomGameObject) { Caronte_Fx_Body bodyComponent = gameObject_.GetComponent <Caronte_Fx_Body>(); GameObject colliderGameObject = bodyComponent.GetColliderGameObject(); return(colliderGameObject.transform.localToWorldMatrix); } else { return(gameObject_.transform.localToWorldMatrix); } }
public void UpdatePositionRotation() { position_ = gameObject_.transform.position; rotation_ = gameObject_.transform.rotation; if (colliderType_ == Caronte_Fx_Body.EColliderType.CustomGameObject) { Caronte_Fx_Body bodyComponent = gameObject_.GetComponent <Caronte_Fx_Body>(); if (bodyComponent != null) { GameObject colliderGameObject = bodyComponent.GetColliderGameObject(); if (colliderGameObject != null) { positionCollider_ = colliderGameObject.transform.position; rotationCollider_ = colliderGameObject.transform.rotation; } } } }
public bool IsValidPositionRotation() { if (gameObject_ == null) { positionRotationCanBeUpdated_ = false; return(false); } if (gameObject_.transform.position != position_ || gameObject_.transform.rotation != rotation_) { return(false); } if (colliderType_ == Caronte_Fx_Body.EColliderType.CustomGameObject) { positionRotationCanBeUpdated_ = false; Caronte_Fx_Body bodyComponent = gameObject_.GetComponent <Caronte_Fx_Body>(); if (bodyComponent == null) { return(false); } GameObject colliderGameObject = bodyComponent.GetColliderGameObject(); if (colliderGameObject == null) { return(false); } if (colliderGameObject.transform.position != positionCollider_ || colliderGameObject.transform.rotation != rotationCollider_) { return(false); } } return(true); }
public bool IsValidScale() { if (gameObject_ == null) { return(false); } if (gameObject_.transform.lossyScale != lossyScale_) { return(false); } if (colliderType_ == Caronte_Fx_Body.EColliderType.CustomGameObject) { Caronte_Fx_Body bodyComponent = gameObject_.GetComponent <Caronte_Fx_Body>(); if (bodyComponent == null) { return(false); } GameObject colliderGameObject = bodyComponent.GetColliderGameObject(); if (colliderGameObject == null) { return(false); } if (colliderGameObject.transform.lossyScale != lossyScaleCollider_) { return(false); } } return(true); }