dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: away3D and dynamic material assignment

  1. #1
    Member
    Join Date
    Nov 2008
    Posts
    52

    away3D and dynamic material assignment

    Hello!
    I have loaded a .obj into away3D with a given material (not using the .mtl file), and through the course of rendering, I want to change the object's material. Here is how I load the .obj:


    --------------------------------
    var object:Object3D;

    function loadObject():void
    {
    var loader:Object3DLoader = Obj.load("object.obj", {material:{bitmap:"texture.jpg", lighting:false}});
    loader.addOnSuccess(objectLoaded);
    view.scene.addChild(loader);
    }

    function objectLoaded(e:LoaderEvent):void
    {
    object = (e.loader.handle as ObjectContainer3D).children[0];
    view.scene.addChild(object);
    }
    --------------------------------

    The line "object.material = <new bitmap>;" doesn't work, apparently I can only set the material once at the init level, is this true, or is there another way to set the Object3D material? The error message is the common message "1119: Access of possibly undefined property material through a reference with static type away3d.core.base:Object3D.".

    Any help would be appreciated, thank you!

  2. #2
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,131
    it's been awhile since I was deeply into away3d ...several rev's ago, but...

    I think the reason it's failing is you're trying to set a material to be a bitmap, rather than to be a new BitmapMaterial or MovieMaterial or whatever you need that's an extender of the base material interface. There should be no problem saying object.material=<BitmapMaterial>... but you can't just throw a bitmap at it and expect it to understand that as a material.

  3. #3
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,131
    hm. Now that I'm looking at it though, maybe .material really isn't a public access var for Object3D at this point... I don't know. They've done a lot with it. Look into the Object3D (not container) code for a way to set the material after init. Can't be that hard.

  4. #4
    Member
    Join Date
    Nov 2008
    Posts
    52
    Quote Originally Posted by joshstrike View Post
    hm. Now that I'm looking at it though, maybe .material really isn't a public access var for Object3D at this point... I don't know. They've done a lot with it. Look into the Object3D (not container) code for a way to set the material after init. Can't be that hard.
    Perhaps if I had an API, but strangely, programs nowadays fail to specify where their respective APIs are present. I am so upset with this, the only two core programming APIs that are accessible without much trouble are Java and MSDN. I mean, why can't they make APIs obvious for other programming languages... It's so vital.

    Anyway, any pointers to the API? Any that I have found are 404 http errors. Thanks a lot!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center