Difference between revisions of "Mesh:setVertices"
(Updated for 0.10.0) |
m |
||
(8 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{newin|[[0.9.0]]|090|type=function}} | {{newin|[[0.9.0]]|090|type=function}} | ||
− | Replaces | + | Replaces a range of vertices in the Mesh with new ones. The total number of vertices in a Mesh cannot be changed after it has been created. This is often more efficient than calling [[Mesh:setVertex]] in a loop. |
== Function == | == Function == | ||
Line 6: | Line 6: | ||
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
− | Mesh:setVertices( vertices, startvertex ) | + | Mesh:setVertices( vertices, startvertex, count ) |
</source> | </source> | ||
=== Arguments === | === Arguments === | ||
− | {{param|table|vertices|The table filled with vertex information tables for each vertex, in the form of <code>{vertex, ...}</code> where each vertex is a table in the form of {attributecomponent, ...}</code>}} | + | {{param|table|vertices|The table filled with vertex information tables for each vertex, in the form of <code>{vertex, ...}</code> where each vertex is a table in the form of <code>{attributecomponent, ...}</code>.}} |
{{subparam|number|attributecomponent|The first component of the first vertex attribute in the vertex.}} | {{subparam|number|attributecomponent|The first component of the first vertex attribute in the vertex.}} | ||
{{subparam|number|...|Additional components of all vertex attributes in the vertex.}} | {{subparam|number|...|Additional components of all vertex attributes in the vertex.}} | ||
{{param|number|startvertex (1)|The index of the first vertex to replace.}} | {{param|number|startvertex (1)|The index of the first vertex to replace.}} | ||
+ | {{New feature|11.3| | ||
+ | {{param|number|count (all)|Amount of vertices to replace.}} | ||
+ | }} | ||
=== Returns === | === Returns === | ||
Nothing. | Nothing. | ||
Line 19: | Line 22: | ||
If no value is supplied for a specific vertex attribute component, it will be set to a default value of 0 if its [[AttributeDataType|data type]] is "float", or 255 if its data type is "byte". | If no value is supplied for a specific vertex attribute component, it will be set to a default value of 0 if its [[AttributeDataType|data type]] is "float", or 255 if its data type is "byte". | ||
+ | |||
+ | == Function == | ||
+ | {{newin|[[0.10.0]]|100|type=variant}} | ||
+ | Sets the vertex components of the Mesh by copying directly from the memory of a [[Data]] object. | ||
+ | === Synopsis === | ||
+ | <source lang="lua"> | ||
+ | Mesh:setVertices( data, startvertex, count ) | ||
+ | </source> | ||
+ | === Arguments === | ||
+ | {{param|Data|data|A Data object to copy from. The contents of the Data must match the layout of this Mesh's [[Mesh:getVertexFormat|vertex format]].}} | ||
+ | {{param|number|startvertex (1)|The index of the first vertex to replace.}} | ||
+ | {{New feature|11.3| | ||
+ | {{param|number|count (all)|Amount of vertices to replace.}} | ||
+ | }} | ||
+ | === Returns === | ||
+ | Nothing. | ||
+ | === Notes === | ||
+ | If LuaJIT's [http://luajit.org/ext_ffi_api.html FFI] is used to populate the Data object via [[Data:getPointer]] and [http://luajit.org/ext_ffi_api.html#ffi_cast ffi.cast], this variant can be drastically more efficient than other methods of setting Mesh vertex data. | ||
== Function == | == Function == | ||
Line 30: | Line 51: | ||
{{subparam|number|[1]|The position of the vertex on the x-axis.}} | {{subparam|number|[1]|The position of the vertex on the x-axis.}} | ||
{{subparam|number|[2]|The position of the vertex on the y-axis.}} | {{subparam|number|[2]|The position of the vertex on the y-axis.}} | ||
− | {{subparam|number|[3]|The horizontal component of the texture coordinate. Texture coordinates are normally in the range of [0, 1], but can be greater or less (see [[WrapMode]]. | + | {{subparam|number|[3]|The horizontal component of the texture coordinate. Texture coordinates are normally in the range of [0, 1], but can be greater or less (see [[WrapMode]]).}} |
− | {{subparam|number|[4]|The vertical component of the texture coordinate. Texture coordinates are normally in the range of [0, 1], but can be greater or less (see [[WrapMode]]. | + | {{subparam|number|[4]|The vertical component of the texture coordinate. Texture coordinates are normally in the range of [0, 1], but can be greater or less (see [[WrapMode]]).}} |
− | {{subparam|number|[5] ( | + | {{subparam|number|[5] (1)|The red color component.}} |
− | {{subparam|number|[6] ( | + | {{subparam|number|[6] (1)|The green color component.}} |
− | {{subparam|number|[7] ( | + | {{subparam|number|[7] (1)|The blue color component.}} |
− | {{subparam|number|[8] ( | + | {{subparam|number|[8] (1)|The alpha color component.}} |
+ | |||
=== Returns === | === Returns === | ||
Nothing. | Nothing. | ||
Line 43: | Line 65: | ||
* [[Mesh:getVertex]] | * [[Mesh:getVertex]] | ||
* [[Mesh:getVertexCount]] | * [[Mesh:getVertexCount]] | ||
+ | * [[Mesh:getVertexFormat]] | ||
[[Category:Functions]] | [[Category:Functions]] | ||
− | {{#set:Description=Replaces | + | {{#set:Description=Replaces a range of vertices in the Mesh with new ones.}} |
== Other Languages == | == Other Languages == | ||
{{i18n|Mesh:setVertices}} | {{i18n|Mesh:setVertices}} |
Latest revision as of 16:05, 6 July 2020
Available since LÖVE 0.9.0 |
This function is not supported in earlier versions. |
Replaces a range of vertices in the Mesh with new ones. The total number of vertices in a Mesh cannot be changed after it has been created. This is often more efficient than calling Mesh:setVertex in a loop.
Contents
Function
Available since LÖVE 0.10.0 |
This variant is not supported in earlier versions. |
Synopsis
Mesh:setVertices( vertices, startvertex, count )
Arguments
table vertices
- The table filled with vertex information tables for each vertex, in the form of
{vertex, ...}
where each vertex is a table in the form of{attributecomponent, ...}
.
number startvertex (1)
- The index of the first vertex to replace.
number count (all)
- Amount of vertices to replace.
Returns
Nothing.
Notes
The values in each vertex table are in the same order as the vertex attributes in the Mesh's vertex format. A standard Mesh that wasn't created with a custom vertex format will use two position numbers, two texture coordinate numbers, and four color components per vertex: x, y, u, v, r, g, b, a.
If no value is supplied for a specific vertex attribute component, it will be set to a default value of 0 if its data type is "float", or 255 if its data type is "byte".
Function
Available since LÖVE 0.10.0 |
This variant is not supported in earlier versions. |
Sets the vertex components of the Mesh by copying directly from the memory of a Data object.
Synopsis
Mesh:setVertices( data, startvertex, count )
Arguments
Data data
- A Data object to copy from. The contents of the Data must match the layout of this Mesh's vertex format.
number startvertex (1)
- The index of the first vertex to replace.
number count (all)
- Amount of vertices to replace.
Returns
Nothing.
Notes
If LuaJIT's FFI is used to populate the Data object via Data:getPointer and ffi.cast, this variant can be drastically more efficient than other methods of setting Mesh vertex data.
Function
Sets the vertex components of a Mesh that wasn't created with a custom vertex format.
Synopsis
Mesh:setVertices( vertices )
Arguments
table vertices
- The table filled with vertex information tables for each vertex as follows:
number [1]
- The position of the vertex on the x-axis.
number [2]
- The position of the vertex on the y-axis.
number [3]
- The horizontal component of the texture coordinate. Texture coordinates are normally in the range of [0, 1], but can be greater or less (see WrapMode).
number [4]
- The vertical component of the texture coordinate. Texture coordinates are normally in the range of [0, 1], but can be greater or less (see WrapMode).
number [5] (1)
- The red color component.
number [6] (1)
- The green color component.
number [7] (1)
- The blue color component.
number [8] (1)
- The alpha color component.
Returns
Nothing.
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info