Esempio n. 1
0
 public static ChiselBrushMaterial CreateInstance(Material renderMaterial, LayerUsageFlags layerUsage = LayerUsageFlags.RenderReceiveCastShadows)
 {
     return(new ChiselBrushMaterial
     {
         LayerUsage = layerUsage,
         RenderMaterial = renderMaterial
     });
 }
Esempio n. 2
0
        public static CSGSurfaceAsset CreateInstance(LayerUsageFlags layerUsage = LayerUsageFlags.None)
        {
            var newSurface = new CSGSurfaceAsset();//ScriptableObject.CreateInstance<CSGSurfaceAsset>();

            //newSurface.name				= "Surface";
            newSurface.LayerUsage = layerUsage;
            return(newSurface);
        }
Esempio n. 3
0
 /// <summary>Constructs a <see cref="RealtimeCSG.Foundation.MeshQuery"/> to use to specify which surfaces should be combined into meshes, and should they be subdivided by a particular layer parameter index.</summary>
 /// <param name="query">Which layer combination would we like to look for and generate a mesh with.</param>
 /// <param name="mask">What layers do we ignore, and what layers do we include in our comparison. When this value is <see cref="RealtimeCSG.Foundation.LayerUsageFlags.None"/>, <paramref name="mask"/> is set to be equal to <paramref name="query"/>.</param>
 /// <param name="parameterIndex">Which parameter index we use to, for example, differentiate between different [UnityEngine.Material](https://docs.unity3d.com/ScriptReference/Material.html)s</param>
 /// <param name="vertexChannels">Which vertex channels need to be used for the meshes we'd like to generate.</param>
 /// <seealso cref="RealtimeCSG.Foundation.SurfaceLayers" />
 public MeshQuery(LayerUsageFlags query, LayerUsageFlags mask = LayerUsageFlags.None, LayerParameterIndex parameterIndex = LayerParameterIndex.None, VertexChannelFlags vertexChannels = VertexChannelFlags.Position)
 {
     if (mask == LayerUsageFlags.None)
     {
         mask = query;
     }
     this.layers          = ((uint)query & ~BitMask) | ((uint)parameterIndex << BitShift);
     this.maskAndChannels = ((uint)mask & ~BitMask) | ((uint)vertexChannels << BitShift);
 }
Esempio n. 4
0
        public static CSGSurfaceAsset CreateInstance(PhysicMaterial physicsMaterial, LayerUsageFlags layerUsage = LayerUsageFlags.Collidable)
        {
            var newSurface = new CSGSurfaceAsset();//ScriptableObject.CreateInstance<CSGSurfaceAsset>();

            //newSurface.name				= "Surface";
            newSurface.LayerUsage      = layerUsage;
            newSurface.PhysicsMaterial = physicsMaterial;
            return(newSurface);
        }
Esempio n. 5
0
        public static CSGSurfaceAsset CreateInstance(Material renderMaterial, LayerUsageFlags layerUsage = LayerUsageFlags.RenderReceiveCastShadows)
        {
            var newSurface = new CSGSurfaceAsset();//ScriptableObject.CreateInstance<CSGSurfaceAsset>();

            //newSurface.name				= "Surface " + renderMaterial.name;
            newSurface.LayerUsage     = layerUsage;
            newSurface.RenderMaterial = renderMaterial;
            return(newSurface);
        }
        public static void OnLayerUsageFlagsChanged(CSGSurfaceAsset surfaceAsset, LayerUsageFlags prevValue, LayerUsageFlags value)
        {
            if (!registeredLookup.Contains(surfaceAsset) || (prevValue == value))
            {
                return;
            }

            if (OnSurfaceAssetChanged != null)
            {
                OnSurfaceAssetChanged(surfaceAsset);
            }
        }
