Easy Ogre Exporter for 3DSMAX

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Post Reply
Pulas
Halfling
Posts: 61
Joined: Sat Oct 29, 2011 9:39 am

Re: Easy Ogre Exporter for 3DSMAX

Post by Pulas »

Hi, arkeon.
Does this exporter support "Shell Material" and "Multi/Sub-Object Material"?
If not, is there any plan for it?
arkeon
Goblin
Posts: 272
Joined: Fri Dec 04, 2009 6:02 pm
x 38

Re: Easy Ogre Exporter for 3DSMAX

Post by arkeon »

Hello,

Yes it support the multi/sub materials.
I'm not sure about the shell one it depend how to max sdk manage it, tell me if it doesn't.
OpenSpace 3D Project manager
http://www.openspace3d.com
drwbns
Orc Shaman
Posts: 788
Joined: Mon Jan 18, 2010 6:06 pm
Location: Costa Mesa, California
x 24

Re: Easy Ogre Exporter for 3DSMAX

Post by drwbns »

Just wanted to say you've done a great job on this so far. Is there anything left for you to work on? or plans for the next release?
arkeon
Goblin
Posts: 272
Joined: Fri Dec 04, 2009 6:02 pm
x 38

Re: Easy Ogre Exporter for 3DSMAX

Post by arkeon »

Thanks :)

Yes, I 'd like to enhance the shader methods.
Manage some special effects like car paint for example from mental ray materials.
choose between multipass shader and limited single light pass.
add the possibility to set a shadow method on materials
I'll have to look deeper in Ogre RTSS, but I'd like to generate compatible materials too.

and sure I'm open to any suggest ^^
OpenSpace 3D Project manager
http://www.openspace3d.com
Pulas
Halfling
Posts: 61
Joined: Sat Oct 29, 2011 9:39 am

Re: Easy Ogre Exporter for 3DSMAX

Post by Pulas »

arkeon wrote:Hello,

Yes it support the multi/sub materials.
I'm not sure about the shell one it depend how to max sdk manage it, tell me if it doesn't.
I'm afraid it doesn't support shell material.
I have a shell material, which is composed of a original material and baked material.
The original material is a multi/sub-object material. The baked material is a standard material.
After exporting, the material has only an empty pass. There is no texture_unit.
But, the mesh has multiple sub-mesh.
The mesh has also 2 UV sets, but 2nd UV coordinate are all 0.
arkeon
Goblin
Posts: 272
Joined: Fri Dec 04, 2009 6:02 pm
x 38

Re: Easy Ogre Exporter for 3DSMAX

Post by arkeon »

ok, could you send me a max sample and explain what is supposed to be exported.
I'll correct that this week.
OpenSpace 3D Project manager
http://www.openspace3d.com
Pulas
Halfling
Posts: 61
Joined: Sat Oct 29, 2011 9:39 am

Re: Easy Ogre Exporter for 3DSMAX

Post by Pulas »

arkeon wrote:ok, could you send me a max sample and explain what is supposed to be exported.
I'll correct that this week.
what's your email address? I will send you a max sample later.

For example, there is a box with a shell material in 3DS Max.
The original material of shell material is a multi/sub-object material, which has six sub materials, each one for one plane of box.
The baked material of shell material is a standard material, which has a baked texture map(lighting map).

It is supposed to export:

1. A box.mesh file, which contain six sub-mesh for six plane of box. Each sub-mesh has its own material name(sub material name), and TWO UV coordinate sets. The first UV coordinate is for the texture map of sub material. The second UV coordinate is for the texture map of baked material.

2. six texture map and one lighting map.

3. A material file, which contain six materials. Each material has two texture_unit. One is for texture of sub material, and the other one is for the baked texture. The materials of top and bottom side of box are similar as below:

Code: Select all

material box_shell_material_top
{
        technique
        {
                pass
                {
                        texture_unit diffuse_map_top
                        {
                                texture DiffuseMapTop.jpg
                        }

                        texture_unit lighting_map
                        {
                                texture LightingMap.jpg
                        }
                }
        }
}

material box_shell_material_bottom
{
        technique
        {
                pass
                {
                        texture_unit diffuse_map_bottom
                        {
                                texture DiffuseMapBottom.jpg
                        }

                        texture_unit lighting_map
                        {
                                texture LightingMap.jpg
                        }
                }
        }
}
If I don't explain clearly, just let me know. I will provide more info.
arkeon
Goblin
Posts: 272
Joined: Fri Dec 04, 2009 6:02 pm
x 38

Re: Easy Ogre Exporter for 3DSMAX

Post by arkeon »

arkeonDOTwork AT gmail
OpenSpace 3D Project manager
http://www.openspace3d.com
Pulas
Halfling
Posts: 61
Joined: Sat Oct 29, 2011 9:39 am

