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
On May 3, 2010, at 1:21 PM, dp wrote:
> 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
>
> On May 2, 10:29 am, dp <[email protected]> wrote:
>> Fantastic, works perfectly. thanks for helping!
>>
>> david
>>
>> On May 1, 9:37 pm, Fabrice3D <[email protected]> wrote:
>>
>>> 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
>>
>>> On May 1, 2010, at 5:16 PM, dp wrote:
>>
>>>> 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.
>>
>>>> On Apr 29, 11:04 pm, Fabrice3D <[email protected]> wrote:
>>>>> 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
>>
>>>>> On Apr 29, 2010, at 10:27 PM, dp wrote:
>>
>>>>>> 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.
>>
>>>>>> On Apr 29, 12:48 pm, Fabrice3D <[email protected]> wrote:
>>>>>>> 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:
>>
>>>>>>>> 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.
>>
>>>>>>>> On Apr 26, 1:37 pm, David Lenaerts <[email protected]> wrote:
>>>>>>>>> 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
>>
>>>>>>>>> On Mon, Apr 26, 2010 at 1:04 PM, Fabrice3D <[email protected]>
>>>>>>>>> wrote:
>>>>>>>>>> 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
>>
>>>>>>>>>> On Apr 25, 2010, at 5:40 PM, dp wrote:
>>
>>>>>>>>>>> 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
>>
>>>>>>>>> --http://www.derschmale.com