예제 #1
0
        private void CreateDirectionalDecal(Shape shape, Vec3 pos, Vec3 normal, int triangleID)
        {
            bool smallDecal = Type.Size < .3f;

            Body body = shape.Body;

            //static objects
            if (shape.ContactGroup == (int)ContactGroup.Collision)
            {
                ShapeTriangleID triangle = new ShapeTriangleID(shape, triangleID);

                //StaticMesh
                {
                    StaticMesh staticMesh =
                        MapSystemWorld.GetMapObjectByShapeWithStaticBatchingSupport(shape, triangleID) as StaticMesh;
                    //StaticMesh staticMesh = StaticMesh.GetStaticMeshByBody( body );
                    if (staticMesh != null)
                    {
                        if (staticMesh.AllowDecals == StaticMesh.DecalTypes.OnlySmall && smallDecal ||
                            staticMesh.AllowDecals == StaticMesh.DecalTypes.All)
                        {
                            CreateDecalForStaticObject(triangle, pos, normal, null);
                            return;
                        }
                    }
                }

                //HeightmapTerrain
                if (HeightmapTerrain.GetTerrainByBody(body) != null)
                {
                    CreateDecalForStaticObject(triangle, pos, normal, null);
                    return;
                }

                if (Type.ApplyToMapObjects)
                {
                    //MapObject: Attached mesh
                    MapObject mapObject = MapSystemWorld.GetMapObjectByBody(body);
                    if (mapObject != null)
                    {
                        bool isCollision = false;

                        foreach (MapObjectAttachedObject attachedObject in mapObject.AttachedObjects)
                        {
                            MapObjectAttachedMesh attachedMesh = attachedObject as MapObjectAttachedMesh;
                            if (attachedMesh != null && attachedMesh.CollisionBody == body)
                            {
                                isCollision = true;
                                break;
                            }
                        }

                        if (isCollision)
                        {
                            CreateDecalForStaticObject(triangle, pos, normal, mapObject);
                            return;
                        }
                    }
                }
            }

            //dynamic objects
            {
                //not implemented
            }
        }