Re: Easy Ogre Exporter for 3DSMAX

Post by Pulas »

I have sent 2 max sample files to you. Check your email box.
arkeon
Goblin
Posts: 272
Joined: Fri Dec 04, 2009 6:02 pm
x 38

Re: Easy Ogre Exporter for 3DSMAX

Post by arkeon »

Ok thank you, I'll look at this ASAP
OpenSpace 3D Project manager
http://www.openspace3d.com
arkeon
Goblin
Posts: 272
Joined: Fri Dec 04, 2009 6:02 pm
x 38

Re: Easy Ogre Exporter for 3DSMAX

Post by arkeon »

after a quick look to your mail, i think that the shell materials are not intended to be use like this.
it permit to switch between the max viewport material and the render one.
EOE should take only the render or the viewport material, not both.

in max if you want to render lightmaps to the current materials, you should select the "Output Into Source" option and choose the "Ambient Color" as a target Map Slot.
Then your material should be complete.

I could manage the case to export both materials into one like you suggest, but what to do if there is already an ambient map in the first material ?
if the graphist want to use the shell material as it should, or to bake complete map not only lightmap.

however even to manage the shell material as it, which one should I convert ? the Viewport or Render one ?
OpenSpace 3D Project manager
http://www.openspace3d.com
Pulas
Halfling
Posts: 61
Joined: Sat Oct 29, 2011 9:39 am

Re: Easy Ogre Exporter for 3DSMAX

Post by Pulas »

arkeon wrote:I could manage the case to export both materials into one like you suggest, but what to do if there is already an ambient map in the first material ?
if the graphist want to use the shell material as it should, or to bake complete map not only lightmap.
As a common usage, It is indeed a problem. I have lots of max files with shell material like that.
So maybe I should develop my own special version based on Easy Ogre Exporter.
arkeon wrote:however even to manage the shell material as it, which one should I convert ? the Viewport or Render one ?
But, IMO, the export should export the original material(Viewport material) for this kind usage of shell material.
Is it difficult to adapt Easy Exporter to export the original material(multi/sub-object material) in my max file?
Hope this feature can be implemented officially.
arkeon
Goblin
Posts: 272
Joined: Fri Dec 04, 2009 6:02 pm
x 38

Re: Easy Ogre Exporter for 3DSMAX

Post by arkeon »

I'll add the shell material and then use the viewport material.

maybe that you could make a max script that copy the light map to the sub materials, and then remove the shell material.
a hack in the material exporter could manage your case but i think it should be easier and cleaner to make your max script for that
OpenSpace 3D Project manager
http://www.openspace3d.com
Pulas
Halfling
Posts: 61
Joined: Sat Oct 29, 2011 9:39 am

Re: Easy Ogre Exporter for 3DSMAX

Post by Pulas »

Great. I will be keeping follow it with interest.
Thanks for your great effort on this exporter.
Pulas
Halfling
Posts: 61
Joined: Sat Oct 29, 2011 9:39 am

Re: Easy Ogre Exporter for 3DSMAX

Post by Pulas »

Hi, again.
I try to compile Easy Ogre Exporter for 3DSMAX 2010 from the latest source.

I found the project is dependent on TinyXML, Boost and NVIDIA Texture Tool.
There is a environment variable $(SCOL_DEPENDENCIES_PATH) in the project setting. So TinyXML should be put in the correct place.It is similar for Boost.
As for NVIDIA Texture Tool, the source should be put in the directory called "nvdtx". After compiling release mode of nvtt project, I have to copy "nvcore.lib", "nvmath.lib", ... to the "ext\nvdtx\project\vc9\Release.win32\lib" directory.

After building the maxsdk\samples\modifiers\morpher lib, I copy "wm3.h" and "resource.h" file to ext max sdk include directory except copying lib.

Another problem is that I have to rename "FreeType2311.lib" to "FreeType.lib" in "Additional Dependencies"..

The weird problem is that "empty" is redefined in value.h of max sdk with vc9's.

line 571, value.h of max sdk

Code: Select all

extern ScripterExport Empty empty;
line 826, ivec.h of vc

Code: Select all

inline static void empty(void) 		{ _m_empty(); }
So, I have to change the variable of max sdk to "_empty".

Finally, I can compile the project without errors. But when I start 3DSMAX loading the plugin, I have to copy "nvtt.lib" to 3DSMAX directory, orterwise the plugin will not be loaded correctly.

Finally finally, I can debug with the hybrid mode.
But when it run to the line 925 in ogreExporter.cpp

Code: Select all

Ogre::MeshManager meshMgr;
Then the plugin has no reponse, but the UI of 3DSMAX has not been blocked.

What's wrong?

Is there any way to debug into Ogre?
I try to use ogre debug version library. But the plugin won't be loaded correctly.

