Page 1 of 2

SketchUp to Ogre Export partially rewritten

Posted: Tue Mar 25, 2008 4:44 pm
by fnunnari
Hello Ogre users and SketchUp modellers (if any).

I wanted to announce that in the last week I worked on improving the SketchUp plugin that exports into the Ogre format.

A preliminary page is here:

Thanks to Kojack for the previous work.
I completely rewrote the materials/textures exporting technique.
The mesh exporting procedure is untouched.

There are still open issues that I should fix in the future.

Please give me some feedback ;-)

Posted: Tue Mar 25, 2008 6:58 pm
by sinbad
I like Sketchup so any enhancements will be welcome. If Kojack's happy with what you're doing I can give you access to CVS so you can commit your changes upstream.

Posted: Wed Mar 26, 2008 8:03 am
by Jerky
Sketchup, even with the material limitations, can be a very powerful tool for teams. In studying how other games do buildings, I found out that the way texture limitation in Sketchup actually works to create architecture to match that of games like Oblivion. The artists who made oblivion's building models used tiling textures per building piece, and therefore all building were made up of multiple parts. Sketchup can do exactly that, and therefore becomes a powerful tool, in my opinion.

I would welcome any enhancements to the exporter.

My only other question is regarding the license on the assets produced by the free version. I haven't looked lately and don't remember what the restrictions were, if any.

Posted: Wed Mar 26, 2008 10:39 am
by Kojack
I've just gotten around (as of a few minutes ago) to updating the current version of the exporter in cvs (been meaning to do that for ages). So your code might need some changing to match the new version.

It's a fairly substantial change. I didn't want to release anything until it worked up to the standard I wanted, which caused it to be dragged on and on.

The main exporter part is pretty much rewritten. It doesn't yet include my scene exporting, but it does do stuff like handle distorted textures about 99.999% correctly (2 giant test models are still slightly wrong on a couple of faces), which took many months of experimenting, several "I'm never touching this program again!" moments (sketchup's api causes MANY of those) and guesswork.

The config file format has changed (now a module instead of global variables). There's no longer a need for hand editing, there's now a config dialog with loading/saving of options:
(Which also caused numerous "I'm never touching this program again!" moments)

You can now select to export front and or back faces, (doing both will generate a lot of triangles).

Hopefully it works. :)

For an idea of the fun this api gives you, I spent a couple of hours last night trying to work out why normals weren't being smoothed. In sketchup the car I was testing looked smooth, in ogre it was flat shaded. Turns out that the sketchup api only exports smoothed normals if the face is inside of at least one group, but will always render them smooth. So what's on screen isn't always what it gives you through the api! If I selected the entire scene, grouped it, then it gave me the right data. GRRR
Also, it doesn't help that Sketchup doesn't like my geforce 8800gts512:
Painful to test models when they look like that. :)

I apologise to anybody who has been waiting for updates. I've been pretty slack with it.

Posted: Wed Mar 26, 2008 5:56 pm
by Kojack
The eiffel tower problem on your page was something I was looking at in one of my tests before updating the cvs. The easiest fix is to just add alpha blending to all materials which have an alpha capable texture format (png, dds, etc). But I don't like that. I think a better way would be to have a user interface which lets extra data be added to materials, like more ogre options (blend modes, etc). It could also handle the annoying looking colourising support for textures. Attribute dictionaries could probably handle it, I haven't tried them yet.

My version exports your box test correctly.

A good test model is St. Peter's Basilica: ... revstart=0
Very painful model. Lots of groups, inherited materials and stuff to confuse the matrices needed for uv coordinate extraction, plus alpha channel pngs for some bits.

UVmapping fixed in beta4

Posted: Wed Mar 26, 2008 6:38 pm
by fnunnari

Thanks for your update on CVS. I was able to fix the UVmap export too :-)

For the alpha problem, today I tried a way to acces the pixels of the texture and manually check if alpha is used. However, there seems to be no way to read the pixels.
I don't think I'm going to add options for users. Instead, we will investigate on why on some textures alpha is recognized and on some others not.

I already found the St.Peter Model few days ago. It seems to export well, with the difference that I still don't export back faces. :-)

I updated my page. Now I noticed an issue related to Axes alignement. Are you coping with it?

I suggest you to also check if some textures cannot be saved. I found a lot of .tif that SketchUp doesn't like. I'll post a case ASAP.


Posted: Thu Mar 27, 2008 3:15 pm
by Kojack
I just fixed (and uploaded) the texture bug which has annoyed me for a while, the top dome of St. Peter's Basilica was coming out wrong. Turns out the material applied to the dome's group was overridding the back face material on the dome itself, so it was picking the wrong texture.

