Hey All,
I'm really excited about the new Away3d 4.0 library, however I've been
running into a lot of trouble loading even the simplest objects.
Embedding objects leads to a missing .mtl file even when I trace
baseUri + mtlurl in OBJParser and it's correct. So I've gone with
loading external assets (which I prefer anyways). I've searched far
and wide on this group to try to find an answer but I'm stuck so here
I am. Here's all the relevant files and the stack with traces at
specific points, any help is greatly appreciated.
----------------------------------------------------------------------------------------
.as File
package
{
import away3d.containers.ObjectContainer3D;
import away3d.containers.View3D;
import away3d.entities.Mesh;
import away3d.events.LoaderEvent;
import away3d.events.ResourceEvent;
import away3d.lights.PointLight;
import away3d.loading.ResourceManager;
import away3d.materials.BitmapMaterial;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
import flash.utils.ByteArray;
public class away3d extends Sprite
{
[Embed(source="/assets/texture.jpg")]
private var Mat:Class;
[Embed(source="/assets/cube.obj", mimeType="application/octet-
stream")]
private var OBJ:Class;
private var view:View3D = new View3D();
private var light:PointLight = new PointLight();
private var container:ObjectContainer3D;
public function away3d():void
{
super();
ResourceManager.instance.addEventListener(ResourceEvent.RESOURCE_RETRIEVED,
onRetrieve);
container =
ObjectContainer3D(ResourceManager.instance.getResource('/assets/
cube.obj'));
container.scale(100);
view.scene.addChild(light);
view.scene.addChild(container);
stage.align = "top";
addEventListener(Event.ENTER_FRAME, onFrame);
}
private function onRetrieve(e:ResourceEvent):void
{
trace('success');
/*
var mesh:Mesh;
var mat:BitmapMaterial = new BitmapMaterial(new
Mat().bitmapData);
mesh = Mesh(e.target.handle);
mesh.material = mat;
*/
}
private function onFrame(e:Event):void
{
view.render();
}
}
}
-------------------------------------------------------
stack
RangeError: Error #1125: The index 0 is out of range 0.
at away3d.loading.parsers::OBJParser/translate()[C:\Users\Mike\Desktop
\away3d\src\away3d\loading\parsers\OBJParser.as:217]
at away3d.loading.parsers::OBJParser/proceedParsing()[C:\Users\Mike
\Desktop\away3d\src\away3d\loading\parsers\OBJParser.as:166]
at away3d.loading.parsers::ParserBase/onInterval()[C:\Users\Mike
\Desktop\away3d\src\away3d\loading\parsers\ParserBase.as:243]
at away3d.loading.parsers::ParserBase/startParsing()[C:\Users\Mike
\Desktop\away3d\src\away3d\loading\parsers\ParserBase.as:258]
at away3d.loading.parsers::ParserBase/parseTextAsync()[C:\Users\Mike
\Desktop\away3d\src\away3d\loading\parsers\ParserBase.as:161]
at away3d.loading::AssetLoader/parse()[C:\Users\Mike\Desktop\away3d
\src\away3d\loading\AssetLoader.as:267]
at away3d.loading::AssetLoader/handleUrlLoaderError()[C:\Users\Mike
\Desktop\away3d\src\away3d\loading\AssetLoader.as:235]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
At OBJParser:loadMtl:139 - Vector _objects created here.
At OBJParser:loadMtl:166 - Method Translate called, no values have
been pushed to _objects.
At OBJParser:loadMtl:216 - Vector groups initialized with
_objects[_objectIndex]. Out of Bounds Error here.
-----------------------------------------------
.obj file
mtllib cube.mtl
v -8.9734 0.0000 20.1663
v -8.9734 0.0000 -19.4264
v 20.8450 0.0000 -19.4264
v 20.8450 0.0000 20.1663
v -8.9734 28.0913 20.1663
v 20.8450 28.0913 20.1663
v 20.8450 28.0913 -19.4264
v -8.9734 28.0913 -19.4264
vn 0.0000 -1.0000 -0.0000
vn 0.0000 1.0000 -0.0000
vn 0.0000 0.0000 1.0000
vn 1.0000 0.0000 -0.0000
vn 0.0000 0.0000 -1.0000
vn -1.0000 0.0000 -0.0000
vt 1.0000 0.0000 0.0000
vt 1.0000 1.0000 0.0000
vt 0.0000 1.0000 0.0000
vt 0.0000 0.0000 0.0000
g Cube
usemtl Material__26
s 2
f 1/1/1 2/2/1 3/3/1 4/4/1
s 4
f 5/4/2 6/1/2 7/2/2 8/3/2
s 8
f 1/4/3 4/1/3 6/2/3 5/3/3
s 16
f 4/4/4 3/1/4 7/2/4 6/3/4
s 32
f 3/4/5 2/1/5 8/2/5 7/3/5
s 64
f 2/4/6 1/1/6 5/2/6 8/3/6
-----------------------------------------------------------
.mtl file
newmtl Material__26
Ns 10.0000
Ni 1.5000
d 1.0000
Tr 0.0000
Tf 1.0000 1.0000 1.0000
illum 2
Ka 0.5880 0.5880 0.5880
Kd 0.5880 0.5880 0.5880
Ks 0.0000 0.0000 0.0000
Ke 0.0000 0.0000 0.0000
map_Ka texture.jpg
map_Kd texture.jpg
-------------------------------------------------------------
I'm stuck because it's referencing an index in _objects however
between when the instance of the object is created and when an index
is referenced in it nothing in between pushes any values to it so I'm
confused how this could possibly work in any instance.
Any help is greatly appreciated.
Thanks,
Mike