Back after being busy for some time, and i’m now (depending on the project) using FlashDevelop so I can use Away3D 4.
But.. i’m not getting the hang of something.. most guides I can find say i’m doing it right.. but it’s not doing it right so.. confused a bit ^_^; some simple error i’m sure.
I’ve created a plane via the mesh->planeGeometry option. When I give it a ColorMaterial, it displays fine, When I give it a TextureMaterial which is casted from an embedded jpg, it doesn’t display any polygons. Debug stats even go from 2 Polys to 0.
since bugger all has been done so far, here is the code (based on one tutorial) i’m using right now:
package
{
import away3d.containers.*;
import away3d.entities.*;
import away3d.materials.*;
import away3d.primitives.*;
import away3d.utils.*;
import away3d.debug.AwayStats;
import away3d.textures.*;
import flash.display.*;
import flash.events.*;
import flash.geom.Vector3D;
[SWF(backgroundColor="#000000", frameRate="60")]
public class Main extends Sprite
{
//plane texture
[Embed(source="Assets/Textures/Grass.jpg")]
public static var GrassFloor:Class;
//engine variables
private var _view:View3D;
//scene objects
private var _plane:Mesh;
public function Main()
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
//setup the view
_view = new View3D();
addChild(_view);
// add away3d debugger
addChild(new AwayStats(_view));
//setup the camera
_view.camera.z = -200;
_view.camera.y = 200;// 500;
_view.camera.lookAt(new Vector3D());
//setup the scene
//var material:ColorMaterial = new ColorMaterial(0x009EE1);
var material:TextureMaterial = new TextureMaterial(Cast.bitmapTexture(GrassFloor));
material.bothSides = true;
_plane = new Mesh(new PlaneGeometry(200, 200), material);
_view.scene.addChild(_plane);
//setup the render loop
addEventListener(Event.ENTER_FRAME, _onEnterFrame);
stage.addEventListener(Event.RESIZE, onResize);
onResize();
}
/**
* render loop
*/
private function _onEnterFrame(e:Event):void
{
_plane.rotationY += 1;
_view.render();
}
/**
* stage listener for resize events
*/
private function onResize(event:Event = null):void
{
_view.width = stage.stageWidth;
_view.height = stage.stageHeight;
}
}
}
the Grass bitmap IS in the correct location, checked by embedded it via the embed code option so that’s all fine.
any idea what stupid thing I’ve done wrong?