Using 3ds max to export to .my3d

A forum to store posts deemed exceptionally wise and useful
frostysnowman
Posts: 83
Joined: Fri Apr 11, 2008 3:06 am
Location: Beaverton, Oregon, US

Using 3ds max to export to .my3d

Post by frostysnowman »

Firstly, let me let you know that I am no expert in 3ds max, but there have been people having issues exporting to .my3d and I know how to do this!

There has been a previous tutorial on this matter, but I thought I could shed some more light to some more areas that weren't explained in as much detail.

my3d Homepage

When I first started using my3d, I had some troubles figuring out how to set up 3ds max right, so here is how.


1.) You need to have 2 map channels in your mind. One is for the diffuse map, and the other is for the lightmap. In my tutorial, I am using map channel 1 for the diffuse map and map channel 3 for the lightmap.

2.)Model your scene, texture it and set up your uvs correctly for the diffuse texture. When your scene is ready, set up your lights and under the light dialogs enable shadows and choose Shadow Map or Ray Traced Shadows (if you want shadows):

Image

3.) Then, you can generate your lightmap. Have your object selected, then goto rendering->Render To Texture choose these settings:

Image
When choosing automatic unwrap, choose the channel that you've designated for your lightmap (mine is 3), seperate to your diffuse channel. Make sure to set a target path for the lightmap to generated on your hardrive.


4.) Ok! Take the lightmap you generated, and set it as the illumination map in the top level of your material (In pic below) that's applied to the object you made a lightmap for. Once the lightmap is set to be the illumination map, you need to check the check box next to the illumination slot to make sure it is enabled.

Image

5.)You also need to make that the map channels are set correctly to your diffuse map and your illumination map. To do this, click on the slots where your diffuse map and your illumination map (your lightmap) is (with an M) and it will switch dialogs to show the map independent stuff. In this dialog, there will be a selector for which map channel is assigned to the map you are currently looking at. You need to change this to be the right map channel. For me, the diffuse map channel is 1, and the illumination map channel (which is for your lightmap) is 3.
Image
Image

