[away3d] BSP - Materials/meshes.

27 views
Skip to first unread message

dp

unread,
Apr 25, 2010, 11:40:59 AM4/25/10
to Away3D.dev
Great work on the new engine, looks like it will be great.

A quick question though - Is it still possible to access all the
materials/meshes with this new format at runtime? and modify them?

eg.
model.materialLibrary.getMaterial("....").material =

cheers,
david.


--
Subscription settings: http://groups.google.com/group/away3d-dev/subscribe?hl=en

Fabrice3D

unread,
Apr 26, 2010, 7:04:03 AM4/26/10
to away3...@googlegroups.com
If you mean awd, yes but not using library. Just access directly the meshes objects.
On other hand, the awd's with BSP outputs do have a new class companion, CentralMaterialLibrary, in order to access the tree material(s) if you need to.

Fabrice

David Lenaerts

unread,
Apr 26, 2010, 7:37:24 AM4/26/10
to away3...@googlegroups.com
Also, I should add that changing the geometry would invalidate the tree in most cases, resulting inrendering issues (sorting, culling, visList errors), so you shouldn't ;-)

David

dp

unread,
Apr 28, 2010, 4:32:20 PM4/28/10
to Away3D.dev
Thanks for the replies guys, yes I guess I wont be altering the
geometry just want access to apply materials.

However I haven't yet made it that far... as I cant seem to get the
output from prefab to work, I've tried a couple of models now, and
both times I just get a blank white screen, the last model was a
simple cube (2 meshes - floor, and ceiling/walls).. Any ideas?

thanks.

Fabrice3D

unread,
Apr 28, 2010, 6:11:43 PM4/28/10
to away3...@googlegroups.com
I do plan to make a tut on this, but be aware that BSP modeling is very strict.

The main rule as David highlighted on his post is to ensure the model is fully solid & encapsulated.
see your model as a party balloon, if there is a tiny hole in it, it will fail no matter what.

In some cases Prefab will generate a red debug boxe around an estimated location of the issue.
it's estimated because the error is triggered during a recursive calculation where its kinda difficult to know where the exact bad guy is.
but so far (cause I went thru that pain as well) the red box was pointing at a correct location on the test error models I did.
only its not pointing you out the exact plane or faces location where the error takes place.
So its important to not close the window directly if you get an error, as this is ment as a visual debug help.
closing the window clears this information.

if you have modeled non continuously or using way too much polys non aligned or snapped, Prefab will eventually render but it will take probably ages.
and playback perf will be certainly poor.

I have generated for another project 2 weeks ago a huge world with 6 rooms, stairs, bridge, applying now lots of these rules (and still learning new ones), it took 8 minutes
to calculate it. The hacienda demo took 26 minutes because the vertexes are not aligned properly.

oooh wait, reading, again at your message, I see you mean, you have generated but not able to see after compiling?
you mean the class is not working? if you trace the constructor, its instanciated?
Cause i have tried both bsp branch and 3.5 it works in both cases. if you do not run latest 3.5 it will not run at all
and you will get tons of errors of missing stuff.

anyway, as said above, I need make a tut for it and do more videos for Prefab.

Send me your model source (the 2 cubes+corridor) so I can see and test it.

Fabrice

Fabrice3D

unread,
Apr 29, 2010, 6:48:30 AM4/29/10
to away3...@googlegroups.com
I have just uploaded an update for AWData that should fix the white material issue you are having.

with bsp typed awd files, a custom path was giving a custompath/images/filename.jpg
instead of custompath/filename.jpg
while there was no issues with the awd's not having the bsp.

can you let me know if it works in your case?

Fabrice



On Apr 28, 2010, at 10:32 PM, dp wrote:

dp

unread,
Apr 29, 2010, 4:27:35 PM4/29/10
to Away3D.dev
Hey Fabrice,

Thanks for helping out here.

I'm fairly sure everything is compiling correctly, no errors, and when
I look at the stats I can see the render elements number change as I
look around the white space. This is still the case it seems with the
updated AWData.

I was going to try again with another model, as I lost track of which
I files I was using and wanted to be sure, before sending anything
over to you... except now whatever I try, PreFab does not seem to want
to load my 3ds textures, for any model I try. I'm not sure if I'm
being stupid, or something changed with the update?

cheers.

Fabrice3D

unread,
Apr 29, 2010, 5:04:38 PM4/29/10
to away3...@googlegroups.com
3ds, not one change made on that side for at least past 5 updates.

Today I have updated the AWData class twice for this and another issue, make sure you run the latest.
running with a fresh copy of 3.5 from svn, I get zero errors and all my textures are loading.

Please add a trace in AWData at empty line 254 trace("["+resolvedP+line+"]");

we'll take it from there...
Are you Windows or mac based?

Fabrice

dp

unread,
May 1, 2010, 11:16:52 AM5/1/10
to Away3D.dev
woohoo, finally got it working today. The latest update must of done
the trick, thanks!

Still have the problem of no materials loading in PreFab though... so
I just had reassigned them, not ideal but it worked well after that.

Now back to my initial problem of the best way to dynamically add/
replace the materials - is using the CentralMaterialLibrary the best
way to do this? if so how exactly? as I'm not having much success
trying.

Also I noticed that getMeshFromMaterialName always returns null, is
this feature implemented?

Cheers!

Just to let you know the trace was:
[./images/floor.png]
[./images/room.png]
[./images/]

and im windows based - flash develop.

Fabrice3D

