Very cool, thank you, katopz!
Will this work on an imported model (max3ds file loaded) once the
object is converted to a mesh? Or is it more complex?
Actually getting compile error:
"1119: Access of possibly undefined property face through a reference
with static type away3dlite.events:MouseEvent3D."
Here is my code if it helps ...
package
{
import away3dlite.core.utils.*;
import away3dlite.cameras.*;
import away3dlite.containers.*;
import away3dlite.core.base.*;
import away3dlite.core.render.*;
import away3dlite.events.*;
import away3dlite.materials.*;
import away3dlite.primitives.*;
import away3dlite.loaders.*;
//import away3dlite.core.base.Face;
//import away3dlite.events.MouseEvent3D;
import net.hires.debug.Stats;
import flash.display.*;
import flash.events.*;
import flash.ui.Keyboard;
import flash.geom.Matrix;
import flash.text.*;
import flash.ui.Keyboard;
import flash.utils.*;
import flash.geom.ColorTransform;
import flash.geom.Matrix;
import flash.geom.Rectangle;
import flash.net.URLRequest;
import com.senocular.utils.*;
//[SWF(backgroundColor="#000000", frameRate="30", quality="LOW",
width="700", height="500")]
[SWF(backgroundColor="#202020", frameRate="60", quality="LOW",
width="700", height="500")]
public class facetest1L extends Sprite
{
//signature swf
[Embed(source="assets/signature_lite.swf", symbol="Signature")]
private var SignatureSwf:Class;
private var scene:Scene3D;
private var camera:HoverCamera3D;
private var view:View3D;
//signature variables
private var Signature:Sprite;
private var SignatureBitmap:Bitmap;
private var mainSphere:Sphere;
//navigation variables
private var move:Boolean = false;
private var lastPanAngle:Number;
private var lastTiltAngle:Number;
private var lastMouseX:Number;
private var lastMouseY:Number;
private var dimX:Number=stage.stageWidth;
private var dimY:Number=stage.stageHeight;
private var KeysPressed = new Array();
private var whatkey:KeyObject;
private var debugText:TextField;
public function facetest1L()
{
init();
}
private function init():void
{
initEngine();
initObjects();
initListeners();
}
private function initEngine():void
{
scene = new Scene3D();
camera = new HoverCamera3D();
camera.panAngle = 45;
camera.tiltAngle = 20;
camera.hover(true);
view = new View3D();
view.scene = scene;
view.camera = camera;
//hack to get framerate up in cs4
var background:Sprite = new Sprite();
background.graphics.lineStyle(1, 0)
background.graphics.drawRect(-400, -300, 800, 600);
view.addChild(background);
//view.addSourceURL("srcview/index.html");
addChild(view);
//add signature
Signature = Sprite(new SignatureSwf());
SignatureBitmap = new Bitmap(new
BitmapData(Signature.width, Signature.height, true, 0));
stage.quality = StageQuality.HIGH;
SignatureBitmap.bitmapData.draw(Signature);
stage.quality = StageQuality.LOW;
addChild(SignatureBitmap);
addChild(new Stats());
}
private function initObjects():void
{
mainSphere = new Sphere();
mainSphere.radius = 200;
mainSphere.x = 0;
mainSphere.z = 0;
mainSphere.y = 0;
scene.addChild(mainSphere);
scene.addEventListener(MouseEvent3D.MOUSE_UP,
onSceneMouseUp);
}
private function initListeners():void
{
whatkey = new KeyObject(stage);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(MouseEvent.MOUSE_DOWN,
onMouseDown);
stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
stage.addEventListener(Event.RESIZE, onResize);
onResize();
}
private function onEnterFrame(event:Event):void
{
//mainSphere.faces[40].material = new
WireColorMaterial();
if(whatkey.isDown(38)) { // "up arrow"
camera.focus += 1;
}
if(whatkey.isDown(40)) { // "down arrow"
camera.focus -= 1;
}
if (move) {
camera.panAngle = 0.3*(stage.mouseX -
lastMouseX) + lastPanAngle;
camera.tiltAngle = 0.3*(stage.mouseY -
lastMouseY) +
lastTiltAngle;
}
camera.hover();
view.render();
}
private function onSceneMouseUp(e:MouseEvent3D):void
{
//if (e.object is Mesh) {
// var mesh:Mesh = e.object as Mesh;
// mesh.material = new WireColorMaterial();
//}
var _face:Face = e.face;
_face.material = new ColorMaterial(int(Math.random() *
0xFFFFFF));
}
/**
* Mouse down listener for navigation
*/
private function onMouseDown(event:MouseEvent):void
{
lastPanAngle = camera.panAngle;
lastTiltAngle = camera.tiltAngle;
lastMouseX = stage.mouseX;
lastMouseY = stage.mouseY;
move = true;
stage.addEventListener(Event.MOUSE_LEAVE,
onStageMouseLeave);
}
private function onMouseUp(event:MouseEvent):void
{
move = false;
stage.removeEventListener(Event.MOUSE_LEAVE,
onStageMouseLeave);
}
private function onStageMouseLeave(event:Event):void
{
move = false;
stage.removeEventListener(Event.MOUSE_LEAVE,
onStageMouseLeave);
}
private function onResize(event:Event = null):void
{
view.x = stage.stageWidth / 2;
view.y = stage.stageHeight / 2;
SignatureBitmap.y = stage.stageHeight - Signature.height;
}
}
}
On Jul 12, 10:46 am, katopz <[email protected]> wrote:
> like this?http://away3d.googlecode.com/svn/branches/lite/bin/ExFaceClick.swf
>
> srchttp://away3d.googlecode.com/svn/branches/lite/src/interactives/ExFac...
>
> libshttp://away3d.googlecode.com/svn/branches/lite
>
> that's only for material, not sure on explode
>
> hth
>
> On 13 July 2010 00:42, Joseph <[email protected]> wrote:
>
>
>
>
>
> > Hello,
>
> > Does away3dlite have the ability to texture a specified face of an
> > object?
>
> > I seem to remember one could "explode" an object to seperate into
> > individual meshes in away3d. These exploded faces could then have
> > textures specified and other tricks done with them.
>
> > I noticed explode doesn't exist anymore in lite (as far as I can
> > tell).
>
> > How else can this be achieved?
>
> > Thanks!
>
> --
> Regards
> -----------------------------------------------------------
> Todsaporn Banjerdkit, katopz,http://sleepydesign.com
> Away3DLite and JigLibFlash Developer Team- Hide quoted text -
>
> - Show quoted text -