« Papervision3D - Animated Movie Asset Material
Animated Models: Blender to PV3D »

Papervision3D- Materials Demo

March 21st, 2008 . Posted by brad in Flash, Papervision3D

I put together a small material demo file to familiarize myself with some of the shade materials in pv3d v2. It’s not exhaustive, only featuring the shadeMaterials (not shaders/shadedmaterials) but I found it useful in getting to grips with the various shading options in pv3d. It also includes some of the simple materials like bitmap Asset, movie Asset, and wireframe for reference.

materials demo

Example
Source

(To rotate model, click + drag left/right)

For users of the SVN repository: This file uses an older revision (442) of the effects branch as there seems to be a bug with replaceMaterialByName and shadeMaterials in the more recent revision (444) at the time of writing.



34 Responses to “Papervision3D- Materials Demo”

  • Posted: P48L0_84ND1N on April 10th, 2008 at 11:37 pm .

    man, you site is very cool. Well done, good content, keep it up!

  • Posted: admin on April 13th, 2008 at 10:58 am .

    thanks pablo!

  • Posted: underdoeg on April 14th, 2008 at 10:43 pm .

    great! Thanks. Exactly what I been looking for!

  • Posted: admin on April 15th, 2008 at 2:55 pm .

    hey underdoeg, glad you found it useful.

  • Posted: makc on April 22nd, 2008 at 9:09 am .

    Nice bunny there :) Hey, did you notice that every picture in your blog is titled “tiled material” ?

  • Posted: admin on May 3rd, 2008 at 8:16 am .

    Thanks makc, I hadn’t noticed the title thing.
    Also, thanks for putting me in touch with Dmitri (cast3d)- I was very happy to hear that cast3d now supports PV3D v2.

  • Posted: AbcDef on May 6th, 2008 at 7:02 pm .

    just hopped into AS3 after a long time without opening no flash at all…
    now i´m looking for a way to store data with dinamically created buttons, as in Your example You did it with the Btn() class, btn.material property, but having a hard time set things up.

    could You share Your btn class, please?
    i´m sure it could be as useful as this daeShadeMaterial one!

    thanks in advice.

    abc>Def

  • Posted: admin on May 8th, 2008 at 10:52 am .

    Hi abc>Def,

    If you’ve ever assigned a linkageID to a symbol in your library with AS2, the process is almost identical:

    1) Create symbol
    2) Right Click (CTRL-Click Mac) on your symbol in the library panel, and select linkage.
    3) Enter a name under class. Mine was “Btn”.

    Flash will automatically generate the linked class for you.

    Now to attach that object from the library, you’d simply need to enter something like:

    var myBtn:Btn=new Btn();
    addChild(myBtn);

    Hope that helps.
    Brad.

  • Posted: AbcDef on May 9th, 2008 at 9:20 am .

    Brad,

    i´m using the Flashdevelop for my project, obviously there´s no library. just a few minutes after posting the previous one, i got my question RIGHT, which should be…

    how do i create a custom class with custom properties?
    btn class with btn.labelTxt, btn.customDataContainer, etc..

    will look into that further.
    anyway. just LOVE Your french bunny!
    keep up rocking Flash!

    salut, abc>Def

  • Posted: Ransom on June 12th, 2008 at 12:58 am .

    Hey Brad,

    FYI I think your example no longer works when compiled against GW >585 (and maybe earlier) .

    I’ve been trying to do what you did on a model of my own and the model and material load in properly, but dae.replaceMaterialByName doesn’t do anything. The mc can be put on a plane no problem.

    For checking I dl’d your source and your bunny.dae, subbed into the dae my own jpg and compiled, and it mapped my jpg onto your bunny model, but nothing doing with the movieclip. Then I remembered I had a earlier copy of GW, and with that it replaces the material correctly.

  • Posted: Ransom on June 12th, 2008 at 1:37 am .

    Brad,

    I found that replacing
    dae.addEventListener(Event.COMPLETE
    with
    dae.addEventListener(FileLoadEvent.LOAD_COMPLETE
    in your code fixed the problem in GW 587

    regards
    RW

  • Posted: admin on June 14th, 2008 at 5:58 pm .

    Hey Abc>Def,

    Apologies for the long delay in reply. I don’t use Flex, so you may need to tweak the following code slightly. If I’m understanding you correctly, you could try one of two different approaches. The first would be to create a class with constructor parameters for the specific variables you need, maybe something along the lines of:

    package {

    import flash.display.*;
    import flash.text.*;

    public class myButton extends MovieClip{

    public function myButton(labelText) {

    buttonText.text=labelText;
    }
    }
    }

    Usage:

    var btn:myButton=new myButton(”buttonName”);
    addChild(btn);

    If you need to create variables on the fly, you could use the other method which would be to create a dynamic class. You can then assign dynamic variables in much the same way as you would’ve done with AS2:

    package {

    dynamic public class dBtn {

    public function dBtn() {
    }
    }
    }

    Usage:

    var dBtn1:dBtn=new dBtn();
    dBtn1.btnLabel=”This is the label”;
    trace(dBtn1.btnLabel);

    Hope that helps.

  • Posted: admin on June 14th, 2008 at 6:06 pm .

    Ransom,

    Thanks for pointing that out. With great white still in alpha, the source changes so often that I struggle to keep up sometimes.

  • Posted: Amanita on June 26th, 2008 at 11:24 am .

    Where the EnviroMap class??? I didn`t found it! Please, help!

    lightMapData = new Bitmap(new EnviroMap(0,0)).bitmapData;

  • Posted: admin on June 26th, 2008 at 1:44 pm .

    Hi Amanita,

    In my example, the enviroMap class was a linked class,that was generated automatically. Here are the steps if you’re not familiar with linked classes:

    1) Import image into flash that you want to use as your environmental map.
    2) Right Click (CTRL-Click Mac) on the image in the library panel, and select linkage.
    3) Enter “EnviroMap” name under class.

    Flash will automatically generate the linked class for you.

  • Posted: [ fla:pik ] Blog » PV3D 2.0 Materials on June 26th, 2008 at 9:13 pm .

    [...] Materials Demo [...]

  • Posted: Andrew on June 30th, 2008 at 11:50 am .

    Hi,

    First off, thanks for the great examples. Awesome stuff. I can’t seem to get this example to work correctly though. I get this error:

    [MaterialObject3D] bitmap:null lineColor:0 fillColor:0

    None of my materials show up and well, everything is broken :)

    I understand if you do not like to post your fla’s, but I believe that my problem relates to how my library is set up. Is there any way you could post your fla to see how you are setting up your materials? Thanks

  • Posted: admin on June 30th, 2008 at 7:39 pm .

    Hey Andrew,

    You’re welcome to d/l the .fla file. It’s very messy, but you can download and check it out here

    hth.
    Brad

  • Posted: Sandro on July 8th, 2008 at 9:26 am .

    Hi,

    can please sombody help me with trunk, seems to be the reason why replaceMaterialByName didn´t work.
    Have non SV. Which .as file should i relpace to work.
    (sorry for bad english!)

    Sandro

  • Posted: brad on July 13th, 2008 at 8:56 am .

    Hi Sandro,

    Probably the simplest way to fix this, would be to use the svn repository. Is there a reason that you’re not using subversion?

    The replaceMaterialByName method is defined in the DAE.as file but you’ll almost certainly run into problems if you’re using a much older version, and only update that file.

    You could try creating your shadeMaterials ,and adding them to a materialsList, but you’ll probably need to use registerObject on each material in order to get it work. It’s not a technique I’ve used, so try searching through the papervision mailing list archive for info on this.

    hth
    brad.

  • Posted: Sabdro on July 17th, 2008 at 10:33 am .

    Hi brad,
    thx a lot…i could´t install SV on my Mac…but i found a tool for a easy install. The materialList apply works fine. Can you tell how i can apply envshader to a PLANE??

    TNX Sandro

  • Posted: brad on July 17th, 2008 at 12:02 pm .

    Sandro,

    I haven’t tried applying shadematerials to planes myself, but apparently the problem has to do with the planes face normals.

    I’ve seen 2 workarounds mentioned:

    Method 1:

    for each(var tri:Triangle3D in plane.geometry.faces){
    tri.createNormal();
    }

    for each(var vert:Vertex3D in plane.geometry.vertices){
    vert.calculateNormal();
    }

    Method 2:

    The other method is simply to move the vertices in the plane by a tiny amount which isn’t enough to be noticed, but is enough to cause a recalculation of the face normals, so it should be something along the lines of:

    for (var i:uint = 0; i < plane.geometry.vertices.length; i++) {
    plane.geometry.vertices[i].z = Math.random()/10;
    }

    Let me know how it goes.

  • Posted: Nathan on July 17th, 2008 at 9:18 pm .

    Can you zip up your source and post it? It looks like you reference some assets or something here, so when I copy your class it doesn’t compile. It’d be nice to be able to build it.

  • Posted: brad on July 18th, 2008 at 6:24 am .

    If you look through the comments above, you’ll find a link to a zip file with the fla you’re looking for.

  • Posted: Boomshanka on July 20th, 2008 at 10:46 pm .

    Nice Stuff … thanks :1

  • Posted: James on July 24th, 2008 at 4:44 pm .

    Your action script references a collada file, where can i get that?

  • Posted: brad on July 30th, 2008 at 9:54 am .

    look through the comments for a zip file with the dae file.

  • Posted: James on July 31st, 2008 at 5:54 pm .

    hi brad, thanks for the response, but the bunny.zip does not contain any dae file. I’ve looked through the FLA file but could not find it either? Please help.

  • Posted: brad on July 31st, 2008 at 8:25 pm .

    Sorry James, I thought I had included the dae file in the zip folder. I’ve zipped up the dae and texture for you.
    http://www.rustpunk.co.za/blog/zip/bunny_Collada.zip

  • Posted: Hans on August 20th, 2008 at 9:31 pm .

    Hi James, looks super…
    If downloaded your zip and your .as files but can’t seem to get it doing anything.

    Could you please inlcude the .fla file to?!?

    Thnx

  • Posted: brad on August 24th, 2008 at 11:07 am .

    Thank you.

    If you look through the comments above you’ll find links to all the files necessary to compile the examples.

    You’ll probably need to make a couple of small tweaks to the code, as there have been a number of small changes to the PV3D source in recent revisions.

    good luck.
    brad

  • Posted: Franck on September 9th, 2008 at 8:22 pm .

    hi,
    your site is very nice !
    To anderstand the Environment Mapping., is it posible to see the file used for the envMap ?

    thx and sorry for my english :o)

  • Posted: brad on September 10th, 2008 at 9:48 am .

    Hi Franck,

    Thanks. Sure, you can download the fla here:
    http://www.rustpunk.co.za/blog/compressed/bunny.zip

    brad.

  • Posted: Franck on September 10th, 2008 at 6:47 pm .

    cool
    Thanks a lot


Add Comment

Comment