Now the only texture bug I know of (besides colouring and the alpha channel thing) is on a london bridge model, 2 root faces (not in a group or component) are misaligned. Adding them to a group fixes it, so I'm probably storing the wrong transform matrix for the root faces.

About the only way to know if a material needs alpha is to guess based on the file name (png and tga support it, jpg doesn't, etc). The use_alpha? method only returns true when the opacity slider is less than 100%.

Some alpha yes, some aplha not

Posted: Thu Mar 27, 2008 6:07 pm
by fnunnari

I found that some png are exporting with transparency, even if the opacity slider are at 100%, while others not. There is a test case on the page.

Can you post a link to the london bridge model?


Posted: Fri Mar 28, 2008 11:21 am
by Kojack
Hmm, the transparency thing doesn't seem to be texture related, there's something still in the material which isn't shown in the material editor.
I took your 2 tests (the tree which has alpha and the eiffel tower which doesn't) and swapped the textures between them (same material, texture changed). With the eiffel tower texture applied to the tree's face, it came with alpha. With the tree texture applied to the tower mesh, it's not alpha.

UVMaps really fixed

Posted: Fri Mar 28, 2008 2:14 pm
by fnunnari
Three things:

First, I've updated also my exporter. UVMaps were still wrong for inherited materials. Thanks to Kojack again

Second. Kojack I've a test case for you. On my web page there is a ... owDoor.skp that, works fine on the UVmaps but don't write the texture.

Third, about transparency. Indeed, it's something in the material.
I saved the material from sketchup. It creates an eiffel.skm file. It is a disguised ZIP archive. I've opened it with 7-Zip. There is a file document.xml containing a line:

Code: Select all

<mat:material colorBlue="222" colorGreen="222" colorRed="221" colorizeType="0" hasTexture="1" name="eiffel" trans="0" type="1" useTrans="0">
The useTrans attribute is the responsible for the Material.has_alpha? method. It is at 1 in the models recognizing transparency.
However, I also don't know how to change it through the editor.


Posted: Fri Mar 28, 2008 9:10 pm
by Kojack
I've played around a bit and found a tif file solution (kind of).
If you tell the texturewriter to save with a different extension to what the texture originally used, it converts the texture to that format (doesn't just change the name). So for a quick test I told my exporter to change the extension of any tif to png, and they all saved fine (alpha channel as well).

I'm thinking the best option would be to try saving like normal, then if an error happened try saving again as a png (since maybe some tifs do save fine).

1_2_0beta6 release exports backfaces

Posted: Mon Mar 31, 2008 5:11 pm
by fnunnari
I just uploaded the 1.2.0beta6 version of the sketchup to ogre plugin which also exports backfaces.

Kojack, I think we are feature-aligned now :-)
The idea of forcing TIFs to PNG is nice.

I'll consider my release non-beta when I'll fix the Axis positioning problem.


Posted: Mon Mar 31, 2008 6:27 pm
by Kojack
Cool. :)

I've had a bit of a look at attribute dictionaries.
An attribute dictionary lets you bind data to string keys and attach them to any entity in sketchup (including materials, and the entire scene as a whole). Any kind of data can be bound to a key, but loading/saving of the file destroys all data except for numbers and strings.

This means it's possible to add custom data to any face, material or other thing, and preserve it when saving.

Normalizing normals

Posted: Mon Apr 14, 2008 11:40 am
by fnunnari
I just updated my exporter with a fix.
I noticed that colors visualization is improved if normals are normalized before being exported to Ogre.

technically I changed:

Code: Select all

			norm = (matrix*mesh[0].normal_at(p)).to_a

Code: Select all

			norm = (matrix*mesh[0].normal_at(p)).normalize.to_a
As far as I know it shouldn't happen. Normals are normals. If anyone thinks it is an ogre bug, please let me know.
I'm using OgreCommand line tools 1.4.4 and LexiView 1.0.7.

The 1.2.0b7 release is available on the web site, together with a test case:


Issues with the partially rewritten version.

Posted: Fri Oct 31, 2008 6:27 am
by noctrine
Using Sketchup, Ogre Command Line Tools 1.4.7 Neoaxis Map Viewer (Ogre 1.4.6)

Whenever I export a model using the most recently added version by Kojack, or the version by fnunnari the models are imported at a weird rotation.

I try to rotate the models when I import them into my engine (using neoaxis game engine) but not knowing the exact rotation I end up getting this issue where my character model slides to one end.

Was wondering if anyone else got this, and also if there was a fix.

EDIT: Alright, I am fairly certain that the sliding is just an issue of how my model is made. But still if anyone has any similar issues your insight would help :)

