If you load and parse a Collada which has several textures specified, will it leave out the materials, or will it load the materials, but as a Wireframe Color or something instead?
Whenever I need to swap out a texture at runtime, I run a for each loop over the materialLibrary property. It's possible that if you load an object and don't pass a material, the for each loop (or for in loop) might still have an entry for each referenced material in the model. Then it's just a matter of linking up the correct file path to that material. At that point, since you might know the name of the material you need, there might be a way to get that URL off of the object, or you might have a library you can reference which will define the file path for that material name. That would make it possible to share textures across different objects. On the other hand, I guess that still is hard-coding URL paths. I am using a unique class with Flash embed code for each model I'm using in my current project, because each one needs to have additional code information for how it interacts inside the environment I've created. If you just needed to load a lot of objects, I can see how this would be difficult. So if you use the standard Collada.load method, it doesn't load the textures, you said? Are you sure that it is finding the textures? Are the paths to the material images correct inside the Collada? Are they relative? On Fri, 19 Feb 2010 06:16:05 -0800, Reinorvak <[email protected]> wrote:
Yeah, that is what I was doing previously, but this ended up being a hard-coded kind of method since each model would have a specific texture. I was looking for a more dynamic way of going about this as we're going to have tons of individual models and textures. Alright let me explain a bit more on how this is working. Currently I have two classes running about being the Item class, which contains all the model data. Then there is my own MatLibrary. I use the MatLibrary to load texture's at run time and place them on the model. However, this requires that I know which texture goes where on the model, as there can be multiple texture's per single model. As is such, I'd like to further separate the need to externally load texture's when loading a model, as want to load it with the Collada loader, not using the bitmap parameter. Currently, this is whats happening in code: On the load call: public function loadModel(url:String):void { m_url = url; var loader:Object3DLoader = Collada.load("Models/test/chair/ box_test.dae"); loader.addOnSuccess(onSuccess); loader.addOnError(onError); } Pretty much just making a basic load call with Collada and setting up event handlers. On the load Success: override protected function onSuccess(e:LoaderEvent) { m_model = (e.loader.handle as ObjectContainer3D); m_model.ownCanvas =true; m_model.renderer = renderer; addChild(m_model); for(var i = 0; i < m_textureNames.length; ++i) { fcsMaterialLibrary.getInstance().addEventListener( "LoadComplete" + m_textureNames[i], initMaterial); } fcsMaterialLibrary.getInstance().CreateMultiMaterial(m_model, m_textureNames); } Turn the model that has been loaded into an object of the class, and then continue on to load the Array of textures. The textures are hard- coded for the time being, and I can get them to show up on the model with some tricks. But what I'd like to do is remove the need for the MaterialLibrary, and just have all texture's loaded on the collada load without having the load the texture beforehand. Thanks again in advance. On Feb 18, 4:58 pm, "Joshua Granick" <[email protected]> wrote:FYI, you can parse on your own like this: Collada.parse (MeshClass, { material: MaterialClass } ); or var material:BitmapMaterial = new BitmapMaterial (Cast.bitmap (MaterialClass), { smoothing: true } ); Collada.parse (MeshClass, { material: material } ); That works great if you're embedding. I don't use the built-in load method, but if you need the Collada and UV to be outside Flash at runtime, you can load them using a URLLoader for the mesh and Loader for the UV, then parse it like this. You wouldn't need to cast the material as a bitmap since that's how it comes from the Loader, and I think you could just pass the text value into the first parameter of the parse method Hope this helps you get up and running On Thu, 18 Feb 2010 13:28:38 -0800, Reinorvak <[email protected]> wrote: > Greetings again everyone, > Recently, I've come across the problem of trying to load a pre- > textured model into away3d using the Collada format. I believe I've > read on something like this before, but couldn't find the post so just > point me in the direction if its already been resolved. > Here's the thing. When I load the model into away3d, the parse > constantly gets stuck on the notifyProgress function. The parser will > first fire a notifySuccess, but then continues to call the > notifyProgess and continues parsing the collada file, after getting > out of its notifyProgress loop. This process will continue forever, > and I'll never get my models on screen. > However, should I not set the texture material onto the model, it > loads just fine and goes on its way. So, I'm not sure if this is a > problem with the .dae file, which it seems to be, or with something in > away3d. Either way, I need models to be able to load textures from > Maya using this collada format. Any help will be appreciated and > thanks in advance. > P.S. I'll keep looking on my own for the solution in the mean time. > Rein
