http://code.google.com/p/tubras/source/detail?r=1893
Added:
/trunk/tools/irrb/doc/_static/img010b.png
/trunk/tools/irrb/doc/_static/img015.png
Modified:
/trunk/tools/irrb/doc/_static/img010.png
/trunk/tools/irrb/doc/custom.rst
/trunk/tools/irrb/doc/material_panel.rst
/trunk/tools/irrb/doc/start.rst
/trunk/tools/irrb/io_export_irrlicht.py
=======================================
--- /dev/null
+++ /trunk/tools/irrb/doc/_static/img010b.png Fri Dec 30 12:56:27 2011
Binary file, no diff available.
=======================================
--- /dev/null
+++ /trunk/tools/irrb/doc/_static/img015.png Fri Dec 30 12:56:27 2011
Binary file, no diff available.
=======================================
--- /trunk/tools/irrb/doc/_static/img010.png Thu Dec 29 04:52:01 2011
+++ /trunk/tools/irrb/doc/_static/img010.png Fri Dec 30 12:56:27 2011
Binary file, no diff available.
=======================================
--- /trunk/tools/irrb/doc/custom.rst Mon Sep 26 10:03:18 2011
+++ /trunk/tools/irrb/doc/custom.rst Fri Dec 30 12:56:27 2011
@@ -1,8 +1,96 @@
=================
Custom Properties
=================
+.. highlight:: cpp
+ :linenothreshold: 5
.. toctree::
:maxdepth: 2
-Exporting custom properties.
+Blender allows custom properties to be added to any object (scene node)
and/or
+object data. **irrB** detects these custom properties and exports them to
the
+corresponding Irrlicht scene node as **userData**.
+
+Custom property types that may be added include String, Integer, Float,
Vector2d,
+and Vector3d. If you include the word "color" in the property name and the
property
+type is a Blender array, **irrB** exports the property as a "colorf" type.
+
+.. container:: irrb-right
+
+ .. image:: _static/img015.png
+
+Given the custom properties added to a Blender "empty" object in the
example image
+located to the right, **irrB** will generate the following scene node
**userData**::
+
+ <node type="empty">
+ <attributes>
+ <string name="Name" value="SpawnPoint1"/>
+ <int name="Id" value="-1"/>
+ <bool name="Visible" value="true"/>
+ <vector3d name="Position" value="7.508336, 3.424855, 7.244886"/>
+ <vector3d name="Rotation" value="0, 0, 0"/>
+ <vector3d name="Scale" value="1, 1, 1"/>
+ <enum name="AutomaticCulling" value="frustum_box"/>
+ <bool name="DebugDataVisible" value="false"/>
+ <bool name="IsDebugObject" value="false"/>
+ <bool name="ReadOnlyMaterials" value="false"/>
+ </attributes>
+ <userData>
+ <attributes>
+ <string name="Test String" value="test value"/>
+ <vector2d name="Test Vector2" value="1, 2"/>
+ <vector3d name="Test Vector3" value="1, 2, 3"/>
+ <float name="TestFloat" value="1.25"/>
+ <int name="spawnPoint" value="1"/>
+ </attributes>
+ </userData>
+ </node>
+
+Custom properties defined at Blender's Object level will only be exported
to that
+specific scene node.
+
+Custom properties defined at Blender's Object Data level, will be exported
to every
+scene node that references that particular data.
+
+----
+
+Accessing User Attributes In Code
+=================================
+
+In order to access scene node userData properties in your application,
+you will need to create a class that implements the
ISceneUserDataSerializer
+interface. This newly created class will also need to override the
+**OnReadUserData** method::
+
+ void SerializerClass::loadScene(const c8* fileName)
+ {
+ //
+ // ISceneManager* sceneManager (previously initialized)
+ //
+ // The 2nd parameter to "loadScene" is a pointer a
ISceneUserDataSerializer
+ // interface.
+ //
+ sceneManager->loadScene(fileName,this);
+ }
+
+ //
+ // this will be invoked for every scene node that contains UserData
attributes.
+ //
+ void SerializerClass::OnReadUserData(ISceneNode* forSceneNode,
+ io::IAttributes* userData)
+ {
+ ESCENE_NODE_TYPE type = forSceneNode->getType();
+ if(type == ESNT_EMPTY)
+ {
+ int isSpawnPoint=0;
+ if(userData->existsAttribute("spawnPoint"))
+ isSpawnPoint = userData->getAttributeAsInt("spawnPoint");
+ if(isSpawnPoint)
+ {
+ // store off the nodes (forSceneNode) position into an array
+ // of spawn locations.
+ }
+ }
+ }
+
+Custom scene node properties aren't limited to just meshes. They may also
be defined for lights and cameras.
=======================================
--- /trunk/tools/irrb/doc/material_panel.rst Thu Dec 29 10:22:13 2011
+++ /trunk/tools/irrb/doc/material_panel.rst Fri Dec 30 12:56:27 2011
@@ -78,7 +78,7 @@
----
irrB Irrlicht Material Properties
-=====================================
+=================================
Irrlicht material properties may be found underneath Blender's Material
panel group.
@@ -144,7 +144,14 @@
**Thickness** - Thickness of non-3dimensional elements such as lines and
points.
-Texture Layer Properties
+* **Texture Layer Properties**
+
+.. container:: irrb-right
+
+ .. image:: _static/img010b.png
+
+Located at the bottom of the Irrlicht material properties panel are the
four
+Irrlicht texture layer property settings.
**UV Wrap Modes** - Texture clamp mode: "Repeat", "Clamp", "Clamp To
Edge",
"Clamp To Border", "Mirror", "Mirror Clamp", "Mirror Clamp To Edge", and
@@ -160,4 +167,116 @@
less blurry than with the default value of 0. The value (divided by 8.f)
is added
to the mipmap level chosen initially, and thus takes a smaller mipmap for
a region
if the value is positive.
-
+
+----
+
+Irrlicht Material Types
+=======================
+
+**solid** - Standard solid material. Only first texture is used as the
diffuse texture.
+
+**solid_2layer** - Solid material with 2 texture layers. The second is
blended onto the first using the alpha value of
+the vertex colors. This material is currently not implemented in OpenGL,
but it works with DirectX.
+
+**lightmap** - Material type with standard lightmap technique: There
should be 2 textures: The first texture layer is
+a diffuse map, the second is a light map. Vertex light is ignored.
+
+**lightmap_add** - Material type with standard lightmap technique but
lightmap and diffuse texture are not
+modulated, but added instead.
+
+**lightmap_m2** - Material type with standard lightmap technique: There
should be 2 textures: The first texture
+layer is a diffuse map, the second is a light map. Vertex light is
ignored. The texture colors are effectively
+multiplied by 2 for brightening.
+
+**lightmap_m4** - Material type with standard lightmap technique: There
should be 2 textures: The first texture
+layer is a diffuse map, the second is a light map. Vertex light is
ignored. The texture colors are effectively
+multiplied by 4 for brightening.
+
+**lightmap_light** - Like lightmap, but also supports dynamic lighting.
+
+**lightmap_light_m2** - Like lightmap_m2, but also supports dynamic
lighting.
+
+**lightmap_light_m4** - Like lightmap_m4, but also supports dynamic
lighting.
+
+**detail_map** - Detail mapped material. The first texture is diffuse
color map, the second is added to this and
+usually displayed with a bigger scale value so that it adds more detail.
The detail map is added to the diffuse
+map using ADD_SIGNED, so that it is possible to add and substract color
from the diffuse map. For example a
+value of (127,127,127) will not change the appearance of the diffuse map
at all. Often used for terrain
+rendering.
+
+**sphere_map** - Environment reflection Material. The "sphere relfection
map" must be Texture 1.
+
+**reflection_2layer** - A reflecting material with an optional additional
non reflecting texture layer. The reflection
+map should be set as Texture 1.
+
+**trans_add** - A transparent material. Only the first texture is used.
The new color is calculated by simply adding
+the source color and the dest color. This means if for example a billboard
using a texture with black background
+and a red circle on it is drawn with this material, the result is that
only the red circle will be drawn a little bit
+transparent, and everything which was black is 100% transparent and not
visible. This material type is useful for
+particle effects.
+
+**trans_alphach** - Makes the material transparent based on the texture
alpha channel. The final color is blended
+together from the destination color and the texture color, using the alpha
channel value as blend factor. Only
+first texture is used. If you are using this material with small textures,
it is a good idea to load the texture in 32
+bit mode (video::IVideoDriver::setTextureCreationFlag()). Also, an alpha
ref is used, which can be manipulated
+using SMaterial::MaterialTypeParam. If set to 0, the alpha ref gets its
default value which is 0.5f and which
+means that pixels with an alpha value >127 will be written, others not. In
other, simple words: this value
+controls how sharp the edges become when going from a transparent to a
solid spot on the texture. Note that
+irrb sets Param1 to 0.000001.
+
+**trans_alphach_ref** - Makes the material transparent based on the
texture alpha channel. If the alpha channel
+value is greater than 127, a pixel is written to the target, otherwise
not. This material does not use alpha
+blending and is a lot faster than trans_alphach. It is ideal for drawing
stuff like leaves of plants, because the
+borders are not blurry but sharp. Only first texture is used. If you are
using this material with small textures and
+3d object, it is a good idea to load the texture in 32 bit mode
(video::IVideoDriver::setTextureCreationFlag()).
+
+**trans_vertex_alpha** - Makes the material transparent based on the
vertex alpha value.
+
+**trans_reflection_2layer** - A transparent reflecting material with an
optional additional non reflecting texture
+layer. The reflection map should be set as Texture 1. The transparency
depends on the alpha value in the vertex
+colors. A texture which will not reflect can be set als Texture 2. Please
note that this material type is currently
+not 100% implemented in OpenGL. It works in Direct3D.
+
+**normalmap_solid* - A solid normal map renderer. First texture is the
color map, the second should be the
+normal map. Note that you should use this material only when drawing
geometry consisting of vertices of type
+S3DVertexTangents (EVT_TANGENTS). You can convert any mesh into this
format using
+IMeshManipulator::createMeshWithTangents() (See SpecialFX2 Tutorial). This
shader runs on vertex shader
+1.1 and pixel shader 1.1 capable hardware and falls back on a fixed
function lighted material if this hardware is
+not available. Only two lights are supported by this shader, if there are
more, the nearest two are chosen.
+Currently, this shader is only implemented for the D3D8 and D3D9 renderers.
+
+**normalmap_trans_add** - A transparent normal map renderer. First texture
is the color map, the second should
+be the normal map. Note that you should use this material only when
drawing geometry consisting of vertices of
+type S3DVertexTangents (EVT_TANGENTS). You can convert any mesh into this
format using
+IMeshManipulator::createMeshWithTangents() (See SpecialFX2 Tutorial). This
shader runs on vertex shader
+1.1 and pixel shader 1.1 capable hardware and falls back on a fixed
function lighted material if this hardware is
+not available. Only two lights are supported by this shader, if there are
more, the nearest two are chosen.
+Currently, this shader is only implemented for the D3D8 and D3D9 renderers.
+
+**normalmap_trans_vertexalpha** - A transparent (based on the vertex alpha
value) normal map renderer. First
+texture is the color map, the second should be the normal map. Note that
you should use this material only when
+drawing geometry consisting of vertices of type S3DVertexTangents
(EVT_TANGENTS). You can convert any
+mesh into this format using IMeshManipulator::createMeshWithTangents()
(See SpecialFX2 Tutorial). This
+shader runs on vertex shader 1.1 and pixel shader 1.1 capable hardware and
falls back on a fixed function
+lighted material if this hardware is not available. Only two lights are
supported by this shader, if there are more,
+the nearest two are chosen. Currently, this shader is only implemented for
the D3D8 and D3D9 renderers.
+
+**parallaxmap_solid** - Just like normalmap_solid, but uses parallax
mapping too, which looks a lot more
+realistic. This only works when the hardware supports at least vertex
shader 1.1 and pixel shader 1.4. First
+texture is the color map, the second should be the normal map. The normal
map texture should contain the
+height value in the alpha component. The
IVideoDriver::makeNormalMapTexture() method writes this value
+automatically when creating normal maps from a heightmap when using a 32
bit texture. The height scale of the
+material (affecting the bumpiness) is being controlled by the
SMaterial::MaterialTypeParam member. If set to
+zero, the default value (0.02f) will be applied. Otherwise the value set
in SMaterial::MaterialTypeParam is
+taken. This value depends on with which scale the texture is mapped on the
material. Too high or low values of
+MaterialTypeParam can result in strange artifacts.
+
+**parallaxmap_trans_add** - A material just like parallaxmap_solid, but it
is transparent, using
+EMT_TRANSPARENT_ADD_COLOR as base material.
+
+**parallaxmap_trans_vertexalpha** - A material just like
EMT_PARALLAX_MAP_SOLID, but it is transparent,
+using EMT_TRANSPARENT_VERTEX_ALPHA as base material.
+
+**onetexture_blend** - BlendFunc = source sourceFactor + dest destFactor (
E_BLEND_FUNC ) Using only
+Textures(0). generic Blender
+
=======================================
--- /trunk/tools/irrb/doc/start.rst Mon Dec 26 10:59:32 2011
+++ /trunk/tools/irrb/doc/start.rst Fri Dec 30 12:56:27 2011
@@ -22,7 +22,7 @@
In a general sense, "Objects" are things (meshes, cameras, lights, etc.)
you add
to a Blender/Irrlicht scene that have three things in common:
-* **Type** - Identifies the object type (mesh, camera, light).
+* **Type** - Identifies the object type (mesh, camera, light, empty, etc.).
* **Transform** - The object position, rotation, and scale.
* **Data** - The object type specific data.
=======================================
--- /trunk/tools/irrb/io_export_irrlicht.py Thu Dec 29 10:22:13 2011
+++ /trunk/tools/irrb/io_export_irrlicht.py Fri Dec 30 12:56:27 2011
@@ -1263,6 +1263,14 @@
elif isinstance(data, float):
stype = 'float'
svalue = float2str(data)
+ elif str(type(data)) == "<class 'Blender IDArray'>":
+ if len(data) == 2:
+ stype = 'vector2d'
+ elif len(data) == 3:
+ stype = 'vector3d'
+
+ list = data.to_list()
+ svalue = _formatFloats(list)
if name.lower().find('color') >= 0:
stype = 'colorf'