コード例 #1
0
        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;
                    }
                }
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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;
                    }
                }
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }