mesh placement within Skybox

Software: Away3D 3.x

Avatar
oladitan, Member
Posted: 20 August 2011 12:12 AM   Total Posts: 71

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 
_viewView3D;
  
  
  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 
_lightPointLight3D;
  private var 
_light2PointLight3D;
  private var 
_ambientAmbientLight3D;
  private var 
_directional DirectionalLight3D;
  
  private var 
_countNumber 0;
  
  private var 
_hiQualBoolean false;
  private var 
_signBitmap;
  private var 
_origin:Vector3D = new Vector3D()
  private var 
skyBox:Skybox;
  
  public function 
CharacterADemo() 
  
{
   stage
.quality StageQuality.LOW;
   
initView();
   
initSkyBox();
   
initLights();
   
initMaterials();
   
   
addEventListener(Event.ENTER_FRAMEonEnterFrame);
   
stage.addEventListener(MouseEvent.CLICKonClick);   
  
}
  
  
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({xstage.stageWidth .5y: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.+= 30;
   
_container.+= 200;
   
_container.rotationY 0;
   
_container.rotationX 90;
   
_view.scene.addChild(_container);
   
   
_view.camera.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);
  
   

Somokon, Member
Posted: 20 August 2011 12:33 AM   Total Posts: 75   [ # 1 ]

Skyboxes are meant to always be “infinitely far away”, so if I understand you correctly, you can’t put an object at the base of the skybox, as no matter where you position the object, the skybox will always look the same

   

Avatar
oladitan, Member
Posted: 20 August 2011 01:37 AM   Total Posts: 71   [ # 2 ]

thank you Somocon. Do you know of any examples of objects that looks well grounded inside of a skybox?

   

Avatar
oladitan, Member
Posted: 21 August 2011 01:02 PM   Total Posts: 71   [ # 3 ]

Hello I have used the Advanced Multipass Lantern Demo Code and textures by David Lenaerts http://www.derschmale.com Model by Fabrice Closier http://www.closier.nl/ to help with my skybox and mesh configuration. I have made some changes such as changing the material from a PhongMultiPassMaterial to a Dot3BitmapMaterialF10. I am having some weird behavior with the ground mesh and the characther mesh. I have updated the code in my first post, and here is a demo:

http://www.swfcabin.com/open/1313928317.

as you can see the faces are not being rendered how they should. I say this becuse the eyes show through the helmet, his body shows through his armor. also the ground mesh occludes his boot and disapears at certain angles. thank you in advance for help.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X