[x3d-public] considering general conversion of metadata (to/from Blender)

Don Brutzman brutzman at nps.edu
Mon Apr 10 18:42:16 PDT 2017


inserting excerpts for readability:

On 4/10/2017 1:29 PM, Michalis Kamburelis wrote:
> 2017-04-10 16:12 GMT+02:00 Don Brutzman <brutzman at nps.edu>:
>>> E.g. when generating X3D from Blender, we could export Blender's
>>> "Custom Properties" to X3D metadata. This is how you define custom
>>> metadata in Blender:
>>> https://docs.blender.org/manual/de/dev/data_system/custom_properties.html
> [...]
>>>   I hope to improve the Blender X3D exporter some day to enable this:)
>>
>> cool.  wondering, is there a Blender example with metadata in Custom
>> Properties that we might use to show a mapping to MetadataSet?
>>
>> it would be good to compare source-to-source to explore a mapping
>
> It's easy to create such example in Blender:)
>
> I have done it, and committed to
>
> - https://github.com/castle-engine/demo-models/blob/master/x3d/blender_custom_properties.blend

======================================================================
import bpy

# A simple test of Blender "Custom Properties".
# Execute this with "Run Script", the result is on the console
# (see https://wiki.blender.org/index.php/User:Fade/Doc:2.6/Manual/Interface/Window_system/Console_window
# how to show the console).
#
# For more about custom properties, see:
# - https://docs.blender.org/manual/de/dev/data_system/custom_properties.html
# - https://docs.blender.org/api/blender_python_api_current/info_quickstart.html#custom-properties

obj = bpy.context.scene.objects["MyObject"]
print("Object string property type: " + str(type(obj["MyObjectProperty"])))
print("Object string property value: " + obj["MyObjectProperty"])

print("Object int property value: " + str(type(obj["IntProperty"])))
print("Object int property value: " + str(obj["IntProperty"]))

print("Object float property value: " + str(type(obj["FloatProperty"])))
print("Object float property value: " + str(obj["FloatProperty"]))

mesh = obj.data
print("Mesh property value: " + mesh["MyMeshProperty"])

material = obj.material_slots["Material"].material
print("Material property value: " + material["MyMaterialProperty"])
======================================================================

> - https://github.com/castle-engine/demo-models/blob/master/x3d/blender_custom_properties.x3d

your corresponding X3D metadata, excerpted:

<MetadataSet name="custom_properties">
	<MetadataString containerField='value' name='MyObjectProperty' value='"object prop value"'/>
	<MetadataInteger containerField='value' name='IntProperty' value='123'/>
	<MetadataFloat containerField='value' name='FloatProperty' value='456.789'/>
</MetadataSet>

and, appropriately located,

<Group DEF="group_ME_Cube">
	<MetadataSet name="custom_properties">
		<MetadataString containerField='value' name='MyMeshProperty' value='"mesh prop value"'/>
	</MetadataSet>

<Material DEF="MA_Material"
	diffuseColor="0.800 0.800 0.800"
	specularColor="0.401 0.401 0.401"
	emissiveColor="0.000 0.000 0.000"
	ambientIntensity="0.333"
	shininess="0.098"
	transparency="0.0"
         >
	<MetadataSet name="custom_properties">
		<MetadataString containerField='value' name='MyMaterialProperty' value='"material prop value"'/>
	</MetadataSet>

> (Choose "Download" on these pages to download a particular file, or
> use GIT to clone the entire demo-models repository). The Blender model
> shows :
>
> - Any number of properties is allowed on any Blender "data block",
> which can be an object, or a mesh, or a material.
>
> - Each property is a name and a value. The type of the property is
> automatically detected from the value by Blender -- if it's an integer
> or a float, Blender detects it and shows a nice slider for it.
>
> - A simple Python script shows that the data is available in Python
> (so it can be used when exporting), the properties are nicely visible
> (and typed, as string or int or float).
>
> Attaching also a screenshot from Blender, if you don't have the time
> to actually run it now:)
>
> You can imagine that these properties could be inserted by the
> File->Export->X3D in Blender to the appropriate X3D file. The X3D file
> that I link above was created by Blender exporter, but then I inserted
> the custom properties (as X3D MetadataXxx nodes) manually:
> https://github.com/castle-engine/demo-models/commit/f0abfe5e7778375105f2b42b7375116db5e002f8
>
> This shows the work that could be done by the Blender X3D exporter in
> the future.
>
> - Blender "object" is a Transform "MyObject_TRANSFORM" in X3D,
> - Blender mesh is a Group "group_ME_Cube" in X3D (because Blender's
> mesh can contain any number of materials),
> - Blender material is an X3D Material.
>
> Regards,
> Michalis

sounds & looks like a pretty general correspondence.  wondering, did you notice anything that doesn't seem mappable?

all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman



More information about the x3d-public mailing list