I found a weird bug that prevents my code from working since I switched from
the broomstick download zip-version from last week to the latest svn
revision: when I now add a light to a material of an loaded object, the
object won't get rendered any more. I have no idea what could cause this
because I had no problems with adding lights to the same objects with the
broomstick version from last week.
I broke it down to the following little testcode, the obj-file can be
downloaded here:
http://die-beiden.com/_temp/broomstick/maptest2.obj
public class loadTest extends Sprite
{
private var _view:View3D;
private var _scene:Scene3D;
private var _light:PointLight;
private var mat:ColorMaterial;
private var mat2:ColorMaterial;
private var terrain:ObjectContainer3D;
[Embed(source="maptest2.obj",
mimeType="application/octet-stream")]
private var Terrain : Class;
public function loadTest()
{
addEventListener(Event.ADDED_TO_STAGE, doStart);
}
private function doStart(e:Event):void
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
_view = new View3D();
addChild(_view);
_light = new PointLight();
_view.scene.addChild(_light);
mat = new ColorMaterial(0x0000ff);
mat2 = new ColorMaterial(0x00ff00);
//mat.lights = [_light]; //<== when uncommented, the blue
terrain won't get rendered
terrain = new ObjectContainer3D();
ResourceManager.instance.addEventListener(ResourceEvent.RESOURCE_RETRIEVED,
onThingsLoaded);
terrain =
ObjectContainer3D(ResourceManager.instance.parseData(new Terrain(),
"terrain", true));
var plane:Plane = new Plane(mat2, 300, 300);
plane.x = 200;
_view.scene.addChild(terrain);
_view.scene.addChild(plane);
_view.camera.y = 100;
_view.camera.lookAt(plane.position);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onThingsLoaded(e:ResourceEvent):void
{
var mesh:Mesh;
for (var i : int = 0; i <
ObjectContainer3D(e.resource).numChildren; ++i) {
mesh = Mesh(ObjectContainer3D(e.resource).getChildAt(i));
mesh.geometry.scale(8);
mesh.material = mat;
}
}
private function onEnterFrame(e:Event):void
{
_view.render();
}
}
Any help would be appreciated :)
cheers,
sven