Is my way of compiling right?
arkeon
Goblin
Posts: 272
Joined: Fri Dec 04, 2009 6:02 pm
x 38

Re: Easy Ogre Exporter for 3DSMAX

Post by arkeon »

Hi,

not bad that you get to this point :)

I'v changed NVTT to build in static mode.
you should copy the dll not the .lib in max directory if you don't want to use the static mode.
Also if you want to use the CUDA version you will have to install the same version on other computers for redist.

I didn't had to change anything in the SDK, do not change the code, but change the order of the paths in Visual project include / lib paths.

Sometimes even in hybrid mode max hang without any catch in the debugger.

good luck :)
OpenSpace 3D Project manager
http://www.openspace3d.com
Pulas
Halfling
Posts: 61
Joined: Sat Oct 29, 2011 9:39 am

Re: Easy Ogre Exporter for 3DSMAX

Post by Pulas »

arkeon wrote:I didn't had to change anything in the SDK, do not change the code, but change the order of the paths in Visual project include / lib paths
The max sdk path is set in the Project Properties. Visual C++ directory is set in the Tools->Options->Projects and Solutions. How to change the order?

The error message:

Code: Select all

1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\ivec.h(826) : error C2365: 'empty' : redefinition; previous definition was 'data variable'
1>        e:\ogre\sources\easyogremaxexporter\ext\2010\include\maxscrpt\value.h(527) : see declaration of 'empty'
My environment:
Windows 7 64bit
Visual Studio 2008 SP1
3DS MAX 2010 32bit, not with SP1, is it necessary?
Ogre 1.8.1 32bit, it is not rebuilt with _SECURE_SCL=0 in preprocessor, but it seems fine.
arkeon
Goblin
Posts: 272
Joined: Fri Dec 04, 2009 6:02 pm
x 38

Re: Easy Ogre Exporter for 3DSMAX

Post by arkeon »

to change the order you just use the arrow buttons on this interface to pull down the path. to make it low priority
OpenSpace 3D Project manager
http://www.openspace3d.com
arkeon
Goblin
Posts: 272
Joined: Fri Dec 04, 2009 6:02 pm
x 38

Re: Easy Ogre Exporter for 3DSMAX

Post by arkeon »

EOE v1.3 available

- Manage the shell material : use the second material if exist the first otherwise
- Use the max Textures channels number (warning empty channels will be exported, but if a channel 3 is used then the material now correpond to the mesh)
- Correction on a crash in case of an empty texture name
- Ignore meshs with 0 vertex in the dot scene file
- Ignore objects in hidden layers
OpenSpace 3D Project manager
http://www.openspace3d.com
Pulas
Halfling
Posts: 61
Joined: Sat Oct 29, 2011 9:39 am

Re: Easy Ogre Exporter for 3DSMAX

Post by Pulas »

Thanks for you managing shell material.

After tested the plugin 1.3 for some max files, I found some problems:
1. It will always export a default material naming "defaultLambert", which is not used in the scene;

Code: Select all

material "defaultLambert"
{
	technique defaultLambert_technique
	{
		pass defaultLambert_standard
		{
			ambient 1 1 1 1
			diffuse 1 1 1 1
			specular 0 0 0 1 0
			emissive 0 0 0 1
		}
	}
}
[s]2. As for transparent material, it will export a additional texture_unit, which is redundant.[/s]

Code: Select all

material "XN-D-100_jz_03_al01"
{
	technique XN-D-100_jz_03_al01_technique
	{
		pass XN-D-100_jz_03_al01_standard
		{
			cull_hardware none
			cull_software none
			ambient 1 1 1 1
			diffuse 1 1 1 1
			specular 0 0 0 0 25.5
			emissive 0 0 0 1

			scene_blend alpha_blend
			depth_write off

			texture_unit XN-D-100_jz_03_al01_Diffuse#0
			{
				texture XN-D-100_jz_31_al01.tga
				tex_coord_set 0
				colour_op modulate
			}

			// redundant texture_unit
			texture_unit XN-D-100_jz_03_al01_UnKnown#1
			{
				texture XN-D-100_jz_31_al01.tga
				tex_coord_set 0
				colour_op modulate
			}
		}
	}
}
3. Sometimes, the exported texture scroll factor is not right. After digging code, I found maybe it's caused by floating point comparison. It should use "Ogre::Math::RealEqual()".

Code: Select all

					//write texture transforms
         if ((m_textures[i].scale_u != 1.0f) || (m_textures[i].scale_v != 1.0f))
		outMaterial << "\t\t\t\tscale " << m_textures[i].scale_u << " " << m_textures[i].scale_v << "\n";
	if ((m_textures[i].scroll_u != 0.0f) || (m_textures[i].scroll_v != 0.0f))
            outMaterial << "\t\t\t\tscroll " << m_textures[i].scroll_u << " " << m_textures[i].scroll_v << "\n";
	if (m_textures[i].rot != 0.0f)
            outMaterial << "\t\t\t\trotate " << m_textures[i].rot << "\n";
