Пример #1
0
        /// <summary>
        /// Returns true if projectiles can penetrate this surface, false otherwise.
        /// </summary>
        /// <param name="triangleIndex">The hit triangle index.</param>
        public bool CanPenetrate(int triangleIndex = -1)
        {
            if (m_SurfaceList == null)
            {
                return(false);
            }

            return(!IsTerrain && m_SurfaceList[SurfaceUtility.GetMaterialIndex(triangleIndex, gameObject)].Penetration);
        }
Пример #2
0
        /// <summary>
        /// Returns true if the surface allows decals to be drawn on it, false otherwise.
        /// </summary>
        /// <param name="triangleIndex">The hit triangle index.</param>
        public bool AllowDecals(int triangleIndex = -1)
        {
            if (m_SurfaceList == null)
            {
                return(false);
            }

            return(!IsTerrain && m_SurfaceList[SurfaceUtility.GetMaterialIndex(triangleIndex, gameObject)].AllowDecals);
        }
Пример #3
0
        /// <summary>
        /// Returns the density of this surface.
        /// </summary>
        /// <param name="triangleIndex">The hit triangle index.</param>
        public float Density(int triangleIndex = -1)
        {
            if (m_SurfaceList == null)
            {
                return(1);
            }

            if (!IsTerrain)
            {
                return(m_SurfaceList[SurfaceUtility.GetMaterialIndex(triangleIndex, gameObject)].Density);
            }
            return(1);
        }
Пример #4
0
        /// <summary>
        /// Returns the SurfaceType at given position.
        /// </summary>
        /// <param name="position">The contact position. (if the GameObject is a Terrain)</param>
        /// <param name="triangleIndex">The hit triangle index.</param>
        /// <returns></returns>
        public SurfaceType GetSurfaceType(Vector3 position, int triangleIndex = -1)
        {
            if (m_SurfaceList == null || m_SurfaceList.Length <= 0)
            {
                return(null);
            }

            if (IsTerrain)
            {
                int index = SurfaceUtility.GetMainTexture(position, ActiveTerrain.transform.position, ActiveTerrain.terrainData);
                return(index < m_SurfaceList.Length ? m_SurfaceList[index].SurfaceType : null);
            }
            return(m_SurfaceList[SurfaceUtility.GetMaterialIndex(triangleIndex, gameObject)].SurfaceType);
        }