[Papervision3D] Simple Cube w/Texture

Merrill, Jason jason.merrill at bankofamerica.com
Thu Jul 2 07:01:11 PDT 2009


Hmmm... nobody?  This is a pretty simple problem, and I'm not sure where to start troubleshooting next...  is there a problem if the dimensions of the image being mapped to the object is larger than the surface area of the object itself?  Just trying to figure out why I'm only getting the wireframe and not the texture.  Code below.  Thanks!

 

 

Jason Merrill 



Bank of  America    Global Learning 

Shared Services Solutions Development 


Monthly meetings on the Adobe Flash platform for rich media experiences - join the Bank of America Flash Platform Community <http://sharepoint.bankofamerica.com/sites/tlc/flash/default.aspx>  

 

 

 

 

From: papervision3d-bounces at osflash.org [mailto:papervision3d-bounces at osflash.org] On Behalf Of Merrill, Jason
Sent: Wednesday, July 01, 2009 3:59 PM
To: papervision3d at osflash.org
Subject: Re: [Papervision3D] Simple Cube w/Texture

 

OK cool - so now I see the cube mesh, and I can rotate it easily, but the texture is not mapped to it.  Can someone check the code I posted about two posts back and see if they see any problems with the way I am adding materials?  The .jpg is in the same directory.  Thanks!

 

 

Jason Merrill 

Bank of  America   Global Learning 

Shared Services Solutions Development 


