<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" 
      xmlns:thr="http://purl.org/syndication/thread/1.0">
  <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/05/textures-wireframe-bitmap-movi-1.html" />
  <link rel="self" type="application/atom+xml" href="http://www.insideria.com/atom.xml" />
  <id>tag:www.insideria.com,2009://34/tag:www.insideria.com,2008://34.23437-</id>
  <updated>2009-11-16T15:43:01Z</updated>
  <title>Comments for Textures (WireFrame, Bitmap, MovieAsset, Video, etc.) PaperVision3D (http://www.insideria.com/2008/05/textures-wireframe-bitmap-movi-1.html)</title>
  <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.21-en</generator>
  <entry>
    <id>tag:www.insideria.com,2008://34.23437</id>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/05/textures-wireframe-bitmap-movi-1.html" />
    <link rel="service.edit" type="application/atom+xml" href="http://blogs.oreilly.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=34/entry_id=23437" title="Textures (WireFrame, Bitmap, MovieAsset, Video, etc.) PaperVision3D" />
    <published>2008-05-29T15:30:00Z</published>
    <updated>2008-05-29T15:37:50Z</updated>
    <title>Textures (WireFrame, Bitmap, MovieAsset, Video, etc.) PaperVision3D</title>
    <summary>Materials
Why do you need to learn about materials in Papervision3D? Take a sphere for example: How do you determine whether the sphere is a globe, an eye, or a basketball? You only know by which material is mapped to the sphere.

This article will cover the basics of the materials available through Papervision3D and teach you how to add materials to Planes. Let&apos;s get started, we&#8217;ve got a lot of &#8220;material&#8221; to cover:
</summary>
    <author>
      <name>John Lindquist</name>
      <uri>http://pv3d.org</uri>
    </author>
    
    <category term="Features" />
    
    <content type="html" xml:lang="en" xml:base="http://www.insideria.com/">
      <![CDATA[<em>Reminder: Papervision3D is still in 2.0 alpha. Before testing these samples, please make sure to update to the latest version of the Papervision3D 2.0 alpha Great White branch.</em><br/>
<br/>
<strong>Materials</strong><br/>
Why do you need to learn about materials in Papervision3D? Take a sphere for example: How do you determine whether the sphere is a globe, an eye, or a basketball? You only know by which material is mapped to the sphere.<br/>
<br/>
This article will cover the basics of the materials available through Papervision3D and teach you how to add materials to Planes. Let's get started, we&#8217;ve got a lot of &#8220;material&#8221; to cover:<br/>
<br/>
<strong>Materials Base Class</strong><br/>
Before we dive into every material available, it's important to note that every material extends an abstract base class called &#8220;MaterialObject3D&#8221; (org.papervision3d.core.proto.MaterialObject3D). This means you'll find the following properties in every material:<br/>
<br/>
<strong>Very Common Usage among All Materials</strong><br/>
1.	<strong>name</strong> (String): the name of the material<br/>
2.	<strong>interactive</strong> (Boolean): allows listeners to be assigned. Interactivity will be covered in an upcoming article.<br/>
3.	<strong>oneSide</strong> or <strong>doubleSided</strong> (Boolean): maps the material to the front AND back of the mesh. For instance, a spinning Plane will show the same material on both sides of the Plane.<br/>
4.	<strong>smooth</strong> (Boolean): applies a smoothing algorithm to the material. Turning this on for many materials or high-resolution materials has  an impact on performance.<br/>
<br/>
<strong>Less Common, but Useful Usage</strong><br/>
5.	<strong>bitmap</strong> (BitmapData): gives you access to the bitmap data of the material.<br/>
6.	<strong>tiled</strong> (Boolean): determines whether the texture is tiled across the material. On primitive objects, you&#8217;ll have to adjust the maxU and maxV for this to take effect. For more information on UV mapping visit: <a href="http://en.wikipedia.org/wiki/UV_mapping" target="_blank">http://en.wikipedia.org/wiki/UV_mapping</a> <br/>
7.	<strong>maxU</strong> (Number): holds the max number of &#8220;U&#8221; in the UV map.<br/>
8.	<strong>maxV</strong> (Number): holds the max number of &#8220;V&#8221; in the UV map.<br/>
9.	<strong>scene</strong> (Scene3D): a reference to the scene where the object belongs.<br/>
<br/>
<strong>Special Situation Usage</strong><br/>
10.	<strong>invisible</strong> (Boolean): indicates whether the mesh faces are drawn.<br/>
11.	<strong>opposite</strong> (Boolean): indicates whether the face is flipped. Only use this if the material is double sided.<br/>
12.	<strong>widthOffset</strong> (Number): holds the original width of the bitmap before auto mip-mapping resizes<br/>
13.	<strong>heightOffset</strong> (Number): holds the original height of the bitmap before auto mip-mapping resizes<br/>
<br/>
<strong>Wireframe Material (or Composite Material including Wireframe Material)</strong><br/>
14.	<strong>lineColor</strong> (Number): holds an RGB value (e.g., 0xabc123) of the faces&#8217; outline.<br/>
15.	<strong>lineAlpha</strong> (Number): holds a number between 0 and 1 representing the percentage of transparency for the line.<br/>
16.	<strong>lineThickness</strong> (Number): determines the thicknesss of the line.<br/>
<br/><strong>
Color Material Only (or Composite Material including Wireframe Material)</strong><br/>
1.	<strong>fillColor</strong> (Number): holds an RGB value (e.g., 0xabc123) of the fill of the mesh.<br/>
2.	<strong>fillAlpha</strong> (Number): holds a number between 0 and 1 representing the percentage of transparency for the fill.<br/>
<br/>
<strong>1. Wireframe</strong><br/>
We used Wireframe materials in Part 1 to show that our 3d objects were truly 3d. The Wireframe material outlines the triangles used to create the entire object.<br/>
<br/>
<img src="http://www.insideria.com/upload/2008/04/textures_wireframe_bitmap_movi_1/WireframeMaterial.JPG" alt="WireframeMaterial.JPG"/><br/>
<br/>
WireframeMaterial( color:Number=0xFF00FF, alpha:Number=100, thickness:Number = 0 )<br/>
<br/>
<strong>2. Color</strong>
Color materials project a solid color on to the 3d object. I've mainly seen color materials used in demos as they don&#8217;t allow for much customization.<br/>
<br/>
<img src="http://www.insideria.com/upload/2008/04/textures_wireframe_bitmap_movi_1/ColorMaterial.JPG" alt="ColorMaterial.JPG"/><br/>
<br/>
ColorMaterial( color:Number=0xFF00FF, alpha:Number = 1, interactive:Boolean = false )<br/>
<br/>
<strong>3. Bitmap</strong>
If you want to use an image on your 3d object, you&#8217;ll need to use one of the following methods to get the bitmap data of your .gif, .jpeg, or .png onto the object.<br/>
<br/>
<img src="http://www.insideria.com/upload/2008/04/textures_wireframe_bitmap_movi_1/Commons.png" alt="Commons.png" width="125"/><br/>
<br/>
The bitmap used in the demos is the Wikimedia commons logo above.
Bitmap Material, Bitmap Asset Material, and Bitmap File Material are three different ways of doing the same thing so they will all yield the following result:<br/>
<br/>
<img src="http://www.insideria.com/upload/2008/04/textures_wireframe_bitmap_movi_1/BitmapMaterial.JPG" alt="BitmapMaterial.JPG"/><br/>
<br/>
<strong>a.	Bitmap</strong><br/>
The Bitmap Material allows you to take any BitmapData and attach it to the material. The most typical usage is embedding a bitmap then grabbing the bitmapData from the bitmap to pass into the material. You can find information on embedding bitmaps in Flex here:<br/>
<a href="http://livedocs.adobe.com/flex/3/html/help.html?content=embed_3.html" target="_blank">http://livedocs.adobe.com/flex/3/html/help.html?content=embed_3.html</a><br/>
BitmapMaterial( asset:BitmapData=null, precise:Boolean = false)<br/>
<br/>
<strong>b.	Asset (Flash CS3 only)</strong><br/>
Bitmap Asset Materials are used to map a bitmap in your Flash library to an object. Just add any bitmap to your library, right-click -> properties<br/>
<br/>
		BitmapAssetMaterial( linkageID:String, precise:Boolean = false )<br/>
<strong>c.	Color</strong><br/>
The Bitmap Color Material works practically the same as the Color Material above, but this bitmap version allows you access to the bitmapData to draw or change pixels of the color to your liking.<br/>
BitmapColorMaterial(color:Number=0xFF00FF, alpha:Number=1)<br/>
<br/>
<strong>d.	File</strong><br/>
Bitmap File Materials simply take a string that points the location of the image. You can also add listeners to the material if you need to check on progress or when the bitmap finishes loading.<br/>
		BitmapFileMaterial( url :String="" )<br/>
<br/>
<strong>e.	Viewport</strong><br/>
<img src="http://www.insideria.com/upload/2008/04/textures_wireframe_bitmap_movi_1/BitmapViewportMaterial.JPG" alt="BitmapViewportMaterial.JPG"/><br/>
<br/>
A Bitmap Viewport Material takes a bitmap snapshot of a viewport and allows you to project that snapshot onto another 3d object. Think of it like being at a basketball game and watching the game on the jumbotron instead of looking directly at the game.

<div class="acode" style="overflow: auto; padding: 10px;" ><div style="overflow-x: visible;">
<mt:CodeBeautify language="actionscript">
BitmapViewportMaterial(bitmapViewport:BitmapViewport3D, precise:Boolean=false);
BitmapViewport3D(viewportWidth:Number=640, 
                              viewportHeight:Number=480,  
                              autoScaleToStage:Boolean = false,
                              bitmapTransparent:Boolean=false, 
                              bgColor:int=0x000000,  
                              interactive:Boolean=false, 
                              autoCulling:Boolean=true);
</mt:CodeBeautify>
</div></div> 
<br/>
<strong>f.	Wireframe</strong><br/>
The Bitmap Wireframe Material is similar to the standard Wireframe Material, but it allows for access to the bitmapData of the material.<br/>
<br/>
BitmapWireframeMaterial(color:Number=0xFF00FF, alpha:Number=1,thickness:Number=3)<br/>
<br/>
<strong>4. MovieClip</strong><br/>
Papervision3D allows you to take your MovieClip directly from your Flash library and attach them your 3d objects using the linkage identifier. For Flex, you embed the published .swfs and MovieClip as you normally would. The following image demonstrates an attached MovieClip in the middle of an animation of a shape tween:<br/>
<br/>
<img src="http://www.insideria.com/upload/2008/04/textures_wireframe_bitmap_movi_1/MovieMaterial.jpg" alt="MovieMaterial.jpg"/><br/>
<br/>
<strong>a.	Asset (Flash CS3 Only)</strong><br/>
MovieAssetMaterial( linkageID:String="", transparent:Boolean=false, animated:Boolean=false, createUnique:Boolean=false, precise:Boolean = false)<br/>
<strong>b.	MovieMaterial</strong><br/>
MovieMaterial( movieAsset:DisplayObject=null, transparent:Boolean=false, animated:Boolean=false, precise:Boolean = false )<br/>
<br/>
<strong>5. Video Stream</strong><br/>
	Yes, you can play videos on 3d objects. Yes, it looks really cool.<br/>
<br/>
<img src="http://www.insideria.com/upload/2008/04/textures_wireframe_bitmap_movi_1/VideoStreamMaterial.JPG" alt="VideoStreamMaterial.JPG"/><br/>
<br/>
VideoStreamMaterial ( video:Video, stream:NetStream , precise:Boolean = false )<br/>
<br/>
<strong>6. Shade</strong><br/>
Since Shaded Materials are all based on a light pointing at a material and reflecting (or not-reflecting) the light, you&#8217;ve probably guessed that you need to create a light first:<br/>
<br/>
light = new PointLight3D();<br/>
<br/>
You can position this light wherever you want using its x, y, and z properties then the shaded objects will appear to look at the light. If you want the light to be visible, you need to add pass in a parameter of &#8220;true&#8221; then &#8220;addChild&#8221; it to the scene. Although, you&#8217;ll probably find yourself leaving the light invisible and creating a 3d object at the same location that appears to be the light source like a sun, lamp, or sunlamp.<br/>
<br/>
This &#8220;light&#8221; will become the first parameter of each shaded material. Only one light is currently supported in Papervision3D, but there are plans to allow multiple lights in the distant future.<br/>
<br/>
The best way to see how all of these materials work is to test them out with the included reference sheet at the end of the article.<br/>
<br/>
<strong>a.	Cell</strong><br/>
<a href="http://en.wikipedia.org/wiki/Cel-shaded_animation" target="_blank">http://en.wikipedia.org/wiki/Cel-shaded_animation</a><br/>
The Cell Material uses two colors and an amount of steps you want to take to blend the two.<br/>
<br/>
<img src="http://www.insideria.com/upload/2008/04/textures_wireframe_bitmap_movi_1/CellMaterial.JPG" alt="CellMaterial.JPG"/><br/>
<br/>
CellMaterial(light:LightObject3D, color_1:int, color_2:int, steps:int)<br/>
<br/>
<strong>b.	Environment Map</strong><br/>
<a href="http://en.wikipedia.org/wiki/Environment_map" target="_blank">http://en.wikipedia.org/wiki/Environment_map</a><br/>
An environment map is receiving a bitmap being projected from the light. More advanced environment maps require &#8220;shaders&#8221; which will be covered in a later article.<br/>
<br/>
<img src="http://www.insideria.com/upload/2008/04/textures_wireframe_bitmap_movi_1/EnvMapMaterial.JPG" alt="EnvMapMaterial.JPG"/><br/>
<br/>
EnvMapMaterial(light:LightObject3D, lightMap:BitmapData, backEnvMap:BitmapData=null, ambientColor:int = 0)<br/>
<br/>
<strong>c.	Flat Shade</strong><br/>
<a href="http://en.wikipedia.org/wiki/Flat_shading" target="_blank">http://en.wikipedia.org/wiki/Flat_shading</a><br/>
Flat shading gives one solid shade of light to each polygon. This effect is much more noticeable on spheres than plane and cubes to you can see the light curve around the sphere.<br/>
<br/>
<img src="http://www.insideria.com/upload/2008/04/textures_wireframe_bitmap_movi_1/FlatShadeMaterial.JPG" alt="FlatShadeMaterial.JPG"/><br/>
<br/>
FlatShadeMaterial(light:LightObject3D, diffuse:uint=0xffffff, ambient:uint=0x000000)<br/>
<br/>
<strong>d.	Gouraud</strong><br/>
<a href="http://en.wikipedia.org/wiki/Gouraud_shading" target="_blank">http://en.wikipedia.org/wiki/Gouraud_shading</a><br/>
Gouraud Materials allow for smoother shading. Limitations are discussed in the link above.<br/>
<br/>
<img src="http://www.insideria.com/upload/2008/04/textures_wireframe_bitmap_movi_1/GouraudMaterial.JPG" alt="GouraudMaterial.JPG"/><br/>
<br/>
GouraudMaterial(light3D:LightObject3D, lightColor:int = 0xFFFFFF, ambientColor:int=0x000000)<br/>
<br/>
<strong>e.	Phong</strong><br/>
<a href="http://en.wikipedia.org/wiki/Phong_shading" target="_blank">http://en.wikipedia.org/wiki/Phong_shading</a><br/>
Phong Materials are similar to Gouraud Materials, but they also allow for specular highlights.<br/>
<br/>
<img src="http://www.insideria.com/upload/2008/04/textures_wireframe_bitmap_movi_1/PhongMaterial.JPG" alt="PhongMaterial.JPG"/><br/>
<br/>
PhongMaterial(light3D:LightObject3D, lightColor:int, ambientColor:int, specular:int)<br/>
<br/>
<strong>7.Composite</strong><br/>
A composite material is simply multiple materials mashed together to form one material. Here we see a bitmap material put together with a wireframe material.<br/>
<br/>
<img src="http://www.insideria.com/upload/2008/04/textures_wireframe_bitmap_movi_1/CompositeMaterial.JPG" alt="CompositeMaterial.JPG"/><br/>
<br/>
<strong>8. Run-Time Material Swapping</strong><br/>
Swapping material at run-time is simple as can be (thanks to a recent update by Ralph):<br/>
<br/>
my3DObject.material = myMaterial;<br/>
<br/>
The most obvious use is for rollovers, but interactivity with Papervision3D is being saved for a later article.<br/>
<br/>
<strong>9. Examples of Materials around the Web</strong><br/>
*Note: Some of these examples use Papervision3D&#8217;s shaders (which I will cover in a later article) and may not be working off the latest Papervision3D repository.<br/>
<br/><a href="http://www.zeropointnine.com/blog/a-papervision-20-alpha-example" target="_blank">
http://www.zeropointnine.com/blog/a-papervision-20-alpha-example</a><br/>
<a href="http://www.unitzeroone.com/blog/2008/03/12/papervision3d-shaders-bumpmap-example-sourcecode-for-cs3/" target="_blank">http://www.unitzeroone.com/blog/2008/03/12/papervision3d-shaders-bumpmap-example-sourcecode-for-cs3/</a><br/>
<br/>
<strong>10. Reference Sheets</strong><br/>
This article includes 
<a href="http://www.insideria.com/upload/2008/04/textures_wireframe_bitmap_movi_1/MaterialsReference.zip">reference sheets</a> for all the materials covered here so you can test all of the properties yourself within Flash and Flex. The Flash sheet covers the two asset materials that are Flash-specific while the Flex sheet covers all of the other materials in an ActionScript project.<br/>
<br/>]]>
      
    </content>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.23437-comment:2017462</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.23437" type="text/html" href="http://www.insideria.com/2008/05/textures-wireframe-bitmap-movi-1.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/05/textures-wireframe-bitmap-movi-1.html#comment-2017462" />
    <title>Comment from Hyphad on 2008-05-30</title>
    <author>
        <name>Hyphad</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>So nice !</p>

<p>Thanks ! </p>

<p>BOOK ! BOOK ! BOOK !</p>]]>
    </content>
    <published>2008-05-30T15:28:44Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.23437-comment:2017645</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.23437" type="text/html" href="http://www.insideria.com/2008/05/textures-wireframe-bitmap-movi-1.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/05/textures-wireframe-bitmap-movi-1.html#comment-2017645" />
    <title>Comment from Brian Davis on 2008-06-09</title>
    <author>
        <name>Brian Davis</name>
        <uri>http://www.flashkeep.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.flashkeep.com">
        <![CDATA[<p>great coverage of the material types and uses for papervision 3D.</p>

<p>I'm working on an AS3 tutorial site, and I'm starting to include papervision tutorials as well...  I could not possibly write this tutorial better than you did here, so I'll link my users to your page for this topic.</p>

<p>great work, and interesting to see that Gouraud Shader can smooth visual quality w/o needing more points... its not perfect but probably could be a performance saver.</p>

<p>sincerely:<br />
Brian Davis of:<br />
www.flashkeep.com</p>

<p><br />
ARG: this Captcha bot prevention is keeping me from posting...  5th try.</p>]]>
    </content>
    <published>2008-06-09T14:54:13Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.23437-comment:2042170</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.23437" type="text/html" href="http://www.insideria.com/2008/05/textures-wireframe-bitmap-movi-1.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/05/textures-wireframe-bitmap-movi-1.html#comment-2042170" />
    <title>Comment from pablow on 2008-09-02</title>
    <author>
        <name>pablow</name>
        <uri>http://synestesia.com.ar</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://synestesia.com.ar">
        <![CDATA[<p>Hey very useful and clear tut! congrats!</p>

<p>now i wonder if u could explain me how to add a phong material to a dae object, or how to give lights and shadows to it.</p>

<p>thank you</p>]]>
    </content>
    <published>2008-09-02T20:22:10Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.23437-comment:2042391</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.23437" type="text/html" href="http://www.insideria.com/2008/05/textures-wireframe-bitmap-movi-1.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/05/textures-wireframe-bitmap-movi-1.html#comment-2042391" />
    <title>Comment from rohit on 2008-09-07</title>
    <author>
        <name>rohit</name>
        <uri>http://rohitnba@gmail.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://rohitnba@gmail.com">
        <![CDATA[<p>Grt tutorial</p>

<p>Need a book...</p>]]>
    </content>
    <published>2008-09-08T03:18:02Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.23437-comment:2043058</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.23437" type="text/html" href="http://www.insideria.com/2008/05/textures-wireframe-bitmap-movi-1.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/05/textures-wireframe-bitmap-movi-1.html#comment-2043058" />
    <title>Comment from Moose on 2008-09-22</title>
    <author>
        <name>Moose</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>sweet: thx!</p>]]>
    </content>
    <published>2008-09-22T16:46:04Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.23437-comment:2066056</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.23437" type="text/html" href="http://www.insideria.com/2008/05/textures-wireframe-bitmap-movi-1.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/05/textures-wireframe-bitmap-movi-1.html#comment-2066056" />
    <title>Comment from Teresa on 2009-06-11</title>
    <author>
        <name>Teresa</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>Hello !<br />
I’m working with augmented reality and i want to create a plane with a movie but i have a problem. could it be possible to send you the code?</p>

<p>Thanks</p>]]>
    </content>
    <published>2009-06-11T18:02:20Z</published>
  </entry>

</feed
