Importing 3dstudio scene into Blitz 3D

Blitz3D Forums/Blitz3D Programming/Importing 3dstudio scene into Blitz 3D

Dicon(Posted 2008) [#1]
I can import a 3DS mesh with baked textures into Blitz3D, but cannot get my head around a group of meshes all with their baked textures.
What there is is good looking and correctly spaced, but.. I get all the meshes but only ONE with the texture. Any advice?

The whole scene looks great rendered in 3DStudio, though..
< sigh >
Dicon


Kryzon(Posted 2008) [#2]
All modelling and texturing and entity placement in Max get a major boon if you use the B3D Pipeline. Just download it, plug it in the right directories and you're off (unless you need to download a special patch for your max version).

You can then use the newly available "Blitz3D Brush" material to properly apply your baked textures and exporting directly into .B3D (with full support to texture flags, entityfx flags, blending modes and skeletal animation. It's awesome).


Naughty Alien(Posted 2008) [#3]
why would you bake textures anyway? Just apply them per object/entity(depending on your needs) and export from 3dsmax (trough pipeline will be my suggestion) and you are okay..


Dicon(Posted 2008) [#4]
Wow!, if it can do what it says, and I can get my brain around it, it will solve most of my problems. Will load in a few minutes

Naughty Alian... I need to bake in the shadows and light levels.
Thanks Kryzon for pointing me to 3DPipeline.
Dicon


Naughty Alien(Posted 2008) [#5]
>>Naughty Alian... I need to bake in the shadows and light levels<<

I understand that, but instead baking for each object(I assume thats what you do), why not just render out one big lightmap for all objects and attach it to UV map2 and thats ok and cool


Dicon(Posted 2008) [#6]
Erm.. Um...
never thought of that. Will try it now.
<FX> Rustle.. rustle.. where did I put that lightmap info? ..< sound of books being moved >

;¬)

Dicon


Dicon(Posted 2008) [#7]
H' OK, I have a feeling this should be in the beginners section, but it's a rather difficult thing for me to see HOW to do it.
I have set up a simple cube with a texture in 3DS.
Then exported both light map, baked map, all over texture, and all else I could think of.

I have a light map
I have an all over texture.
But I still get a complete map on each side of the cube.
So, there looks to be two things to understand.
How to map one image of six sides onto the correct face.
or
How to incorperate the light map into the all over texture.
Perhaps both.
Any advice or demo or... whatever will help.
I will now look through the achives for a solution.
Sorry if I seem a total noob ( OK, nearly, but it has been a tough time in this houshold the last week or two, illness & stuff.
Thanks for the advice, I will keep trying.

Dicon


Naughty Alien(Posted 2008) [#8]
..here is how...I assume that difuse texture you have assigned on to UV map channel 1 .. so in that case lightmap going on to UV map channel 2...it can work reverse too..so..

load your lightmap
LightMap=loadtexture("MyLightmap.PNG")
TextureBlend LightMap,5
TextureCoords LightMap,1 <---- this is part where you telling to B3D what UV map channel to use for what texture , 0=first UV map layer 1=second UV map layer

now after you did this simply pass trough your objects hierarchy and apply LightMap on to each object , something like this
MyLevel=LoadAnimMesh("MyLevel.B3D")
If CountChildren(MyLevel) > 0
For objectcount = 1 To CountChildren(MyLevel)
Entity = GetChild(MyLevel,objectcount)
EntityTexture Entity,LightMap,0,2
Next
EndIf

this should work, since im using it all time and no problems at all


Dicon(Posted 2008) [#9]
Ok, thanks, will try that later today.

Dicon


Kryzon(Posted 2008) [#10]
Well, you are doing that by code. But you can define the texture channel while inside max so you export your fully lightmapped model ready to use.
Quoting what somebody said once here about lightmapping in 3DS:


Originally posted by Liberator (Posted 2 years ago)

1) Bust open 3dsmax. Make sure your scene is fully textured all under map channel #1. You can mix textures, as long as all the textures are UVW mapped/unwrapped under channel 1.

2) Add in lights. Set up the shadows exactly as you want them to be on the shadow map, do some quick renders from different angles to ensure the enviroment looks like you want it to with the current lighting.

3) Once you're happy with the lighting, combine all the meshes you want affected into one big mesh (you can always break it back up later). You can do this by putting an edit mesh modifier on an object, the use the "attach" tool to add all the mesh pieces together.

4) Once the scene is one mesh, make sure you have the mesh selected and hit the '0' key, or go to Rendering -> Render to Texture.

5) Inside the window that just popped up, locate the Output scroll. Click on the Add button. This will bring up a list Texture Elements. Select shadow map. Hit the Add Elements button.

6) Scroll down a bit more (still inside the Output scroll) and choose your texture size. I find that 256-512 is a good texture size for shadow maps. Once you've got that, scroll back up to the top of the window and find the Output Path field under the General Setting scroll. Select the folder where you want the texture to be created.

7) Hit render. Note that the resulting image that comes up is *not* the final rendering, it is a preview (this one does not have an alpha channel). The actual texture is located in the file path you saved to. Max just shows you that sample render as a preview of its progress.

8) Now you have your lightmap texture, all that's left is to assign it to the mesh. Close the Render to Texture window and check out the side bar where your modifier stack is. there will be an Automatic Flatten UVW modifier added to the stack. This is the UVW mapping you want to use.

9) This next step is unnecessary, but I highly recommend it. I say this coming from years of experience with this tool. The automatic UVW modifier is a bit different than the normal unwrap modifier and sometimes Pipeline does not export it correctly, so it's always best to use a normal Unwrap UVW modifier. Simply hit the Save button under Parameters tab in the Automatic Flatten UVW that was added to the stack. Save the UVW file. Delete the Automatic Flatten UVW off the stack and now add a Unwrap UVW modifier. Hit the Load button, and load back the .uvw file you just saved out.

10) Now that you have loaded back the UVW data, set the Map Channel to #2 (this is vital). All that is left now is to apply the texture in the material editor. Add your texture infomation to the first tab in a Blitz3d material, and make sure it is set to channel 1. Then, add the shadow map that you rendered out earlier to tab 2 in the blitz material. Make sure that one is set to channel 2.

And that will do it. Export it with pipeline and you will have a perfectly lightmapped scene all done from within 3dsmax.



I hope it helps. This method also allows you to bake Ambient Occlusion, to give further depth and realism to your models! (just by enabling the Light Tracer from max and rendering to texture, it'll bake the AO altogether).

Good luck,
Rafael -Kryzon-


Dicon(Posted 2008) [#11]
Lots of info here..
This is what I did with Naughty Alians code............

Graphics3D 640,480
SetBuffer BackBuffer()

camera=CreateCamera()
MoveEntity camera, 0,220,0
TurnEntity camera,0,183,0
light=CreateLight()

;..................................... Your bit .....................................

;Lightmapper
;load your lightmap
LightMap=LoadTexture("Box01lightingmap.tga")
TextureBlend LightMap,5
TextureCoords LightMap,1; <---- this is part where you telling To B3D what UV map channel To use For what texture , 0=First UV map layer 1=second UV map layer

;now After you did this simply pass through your objects hierarchy And apply LightMap on To Each Object , something like this
MyLevel=LoadAnimMesh("box.3Ds")
;..................................... my bit ....................
tex=LoadTexture("mold.tga") ; this is a plain texture,
EntityTexture mylevel,tex
;.................................................................
If CountChildren(MyLevel) > 0
For objectcount = 1 To CountChildren(MyLevel)
Entity = GetChild(MyLevel,objectcount)
EntityTexture Entity,LightMap,0,2
Next
EndIf


PositionEntity mylevel,0,0,0


While Not KeyDown( 1 )

; Change rotation values depending on the key pressed
If KeyDown( 208 )=True Then pitch#=pitch#-1
If KeyDown( 200 )=True Then pitch#=pitch#+1
If KeyDown( 203 )=True Then yaw#=yaw#-1
If KeyDown( 205 )=True Then yaw#=yaw#+1
If KeyDown( 45 )=True Then roll#=roll#-1
If KeyDown( 44 )=True Then roll#=roll#+1

; Rotate cone using rotation values
RotateEntity camera,pitch#,yaw#,roll#

;RotateEntity camera,0,yaw#,0
RenderWorld

Text 0,0,"Use cursor/Z/X keys to change cone rotation"
Text 0,20,"Pitch: "+pitch#
Text 0,40,"Yaw : "+yaw#
Text 0,60,"Roll : "+roll#

Flip

Wend

End

It still brings up a plain white box. Hope you can clarify that.
Dicon.
P.S. My brain hurts!


Dicon(Posted 2008) [#12]
To Kryzon....
This whole "get a Shadow into Blitz3D" thing is getting silly.

Swift Shadow system is well out of date and I lack the skills to fudge ito action. Even with the down-grade. It's a shame., it used to be a good utility.

Pipeline doesn't work and I get a "B3dexp.dle fails to initialize, error code 127. No report back from the forum on that one.

I am trying to get the code Naughty Alkian sent me to work. Thanks Naughty, it's me, not you. Sorry, I will keep trying. It's been to long away from coding that is the problem. If it is to work I need a sample. Monky see- monkey do.

Kryzon, I will try your approach to the problem tomorrow, but in the last bit of the code, it appears I must use Pipeline. ( see above ). Erm, do I need pipeline for that?

I think in the long run, I will just present a folio with stills and a B3D file inthe folio.
Or a watercolour.
Dicon


Kryzon(Posted 2008) [#13]
Wait, if the pipeline didn't work it's because your 3DS Max version isn't compatible with it or you didn't install it appropriately on the required folders. I'm running Max 9 with pipeline alive and kicking, no problems there.

And secondly, you shouldn't be texturing your level through code at all!. Once you use the pipeline's materials B3D Brush and B3D Map inside max's Material Editor, and export the model through the pipeline to the same folder where every texture the level uses are, you load it with...
mesh = LoadMesh("level.b3d")

and it will come fully textured (and lightmapped, if you follow those instructions I posted). Just with that one line of code (instead of the "Your bit" part)

You need to ease whatever you will do. The pipeline can help you a lot, spare you lot's of confusing code like iterating through every child of the level applying the lightmap texture like you are doing.

If you export correctly from the pipeline, using the right B3D materials, you don't need to texture through code at all.


Naughty Alien(Posted 2008) [#14]
..well..i heavily disagree that lightmapping shouldnt be done trough code simply because of many other things you going to do with your objects later, especially if texturing that way is just one function call what will take up time same as typing loadmesh...however, to achieve that painless, i do have rule that every object on scene containing within its name (appart from few other parameters) name of the texture used on it(without extension)..when all set like that, use of texturing trough code is simple, fast and giving you ability to do many other things than just plain loading lightmaped mesh in to scene..Ill post lightmapped mesh + code + max file source when I get back home today, so you can see for yourself Dicon..


Dicon(Posted 2008) [#15]
Great, thanks.
I really am trying to crack this. And I have checked that all the pipeline code is in the right folders with pipeline. (I am using XP on my computer ).
Of to work now. Thanks to you both.
Dicon


Naughty Alien(Posted 2008) [#16]
..here are your files...max file is 3dsmax8...I hope it helps

http://w14.easy-share.com/1702422352.html


Ross C(Posted 2008) [#17]
I actually load my level, then loop through all the meshes and store each meshes textures and other vital info. It all help when you want to dynamically change textures, rotate/scale/move textures etc etc.


Dicon(Posted 2008) [#18]
I am not too sure what this is...........
file url:
I did access the address and got a lot of pictures of healthy young women with big bottoms.
Is this a joke?
There is nothing that I can see ( apart from large asses TO download)


Dicon


Naughty Alien(Posted 2008) [#19]
chicks are okay man..just wait about 20 or 30 seconds and download link will appear..sorry, I had no idea they will do that..i just tried now..


Naughty Alien(Posted 2008) [#20]
..this one should be without naked gurlz...sorry i luv them

http://www.filefactory.com/file/d0ae17/n/MAX_LM_TEST_zip


Dicon(Posted 2008) [#21]
Got it.
Sorry about terse reply. Just returned from St. Davids Hospice to visit partner.
Life goes on.......

Will unpack and peruse later. Thanks for all ther trouble you have taken.

Dicon


Dicon(Posted 2008) [#22]
There appears to be a problem with the code at this point.

In the ....Function Load_Mesh(Level$,LightMap$,LightMapChannel=0)

the line below
If CountChildren(map) > 0

gives an error at this point with " entity does not exist"

I have downloaded the latest version of Blitz3D, ( 1.64 ) just to make sure my version was uncorrupted & up to date but it makes no difference.
Are there any ways around the problem please?

It keeps "baulking" at "CountChildren(Map)", doesn't seem to like that bit.


Dicon


Naughty Alien(Posted 2008) [#23]
..well..latest version of blitz3D should be 1.99 if im not mistaken...source compiling here just fine, so make sure that you have updated B3D properly..


Dicon(Posted 2008) [#24]
Yup, you were right. way too old Blitz. I downloded the latest.
Your demo works wonderfully.

Just one more thing.
How do I get the meshes & textures out of 3dsMax.
You have Test_c.b3d
Not too sure of the way to export. I hope it is not Pipeline because I get a "b3dexp.dle failed to initialize"
"The specified procedure could not be found"
I did ask about this problem over at the Pipeline Forum, but there has been no response, even after a few days.
So far so good.
Dicon


Naughty Alien(Posted 2008) [#25]
Everything is exported trough Pipeline...and i never had any single issue with pipeline..have you follow properly installation guidelines??


Dicon(Posted 2008) [#26]
Gods... who knows! I read all I could.
Will go back and re-install all the download again into the folders.
I will go back and download the whole kit ( pipeline)again and start afresh.
Dicon


Dicon(Posted 2008) [#27]
Downloaded pipeline again, put all the code & scripts into the right folders.
Won't load the b3dexp.dle
Used the plug in manager in Max and went to folder.
got the same answer when I tried to load it.
failed to initialize
The specified procedure could not be found.
It seems that part IS the sticking point.

Shall I keep trying or give up and look for a b3d importer that will load in the meshes, etc. from Max?
Dicon


Naughty Alien(Posted 2008) [#28]
if you have 3dsmax8, you have to install first usual installation package THEN download PATCH for pipeline for 3dsmax6 (working for version 8), and then it should work...if you using 3dsmax9 then just download version for 3dsmax9..


Dicon(Posted 2008) [#29]
I have followed all the instructions and I STILL get the not found, error code 127. With the patch, and using the instal plugin menu in Max.
So, I am stopping, rather than waste both our times on a fruitless goose chase. ( Sorry about the mixed metaphores there. ) I will keep on with Max, but look out for another simple engine that will allow me to demo my levels. Or not bather at all. I like Blitz3D and I won't stop playing with that, but keep the two seperate for now.
Thanks for all your trouble Naughty Alian.
Dicon