ImmediateMesh

继承: Mesh < Resource < RefCounted < Object

Mesh optimized for creating geometry manually.

描述

A mesh type optimized for creating geometry manually, similar to OpenGL 1.x immediate mode.

Here's a sample on how to generate a triangular face:


    var mesh = ImmediateMesh.new()
    mesh.surface_begin(Mesh.PRIMITIVE_TRIANGLES)
    mesh.surface_add_vertex(Vector3.LEFT)
    mesh.surface_add_vertex(Vector3.FORWARD)
    mesh.surface_add_vertex(Vector3.ZERO)
    mesh.surface_end()

    var mesh = new ImmediateMesh();
    mesh.SurfaceBegin(Mesh.PrimitiveType.Triangles);
    mesh.SurfaceAddVertex(Vector3.Left);
    mesh.SurfaceAddVertex(Vector3.Forward);
    mesh.SurfaceAddVertex(Vector3.Zero);
    mesh.SurfaceEnd();

Note: Generating complex geometries with ImmediateMesh is highly inefficient. Instead, it is designed to generate simple geometry that changes often.

方法

voidclear_surfaces ( )
voidsurface_add_vertex ( vertex: Vector3 )
voidsurface_add_vertex_2d ( vertex: Vector2 )
voidsurface_begin ( primitive: PrimitiveType, material: Material = null )
voidsurface_end ( )
voidsurface_set_color ( color: Color )
voidsurface_set_normal ( normal: Vector3 )
voidsurface_set_tangent ( tangent: Plane )
voidsurface_set_uv ( uv: Vector2 )
voidsurface_set_uv2 ( uv2: Vector2 )

方法说明

void clear_surfaces ( )

Clear all surfaces.


void surface_add_vertex ( vertex: Vector3 )

Add a 3D vertex using the current attributes previously set.


void surface_add_vertex_2d ( vertex: Vector2 )

Add a 2D vertex using the current attributes previously set.


void surface_begin ( primitive: PrimitiveType, material: Material = null )

Begin a new surface.


void surface_end ( )

End and commit current surface. Note that surface being created will not be visible until this function is called.


void surface_set_color ( color: Color )

Set the color attribute that will be pushed with the next vertex.


void surface_set_normal ( normal: Vector3 )

Set the normal attribute that will be pushed with the next vertex.


void surface_set_tangent ( tangent: Plane )

Set the tangent attribute that will be pushed with the next vertex.


void surface_set_uv ( uv: Vector2 )

Set the UV attribute that will be pushed with the next vertex.


void surface_set_uv2 ( uv2: Vector2 )

Set the UV2 attribute that will be pushed with the next vertex.

1

本方法通常需要用户覆盖才能生效。

2

本方法无副作用,不会修改该实例的任何成员变量。

3

本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。

4

本方法用于构造某个类型。

5

调用本方法无需实例,可直接使用类名进行调用。

6

本方法描述的是使用本类型作为左操作数的有效运算符。

7

这个值是由下列位标志构成位掩码的整数。

8

无返回值。