Thanks all. Fabrice and Choons thanks for your time I know its
valuable.
In short Fabrice it is the duplicate issue. In the past I had used an
as3 class from prefab and just made new instances of the class. I
would like to use clone but the awd1 fish.clone() returns an object3d
when I cast that when I add to the clone to the scene it complains of
a null value.
I would like to use clone and clone the AWD1 100 times and give all
the fish a unique location.
I also noticed the md5stress test in the current build and I see them
using Mesh in the clone but if I tried to reconfigure my code to be
somewhat similar although the AWD returns an ObjectContainer3D.
//Current code:
public function tweetank()
{
_view = new View3D();
_view.camera.z = -2000;
addChild(_view);
ResourceManager.instance.addEventListener(ResourceEvent.RESOURCE_RETRIEVED,
onResourceRetrieved);
ResourceManager.instance.addEventListener(LoaderEvent.LOAD_ERROR,
onResourceLoadingError);
ResourceManager.instance.addEventListener(LoaderEvent.LOAD_MAP_ERROR,
onResourceMapsLoadingError);
var url:String = "assets/models/MdlFish.awd";
ResourceManager.instance.getResource(url, false,
AWD1Parser );
}
private function onResourceRetrieved(e : ResourceEvent) : void
{
fish = ObjectContainer3D(e.resource);
_view.scene.addChild(fish);
for(var i:int = 0; i <= 100; i++){
fishArr[i] = Object3D();
fishArr[i] = fish.clone();
fishArr[i].name = 'fish'+i;
fishArr[i].z = randRange(-600,600);
fishArr[i].x = randRange(-600,600);
fishArr[i].y = randRange(-600,600);
_view.scene.addChild(fishArr[i] as ObjectContainer3D);
}
this.addEventListener(Event.ENTER_FRAME,
handleEnterFrame);
}
private function onResourceLoadingError(e:LoaderEvent) : void
{
trace("Oops, file loading failed");
}
private function onResourceMapsLoadingError(e:LoaderEvent) :
void
{
trace("A map failed to load in this model:
["+e.url+"]");
}
private function handleEnterFrame(e : Event) : void
{
fishArr[i].rotationY += 5;
}
firstFrame = false;
_view.render();
}
private function randRange(min:Number, max:Number):Number {
// Generate a number between and including min - max
var randomNum:Number =
Math.floor(Math.random()*(max-min+1))+min;
trace(randomNum);
return randomNum;
}
}
Thanks for your input in advance.
On Apr 26, 4:33 pm, Fabrice3D <[email protected]> wrote:
> I've added a awd(1) parser to Broomstick,
> Prefab 1.0 exports these and they are displayed in latest version in svn
> Prefab 2.0 will hold as3 4.0 compatible, once I can go cruise speed on this
> baby. For now, Away is prio #1.
>
> Your loop doesn't makes much sens to me at first sight. What is it suposed to
> do? 100 duplicates?
> you should consider loop and clone instead. Here you seam to asign same
> instance over and over and addChild it.
>
> Its probably me, but what is the issue with awd exactly, is it not showing up
> if you addChild e.resource?
> or is it the duplicate part?
>
> Fabrice
>
> On Apr 26, 2011, at 6:43 PM, seacloud9 wrote:
>
>
>
>
>
>
>
> > for(var i:int = 0; i <= 100; i++){
> > fishArr.push(new ObjectContainer3D());
> > fishArr[i] = ObjectContainer3D(e.resource);
> > fishArr[i].name = 'fish'+i;
> > fishArr[i].z = randRange(-600,600);
> > fishArr[i].x = randRange(-600,600);
> > fishArr[i].y = randRange(-600,600);
> > trace(fishArr[i]);
> > _view.scene.addChild(fishArr[i] as ObjectContainer3D);
> > }
>
> > any help on this matter would be greatly appreciated thanks in
> > advance.
>
> > On Apr 26, 7:33 am, seacloud9 <[email protected]> wrote:
> >> Help on this issue would be greatly appreciated.
>
> >> Prefab currently does not appear able to export to Broomstick has
> >> anyone else been able to export a model as a class is as3 for
> >> broomstick? I am of course using models where the textures are a
> >> power of 2.
>
> >> Currently when it loops it is populating all AWD1 with a random x,y,z
> >> although when it comes to the last item in the loop it overrides all
> >> the others that were previously pushed to the array. I can see this
> >> information in the debug output.
>
> >> On Apr 25, 10:24 pm,seacloud9<[email protected]> wrote:
>
> >>> Side note I was originally trying to use fish.clone() where I had
> >>> assigned the fish to an ObjectContainer3D above the loop and then
> >>> convert it to an ObjectContainer3D when I add it to the scene because
> >>> fish.clone() returns an Object3D.
> >>> _view.scene.addChild(fishArr[i] as ObjectContainer3D);
>
> >>> On Apr 25, 10:00 pm,seacloud9<[email protected]> wrote:
>
> >>>> RandRange is a custom function for a random number for a range and I
> >>>> have used it for a long time so I know this is not the issue.
>
> >>>> On Apr 25, 7:23 pm,seacloud9<[email protected]> wrote:
>
> >>>>> I created an AWD1 file with prefab. I can import it in and display
> >>>>> one my problem comes in when I try to loop through and create more or
> >>>>> clone.
>
> >>>>> The code below will not create a new ObjectContainer3D for some reason
> >>>>> and I am sorry my error might be something simple. When I loop
> >>>>> through this function and push and push a model into the array and
> >>>>> then display it in the view all items in the array have the same x,y,z
> >>>>> and name. So I am kind of perplexed. For some reason right now I
> >>>>> also noticed with prefab I am having issues with export to as3 class
> >>>>> file. I have done these things before and I am trying to redo an old
> >>>>> demo I made with away3d.
>
> >>>>> I have also tried to clone the model but this has not been successful
> >>>>> either.
>
> >>>>> for(var i:int = 0; i <= 100; i++){
> >>>>> fishArr.push(new ObjectContainer3D());
> >>>>> fishArr[i] = ObjectContainer3D(e.resource);
> >>>>> fishArr[i].name = 'fish'+i;
> >>>>> fishArr[i].z = randRange(-600,600);
> >>>>> fishArr[i].x = randRange(-600,600);
> >>>>> fishArr[i].y = randRange(-600,600);
> >>>>> trace(fishArr[i]);
> >>>>> _view.scene.addChild(fishArr[i] as ObjectContainer3D);
>
> >>>>> }
>
> >>>>> Original Demo might donkey punch an old
> >>>>> processor.http://i-create.org/actionscript/TweetTank/
>
> >>>>> I also tried to export a wavefront .obj but I ran into the same issue
> >>>>> that is discussed
> >>>>> here:http://ultravisual.co.uk/blog/2011/03/22/more-molehill-away3d-fun/
>
> >>>>> Any help on this endeavor would be greatly appreciated. Thank you in
> >>>>> advance.