4. It seems that the exporting path can not contain non-English character, isn't it?

PS.
I commented out the following code, then the error which is "empty" variable redefinition has gone. Finally, I can compile and debug the source now.
ExPrerequisities.h

Code: Select all

//#ifdef PRE_MAX_2011
//#include "maxscrpt/maxscrpt.h"
//#else
//#include "maxscript/maxscript.h"
//#endif
PS.PS.
when compiling, there are some critical warnings:

Code: Select all

warning C4265: 'EasyOgreExporter::ExShader' : class has virtual functions, but destructor is not virtual

warning C4265: 'EasyOgreExporter::ExVsAmbShader' : class has virtual functions, but destructor is not virtual

warning C4265: 'EasyOgreExporter::ExFpAmbShader' : class has virtual functions, but destructor is not virtual

warning C4265: 'EasyOgreExporter::ExVsLightShader' : class has virtual functions, but destructor is not virtual

warning C4265: 'EasyOgreExporter::ExFpLightShader' : class has virtual functions, but destructor is not virtual
destructor of these class should be virtual.
Last edited by Pulas on Wed Nov 28, 2012 9:29 am, edited 1 time in total.
arkeon
Goblin
Posts: 272
Joined: Fri Dec 04, 2009 6:02 pm
x 38

Re: Easy Ogre Exporter for 3DSMAX

Post by arkeon »

Thank you ! i'll look at this too.
OpenSpace 3D Project manager
http://www.openspace3d.com
Pulas
Halfling
Posts: 61
Joined: Sat Oct 29, 2011 9:39 am

Re: Easy Ogre Exporter for 3DSMAX

Post by Pulas »

Sorry, the 2nd problem I listed above is not a bug of the export plugin. My bad. The plugin can export transparent material right.
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: Easy Ogre Exporter for 3DSMAX

Post by AshMcConnell »

Hi Guys,

Is there any way to attach "user data" to each object? We are currently using OgreMax and we tag each object with userdata, e.g. steering wheel, tyre (with various attributes), car body.

Is there a standard way of doing this with EOE?

Thanks!

All the best,
Ash
arkeon
Goblin
Posts: 272
Joined: Fri Dec 04, 2009 6:02 pm
x 38

Re: Easy Ogre Exporter for 3DSMAX

Post by arkeon »

Hi !

yes now it can ^^

EOE v1.4
- this include the corrections seen by pulas
- the default material is exported only when needed
- shader and program files are not created when there is no shaders anymore
- the "userData" keyword is now managed in the max object properties.

Max allow only user data on a mesh :/ this is not available on dummies or other.
A user data can only be on one line in the max interface.

for example :
userData=my user params on only one line :/

tell me if this is sufficient for your needs, but I don't know how I could manage this else where without an additional max plugin.
in the dot scene the <userData> markup is set in the mesh one.
OpenSpace 3D Project manager
http://www.openspace3d.com
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: Easy Ogre Exporter for 3DSMAX

Post by AshMcConnell »

Hi Arkeon,

Wow, Thanks! :)

What I found really useful when using OgreMax is that it allowed the specification of an XML structure for the userdata itself, then from this userdata it created a kind of user interface in 3dsmax.

For example I can specify the following XML: -

Code: Select all

<class name="CarCamera" displayName="Car Camera" usage="object">
		<data name="HeadMovementsOn" displayName="Allow Head Movements" type="bool" default="false"/>
		<data name="Default" displayName="Default Camera" type="bool" default="false"/>
		<data name="CockpitCam" displayName="Cockpit Cam" type="bool" default="true"/>
</class>
and if I assign this CarCamera class to an object I can then assign the fields: -

Allow Head Movements [ ]
Default Camera [ ]
Cockpit Cam [ ]

When it exports the camera I get some XML in the userdata field: -

Code: Select all

<camera name="Onboard001Cam" fov="1.29644">
            <userData>
                <![CDATA[<CarCamera><HeadMovementsOn>false</HeadMovementsOn><Default>false</Default><CockpitCam>false</CockpitCam></CarCamera>]]>
            </userData>
            <clipping near="0.11" far="1000" />
</camera>
In this way 3dsmax itself can be used as a way to build a level (in my case - a track) or a player model (in my case a car), rather than exporting the raw models and assembling them in a separate level / model editor. I find it's a nice way to speed up the development iterations :)

I think it would be a nice addition, I'm not sure how hard it would be as I haven't done any 3dsmax plugin stuff before.

All the best,
Ash
Post Reply