Monthly meetings on the Adobe Flash platform for rich media experiences - join the Bank of America Flash Platform Community <http://sharepoint.bankofamerica.com/sites/tlc/flash/default.aspx>  

 

 

	 

	Here is all my code (a few things are irrelevant since I was messing around with some other things):

	 

	package 

	{

	            import flash.display.Bitmap;

	            import flash.display.BitmapData;

	            import flash.display.Sprite; 

	            import flash.events.Event;

	            import flash.events.MouseEvent;

	            import org.papervision3d.core.proto.MaterialObject3D;

	            import org.papervision3d.materials.BitmapFileMaterial;

	            import org.papervision3d.materials.BitmapMaterial;

	            import org.papervision3d.materials.utils.MaterialsList;

	            import org.papervision3d.materials.WireframeMaterial;

	            import org.papervision3d.objects.primitives.Cube;

	            import org.papervision3d.view.Viewport3D; 

	            import org.papervision3d.scenes.Scene3D; 

	            import org.papervision3d.cameras.Camera3D; 

	            import org.papervision3d.materials.ColorMaterial; 

	            import org.papervision3d.render.BasicRenderEngine; 

	 

	            public class MyPV3DTest extends Sprite

	            {

	                        

	                        private var viewport: Viewport3D; 

	                        private var scene: Scene3D; 

	                        private var camera: Camera3D; 

	                        private var material:MaterialObject3D;

	                        private var materials:MaterialsList;

	                        private var primitive:Cube

	                        private var renderer: BasicRenderEngine;

	                        

	                        public function MyPV3DTest ():void

	                        {

	                                    //viewport = new Viewport3D(w, h, scaleToStage, interactive); 

	                                    viewport = new Viewport3D(550, 400, false, true); 

	                                    addChild(viewport); 

	 

	                                    //instantiates a Scene3D instance 

	                                    scene = new Scene3D(); 

	 

	                                    //instantiates a Camera3D instance 

	                                    camera = new Camera3D(); 

	 

	                                    //renderer draws the scene to the stage 

	                                    renderer = new BasicRenderEngine(); 

	 

	                                    var wireframeMaterial:WireframeMaterial = new WireframeMaterial(0x333333);

	                                    wireframeMaterial.doubleSided = true;

	 

	                                    var bitmapFileMaterial:BitmapFileMaterial = new BitmapFileMaterial("city.jpg");

	                                    bitmapFileMaterial.doubleSided = true;

	            

	                                     var materialsList:MaterialsList = new MaterialsList(); 

	                                     materialsList.addMaterial(wireframeMaterial, "front"); 

	                                     materialsList.addMaterial(wireframeMaterial, "back"); 

	                                     materialsList.addMaterial(bitmapFileMaterial, "left"); 

	                                     materialsList.addMaterial(wireframeMaterial, "right"); 

	                                     materialsList.addMaterial(wireframeMaterial, "top"); 

	                                     materialsList.addMaterial(wireframeMaterial, "bottom"); 

	 

	                                     var cube:Cube = new Cube(materialsList, 200, 200, 200, 3, 3, 3);

	                                    scene.addChild(cube);

	                        }

	            }

	}

	 

	 

	 

	 

	Jason Merrill 

	Bank of  America <image001.jpg>  Global Learning 

	Shared Services Solutions Development 

	
	Monthly meetings on the Adobe Flash platform for rich media experiences - join the Bank of America Flash Platform Community <http://sharepoint.bankofamerica.com/sites/tlc/flash/default.aspx>  

	 

	 

	 

	 

	From: papervision3d-bounces at osflash.org [mailto:papervision3d-bounces at osflash.org] On Behalf Of Javier España | javierespana.com
	Sent: Tuesday, June 30, 2009 4:13 PM
	To: papervision3d at osflash.org
	Subject: Re: [Papervision3D] Simple Cube w/Texture

	 

	Try this out instead, it seems that you are using a cube and aren't loading the material list correctly.
	
	            wireframeMaterial = new WireframeMaterial(0x333333);
	            wireframeMaterial.doubleSided = true;
	            ///
	            //BitmapFileMaterial, doubleSided draws the color on both sides of the geometry normals
	            bitmapFileMaterial = new BitmapFileMaterial("AJ.png");
	            bitmapFileMaterial.doubleSided = true;
	            ///
	            var materialsList:MaterialsList = new MaterialsList(); 
	            materialsList.addMaterial(wireframeMaterial, "front"); 
	            materialsList.addMaterial(wireframeMaterial, "back"); 
	            materialsList.addMaterial(bitmapFileMaterial, "left"); 
	            materialsList.addMaterial(wireframeMaterial, "right"); 
	            materialsList.addMaterial(wireframeMaterial, "top"); 
	            materialsList.addMaterial(wireframeMaterial, "bottom"); 
	            ///
	            //cube = new Cube(MaterialList applied to object, width, depth, height, wSegments, dSegments, hSegments);
	            cube = new Cube(materialsList, 200, 200, 200, 3, 3, 3);
	            scene.addChild(cube);
	
	That's a quick example that loads a bitmap on a side of the cube, and renders a wireframe material on the other sides...
	
	Hope it helps =)
	
	Javier

	On Tue, Jun 30, 2009 at 4:48 PM, Merrill, Jason <jason.merrill at bankofamerica.com> wrote:

	Hey all,

	 

	I'm new developing with Papervision3d (though not new to Flash/Flex/Actionscript) and have a really basic problem. I was able to display my first code-generated plane and rotate it, and also load a model collada file built with Swift3d.  Now I am trying to create a box with texture, but having problems.  Here is the relevant part of my code:

	 

	(CubeTexture is a bitmap in Flash CS3 with linkage exported as class: CubeTexture and base class: flash.display.BitmapData)

	 

	var bitmap:Bitmap = new Bitmap(new CubeTexture(0,0));

	material = new MaterialObject3D();

	material.bitmap = bitmap.bitmapData;

	 

	materials = new MaterialsList();

	materials.addMaterial(material);

	 

	primitive = new Cube(materials, 200, 200, 200);

	scene.addChild(primitive);

	 

	I get this error:

	 

	"WARNING: Required material not found in given materials list. Supported materials are: front, back, right, left, top, bottom & all."

	 

	Any ideas what I'm doing wrong?  Thanks.

	 

	 

	Jason Merrill 

	Bank of  America Error! Filename not specified.  Global Learning 

	Shared Services Solutions Development 

	
	Monthly meetings on the Adobe Flash platform for rich media experiences - join the Bank of America Flash Platform Community <http://sharepoint.bankofamerica.com/sites/tlc/flash/default.aspx>  

	 

	
	_______________________________________________
	Papervision3D mailing list
	Papervision3D at osflash.org
	http://osflash.org/mailman/listinfo/papervision3d_osflash.org

	 

	_______________________________________________
	Papervision3D mailing list
	Papervision3D at osflash.org
	http://osflash.org/mailman/listinfo/papervision3d_osflash.org

 


_______________________________________________
Papervision3D mailing list
Papervision3D at osflash.org
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20090702/9e23d2d3/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 1272 bytes
Desc: image001.jpg
URL: <http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20090702/9e23d2d3/attachment-0001.jpg>


More information about the Papervision3D mailing list