Hm i use the following function to merge the houses in the AWD file:
private function mergeHouses():void {
trace("merging")
var arr:Array = getHouses();
var merge:Merge = new Merge(true,true, false);
var length:int = arr.length
var childLength:int
var children:Array
for (var i:int = 0; i < length ;++i ) {
childLength = arr[i].children.length
for (var a:int = 1; a < childLength; ++a) {
merge.apply(arr[i].children[0],
arr[i].children[a]);
trace("merge : "+i+"| 0 + "+a);
}
var m:Mesh = arr[i].children[0]
m.y = 200
scene.addChild(m);
}
}
Which resulted in this : http://labs.speak.nl/3d/away3d/example4.jpg
The houses are being merged but the x,y,z positions/rotations/scale of
each house aren't used :(.
On 11 dec, 12:51, Fabrice3D <[email protected]> wrote:
> if you have more than one mesh in the awd file, the parser returns an
> Object3D of type ObjectContainer3D
> you can access the nested meshes using children array
>
> Fabrice
> On Dec 11, 2009, at 12:02 PM, wsvdmeer wrote:
>
>
>
> > So i have to call the meshes in the loaded AWD file?
> > How can i loop through the meshes?
>
> > The model (3 houses in 1) is found here : labs.speak.nl/3d/away3d/
> > merge.rar
>
> > On 11 dec, 11:50, Fabrice3D <[email protected]> wrote:
> >>> how does it work with one model?
>
> >> it doesn't! :))
>
> >> Merge --> add secondmesh data to first mesh --> one mesh looking
> >> like 2
>
> >> so in your case, with 3 models, you need run it 2 times
>
> >> house1 merge with house 2
> >> house1 merge with house 3
>
> >> house 1 == 3 houses data
>
> >> Fabrice
>
> >> On Dec 11, 2009, at 11:32 AM, wsvdmeer wrote:
>
> >>> Oke got a view models in prefab and scaled, rotated and placed them.
> >>> Loaded the model in away3d and everything looks fine.
> >>> Maybe it's a stupid question but how can you merge 1 model?
> >>> The model is built up from 3 houses i know the merge class is used
> >>> like this merge.apply(mesh1,mesh2) but how does it work with one
> >>> model?
>
> >>> On 11 dec, 10:26, Fabrice3D <[email protected]> wrote:
> >>>> if you select a house, and have the editobject panel open, you can
> >>>> change scale properties to the selected mesh...
> >>>> one set, hit apply scale
>
> >>>> Fabrice
>
> >>>> On Dec 11, 2009, at 10:17 AM, wsvdmeer wrote:
>
> >>>>> Prefab rules and i totally understand that it's a work in progress
> >>>>> it's amazing that you do all of this next to your day job.
> >>>>> I could import all the models in prefab but the models themselves
> >>>>> have
> >>>>> different scales we didnt have accurate material to make the
> >>>>> models so
> >>>>> we made the models and adjusted the size while importing them in
> >>>>> away3d. It's not the most efficient way but visually it looked
> >>>>> rather
> >>>>> good.
> >>>>> Is it possible to scale each house and when all houses are scaled
> >>>>> and
> >>>>> positioned to scale the scene after that?
> >>>>> Or can you only scale the whole scene.
> >>>>> Hope i'm not a to big pain in the @ss haha.
>
> >>>>> On 11 dec, 10:04, Fabrice3D <[email protected]> wrote:
> >>>>>> if you load them all in prefab, place them one by one where they
> >>>>>> should be
> >>>>>> use scenescale, you can then export to awd in one shot. after
> >>>>>> load of
> >>>>>> awd data, just merge and you're done
>
> >>>>>> note that Prefab is atm ungoing major changes. In upcomming
> >>>>>> releases,
> >>>>>> assembling should become way more friendly.
> >>>>>> Started as good little utility, It has now entered the
> >>>>>> application
> >>>>>> playground, but fails bigtime in this league on usability and
> >>>>>> espected
> >>>>>> behaviors.
> >>>>>> I'm not going to let it this way!
>
> >>>>>> Fabrice
> >>>>>> On Dec 11, 2009, at 9:31 AM, wsvdmeer wrote:
>
> >>>>>>> Hey Fabrice,
>
> >>>>>>> Sorry for my late response, it did have to do with the scale,
> >>>>>>> rotation
> >>>>>>> and position of my models. Problem is that it's a lot of work to
> >>>>>>> rescale all the objects in milkshape import them to prefab and
> >>>>>>> export
> >>>>>>> them to AWD. So the merge class works as it should but i cannot
> >>>>>>> use it
> >>>>>>> on the models i'm using. Would you advise to rescale all the
> >>>>>>> objects
> >>>>>>> before importing them in away3d? I'm considering to split up the
> >>>>>>> scene
> >>>>>>> in 3 parts to enhance performance but it would be great to walk
> >>>>>>> through the whole scene. By the way any advise is welcome :D.
>
> >>>>>>> On 8 dec, 22:38, Fabrice3D <[email protected]> wrote:
> >>>>>>>> btw, you do not mention if the original problem is now
> >>>>>>>> solved... is
> >>>>>>>> it?
>
> >>>>>>>> Fabrice
> >>>>>>>> On Dec 8, 2009, at 10:28 PM, wsvdmeer wrote:
>
> >>>>>>>>> Hey Fabrice,
>
> >>>>>>>>> Is there a way to do the scaling in prefab so that the
> >>>>>>>>> bounderies
> >>>>>>>>> arren't that huge?
> >>>>>>>>> And can i build parts of the scene up in prefab resulting in
> >>>>>>>>> less
> >>>>>>>>> "loose" models , and if so does this increase performance?
>
> >>>>>>>>> On 8 dec, 14:40, Fabrice3D <[email protected]> wrote:
> >>>>>>>>>> Hey wsvdmeer,
> >>>>>>>>>> I have updated the class & updated the svn.
> >>>>>>>>>> The update resolves the geometrical artefact and code was in
> >>>>>>>>>> need
> >>>>>>>>>> of
> >>>>>>>>>> an update anyway.
> >>>>>>>>>> I have just done a series of tests using this latest update
> >>>>>>>>>> and
> >>>>>>>>>> everything seams working just fine.
>
> >>>>>>>>>> Now looking at your awd files and your xml definition, the
> >>>>>>>>>> first
> >>>>>>>>>> thing that might clarify your problem, is the scale/position
>
> >>>>>>>>>> if I look in Prefab at eddydejong.awd, it's having bounderies
> >>>>>>>>>> of
> >>>>>>>>>> width
> >>>>>>>>>> 25000, height 16000, depth 11000
> >>>>>>>>>> now, the position of this one is at 120, 80, 1470.
>
> >>>>>>>>>> now you want to merge this model with lets say etos.awd
> >>>>>>>>>> etos bounds are width 15590, height 12000 and 7672 for depth
> >>>>>>>>>> its position is 100, 60, 1290
>
> >>>>>>>>>> Looking at this data, it explains clearly your problem...
> >>>>>>>>>> they
> >>>>>>>>>> simply
> >>>>>>>>>> overlap each other, with or without Merge in the game.
> >>>>>>>>>> if you have rescaled in Prefab prior to export, just multiply
> >>>>>>>>>> by
> >>>>>>>>>> same
> >>>>>>>>>> factor the xml position data and you should be ok.
>
> >>>>>>>>>> Fabrice
>
> >>>>>>>>>> On Dec 8, 2009, at 1:46 PM, wsvdmeer wrote:
>
> >>>>>>>>>>> Hey Fabrice,
>
> >>>>>>>>>>> Did you have time looking at my problem?
>
> >>>>>>>>>>> On 7 dec, 16:19, wsvdmeer <[email protected]> wrote:
> >>>>>>>>>>>> Hey Fabrice,
>
> >>>>>>>>>>>> I added 3 models here
> >>>>>>>>>>>> :http://labs.speak.nl/3d/away3d/models/models.rar
> >>>>>>>>>>>> The positions can be found here:
>
> >>>>>>>>>>>> <model>
> >>>>>>>>>>>> <file>../assets/models/eddydejong/
> >>>>>>>>>>>> eddydejong.awd</
> >>>>>>>>>>>> file>
> >>>>>>>>>>>> <texture>../assets/models/eddydejong/</
> >>>>>>>>>>>> texture>
> >>>>>>>>>>>> <name>Bakker Eddy de Jong</name>
> >>>>>>>>>>>> <xposition>120</xposition>
> >>>>>>>>>>>> <yposition>80</yposition>
> >>>>>>>>>>>> <zposition>-1470</zposition>
> >>>>>>>>>>>> <xrotation>0</xrotation>
> >>>>>>>>>>>> <yrotation>90</yrotation>
> >>>>>>>>>>>> <zrotation>0</zrotation>
> >>>>>>>>>>>> <scale>0.01</scale>
> >>>>>>>>>>>> </model>
> >>>>>>>>>>>> <model>
> >>>>>>>>>>>> <file>../assets/models/etos/etos.awd</file>
> >>>>>>>>>>>> <texture>../assets/models/etos/</texture>
> >>>>>>>>>>>> <name>Etos</name>
> >>>>>>>>>>>> <xposition>100</xposition>
> >>>>>>>>>>>> <yposition>60</yposition>
> >>>>>>>>>>>> <zposition>-1290</zposition>
> >>>>>>>>>>>> <xrotation>0</xrotation>
> >>>>>>>>>>>> <yrotation>95</yrotation>
> >>>>>>>>>>>> <zrotation>0</zrotation>
> >>>>>>>>>>>> <scale>0.01</scale>
> >>>>>>>>>>>> </model>
> >>>>>>>>>>>> <model>
> >>>>>>>>>>>> <file>../assets/models/pearle/pearle.awd</
> >>>>>>>>>>>> file>
> >>>>>>>>>>>> <texture>../assets/models/pearle/</texture>
> >>>>>>>>>>>> <name>Pearle</name>
> >>>>>>>>>>>> <xposition>140</xposition>
> >>>>>>>>>>>> <yposition>71</yposition>
> >>>>>>>>>>>> <zposition>-1155</zposition>
> >>>>>>>>>>>> <xrotation>0</xrotation>
> >>>>>>>>>>>> <yrotation>102</yrotation>
> >>>>>>>>>>>> <zrotation>0</zrotation>
> >>>>>>>>>>>> <scale>0.01</scale>
> >>>>>>>>>>>> </model>
>
> >>>>>>>>>>>> On 7 dec, 15:08, Fabrice3D <[email protected]> wrote:
>
> >>>>>>>>>>>>> Are you sure your models are perfectly centered?
> >>>>>>>>>>>>> otherwijze send me offline max 3 of them + the position
> >>>>>>>>>>>>> you
> >>>>>>>>>>>>> give
> >>>>>>>>>>>>> them
> >>>>>>>>>>>>> in worldspace,
> >>>>>>>>>>>>> I'll make a test here.
>
> >>>>>>>>>>>>> Fabrice
>
> >>>>>>>>>>>>> On Dec 7, 2009, at 2:21 PM, wsvdmeer wrote:
>
> >>>>>>>>>>>>>> I all ready place the objects first and call the
> >>>>>>>>>>>>>> mergeHouses
> >>>>>>>>>>>>>> function
> >>>>>>>>>>>>>> after all the objects are loaded and placed.
> >>>>>>>>>>>>>> When setting the useobjectSpace parameter to false the
> >>>>>>>>>>>>>> following
> >>>>>>>>>>>>>> happens:
>
> >>>>>>>>>>>>>>http://labs.speak.nl/3d/away3d/example3.jpg
>
> >>>>>>>>>>>>>> On 7 dec, 14:17, wsvdmeer <[email protected]> wrote:
> >>>>>>>>>>>>>>> Oke changed the loop to :
>
> >>>>>>>>>>>>>>> private function mergeHouses():void {
> >>>>>>>>>>>>>>> var arr:Array = getHouses()
> >>>>>>>>>>>>>>> var merge:Merge = new Merge(true,false, false);
> >>>>>>>>>>>>>>> var length:int = arr.length
> >>>>>>>>>>>>>>> for (var i:int = 1; i <length ;++i ) {
> >>>>>>>>>>>>>>> merge.apply(arr[0], arr[i])
> >>>>>>>>>>>>>>> scene.removeChild(arr[i])
> >>>>>>>>>>>>>>> trace("merge house0 + house" + i);
> >>>>>>>>>>>>>>> if (i == length - 1) {
> >>>>>>>>>>>>>>> trace("merging complete")
> >>>>>>>>>>>>>>> }
> >>>>>>>>>>>>>>> }
>
> >>>>>>>>>>>>>>> }
>
> >>>>>>>>>>>>>>> And only loaded a few houses on the rightside of the
> >>>>>>>>>>>>>>> scene.
>
> >>>>>>>>>>>>>>> The result was the same:
>
> >>>>>>>>>>>>>>>http://labs.speak.nl/3d/away3d/example2.jpg
>
> >>>>>>>>>>>>>>> On 7 dec, 13:55, Fabrice3D <[email protected]> wrote:
>
> >>>>>>>>>>>>>>>> The loop
> >>>>>>>>>>>>>>>> No need to make new Merge instance each iteration
> >>>>>>>>>>>>>>>> place this line above loop start
>
> >>>>>>>>>>>>>>>>> var
>
> ...
>
> meer lezen »