6.)File-Export-my3d. Choose to save and check standalone (lightmaps embedded never work for me). You also have to create a folder where your my3d model is that is called "Lightmaps" and you need to copy your lightmap there, or already have it there in a "Lightmaps" folder already created and have the material in 3ds max link straight to it at that location (that's what I do).
Image


All you have to do to load the my3d model in C++ in main() or whatever before your irrlicht loop is:

Code: Select all

scene::IAnimatedMesh* my3dMesh = smgr->getMesh("media/my3dmesh.MY3D");
scene::IAnimatedMeshSceneNode* my3dNode = smgr->addAnimatedMeshSceneNode(my3dMesh);
If you go to the my3d website, it will say you have to replace the irrlicht .my3d loaders with the ones on the website. From my experience, loading .my3d files has worked fine so far, but there is a post in the bug forums that says you need to update it. If you want to, you can update it but for me .my3d files load fine for me with Irrlicht 1.4.


Additional Notes:
  • The lightmap uvs are best to be an automatic flattening. The reason for this is that you will not have to take the lightmap into photoshop and paint on it. There can be a million seams, and you don't have to worry about it because the render to texture automatically paints the lightmap on within the seams, and still has it all blend together. But if for some strange reason you want to have a uv template for your lightmap that has minimal seams, you can apply a unwrap uvw modifier and set the map channel box to whatever map channel you have for your lightmap, then just edit the uvs away. Additionally, if you don't want the render to texture to flatten the uvs automatically: apply a unwrap uvw modifier, select all the faces, click on edit in the modifier dialog, then go mapping->flatten mapping. This is the equivalent of the automatic flatten done by the render to texture.

    You can also edit the parameters for the automatic uvw flattening in the render to texture dialog if you scroll down.

    You do not have to use scmgr->getStringParameters()->setParameter(
    scene::MY3D_TEXTURE_PATH, "path/to/your/textures" in the newest version of Irrlicht. I read this from a previous 3dsMax & my3d tut.

    if your 3ds max scene has multiple objects, and multiple materials applied to them, then in step 3 select all of your objects, then go to render to texture and create lightmaps for all of them. Once you have these lightmaps, you can proceed through the tutorial except repeat the following steps for each material.
EDIT: I just uploaded a helpful zip file containing various my3d example meshes, a sample 3dsmax7 scene which is ready to export to .my3d, and a VC++ 2008 project that loads the my3d scenes. From the README.txt included in the upload:

This contains a VC++ 2008 project for loading .my3d scenes and contains a 3ds max 7 scene ("my3dTest.max") which
is fully ready to export to .my3d format.

If you do not have VC++ 2008, navigate to ".\my3d\my3d". This is where the two files for the program are,
main.cpp and globals.h. In ".\my3d\my3d\media" there are the files needed for the program to run,
including textures lightmaps, and my3d meshes. There is more than one my3d sample mesh to load in the
media directory, so you can edit main.cpp to load other sample my3d scenes.



Frostysnowman4@hotmail.com
The uploaded zip file is here and is also linked now in my first post.
Last edited by frostysnowman on Sat May 24, 2008 10:19 pm, edited 10 times in total.
MikeP
Posts: 25
Joined: Fri May 16, 2008 1:51 pm

Post by MikeP »

Hi. Thanks for this,
I don't think it's THAT simple :
All you have to do to load the my3d model in C++ is:

Code: Select all

scene::IAnimatedMesh* my3dMesh = smgr->getMesh("media/my3dmesh.MY3D");
scene::IAnimatedMeshSceneNode* my3dNode = smgr->addAnimatedMeshSceneNode(my3dMesh);
my code :

Code: Select all

#include <irrlicht.h>
#include <iostream>
#include <stdio.h>

using namespace irr;

#pragma comment(lib, "Irrlicht.lib")

int main()
{
	IrrlichtDevice *device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(800, 600),32, false, true, false,0);

    video::IVideoDriver* driver = device->getVideoDriver();
    scene::ISceneManager* smgr = device->getSceneManager();
    gui::IGUIEnvironment* env = device->getGUIEnvironment();
    driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);

     smgr->getParameters()->setAttribute(scene::MY3D_TEXTURE_PATH, "./data/");
     scene::IAnimatedMesh* mesh;
     mesh = smgr->getMesh("./data/supertest.MY3D");

    scene::ISceneNode* test_scene = smgr->addOctTreeSceneNode(mesh->getMesh(0));
    test_scene->setPosition( irr::core::vector3df(0,0,0) );
    test_scene->setScale( irr::core::vector3df(2,2,2) );
    test_scene->setRotation( irr::core::vector3df(0,0,0) );
   test_scene->setMaterialFlag(video::EMF_LIGHTING, false);

	scene::ISceneNode* skyboxNode = 0;
	skyboxNode = smgr->addSkyBoxSceneNode(
	driver->getTexture("./data/rocky_up.jpg"),
	driver->getTexture("./data/rocky_dn.jpg"),
	driver->getTexture("./data/rocky_lf.jpg"),
	driver->getTexture("./data/rocky_rt.jpg"),
	driver->getTexture("./data/rocky_ft.jpg"),
	driver->getTexture("./data/rocky_bk.jpg"));

	SKeyMap keyMap[8];

	keyMap[1].Action = EKA_MOVE_FORWARD;
	keyMap[1].KeyCode = KEY_KEY_W;

	keyMap[3].Action = EKA_MOVE_BACKWARD;
	keyMap[3].KeyCode = KEY_KEY_S;

	keyMap[5].Action = EKA_STRAFE_LEFT;
	keyMap[5].KeyCode = KEY_KEY_A;

	keyMap[7].Action = EKA_STRAFE_RIGHT;
	keyMap[7].KeyCode = KEY_KEY_D;

    scene::ICameraSceneNode* camera = 0;
    camera = smgr->addCameraSceneNodeFPS(0,200.0f,300.0f,-1, keyMap, 8);
    camera->setFarValue (50000.0f) ;
    camera->setFOV(1.1f);
    camera->setPosition(core::vector3df(0,50,0));
    camera->setTarget( core::vector3df(0,0,0));
    camera->setRotation(core::vector3df(0,0,0));

    device->getCursorControl()->setVisible(false);

	f32 text_rot=0;

    int lastFPS = -1;
    while(device->run())
    {
        driver->beginScene(true, true, video::SColor(255,0,0,0));
        smgr->drawAll();
        driver->endScene();

		  int fps = driver->getFPS();

        if (lastFPS != fps)
        {
                   lastFPS = fps;
        }
    }

    device->drop();
    return 0;
}

