Help for a lighting idiot?

Software: Away3D 4.x

peytofu, Newbie
Posted: 16 March 2013 04:00 PM   Total Posts: 3

Pardon my format, but I don’t want to waste too much of your time.
I am having alot of difficulty solving this issue.
I am using away3D 4.0.9.

Goals:
—Create a scene with the perelith knight, a floor, and a light. (done)
—All 3 are created in a class file(package) of their own. (done)
—The light class returns a directional light that colors the scene & casts shadows.

Issue:
When I omit the light class & just create the light in the main/default class, everything works fine(both color & shadows). But when I try to use a light returned from my light class, I only get the default white lighting.

Questions:
—What is the correct structure of a custom class that will return a directional light?
—Should the light be created in a function, and then modified with the custom light class…versus creating the light within the custom light class? Why? (Pardon my ignorance)

I am trying to build the app this way because I want to force OOP as far as I can…because the app will be large when completed.

Many thanks for your help!

   

Avatar
Fabrice Closier, Administrator
Posted: 16 March 2013 06:48 PM   Total Posts: 1265   [ # 1 ]

The question is: how does your class look like and how do you assign the returned light to the staticlightpicker and how the picker is assigned to materials.

   

peytofu, Newbie
Posted: 16 March 2013 08:21 PM   Total Posts: 3   [ # 2 ]

Here is the rough breakdown:

Here is the call from the main class:

_light = new RPTlights();
_view.scene.addChild(_light);
_lightPicker = new StaticLightPicker([_light.setupLight()]); 

Here is the custom light class:

public class RPTlights extends ObjectContainer3D
 {
  
public var _mylight DirectionalLight;
  private var 
_lightPicker StaticLightPicker;
  public function 
RPTlights()
  
{
   super
();
  
}
  
  
public function setupLight():DirectionalLight
  {
   _mylight 
= new DirectionalLight();
   
_mylight.300;
   
_mylight.0;
   
_mylight.0;
   
//_light.lookAt(
   
_mylight.diffuse 0.7;
   
_mylight.ambient 0.1
   _mylight
.ambientColor 0x00ff00;
   
_mylight.specular 0.25
   _mylight
.castsShadows true;
   
_mylight.name "mylight";
   
addChild(_mylight);
   return 
_mylight;
   
  
}
  
  
 } 

Then, I pass the light to the materials class like:

setMaterials(_light.setupLight()); 

Then, I handle the mats… but now this is throwing an error.

public function setMaterials(_tmpLight:DirectionalLight):void{

 floorMats
(_tmpLight);
 
playerMats(_tmpLight);
}
public function floorMats(_tmpLight:DirectionalLight):void
{
 _floorMaterial 
= new TextureMaterial(Cast.bitmapTexture(FloorDiffuse));
 
_floorMaterial.lightPicker _lightPicker;
 
_floorMaterial.specular .3;
 
_floorMaterial.ambient 1;
 
_floorMaterial.repeat true;
 
_floorMaterial.shadowMethod = new NearShadowMapMethod(new FilteredShadowMapMethod(_tmpLight));
}
public function playerMats(_tmpLight:DirectionalLight):void{
 _playerMaterial 
= new TextureMaterial(Cast.bitmapTexture(PlayerDiffuse));
 
_playerMaterial.lightPicker _lightPicker;
 
_playerMaterial.specular .3;
 
_playerMaterial.ambient 1;
 
_playerMaterial.repeat true;
 
_playerMaterial.shadowMethod = new NearShadowMapMethod(new FilteredShadowMapMethod(_tmpLight));
 
   

Avatar
Fabrice Closier, Administrator
Posted: 16 March 2013 09:31 PM   Total Posts: 1265   [ # 3 ]

I do not see why your class is extending objectcontainer3d… simply pass the main scene to this class via constructor, when you declare light addchild it to the scene. When you receive this light in main, add the light to your picker and set it if not done yet.

   

peytofu, Newbie
Posted: 17 March 2013 02:55 PM   Total Posts: 3   [ # 4 ]

Thanks for the help.
I changed the light class to extend directionalLight and I also changed this line:

setMaterials(_light.setupLight());

to be:

setMaterials(_light._mylight);

and now it appears to be behaving.

Thanks again.

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X