Okay thanks for your time
On Jun 26, 6:28 pm, Th3Sh33p <[email protected]> wrote: > Oh sorry forgot to mention the constructed object is called by the > "create" function, maybe because I clone the model it isn't working? > > On Jun 26, 6:21 pm, Th3Sh33p <[email protected]> wrote: > > > > > Sorry Fabrice, but I can't get this to work, here's my entire class. > > Maybe it isn't working because i'm trying to clone the object? > > > package { > > import away3dlite.containers.ObjectContainer3D > > import away3dlite.loaders.Loader3D > > import away3dlite.events.Loader3DEvent; > > import away3dlite.loaders.AbstractParser > > import away3dlite.loaders.AWData; > > import away3dlite.containers.ObjectContainer3D > > import flash.display.Sprite > > import flash.events.Event; > > import away3dlite.primitives.Cube6; > > import away3dlite.materials.WireColorMaterial; > > import away3dlite.containers.ObjectContainer3D > > import away3dlite.materials.BitmapMaterial; > > > public class ObjectMani extends Sprite{ > > private var knownObjects:Array = ["Tree","Tree"]; > > private var constructed:Array = []; > > > public var afterLoadFunction:Function; > > public var objectsLoaded:int = 0; > > public function ObjectMani(func:Function = null){ > > afterLoadFunction = func > > for (var i:int = 0;i<knownObjects.length;i++){ > > var ld:Loader3D = new Loader3D() > > > > ld.addEventListener(Loader3DEvent.LOAD_SUCCESS,model_loaded); > > > > ld.addEventListener(Loader3DEvent.LOAD_ERROR,model_errored); > > ld.name = String(i); > > var ap:AWData = new AWData() > > ap.pathToSources = > > "C:/xampp/htdocs/3d/unit/"+knownObjects[i] > > +"/"+knownObjects[i]+"/images" > > > > ld.loadGeometry("unit/"+knownObjects[i]+"/"+knownObjects[i] > > +".awd",ap); > > } > > //addEventListener(Event.ADDED,added); > > } > > private function added(e:Event){ > > //afterLoadFunction() > > } > > private function model_loaded(e:Loader3DEvent){ > > trace("Model "+knownObjects[Number(e.target.name)], > > " : Successful > > Load!"); > > constructed[Number(e.target.name)] = e.target.handle > > objectsLoaded++; > > if (objectsLoaded>=knownObjects.length){ > > afterLoadFunction() > > } > > } > > private function model_errored(e:Loader3DEvent){ > > trace("Model "+knownObjects[Number(e.target.name)], > > " : Load > > Fail!"); > > } > > public function getId(str:String){ > > var found:Boolean = false > > for (var i:int = > > 0;i<knownObjects.length&&!found;i++){ > > if (str == knownObjects[i]){ > > return i; > > found = true > > } > > } > > if (!found){ > > return 0; > > } > > } > > public function create(id:int,scl:Number = 1) { > > //return getDef() > > return fixModel(constructed[id].clone(),scl); > > //return this["create"+knownObjects[id]]() > > } > > private function getDef():ObjectContainer3D{ > > var n:Cube6 = new Cube6(new > > WireColorMaterial(),10,20,10,2,2,2); > > var con:ObjectContainer3D = new > > ObjectContainer3D(n); > > return con; > > } > > private function fixModel(mv:ObjectContainer3D,scl:Number){ > > mv.y -= 100 > > mv.scaleX = .1*scl > > mv.scaleY = .1*scl > > mv.scaleZ = .1*scl > > return mv > > } > > > } > > > } > > > On Jun 26, 3:57 pm, Fabrice3D <[email protected]> wrote: > > > > its a setter... sorry for the typo. > > > > >> ap.pathToSources("/stuff/otherstuff/myimages/"); > > > > should be ap.pathToSources = "/stuff/otherstuff/myimages/"; > > > > /** > > > * Allows to set custom path to source(s) map(s) other > > > than set in file > > > * Standard output url from Prefab awd files is > > > "images/filename.jpg" > > > * when set pathToSources, url becomes > > > [newurl]filename.jpg. > > > * Example: AWData.pathToSources = "mydisc/myfiles/"; > > > * Only required for load method using Loader3D > > > * var awd:AWData = new AWData(); > > > * awd.pathToSources = "mydisc/myfiles/"; > > > * loader = new Loader3D(); > > > * loader.addEventListener(Loader3DEvent.LOAD_SUCCESS, > > > onSuccess); > > > * loader.loadGeometry("mymodels/car.awd", awd); > > > * > > > */ > > > public function set pathToSources(url:String):void > > > { > > > customPath = url; > > > } > > > > Fabrice > > > > On Jun 26, 2010, at 9:22 PM, Th3Sh33p wrote: > > > > > Thanks for quick reply Fabrice, > > > > > After modifying my script like so... > > > > > var model_number:int = 0 > > > > var model:String = "tree"; > > > > var ld:Loader3D = new Loader3D() > > > > ld.addEventListener(Loader3DEvent.LOAD_SUCCESS,model_loaded); > > > > ld.addEventListener(Loader3DEvent.LOAD_ERROR,model_errored); > > > > ld.name = String(model_number); > > > > var ap:AWData = new AWData() > > > > ap.pathToSources("unit/"+model+"/"+model+"/images") > > > > ld.loadGeometry("unit/"+model+"/"+model+".awd",ap); > > > > private function model_loaded(e:Loader3DEvent){ > > > > constructed[Number(e.target.name)] = e.target.handle > > > > } > > > > > I get the error > > > > > Line 29 1061: Call to a possibly undefined method pathToSources > > > > through a reference with static type away3dlite.loaders:AWData. > > > > > Is this possible in away3dlite? > > > > > On Jun 26, 3:07 pm, Fabrice3D <[email protected]> wrote: > > > >> Prefab resolves urls and also unescape them. > > > >> just open bitmapFilematerial and add a trace where the url is passed > > > >> to load the image. > > > >> you probably will get hints there. > > > > >> note that you also can pass a custom path to AWData parser for your > > > >> images directory as well. > > > > >> like var ap:AWData = new AWData(); > > > >> ap.pathToSources("/stuff/otherstuff/myimages/"); > > > > >> you also can add to init object of the AWData instance like this if > > > >> you use the parse handler for embedded awd files > > > >> var ap:AWData = new AWData({customPath:"/stuff/otherstuff/myimages/"}); > > > > >> Fabrice > > > > >> On Jun 26, 2010, at 7:37 PM, Th3Sh33p wrote: > > > > >>> I created a tree model, which I would like to place in my project, it > > > >>> was created as a obj file, imported into prefab, then a texture was > > > >>> added and I exported as a awd file. Then I used this script... > > > > >>> var model_number:int = 0 > > > >>> var model:String = "tree"; > > > >>> var ld:Loader3D = new Loader3D() > > > >>> ld.addEventListener(Loader3DEvent.LOAD_SUCCESS,model_loaded); > > > >>> ld.addEventListener(Loader3DEvent.LOAD_ERROR,model_errored); > > > >>> ld.name = String(model_number); > > > >>> var ap:AWData = new AWData() > > > >>> ld.loadGeometry("unit/"+model+"/"+model+".awd",ap); > > > > >>> private function model_loaded(e:Loader3DEvent){ > > > >>> constructed[Number(e.target.name)] = e.target.handle > > > >>> } > > > >>> .. to import the model, which was successful, however the model has no > > > >>> material or texture. I have tried various things I've seen on other > > > >>> threads but the model is always white when imported.The folder > > > >>> "images" is located next to "tree.awd". > > > > >>> How can I import this model with it's material? > > > > >>> *The model imports successfully with textures back into prefab