Esempio n. 7
0
        public static ChiselRenderObjects Create(string name, Transform parent, GameObjectState state, LayerUsageFlags query, bool debugHelperRenderer = false)
        {
            var renderContainer = ChiselObjectUtility.CreateGameObject(name, parent, state, debugHelperRenderer: debugHelperRenderer);
            var meshFilter      = renderContainer.AddComponent <MeshFilter>();
            var meshRenderer    = renderContainer.AddComponent <MeshRenderer>();

            meshRenderer.enabled = false;

            var renderObjects = new ChiselRenderObjects
            {
                invalid             = false,
                query               = query,
                container           = renderContainer,
                meshFilter          = meshFilter,
                meshRenderer        = meshRenderer,
                renderMaterials     = new Material[0],
                debugHelperRenderer = debugHelperRenderer
            };

            renderObjects.EnsureMeshesAllocated();
            renderObjects.Initialize();
            return(renderObjects);
        }
        public static ChiselRenderObjects Create(string name, Transform parent, GameObjectState state, LayerUsageFlags query)
        {
            var renderContainer = ChiselObjectUtility.CreateGameObject(name, parent, state);
            var sharedMesh      = new Mesh {
                name = name
            };

#if UNITY_EDITOR
            var partialMesh = new Mesh {
                name = name
            };
            partialMesh.hideFlags = HideFlags.DontSave;
#endif
            var meshFilter   = renderContainer.AddComponent <MeshFilter>();
            var meshRenderer = renderContainer.AddComponent <MeshRenderer>();
            meshRenderer.enabled = false;

            var renderObjects = new ChiselRenderObjects
            {
                query        = query,
                container    = renderContainer,
                meshFilter   = meshFilter,
                meshRenderer = meshRenderer,
                sharedMesh   = sharedMesh,
#if UNITY_EDITOR
                partialMesh = partialMesh,
#endif
                renderMaterials = new Material[0]
            };
            renderObjects.Initialize();
            return(renderObjects);
        }
 public static ChiselBrushMaterial CreateInstance(Material renderMaterial, PhysicMaterial physicsMaterial, LayerUsageFlags layerUsage = LayerUsageFlags.RenderReceiveCastShadows | LayerUsageFlags.Collidable)
 {
     return(new ChiselBrushMaterial
     {
         LayerUsage = layerUsage,
         RenderMaterial = renderMaterial,
         PhysicsMaterial = physicsMaterial
     });
 }
 public static ChiselBrushMaterial CreateInstance(PhysicMaterial physicsMaterial, LayerUsageFlags layerUsage = LayerUsageFlags.Collidable)
 {
     return(CreateInstance(null, physicsMaterial, layerUsage));
 }
 public static ChiselBrushMaterial CreateInstance(Material renderMaterial, LayerUsageFlags layerUsage = LayerUsageFlags.RenderReceiveCastShadows)
 {
     return(CreateInstance(renderMaterial, null, layerUsage));
 }
 public static ChiselBrushMaterial CreateInstance(LayerUsageFlags layerUsage = LayerUsageFlags.None)
 {
     return(CreateInstance(null, null, layerUsage));
 }
Esempio n. 13
0
 public static ChiselBrushMaterial CreateInstance(PhysicMaterial physicsMaterial, LayerUsageFlags layerUsage = LayerUsageFlags.Collidable)
 {
     return(new ChiselBrushMaterial
     {
         LayerUsage = layerUsage,
         PhysicsMaterial = physicsMaterial
     });
 }
Esempio n. 14
0
 public static ChiselBrushMaterial CreateInstance(LayerUsageFlags layerUsage = LayerUsageFlags.None)
 {
     return(new ChiselBrushMaterial {
         LayerUsage = layerUsage
     });
 }
Esempio n. 15
0
        public static void OnLayerUsageFlagsChanged(ChiselBrushMaterial brushMaterial, LayerUsageFlags prevValue, LayerUsageFlags value)
        {
            if (!registeredLookup.Contains(brushMaterial) || (prevValue == value))
            {
                return;
            }

            OnBrushMaterialChanged?.Invoke(brushMaterial);
        }