Posted: Sat Nov 22, 2008 12:36 pm
by amigoface
after 2 days on this without success i have one simple question :

how it works ???????????????????!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

i downloaded the sript : ...
put it in the sketchup plugins folder (v 6.4.112)

load some models and try to export them
but i have only this simple dialog box

if i put some thing in the file name and i click ok nothing happen
and i have no output file

the ideal is to export to blender and then to ogre
i have also tried some blender script (kmz,kml, collada) without success too

so give me working solution please


Posted: Sun Nov 23, 2008 9:43 am
by Kojack
The current svn of Ogre Addons has my version which gives a better configuration panel, as my screenshot several posts above this one shows.
Both fnunnari's exporter (the one you are using) and mine (the ogre addons version) can export the same data, but mine has the easier to use interface.

For my one, make sure all the paths in the config dialog (for the features you enable) exist, otherwise it will probably fail.

For the one you are using (I'm not familiar with what's different from my original version) check the ogre_export_config.rb file, all the settings for file paths, location of the ogrexxmlconverter.exe file, etc, need to be set by hand before use.

Posted: Mon Nov 24, 2008 3:58 pm
by fnunnari
Indeed, edit the file named "ogre_export_config.rb" and set the right paths and options. There is also a README that should explain everything.

I focused on making the whole code more clean, readable, mainteanable and (hopefully) fast and correct. I didn't put any effort on the GUI.

The only feature I offer in addition to the code of Kojack, is the posibility to export materials and textures with a unique IDs in their name; in order to avoid name conflicts by the OgreResourceManager (I really HATE this name handling policy).

Of course, it would be nice to see the best aspects of both projects merged in a single one. Unfortunately, I don't have enough free time to work on this.


Posted: Wed Nov 26, 2008 8:04 am
by amigoface
sorry for the late replay

i want just to say that it worked just perfectly :)

thanks a lot

Re: SketchUp to Ogre Export partially rewritten

Posted: Thu Mar 05, 2009 10:52 am
by skektox
Hi everyone

Fisrt of all, sorry for my english...

I have a problem using the exporter.

The exporter runs fine (good job!) when i load a mesh in the OgreMeshViewer in Windows XP.

When I use the same mesh and material in my linux application ((Ubuntu 8.04), the mesh don't apply the material and the shadows are very poor. The interpolation between the shadow zone and light zone is a line.

I have the same problem using the blender exporter.

What's the matter? The oGre version, my code ?

Thanks in advance

I can paste my code and the screenshots if you can't understand me.

Re: SketchUp to Ogre Export partially rewritten

Posted: Fri Mar 06, 2009 1:59 pm
by Kojack
There shouldn't be anything strange about the mesh coming from sketchup, it uses the standard ogre xml converter.
If the blender exporter (which is pretty popular and widely used) is causing problems too, my first assumption would be a bad resource directory setup (for the materials to not show up) or drivers (for the shadows to look wrong).
I don't use linux anymore, so I might be missing some other explanation.

Re: SketchUp to Ogre Export partially rewritten

Posted: Sat Mar 07, 2009 2:28 pm
by skektox

Finally, the problem was the Ogre version. In the last version the meshes look OK.

Thanks for the reply


Re: SketchUp to Ogre Export partially rewritten

Posted: Tue Nov 03, 2009 10:13 am
by mehdithe

Very amazing work, thank you!

I have a question :

What about animations support with the last release of SketchUp exporter?

Thanks in advance for any informations

Re: SketchUp to Ogre Export partially rewritten

Posted: Wed Nov 04, 2009 3:02 am
by Kojack
Model animation is only supported (as far as I know) in Sketchup Pro, which costs money. I only have the free version. So unless google give me a free copy, or they move the feature to the free version, animation won't be supported.

Re: SketchUp to Ogre Export partially rewritten

Posted: Sun Nov 08, 2009 11:48 am
by mehdithe

Thanks for the response,

It seems it is possible to make animation whitout the pro version of SketchUp. We could find a tutorial at : ... -animation

I'm working on the OpenSpace3d platform based on Ogre3D and Newton for physics.

Our users are really interested about your work because we would like to give to non-graphist people the possibility
to make intercative 3D environnement based on 3D models by SketchUp.

What do you think about this project?

Thank you in advance.