﻿<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=Ready_for_serialization_mesh_data_structure</id>
	<title>Ready for serialization mesh data structure - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=Ready_for_serialization_mesh_data_structure"/>
	<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Ready_for_serialization_mesh_data_structure&amp;action=history"/>
	<updated>2026-04-19T19:09:41Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=Ready_for_serialization_mesh_data_structure&amp;diff=149695&amp;oldid=prev</id>
		<title>Yamyam: 1版 をインポートしました</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Ready_for_serialization_mesh_data_structure&amp;diff=149695&amp;oldid=prev"/>
		<updated>2018-06-28T21:13:56Z</updated>

		<summary type="html">&lt;p&gt;1版 をインポートしました&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;2018年6月28日 (木) 21:13時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ja&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(相違点なし)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Yamyam</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=Ready_for_serialization_mesh_data_structure&amp;diff=149694&amp;oldid=prev</id>
		<title>2015年5月8日 (金) 11:25にwiki&gt;Dalによる</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Ready_for_serialization_mesh_data_structure&amp;diff=149694&amp;oldid=prev"/>
		<updated>2015-05-08T11:25:27Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Blender has a good Python API for internal data access. There is the possibility to access objects and their properties: meshes, texture coordinates, vertex coordinates, faces, normals etc.&lt;br /&gt;
&lt;br /&gt;
In the past, the '''Blend4Web exporter''' had been using Python API to access and export the data of 3D models. However, '''Python did not have required performance and flexibility in terms of mesh data access'''. As a result, the Blend4Web developers had to reject Python in favor of C. The whole mesh data access code has been rewritten in C, which resulted in much more compact and faster Python API.&lt;br /&gt;
&lt;br /&gt;
The purpose of this draft is to suggest a fast method for transferring the mesh data to a simple format for further serialization and export. The proposed Python module can be used by any exporters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Definitions ==&lt;br /&gt;
&lt;br /&gt;
In OpenGL 2+ and DirectX 9+, a batch of geometry is rendered in a single draw call. This way only a single shader (which corresponds to the Blender material) can be set up in a time. On the other hand, Blender's meshes can have more then one material. &lt;br /&gt;
&lt;br /&gt;
To reflect this fact, we would like to introduce a concept of '''submesh''' - a part of the mesh to which a single material is assigned. This way, any mesh which has more than one material is divided into submeshes. Submesh data can be optimized and serialized for use in external engines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Problems to Resolve ==&lt;br /&gt;
&lt;br /&gt;
* Retrieving submesh data &lt;br /&gt;
* Submesh optimization&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Python API ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
submesh = object.data.get_submesh(format = 'TRIANGLES', matid=mid, \&lt;br /&gt;
weld = True, uv=['uv1','uv2'], request = ['TANGENT', 'NORMAL', \&lt;br /&gt;
'VGROUPS'...], custom_in={'key1':{'DATA':[...], 'MAPPING': 'LOOP'}})&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''format''' - data format, can be TRIANGLES or POLYGONS&lt;br /&gt;
&lt;br /&gt;
'''matid''' - material identifier&lt;br /&gt;
&lt;br /&gt;
'''weld''' - optimize the vertices count by welding (see [[#Submesh Welding|welding]])&lt;br /&gt;
&lt;br /&gt;
'''uv''' - the list of UV identifiers that may be required during submesh retrieval&lt;br /&gt;
&lt;br /&gt;
'''request''' - the list of data types to retrieve; 'POSITION', 'INDICES' will be in the submesh struct even if they are not present in this list&lt;br /&gt;
&lt;br /&gt;
'''custom_in''' - custom user data (see [[#Submesh Welding|welding]]); this data is ordered according to the 'MAPPING' field; 'MAPPING' can be 'LOOP', 'VERTEX' or 'POLYGON'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Output Data Format (Submesh Structure) ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
'FORMAT': format,&lt;br /&gt;
'POSITION': [float_data],&lt;br /&gt;
'INDICES': [int_data],&lt;br /&gt;
'POLYLEN': [int_data],&lt;br /&gt;
'TEXCO': [{'uv1':[float_data], 'uv2':[float_data]}, ...],&lt;br /&gt;
'TANGENT': [{'uv1':[float_data], 'uv2':[float_data]}, ...],&lt;br /&gt;
'VGROUPS': [{'vg1':[float_data], 'vg2':[float_data]}, ...],&lt;br /&gt;
'COLOR': [{'col1':[float_data], 'col2':[float_data]}, ...],&lt;br /&gt;
'NORMAL': [float_data],&lt;br /&gt;
'CUSTOM': {'custom1':{'DATA':[...], 'MAPPING':mapping}, 'custom2':..., ...}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''FORMAT''' - data format; possible values: 'TRIANGLES' or 'POLYGONS'&lt;br /&gt;
&lt;br /&gt;
'''POSITION''' - vertex coordinates, plain array of (x,y,z) of float type&lt;br /&gt;
&lt;br /&gt;
'''INDICES''' - triangles/polygons indices of int type&lt;br /&gt;
&lt;br /&gt;
'''POLYLEN''' - polygon vertices count; if the value of the 'FORMAT' field is 'TRIANGLES' then this field may not be present and is defaulted to 3&lt;br /&gt;
&lt;br /&gt;
'''TEXCO''' - texture coordinates; named plain arrays of (u, v) of float type&lt;br /&gt;
&lt;br /&gt;
'''VGROUPS''' - vertex groups; named plain arrays of weights of float type&lt;br /&gt;
&lt;br /&gt;
'''COLOR''' - vertex color; named plain arrays of (r, g, b) of float type&lt;br /&gt;
&lt;br /&gt;
'''TANGENT''' - tangent space description; named plain arrays of (T.x, T.y, T.z, Sign) of float type&lt;br /&gt;
&lt;br /&gt;
'''NORMAL''' - normal; plain array of (n.x, n.y, n.z) of float type&lt;br /&gt;
&lt;br /&gt;
'''CUSTOM''' - custom output data; has order according to 'FORMAT'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Submesh Welding ===&lt;br /&gt;
&lt;br /&gt;
We call submesh non-optimized if it is possible to represent it by the lesser amount of data, primarily, by the lesser count of vertices.&lt;br /&gt;
&lt;br /&gt;
Under specific conditions, such as equality of positions, normals etc., we can assume that the vertices are identical and 'weld' them into a single vertex. Thus, the total number of vertices is decreased, which leads to memory savings and increased performance.&lt;br /&gt;
&lt;br /&gt;
=== Custom Data ===&lt;br /&gt;
&lt;br /&gt;
In addition to the standard fields, there is also a 'CUSTOM' field in the submesh structure. Correspondingly, the 'custom_in' parameter is present in the 'get_submesh' function written in the same format.&lt;br /&gt;
&lt;br /&gt;
'MAPPING' defines 'DATA' elements order. On the C side, each 'CUSTOM' element is interpreted as a byte-array; the length of the element will be calculated automatically.&lt;br /&gt;
&lt;br /&gt;
Welding processes the 'CUSTOM' data in the same way as the standard fields such as 'NORMAL'.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Serialization ===&lt;br /&gt;
&lt;br /&gt;
Retrieved data can be processed in Python, because it is essentially not a raw data but the typed arrays.&lt;br /&gt;
&lt;br /&gt;
Architecture-independent serialization can be implemented for each field accordingly to the data type (see [[http://en.wikipedia.org/wiki/Endianness]]&lt;/div&gt;</summary>
		<author><name>wiki&gt;Dal</name></author>
		
	</entry>
</feed>