by Graham O'Neill
Create the object. Try to keep the number of vertices down or the models can get very big. If the object has an irregular shape try applying a Decimate modifier to reduce the number of vertices. Curved surfaces can be smoothed using creaseAngle in the WRL file so you might not need as many sides to the object as you think.
Use the scale of 1 Blender Unit to 1 meter. If you use 1BU to 1cm it seems you get rounding errors that can significantly affect the actual size of the object in Room Arranger.
Don't bother using double edges to put lines on the object as they don't export.
Convert any curves to mesh.
Faces default to being only one sided so are invisible from the back. Check the Normals using the button on the “N” Properties panel, and use Mesh > Normals Flip as necessary. Or edit the SOLID value in the exported WRL file if faces really need to be double sided.
Exporting colours and materials to VRML is very limited and how you do it depends on the type of object.
1. Single colour
Don't bother with colours in Blender. Set it in the WRL file later.
2. Parts in different colours
If distinct parts of the object are in different colours then separate them into individual objects. You can set each one to a different colour to make modelling easier, but the actual colours will be set in the WRL file later.
To move the objects around as one unit, select them all and use Parent > Object (the last selected object will become the parent).
3. Faces with different colours
If different faces of one object are different colours and can't be separated easily then colour them in Blender. This depends on the renderer being used:
You won't be able to adjust individual colours transparency etc in this case as the colours will be set in the WRL geometry node rather than the appearance node.
The VRML export only handles textures created for the Blender renderer, and only using UV wrapping not the built-in material textures.
There are three other items to consider in Blender: the orientation of the model, its origin point and its position. You don't need to worry about the model's size as RoomArranger will detect it for you.
You must set the orientation so that the object faces “away” from you, that is with the front towards the +Y axis and the back towards the -Y axis. The origin and position may be ignored since RA can automatically set it but there are reasons why it's a good idea to do it manually (see “Origins and Position Offsets” below).
Move the object to the top left (-X,Y) segment, touching the X and Y axes and with the bottom at Z=0. The object dimensions shown in Blender are absolute sizes irrespective of its rotation, so if necessary check the global coordinates of individual vertices in Edit mode to do this. Note that in Room Arranger any 2D rotation will be about the Z axis and 3D rotation will be about the X axis through the object's Origin point.
To set the object's Origin:
[Edit mode] | Select the require point (e.g. a vertex) |
Shift-S: Cursor to Selected | |
[Object mode] | Select object |
Object > Transform > Origin to 3D Cursor |
To move the Origin to the centre (0,0,0):
[Object mode] | Shift-S: Cursor to Centre (or just Shift-C) |
Select object | |
Shift-S: Selection to Cursor |
You need the “VRML2 Export” add-on activated (in User Preferences > Add-Ons).
Select File > Export > VRML2
If it is greyed out it means you have objects selected (e.g. a lamp or camera) that can't be exported. In that case select only the objects that you will be exporting. On the export screen set:
Selection only | Off | Unless you really want to export just part of the model |
Apply modifiers | Off | Unless you've used modifiers such as Array |
Texture/UVs | Off | Unless you've used UV wrapped textures |
Vertex colours | Off | Unless you've had to do (3) in Colours above |
Colour | - | Makes no difference which choice |
Forward | Z forward | |
Up | Y up |
If the object was exported as all one item (i.e. elements were joined if created separately) add the following lines around the shape{} definition:
PROTO objname [] { shape {..} }
If there are multiple Shape{} definitions (i.e. the object uses parent levels) add:
PROTO objname [] { Group { children [ shape {..} shape {..} ]}}
You can combine multiple PROTO objects into one WRL file as long as each objname is unique.
The IndexedFaceSet{..} definition can include:
creaseAngle | value | where value is 0.0 to 2π. Angles greater than value (in Radians) are smoothed. Note that 90° = π/2 = 1.57 |
solid | FALSE | if faces should be double sided rather than transparent from one side. |
Some of the Material{..} definitions use RGB sets (three numbers, each in the range 0 to 1) and others use a value (range 0 to 1). Allowed entries are:
diffuseColor | RGB | Colour of the object |
specularColor | RGB | Colour of shiny spots, reflectivity |
shininess | value | Intensity of the shiny spots (0 to 1) |
emissiveColor | RGB | Colour for glowing objects |
ambientIntensity | value | Amount of light reflected by the object |
transparency | value | where 0 is opaque and 1 completely transparent |
If you want to set the colours from RA then you need to include at least a NULL appearance node in the PROTO line:
PROTO objname [field SFNode appearance NULL] {
and in the Shape{} section replace the appearance Appearance {}
node with:
appearance IS appearance
Make sure the SFNode option is turned on for the object in RA, as otherwise the object will be plain white.
To provide a default colour you can achieve this by changing NULL to an Appearance setting, for example:
PROTO objname [field SFNode appearance Appearance { material Material { diffuseColor 0.6 0.6 0.6 } } ] {
Any material, texture or texturetransform settings can be used but if the SFNode option is set in RA then they will all be overridden.
The coordinates are exported to six decimal places. Trailing zeros can be removed to save space if wanted using, for example, a Notepad++ macro.
Note how you can repeat textures easily by using a TextureTransform. The scale field tells how many times to repeat a bitmap in the s and t direction. (Note: s and t is more or less like a standard x, y of a plane).
Shape { appearance Appearance { texture ImageTexture { repeatS TRUE repeatT TRUE url "picture.jpg" } textureTransform TextureTransform { scale 10 10 rotation 0 center 0 0 translation 0 0 } }
If the image is saved as grayscale (in Photoshop: Image > Mode > Grayscale) it will be combined with the material diffuseColor. Transparent areas will make the object itself transparent and white areas will take on the diffuseColor setting.
If you want to use a grayscale/colored texture that is provided inside RA, export the project as a web page and then look in the Textures subdirectory for the required PNG file.
Add an object and click on:
Properties > More 3D
Select the file and choose the objname for the # id.
If you provided the SFNode field in the PROTO line and want RA to set the colours for the object then turn on the “field SFNode appearance” check box.
The size of the object in Blender Units is treated as metres in RA. On the three size fields enter the dimensions or just use the Detect button to determine these for you.
Then use the properties on the object screen to set the size you want in cm
If you set the VRML object to use a texture (even if it's internal in the WRL file) select that texture on the object's Color Picker screen but do not set Tiling on as it stops the VRML working.
Editing the original WRL file doesn't work as RA caches the inputs, but you can edit the WRL directly in:
c:\Users\<username>\AppData\Local\Room Arranger\ProjUnpack\<project>
You must close and reopen the 3D viewer for it to take effect as a viewer refresh won't reload the file. Remember to force a project resave to keep any changes you make.
Most of your objects will have their Origins at the left, back, bottom corner but you don't need to set this in Blender. The Detect option in RA will automatically determine it for you and will set the Offsets accordingly.
But you will probably find yourself creating objects where you want to specify a different Origin. This might be for an object that hangs from a point and you want the Z value in RA to be where the hanging point is rather than the bottom of the object. Or you might want the Origin to be in the centre of the object so that it will rotate around that point in RA.
In these cases you will need to set the Origin correctly and also move that Origin to 0,0,0 in Blender. When you use Detect to get the object size RA will try to move the Origin by putting in the Offset values. To stop this, just reset the Offsets back to 0,0,0 and your object will position or rotate as you wanted.
Since these objects require offsets of 0,0,0 you will probably find it easier if you consistently set the object Origin to the centre in Blender for every object you create and always use offsets of 0,0,0 in RA. Otherwise you are likely to get confused about which objects use an offset and which don't.