private static extern void Internal_SetValueRef(IntPtr nativeInstance, RRef <Texture> value);
private static extern void Internal_setTexture(IntPtr thisPtr, string name, RRef <Texture> value, uint mipLevel, uint numMipLevels, uint arraySlice, uint numArraySlices);
private static extern void Internal_setSpriteTexture(IntPtr thisPtr, string name, RRef <SpriteTexture> value);
private static extern void Internal_create0(Material managedInstance, RRef <Shader> shader);
/// <summary>Creates a new material with the specified shader.</summary> public Material(RRef <Shader> shader) { Internal_create0(this, shader); }
private static extern bool Internal_convexOverlapAny(RRef <PhysicsMesh> mesh, ref Vector3 position, ref Quaternion rotation, ulong layer);
private static extern void Internal_setShader(IntPtr thisPtr, RRef <Shader> shader);
private static extern bool Internal_convexCastAny(RRef <PhysicsMesh> mesh, ref Vector3 position, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
private static extern Collider[] Internal_convexOverlap(RRef <PhysicsMesh> mesh, ref Vector3 position, ref Quaternion rotation, ulong layer);
/// <summary> /// Performs a sweep into the scene using a convex mesh and checks if it has hit anything. This can be significantly more /// efficient than other types of cast* calls. /// </summary> /// <param name="mesh">Mesh to sweep through the scene. Must be convex.</param> /// <param name="position">Starting position of the mesh.</param> /// <param name="rotation">Orientation of the mesh.</param> /// <param name="unitDir">Unit direction towards which to perform the sweep.</param> /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.</param> /// <param name="max"> /// Maximum distance at which to perform the query. Hits past this distance will not be detected. /// </param> /// <returns>True if something was hit, false otherwise.</returns> public static bool ConvexCastAny(RRef <PhysicsMesh> mesh, Vector3 position, Quaternion rotation, Vector3 unitDir, ulong layer = 18446744073709551615, float max = 3.40282347E+38f) { return(Internal_convexCastAny(mesh, ref position, ref rotation, ref unitDir, layer, max)); }
/// <summary>Checks if the provided convex mesh overlaps any other collider in the scene.</summary> /// <param name="mesh">Mesh to check for overlap. Must be convex.</param> /// <param name="position">Position of the mesh.</param> /// <param name="rotation">Orientation of the mesh.</param> /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.</param> /// <returns>True if there is overlap with another object, false otherwise.</returns> public static bool ConvexOverlapAny(RRef <PhysicsMesh> mesh, Vector3 position, Quaternion rotation, ulong layer = 18446744073709551615) { return(Internal_convexOverlapAny(mesh, ref position, ref rotation, layer)); }
/// <summary> /// Assigns a sprite texture to the specified material parameter. Sprite texture is allowed to be animated, or just /// used for referencing a subset of a texture atlas. /// </summary> /// <param name="name">Name of the texture parameter.</param> /// <param name="texture">Texture resource to assign.</param> public void SetSpriteTexture(string name, RRef <SpriteTexture> texture) { Internal_setSpriteTexture(mCachedPtr, name, texture); }
/// <summary> /// Assigns a texture to the specified material parameter. /// </summary> /// <param name="name">Name of the texture parameter.</param> /// <param name="texture">Texture resource to assign.</param> public void SetTexture(string name, RRef <Texture> texture) { Internal_setTexture(mCachedPtr, name, texture, 0, 0, 0, 0); }
/// <summary> /// Assigns a texture to the specified material parameter. Allows you to specify a surface parameter that allows you /// to bind only a sub-set of the texture. /// </summary> /// <param name="name">Name of the texture parameter.</param> /// <param name="texture">Texture resource to assign.</param> /// <param name="surface">Subset of the texture to assign.</param> public void SetTexture(string name, RRef <Texture> texture, TextureSurface surface) { Internal_setTexture(mCachedPtr, name, texture, surface.mipLevel, surface.numMipLevels, surface.face, surface.numFaces); }
private static extern void Internal_setMaterial(IntPtr thisPtr, RRef <PhysicsMaterial> material);
private static void Draw(ParticleSystem component) { SceneObject so = component.SceneObject; // Draw collision planes, if enabled Gizmos.Color = Color.Yellow; ParticleEvolver[] evolvers = component.Evolvers; foreach (var entry in evolvers) { if (entry is ParticleCollisions collisions) { if (collisions.Options.mode == ParticleCollisionMode.Plane) { void DrawPlane(Vector3 position, Vector3 right, Vector3 up, Vector3 forward) { Vector3 topLeft = position - right + up; Vector3 topRight = position + right + up; Vector3 botLeft = position - right - up; Vector3 botRight = position + right - up; Gizmos.DrawLine(topLeft, topRight); Gizmos.DrawLine(topRight, botRight); Gizmos.DrawLine(botRight, botLeft); Gizmos.DrawLine(botLeft, topLeft); Gizmos.DrawLine(position, position + forward * 0.4f); } SceneObject[] planeObjects = collisions.PlaneObjects; foreach (var planeSO in planeObjects) { Vector3 position = planeSO.Position; Vector3 right = planeSO.Rotation.Rotate(Vector3.XAxis); Vector3 up = planeSO.Rotation.Rotate(Vector3.YAxis); Vector3 forward = planeSO.Forward; DrawPlane(position, right, up, forward); } Plane[] planes = collisions.Planes; foreach (var plane in planes) { Vector3 right, up; Vector3.OrthogonalComplement(plane.normal, out right, out up); DrawPlane(plane.normal * plane.d, right, up, plane.normal); } } } } // Draw emitter shapes Gizmos.Transform = Matrix4.TRS(so.Position, Quaternion.LookRotation(so.Rotation.Forward, so.Rotation.Up), Vector3.One); Gizmos.Color = Color.Green; ParticleEmitter[] emitters = component.Emitters; foreach (var entry in emitters) { ParticleEmitterShape shape = entry?.Shape; if (shape == null) { continue; } if (shape is ParticleEmitterBoxShape boxShape) { Gizmos.DrawWireCube(Vector3.Zero, boxShape.Options.extents); } else if (shape is ParticleEmitterSphereShape sphereShape) { ParticleSphereShapeOptions options = sphereShape.Options; Gizmos.DrawWireSphere(Vector3.Zero, options.radius); if (options.thickness > 0.0f) { float innerRadius = options.radius * (1.0f - MathEx.Clamp01(options.thickness)); if (options.thickness < 1.0f) { Gizmos.Color = Color.Green * new Color(0.5f, 0.5f, 0.5f); Gizmos.DrawWireSphere(Vector3.Zero, innerRadius); } Gizmos.Color = Color.Green * new Color(0.25f, 0.25f, 0.25f); Gizmos.DrawLine(Vector3.XAxis * innerRadius, Vector3.XAxis * options.radius); Gizmos.DrawLine(-Vector3.XAxis * innerRadius, -Vector3.XAxis * options.radius); Gizmos.DrawLine(Vector3.YAxis * innerRadius, Vector3.YAxis * options.radius); Gizmos.DrawLine(-Vector3.YAxis * innerRadius, -Vector3.YAxis * options.radius); Gizmos.DrawLine(Vector3.ZAxis * innerRadius, Vector3.ZAxis * options.radius); Gizmos.DrawLine(-Vector3.ZAxis * innerRadius, -Vector3.ZAxis * options.radius); } } else if (shape is ParticleEmitterHemisphereShape hemisphereShape) { ParticleHemisphereShapeOptions options = hemisphereShape.Options; Gizmos.DrawWireHemisphere(Vector3.Zero, options.radius); DrawArcWithThickness(Vector3.Zero, options.radius, new Degree(360.0f), options.thickness, Color.Green); if (options.thickness > 0.0f) { float innerRadius = options.radius * (1.0f - MathEx.Clamp01(options.thickness)); if (options.thickness < 1.0f) { Gizmos.Color = Color.Green * new Color(0.5f, 0.5f, 0.5f); Gizmos.DrawWireHemisphere(Vector3.Zero, innerRadius); } Gizmos.Color = Color.Green * new Color(0.25f, 0.25f, 0.25f); Gizmos.DrawLine(Vector3.XAxis * innerRadius, Vector3.XAxis * options.radius); Gizmos.DrawLine(-Vector3.XAxis * innerRadius, -Vector3.XAxis * options.radius); Gizmos.DrawLine(Vector3.YAxis * innerRadius, Vector3.YAxis * options.radius); Gizmos.DrawLine(-Vector3.YAxis * innerRadius, -Vector3.YAxis * options.radius); Gizmos.DrawLine(Vector3.ZAxis * innerRadius, Vector3.ZAxis * options.radius); } } else if (shape is ParticleEmitterCircleShape circleShape) { ParticleCircleShapeOptions options = circleShape.Options; DrawArcWithThickness(Vector3.Zero, options.radius, options.arc, options.thickness, Color.Green); } else if (shape is ParticleEmitterLineShape lineShape) { float halfLength = lineShape.Options.length * 0.5f; Gizmos.DrawLine(new Vector3(-halfLength, 0.0f, 0.0f), new Vector3(halfLength, 0.0f, 0.0f)); } else if (shape is ParticleEmitterRectShape rectShape) { Vector2 extents = rectShape.Options.extents; Vector3 right = new Vector3(extents.x, 0.0f, 0.0f); Vector3 up = new Vector3(0.0f, extents.y, 0.0f); Vector3 topLeft = -right + up; Vector3 topRight = right + up; Vector3 botLeft = -right - up; Vector3 botRight = right - up; Gizmos.DrawLine(topLeft, topRight); Gizmos.DrawLine(topRight, botRight); Gizmos.DrawLine(botRight, botLeft); Gizmos.DrawLine(botLeft, topLeft); } else if (shape is ParticleEmitterConeShape coneShape) { ParticleConeShapeOptions options = coneShape.Options; float topRadius = options.radius; float baseRadius = options.length * MathEx.Tan(options.angle); Radian arc = options.arc; if (topRadius > 0.0f) { DrawArcWithThickness(Vector3.Zero, topRadius, arc, options.thickness, Color.Green); } DrawArcWithThickness(new Vector3(0.0f, 0.0f, -options.length), baseRadius, arc, options.thickness, Color.Green); Gizmos.Color = Color.Green; DrawConeBorder(topRadius, baseRadius, arc, options.length); if (options.thickness > 0.0f && options.thickness < 1.0f) { Gizmos.Color = Color.Green * new Color(0.5f, 0.5f, 0.5f); DrawConeBorder( topRadius * (1.0f - MathEx.Clamp01(options.thickness)), baseRadius * (1.0f - MathEx.Clamp01(options.thickness)), arc, options.length); } } else if (shape is ParticleEmitterStaticMeshShape staticMeshShape) { RRef <Mesh> mesh = staticMeshShape.Options.mesh; if (mesh.IsLoaded) { Gizmos.DrawWireMesh(mesh.Value.MeshData); } } else if (shape is ParticleEmitterSkinnedMeshShape skinnedMeshShape) { Renderable renderable = skinnedMeshShape.Options.renderable; if (renderable != null) { RRef <Mesh> mesh = renderable.Mesh; if (mesh.IsLoaded) { Gizmos.DrawWireMesh(mesh.Value.MeshData); } } } } // Draw manual bounds if (!component.Settings.UseAutomaticBounds) { Gizmos.Color = Color.LightGray; AABox bounds = component.Settings.CustomBounds; Gizmos.DrawWireCube(bounds.Center, bounds.Size * 0.5f); } }