Trouble with Skybox Tutorial

Software: Away3D 4.x

christiancillo, Newbie
Posted: 07 January 2013 12:30 PM   Total Posts: 8

Hi everyone!! I’m new, so please forgive me if i’m posting in the wrong place.

It’s lame, but i’m having trouble with the skybox tutorial. When i try to apply the jpg’s to form the BitmapCubeTexture, i get an error saying that BitmapCubeTexture only accepts 1 argument. But I know you need 6!

Sorry, English is not my first language and i’m having trouble explaining myself. Take a look at the code, please.

var cubeTexture:BitmapCubeTexture = new BitmapCubeTexture(
     
Cast.bitmapData(EnvPosX), Cast.bitmapData(EnvNegX), Cast.bitmapData(EnvPosY), 
     
Cast.bitmapData(EnvNegY), Cast.bitmapData(EnvPosZ), Cast.bitmapData(EnvNegZ)
    ); 

I have no idea how to fix this, or whatever it is i am doing wrong. So i’d appreciate some help. Thank you smile

   

_kihu, Jr. Member
Posted: 07 January 2013 02:32 PM   Total Posts: 43   [ # 1 ]

Please post the whole code you have. The line you’ve posted is ok.

   

christiancillo, Newbie
Posted: 07 January 2013 02:34 PM   Total Posts: 8   [ # 2 ]

Ok, there smile

package  {
 
 import away3d
.cameras.lenses.*;
 
import away3d.containers.*;
 
import away3d.entities.*;
 
import away3d.materials.*;
 
import away3d.materials.methods.*;
 
import away3d.primitives.*;
 
import away3d.textures.*;
 
import away3d.utils.*;

 
import flash.display.*;
 
import flash.events.*;
 
import flash.geom.Vector3D;
 
 
 public class 
PruebaSkybox extends Sprite 
 {
  
  
private var _view:View3D;

  
//scene objects
  
private var _skyBox:SkyBox
  private var 
_torus:Mesh;
  
  public function 
PruebaSkybox() 
  
{
   stage
.scaleMode StageScaleMode.NO_SCALE;
   
stage.align StageAlign.TOP_LEFT;

   
//setup the view
   
_view = new View3D();
   
addChild(_view);

   
//setup the camera
   
_view.camera.= -600;
   
_view.camera.0;
   
_view.camera.lookAt(new Vector3D());
   
_view.camera.lens = new PerspectiveLens(90);

   
//setup the cube texture
   
var cubeTexture:BitmapCubeTexture = new BitmapCubeTexture(
     
Cast.bitmapData(EnvPosX), Cast.bitmapData(EnvNegX), Cast.bitmapData(EnvPosY), 
     
Cast.bitmapData(EnvNegY), Cast.bitmapData(EnvPosZ), Cast.bitmapData(EnvNegZ)
    );

   
//setup the environment map material
   
var material:ColorMaterial = new ColorMaterial();
   
material.addMethod(new EnvMapMethod(cubeTexture1));

   
//setup the scene
   
_torus = new Mesh(new TorusGeometry(150604020), material);
   
_view.scene.addChild(_torus);

   
_skyBox = new SkyBox(cubeTexture);
   
_view.scene.addChild(_skyBox);

   
//setup the render loop
   
addEventListener(Event.ENTER_FRAME_onEnterFrame);
   
stage.addEventListener(Event.RESIZEonResize);
   
onResize();
  
}
  
  
private function _onEnterFrame(e:Event):void
  {
   _torus
.rotationX += 2;
   
_torus.rotationY += 1;

   
_view.camera.position = new Vector3D();
   
_view.camera.rotationY += 0.5*(stage.mouseX-stage.stageWidth/2)/800;
   
_view.camera.moveBackward(600);

   
_view.render();
  
}

  
/**
   * stage listener for resize events
   */
  
private function onResize(event:Event null):void
  {
   _view
.width stage.stageWidth;
   
_view.height stage.stageHeight;
  
}
 }
 

Thank you very much!

   

_kihu, Jr. Member
Posted: 07 January 2013 02:41 PM   Total Posts: 43   [ # 3 ]

In the example notice the following lines:

// Environment map.
  
[Embed(source="../embeds/skybox/snow_positive_x.jpg")]
  
private var EnvPosX:Class;
  
[Embed(source="../embeds/skybox/snow_positive_y.jpg")]
  
private var EnvPosY:Class;
  
[Embed(source="../embeds/skybox/snow_positive_z.jpg")]
  
private var EnvPosZ:Class;
  
[Embed(source="../embeds/skybox/snow_negative_x.jpg")]
  
private var EnvNegX:Class;
  
[Embed(source="../embeds/skybox/snow_negative_y.jpg")]
  
private var EnvNegY:Class;
  
[Embed(source="../embeds/skybox/snow_negative_z.jpg")]
  
private var EnvNegZ:Class; 

They’re placed in variable declaration piece of code. The code in brackets [] is used to embed external files into your program. These are the images from which the skybox is composed. Paste this code into your class and make sure you have embeds/skybox folder with jpg’s inside.

   

christiancillo, Newbie
Posted: 07 January 2013 03:09 PM   Total Posts: 8   [ # 4 ]

Thank you, the problem is fixed now. I thought i read somewhere that it was enough importing the images to the library, but apparently i misunderstood. Thanks again!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X