here's my result with it :
what I have in 3DSMax :
http://www.youtube.com/watch?v=ALvvZMihK54

what I get in Irrlicht :
http://www.youtube.com/watch?v=ibshtt-mdXo

I think I'm gonna cry :cry:
Last edited by MikeP on Sat May 24, 2008 10:28 am, edited 1 time in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

It seesm that your mesh has somehow changed to refelction instead of lightmap. First of all try to get rid of the octree scene node. Doesn't make any sense for your mesh (it's intended for huge meshes...). Then please show the console log to be sure which textures are loaded. Finally, try to patch your loader as suggested in the bug forum's post about my3d, or simply make your filename longer than 10 characters when exporting from 3ds (that would make the lightmap loading bug disappear automatically).
MikeP
Posts: 25
Joined: Fri May 16, 2008 1:51 pm

Post by MikeP »

hi hybrid, thanks for answering me.
Yes there was a loading problem with the lightmap.. I left it in "Lightmaps" folder which was in the same folder as the *.my3D ..as frostysnowman asked. And the console showed it wasn't loading because it was trying to find it in the folder I specified in MY3D_TEXTURE_PATH.
so I corrected it :
Image

I re-exported the my3D with a longer than 10 chars name (and changed it in the code as well)

About the octtree, it was something left from this tutorial :
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=7494
I got rid off it as you asked

Here's the lightmap file (not actual size... it's 1024² but I've shrinked it for the forum)
Image

And it gotten even worse :
http://www.youtube.com/watch?v=14BsbXmsvM0

Now I have to understand what "patch your loader" means and find that post in the bug forum... sorry I'm a begginer but you all have been at one point.

I'm almost tempted to give up and use B3D :/
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

Thanks, frostysnowman! This may become handy. I`ll try it for sure, when I find such an exporter for Max9 and will share my results.

MikeP: buddy, keep on and I`m sure you`ll discover a plenty of next-generation material effects. I really have to work a lot to get yor first effect. :D

I think the problem is somewhere in the Max material settings. There are many bugs going out of the exporters due to those nasty setting. Try different combinations. As an example I`m using PandaX exporter for the static meshes and kWexporter (or sth alike- too lazy to check right now) for the animated ones. The first misses the animation, the second misses the materials, but will fix it when I get my models finished- currently just testing.

Good luck! :wink:
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
MikeP
Posts: 25
Joined: Fri May 16, 2008 1:51 pm

Post by MikeP »

shadowslair wrote: MikeP: buddy, keep on and I`m sure you`ll discover a plenty of next-generation material effects. I really have to work a lot to get yor first effect. :D
well, for the moment I'm wasting hours and hours on old outdated non working stuff.
Another one here : about 3h lost http://irrlicht.sourceforge.net/phpBB2/ ... 477#158477

actually thinking of moving to Ogre and check if they got the same versions mess or if what we find on tutorial/forums are working stuff because this is driving me crazy and pure waste of time.
frostysnowman
Posts: 83
Joined: Fri Apr 11, 2008 3:06 am
Location: Beaverton, Oregon, US

Post by frostysnowman »

@MikeP