unread,
May 1, 2010, 3:37:47 PM5/1/10
to away3...@googlegroups.com
say a mesh is named a mesh in Prefab as "aw_12" or whatever name you give to a specific mesh
var mat:BitmapMaterial = CentralMaterialLibrary.getMaterial("aw_12") as BitmapMaterial;
use this method to alter the same material. Like if you want to display another bitmap.

As about setting the material in case of another type, there is no specific access yet in centralMaterialLibrary

But just added a new method for this.

access the bspTree with actual and new material

_tree.replaceMaterial(theMaterialActuallyApplied, theNewMaterial, false); //boolean defines if you want clear the previousmaterials. Note that if it holds a bitmapdata
you will need to dispose() it yourself

you can get the previous applied material from the centralMaterialLibrary. also here, if you plan to repeat this, take care about saving the new material, in order to allow compare old/new material
the next time you need it.

Fabrice

dp

unread,
May 2, 2010, 4:29:32 AM5/2/10
to Away3D.dev
Fantastic, works perfectly. thanks for helping!

david

dp

unread,
May 3, 2010, 7:21:24 AM5/3/10
to Away3D.dev
Hey Fabrice,

One more question regarding this - is there a relatively easy way to
implement mouse events? as I need to be able to find out what
material / or mesh is under the mouse, I really hope there is - as
converting my project would work so much better with this BSP format!

thansk, david

Fabrice3D

unread,
May 3, 2010, 9:47:06 AM5/3/10
to away3...@googlegroups.com
Here a little snippet that could be used from content from a Prefab3D AS3 class

var holder:Dynamics = new Dynamics();
for(var i:int=0;i<holder.meshes.length;++i){
if(holder.meshes[i].name== "somecoolname"){
holder.meshes[i].collider = true;
holder.meshes[i].addOnMouseDown(pressDownOnDynamicObjectColliding);
} else{
holder.meshes[i].addOnMouseDown(pressDownOnDynamicObjectNonColliding);
}
_tree.addChild(holder.meshes[i]);
}


If you want that furniture draw to dispatch an event, or the poster on the wall that becomes a video.
model the tree smart and add these as dynamics.

Keep in mind its the first intergration, we will enhance and ease its use in the future.
but for now, I would unless you really really really cannot do else, not use the tree geometry for mouseEvents

To get the best performance, you should simplify as much as possible.
For instance if you try to build a church, the ceiling geometry better be a cube in witch you would insert as dynamic the ceiling in roman style.
This would add lots of unecessary data. That's the kind of mistake I did in the hascienda demo for instance.
Less is really more!

Fabrice

dp

unread,
May 5, 2010, 2:45:35 PM5/5/10
to Away3D.dev
Hi fabrice,

Thanks for the snippet... your going to have to enlighten me though -
where do i find this Dynamics class??

cheers,
david

Fabrice3D

unread,
May 5, 2010, 3:13:09 PM5/5/10
to away3...@googlegroups.com
ah, good that you are around :)
christian seems to have issues with outputs loaded in 3.5 regarding "Material", do you?
"prefab and the latest away3d revision" thread

> where do i find this Dynamics class??

ha sorry for the confusion, (was ment to be clearer :)) )

in this case Dynamic reffers to a Prefab output holding meshes, and saved with classname "Dynamics"
so it could be any other names.

basically you can do tree.addChild(myMesh);

or say myMesh.collider = true, then addChild it
one detail on this, if you look at the chair in Hacienda demo, i made mistake to applyRotation
as a result the collider box is not rotated with the chair. Its not obvious, but thats also one of the many details this demo learned me...

Also there are still known issues if you do not want it collides anymore. After its addChilded, setting collider false, doesn't work.

Fabrice

dp

unread,
May 6, 2010, 10:17:30 AM5/6/10
to Away3D.dev
oh yeah sorry - should of mentioned the material problem but forgot
about it after importing the classes ;)

Thanks for the clarification, looking forward to having another play
with this when I get a chance.

cheers,

Fabrice3D

unread,
May 6, 2010, 10:25:10 AM5/6/10
to away3...@googlegroups.com
David and me are very very curious to see the first babies using BSP.
Please send us urls so we can enjoy! :)

It doesn't have to be finished... In fact I would love see the progresses and hear about the dev issues or stuffs
that could be enhanced.

Fabrice

John Brookes

unread,
May 9, 2010, 7:01:30 AM5/9/10
to away3...@googlegroups.com
I have a single mesh, with multiple file materials assigned to faces in Maya (2009).

If I export to dae (open collada) and load that dae in prefab, the materials never show. All I get is the default white material.
Although the loading log shows
"try load image: [file:///E:/JB/Awa3DHouseBSP/Maya/dae/Away3DFloor.jpg] etc

Exporting to bsp works fine,no errors, but I dont get any reference to the materials, only the default white material.

Any Ideas?

dp

unread,
May 10, 2010, 3:41:20 PM5/10/10
to Away3D.dev
I had this exact same problem, but with a 3ds file but this also
happened when I exported it as other formats like dae.

I couldn't work out what the problem was, tried all kinds of things
upper case, short names etc. In the end I just manually reassigned the
materials in prefab. what is strange is a while back had a model that
did load the textures ok, which now doesn't it seems.

It would be really usual if someone could upload a model with a
texture applied that should load correctly, so we can check if its our
models, or another problem.


anyway hoping to get a few evenings in this week, to really push
forward with this and have something to show!

John Brookes

unread,
May 10, 2010, 3:47:19 PM5/10/10
to away3...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages