hello. I am using away 3d 3.6.0. I have a character loaded into a scene with hovercam3d targeting it inside of a skybox. I would like to posistion the character at the base of the skybox. how do i do this while the hovercam is targeting the mesh.
here is an example: http://www.swfcabin.com/open/1313794246
my character mesh is given the variable “sphere”
here is the code:
package
{
import away3d.core.session.BitmapSession;
import away3d.debug.AwayStats;
import away3d.core.utils.Cast;
import away3d.containers.*;
import away3d.core.base.*;
import away3d.lights.*;
import away3d.materials.*;
import away3d.materials.utils.*;
import away3d.primitives.*;
import away3d.primitives.utils.*;
import away3d.sprites.*;
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import away3d.materials.Dot3BitmapMaterial
/**
* ...
* @author Olubukola Laditan
*/
[SWF(width="800", height="600", frameRate="30", backgroundColor="0x000000")]
public class CharacterADemo extends Sprite
{
[Embed(source='left.png')]
private var PanoramaImageL : Class;
[Embed(source='right.png')]
private var PanoramaImageR : Class;
[Embed(source='top.png')]
private var PanoramaImageU : Class;
[Embed(source='bottom.png')]
private var PanoramaImageD : Class;
[Embed(source='back.png')]
private var PanoramaImageB : Class;
[Embed(source='front.png')]
private var PanoramaImageF : Class;
[Embed(source='diffuse1_character1.png')]
private var _texture : Class;
[Embed(source='specular1_character1.png')]
private var _specularMap : Class;
[Embed(source='normal_character1.png')]
private var _normalMap : Class;
[Embed(source='groundDiffuseMap1.png')]
private var _grass : Class;
[Embed(source='groundSpecularMap1.png')]
private var _grassSpecular : Class;
[Embed(source='groundNormalMap1.png')]
private var _grassNormal : Class;
private var _view: View3D;
private var panoramaMaterialF:BitmapMaterial;
private var panoramaMaterialL:BitmapMaterial;
private var panoramaMaterialB:BitmapMaterial;
private var panoramaMaterialR:BitmapMaterial;
private var panoramaMaterialU:BitmapMaterial;
private var panoramaMaterialD:BitmapMaterial;
private var _container:CharacterA2;
private var _characterAMesh:Mesh;
private var _floorMesh:Mesh;
private var _characterAMaterial:Dot3BitmapMaterialF10;
private var _floorMaterial:Dot3BitmapMaterialF10;
private var _light: PointLight3D;
private var _light2: PointLight3D;
private var _ambient: AmbientLight3D;
private var _directional : DirectionalLight3D;
private var _count: Number = 0;
private var _hiQual: Boolean = false;
private var _sign: Bitmap;
private var _origin:Vector3D = new Vector3D()
private var skyBox:Skybox;
public function CharacterADemo()
{
stage.quality = StageQuality.LOW;
initView();
initSkyBox();
initLights();
initMaterials();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(MouseEvent.CLICK, onClick);
}
private function onClick(event:MouseEvent):void
{
_hiQual = !_hiQual;
if (_hiQual)
stage.quality = StageQuality.HIGH;
else
stage.quality = StageQuality.LOW;
}
private function initMaterials() : void
{
// multiple lights hitting the surface
_characterAMesh.material = new Dot3BitmapMaterialF10(Cast.bitmap(_texture), Cast.bitmap(_normalMap));
// only rendering green light for the floor
_floorMesh.material = new Dot3BitmapMaterialF10(Cast.bitmap(_grass), Cast.bitmap(_grassNormal));
}
private function initView():void
{
_view = new View3D({x: stage.stageWidth * .5, y:stage.stageHeight *.5});
_view.addSourceURL("srcview/index.html");
addChild(_view);
_container = new CharacterA2();
_container.scaleX = _container.scaleY = _container.scaleZ = 1;
_floorMesh = _container.meshes[0];
_characterAMesh = _container.meshes[1];
_container.x += 30;
_container.y += 200;
_container.rotationY = 0;
_container.rotationX = 90;
_view.scene.addChild(_container);
_view.camera.z = 1500;
var characterAMesh :Mesh = _container.meshes[1];
_characterAMesh.material = _characterAMaterial;
var floorMesh:Mesh = _container.meshes[0];
_floorMesh.material = _floorMaterial;
}
private function initSkyBox():void
{
panoramaMaterialF = new BitmapMaterial(Cast.bitmap(PanoramaImageF));
panoramaMaterialL = new BitmapMaterial(Cast.bitmap(PanoramaImageL));
panoramaMaterialB = new BitmapMaterial(Cast.bitmap(PanoramaImageB));
panoramaMaterialR = new BitmapMaterial(Cast.bitmap(PanoramaImageR));
panoramaMaterialU = new BitmapMaterial(Cast.bitmap(PanoramaImageU));
panoramaMaterialD = new BitmapMaterial(Cast.bitmap(PanoramaImageD));
skyBox = new Skybox(
panoramaMaterialF,
panoramaMaterialL,
panoramaMaterialB,
panoramaMaterialR,
panoramaMaterialU,
panoramaMaterialD
);
skyBox.scale(0.005);
skyBox.rotationY = 180;
_view.scene.addChild(skyBox);
}