You do not have to use scmgr->getStringParameters()->setParameter(
scene::MY3D_TEXTURE_PATH, "path/to/your/textures" in the newest version of Irrlicht. I read this from a previous 3dsMax & my3d tut.
Hi. Thanks for this,
I don't think it's THAT simple :
I see how that could be misinterpreted, so I edited what I said about that piece of code to "All you have to do to load the my3d model in C++ in main() or whatever before your irrlicht loop is:".

In your new video, it looks like your diffuse uvs are mixed with your lightmap uvs.. But I still don't know why you are getting reflection.

I just uploaded a zip file that could be helpful to you containing various my3d example meshes, a sample 3dsmax7 scene which is ready to export to .my3d, and a VC++ 2008 project that loads the my3d scenes. From the README.txt included in the upload:

This contains a VC++ 2008 project for loading .my3d scenes and contains a 3ds max 7 scene ("my3dTest.max") which
is fully ready to export to .my3d format.

If you do not have VC++ 2008, navigate to ".\my3d\my3d". This is where the two files for the program are,
main.cpp and globals.h. In ".\my3d\my3d\media" there are the files needed for the program to run,
including textures lightmaps, and my3d meshes. There is more than one my3d sample mesh to load in the
media directory, so you can edit main.cpp to load other sample my3d scenes.



Frostysnowman4@hotmail.com
The uploaded zip file is here and is also linked now in my first post.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Could you please upload the broken my3d mesh somewhere? I really don't understand why you get a reflection type of material.
jontan6
Posts: 278
Joined: Fri Jun 13, 2008 5:29 pm

Post by jontan6 »

Hello, I tried following the tutorial but I cant seem to have the correct output. I have 1 mesh and 1 light source in my scene, the ff. are the series of what I did

Image
I setup first the light and texture of the mesh


Image
i rendered to texture channel 3


Image
the resulting tga file


Image
i place the tga in the material, channel 3. diffuse is channel 1.


Image
i exported as my3d and load in irrlicht.


but it doesnt look ok.

any ideas which step i went wrong? thanks!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Looks like you didn't export the texture coords properly.
jontan6
Posts: 278
Joined: Fri Jun 13, 2008 5:29 pm

Post by jontan6 »

i tried many permutation on how to do it properly but always not ok. any ideas how to make sure the uvs are right? thanks
frostysnowman
Posts: 83
Joined: Fri Apr 11, 2008 3:06 am
Location: Beaverton, Oregon, US

Post by frostysnowman »

Try doing it over with map channel 2 for your lightmap uvws (you must have done something wrong in the process). From looking at your screen shot I am positive that your uvws are mixed up like hybrid said.

What's your code for loading your my3d file? Most likely the problem is not within your code, but paste it anyways.
jontan6
Posts: 278
Joined: Fri Jun 13, 2008 5:29 pm

Post by jontan6 »

Hello,

thanks for the help, my code is pasted below. i will try channel 2. for lightmap i cant use channel 1 for both right? thanks

Code: Select all

	IAnimatedMesh* mesh = smgr->getMesh("test.my3d");
	IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
	if (node) {
		node->setMaterialFlag(EMF_LIGHTING, false);
		node->setScale(core::vector3df(20,20,20));
		node->setRotation(core::vector3df(0,30,0));
	}
e^x
Posts: 11
Joined: Fri Oct 03, 2008 5:33 pm
Location: CANADA

Post by e^x »

Ok, kind of late reply. But anyway...
Try using the automatic unwrap first before even baking. Use the automatic unwrap, then go to render to texture, using channel one rather than 3. I'M not sure but the way I see it is Irrlicht is looking for channel 1 which is not unwrapped.
Try that, it might work.
Exponentially evolving. Leaving behind the obsolete...
frostysnowman
Posts: 83
Joined: Fri Apr 11, 2008 3:06 am
Location: Beaverton, Oregon, US

Post by frostysnowman »

e^x wrote:Ok, kind of late reply. But anyway...
Try using the automatic unwrap first before even baking. Use the automatic unwrap, then go to render to texture, using channel one rather than 3. I'M not sure but the way I see it is Irrlicht is looking for channel 1 which is not unwrapped.
Try that, it might work.
If you used channel 1 for your lightmap mapping coordinates, which channel would be used for the diffuse mapping coordinates? What you say does not make sense.
Post Reply