Class Geometry3DInstance
- Namespace
- Godot
- Assembly
- GodotSharp.dll
Provides a set of helper functions to create geometric shapes, compute intersections between shapes, and process various other geometric operations in 3D.
[GodotClassName("Geometry3D")]
public class Geometry3DInstance : GodotObject, IDisposable
- Inheritance
-
Geometry3DInstance
- Implements
- Inherited Members
Methods
BuildBoxPlanes(Vector3)
Returns an array with 6 Planes that describe the sides of a box centered at the origin. The box size is defined by extents
, which represents one (positive) corner of the box (i.e. half its actual size).
public Array<Plane> BuildBoxPlanes(Vector3 extents)
Parameters
extents
Vector3
Returns
BuildCapsulePlanes(float, float, int, int, Axis)
Returns an array of Planes closely bounding a faceted capsule centered at the origin with radius radius
and height height
. The parameter sides
defines how many planes will be generated for the side part of the capsule, whereas lats
gives the number of latitudinal steps at the bottom and top of the capsule. The parameter axis
describes the axis along which the capsule is oriented (0 for X, 1 for Y, 2 for Z).
public Array<Plane> BuildCapsulePlanes(float radius, float height, int sides, int lats, Vector3.Axis axis = Axis.Z)
Parameters
Returns
BuildCylinderPlanes(float, float, int, Axis)
Returns an array of Planes closely bounding a faceted cylinder centered at the origin with radius radius
and height height
. The parameter sides
defines how many planes will be generated for the round part of the cylinder. The parameter axis
describes the axis along which the cylinder is oriented (0 for X, 1 for Y, 2 for Z).
public Array<Plane> BuildCylinderPlanes(float radius, float height, int sides, Vector3.Axis axis = Axis.Z)
Parameters
Returns
ClipPolygon(Vector3[], Plane)
Clips the polygon defined by the points in points
against the plane
and returns the points of the clipped polygon.
public Vector3[] ClipPolygon(Vector3[] points, Plane plane)
Parameters
Returns
- Vector3[]
ComputeConvexMeshPoints(Array<Plane>)
Calculates and returns all the vertex points of a convex shape defined by an array of planes
.
public Vector3[] ComputeConvexMeshPoints(Array<Plane> planes)
Parameters
Returns
- Vector3[]
GetClosestPointToSegment(Vector3, Vector3, Vector3)
Returns the 3D point on the 3D segment (s1
, s2
) that is closest to point
. The returned point will always be inside the specified segment.
public Vector3 GetClosestPointToSegment(Vector3 point, Vector3 s1, Vector3 s2)
Parameters
Returns
GetClosestPointToSegmentUncapped(Vector3, Vector3, Vector3)
Returns the 3D point on the 3D line defined by (s1
, s2
) that is closest to point
. The returned point can be inside the segment (s1
, s2
) or outside of it, i.e. somewhere on the line extending from the segment.
public Vector3 GetClosestPointToSegmentUncapped(Vector3 point, Vector3 s1, Vector3 s2)
Parameters
Returns
GetClosestPointsBetweenSegments(Vector3, Vector3, Vector3, Vector3)
Given the two 3D segments (p1
, p2
) and (q1
, q2
), finds those two points on the two segments that are closest to each other. Returns a Vector3[] that contains this point on (p1
, p2
) as well the accompanying point on (q1
, q2
).
public Vector3[] GetClosestPointsBetweenSegments(Vector3 p1, Vector3 p2, Vector3 q1, Vector3 q2)
Parameters
Returns
- Vector3[]
GetTriangleBarycentricCoords(Vector3, Vector3, Vector3, Vector3)
Returns a Vector3 containing weights based on how close a 3D position (point
) is to a triangle's different vertices (a
, b
and c
). This is useful for interpolating between the data of different vertices in a triangle. One example use case is using this to smoothly rotate over a mesh instead of relying solely on face normals.
Here is a more detailed explanation of barycentric coordinates.
public Vector3 GetTriangleBarycentricCoords(Vector3 point, Vector3 a, Vector3 b, Vector3 c)
Parameters
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
RayIntersectsTriangle(Vector3, Vector3, Vector3, Vector3, Vector3)
Tests if the 3D ray starting at from
with the direction of dir
intersects the triangle specified by a
, b
and c
. If yes, returns the point of intersection as Vector3. If no intersection takes place, returns null
.
public Variant RayIntersectsTriangle(Vector3 from, Vector3 dir, Vector3 a, Vector3 b, Vector3 c)
Parameters
Returns
SegmentIntersectsConvex(Vector3, Vector3, Array<Plane>)
Given a convex hull defined though the Planes in the array planes
, tests if the segment (from
, to
) intersects with that hull. If an intersection is found, returns a Vector3[] containing the point the intersection and the hull's normal. Otherwise, returns an empty array.
public Vector3[] SegmentIntersectsConvex(Vector3 from, Vector3 to, Array<Plane> planes)
Parameters
Returns
- Vector3[]
SegmentIntersectsCylinder(Vector3, Vector3, float, float)
Checks if the segment (from
, to
) intersects the cylinder with height height
that is centered at the origin and has radius radius
. If no, returns an empty Vector3[]. If an intersection takes place, the returned array contains the point of intersection and the cylinder's normal at the point of intersection.
public Vector3[] SegmentIntersectsCylinder(Vector3 from, Vector3 to, float height, float radius)
Parameters
Returns
- Vector3[]
SegmentIntersectsSphere(Vector3, Vector3, Vector3, float)
Checks if the segment (from
, to
) intersects the sphere that is located at spherePosition
and has radius sphereRadius
. If no, returns an empty Vector3[]. If yes, returns a Vector3[] containing the point of intersection and the sphere's normal at the point of intersection.
public Vector3[] SegmentIntersectsSphere(Vector3 from, Vector3 to, Vector3 spherePosition, float sphereRadius)
Parameters
Returns
- Vector3[]
SegmentIntersectsTriangle(Vector3, Vector3, Vector3, Vector3, Vector3)
Tests if the segment (from
, to
) intersects the triangle a
, b
, c
. If yes, returns the point of intersection as Vector3. If no intersection takes place, returns null
.
public Variant SegmentIntersectsTriangle(Vector3 from, Vector3 to, Vector3 a, Vector3 b, Vector3 c)