[Papervision3D] [PAPERVISION 3D] - problems with multiple equal MovieAssetMaterials
o renken
renkster at gmail.com
Tue Jun 5 19:39:05 EDT 2007
hey,
maybe i asked a little bit too diffuse. i prepared the helloHotspot example.
what i want to do is to attach some planes to the scene and spend them
a texture from a libary asset. like we do the whole time in flash.
youve got an mc with some textfields and lets say a container for an
image. its only one MC in the lib and x instances on stage.
if i try this with an MovieAssetMaterial for a plane-object that doesnt work!
maybe the material have to be cloned after updating.
here is the example. there a two situations youll see it in the comments
situation 1) one material for all planes. feeding its textfield in the
for-loop with the loop-id and updateBitmap() . 49 planes with the same
material and the same number on it 49
situation2) a new material for each plane in the for-loop. result:
only the first plane is visible. thats the problem i talked about
use helloHotspot.fla und create a MovieAsset from the bitmap called : MC_bitmap
base = revision 75 AS2
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.materials.MovieAssetMaterial;
import org.papervision3d.scenes.MovieScene3D;
import org.papervision3d.objects.Plane;
class HelloHotspot extends MovieClip
{
// _______________________________________________________________________
// vars3D
var container :MovieClip;
var scene :MovieScene3D;
var camera :Camera3D;
// _______________________________________________________________________
// Main
function HelloHotspot()
{
init3D();
this.onEnterFrame = loop3D;
}
// _______________________________________________________________________
// Init3D
function init3D()
{
// Create container movieclip and center it
container = this.createEmptyMovieClip( "container",
this.getNextHighestDepth() );
container._x = 320;
container._y = 240;
// Create MovieScene for hotspot mode
// This scene renders each object in a separate movie clip, so you
can add events to them easily.
// This movie clip is called container.
scene = new MovieScene3D( container );
// Create camera
camera = new Camera3D();
camera.z = -2000;
camera.zoom = 1;
camera.focus = 500;
//
// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::START::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//
// 1) OFF -> try to write the loop-index(i) inside of the
MovieAssetMaterial container(movie) TextField (TF)
// 1) result: same texture each plane, here have maybe some
bitmap-cloning to be done?
// 2) ON -> try to attach the same MovieAssetMaterial for each
plane pushed into the MovieScene3D
// 2) result: only the first attached plane gets textured
// Create material
// 1) var material :MovieAssetMaterial = new MovieAssetMaterial(
"MC_Bitmap" );
// 1) material.oneSide = false; // Make it double sided
// Create Planes x50
var radius:Number = 2500;
for( var i:Number = 0; i < 50; i++ )
{
// try to attach the same Flash Libary Asset for each plane attached
// 2) var material :MovieAssetMaterial = new MovieAssetMaterial(
"MC_Bitmap" );
// 2) material.oneSide = false;
var material :MovieAssetMaterial = new MovieAssetMaterial( "MC_Bitmap" );
material.oneSide = false;
//
// :::::::: some dynamic stuff for the planes texture:::::::::::::::::::
//
material.movie.TF.text=i
material.updateBitmap()
//
// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//
// 2) scene.push(material) // ?? doesnt work, too
scene.push(material) // ?? doesnt work, too
// :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::END::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
var plane :Plane = new Plane( material, 1.5 );
// Randomize position
plane.x = Math.random() * radius - radius/2;
plane.y = Math.random() * radius - radius/2;
plane.z = Math.random() * radius - radius/2;
// Randomize rotation
plane.rotationX = Math.random() * 360;
plane.rotationY = Math.random() * 360;
plane.rotationZ = Math.random() * 360;
// Include in scene
scene.push( plane );
var container:MovieClip = plane.container;
container._alpha = 50;
container.onRollOver = function()
{
this._alpha = 100;
this.displayObject3D.scaleX = this.displayObject3D.scaleY = 1.5;
};
container.onRollOut = container.onReleaseOutside = function()
{
this._alpha = 50;
this.displayObject3D.scaleX = this.displayObject3D.scaleY = 1;
};
container.onPress = function()
{
this.displayObject3D.visible = false;
};
}
}
// _______________________________________________________________________
// Loop
function loop3D()
{
// Some easing for the camera
camera.x -= (camera.x + container._xmouse) /8;
camera.y -= (camera.y + container._ymouse) /8;
// Render
scene.renderCamera( camera );
}
}
i guess somebody had this problem before?!
goodnite
olee
--
http://www.renkster.de/#/about/
More information about the Papervision3D
mailing list