[Resolved] 3DS LightPicker Problem

Software: Away3D 4.x

Jeds, Newbie
Posted: 29 June 2012 05:28 AM   Total Posts: 5

Hi Everyone,

I am new in Away3D. I would like to ask the help of everyone because I have been trying to make this code work for the past few days and it seems I am stuck with this LightPicker thingy.

Basically this is my code for initializing the PointLight and LightPicker which is then I used to apply on the texture material of my 3DS file.

private var staticLightPicker:StaticLightPicker;
  private var 
pointlight_0:PointLight;
  
  private function 
initLights():void
  {
   pointlight_0 
= new PointLight();
   
pointlight_0.ambientColor 0xFFFFFF;
   
pointlight_0.diffuse 1;
   
pointlight_0.0;
   
pointlight_0.0;
   
pointlight_0.500;
   
pointlight_0.castsShadows false;
   
pointlight_0.ambient 0.5;
   
pointlight_0.fallOff Number.MAX_VALUE ;
   
pointlight_0.name "pointlight_0";
   
pointlight_0.specular 0.8;
   
pointlight_0.color 0xFFFFFF;
   
pointlight_0.radius Number.MAX_VALUE ;
   
   
// Setup the static light picker
   
staticLightPicker = new StaticLightPicker([pointlight_0]);
   
   
// Add the light to the Away3D scene
   
scene.addChild(pointlight_0);
   
  
}
  
  
private var objLoader3d:Loader3D;
  
  private function 
loadMapObj():void
  {
   Parsers
.enableAllBundled();
   
   var 
loaderContext:AssetLoaderContext = new AssetLoaderContext(true"assets2");
   
   
objLoader3d = new Loader3D();
   
objLoader3d.addEventListener(AssetEvent.ASSET_COMPLETEmapObjAssetLoaded);
   
objLoader3d.addEventListener(LoaderEvent.RESOURCE_COMPLETEonAwdComplete);
   
objLoader3d.load(new URLRequest("assets2/Map_LVL3.3DS"), loaderContext);
  
}
  
  
private function onAwdComplete(e:LoaderEvent):void 
  {
   container3D
.addChild(objLoader3d);
  
}
  
  
private var mapTextureMaterial:MaterialBase;
  
  private function 
mapObjAssetLoaded(e:AssetEvent):void 
  {
   
switch (String(e.asset.assetType))
   
{
    
case AssetType.MESH:
     break;
    case 
AssetType.TEXTURE:
     break;
    case 
AssetType.MATERIAL:
     if (
e.asset is TextureMaterial{
      mapTextureMaterial 
e.asset as TextureMaterial;
      
      (
mapTextureMaterial as TextureMaterial).lightPicker staticLightPicker;
      (
mapTextureMaterial as TextureMaterial).diffuseLightSources LightSources.LIGHTS;
      
     
else {
      mapTextureMaterial 
e.asset as ColorMaterial;
      (
mapTextureMaterial as ColorMaterial).lightPicker staticLightPicker;
     
}
     
     
break;
    
    case 
AssetType.GEOMETRY:
     break;
    default:
     break;
   
}
   
  } 

Normally, the 3DS file without LightPicker on my code looks like as per attachment 1.

Using prefab, I attached a LightPicker with it and it looks like as per attachment No 2.

However, if I assign my LightPicker on TextureMaterial in my code it appears like as per attachment No 3. The meshes looks ugly and nothing like attachment no 2.

Any help is greatly appreciated.

Edit: From Prefab3D, it is reporting this message whenever I load the 3DS file:

One or more normals buffers were either empty or invalid(65)
The normals buffer was rebuilded.

If this is what’s causing my problem, how do I do the same thing like Prefab3D to fix the normals as I load the 3DS file.

 

   

Avatar
theMightyAtom, Sr. Member
Posted: 29 June 2012 08:11 AM   Total Posts: 669   [ # 1 ]

wild guess, Number.MAX_VALUE is returning something the engine can’t use. Try 100000 instead.

Good Luck!

   

Jeds, Newbie
Posted: 29 June 2012 08:17 AM   Total Posts: 5   [ # 2 ]

tried but did not work. but thanks for reply theMightyAtom

I really think this has something to do with geometry normals of the 3DS, too bad I cant re-save the 3DS under prefab3D.

If I can just find out how prefab fixes the normals on model import, maybe I could also do it on the fly raspberry

cheers and hope more inputs to come :D

   

Avatar
theMightyAtom, Sr. Member
Posted: 29 June 2012 08:42 AM   Total Posts: 669   [ # 3 ]

Sorry, I did not read your entire post thoroughly
You can get Away to rebuild your normals.
I the mesh part of you loading callback, try adding
autoDeriveVertexNormals and autoDeriveVertexTangents

http://www.away3d.com/livedocs/away3d/4.0/away3d/core/base/SubGeometry.html

If it’s a normals error, that should fix it for most simple geometry.
Otherwise you need to do it in a software package like 3D studio Max, or even better, save it out as AWD2 from Prefab!

   

Richard Olsson, Administrator
Posted: 29 June 2012 08:47 AM   Total Posts: 1192   [ # 4 ]

It doesn’t look like a normals issue (but it’s hard to tell) with the extreme lighting and it’s not even likely to be a normal issue because the engine automatically rebuilds them if they are missing (as they very often, mostly even, are.)

It’s also not really an issue with the light picker per sé. Instead, I’m pretty sure you simply need to tweak your light settings. If you like the result you get in Prefab, I suggest you just use the exact same light settings in Away3D. You can even export your Prefab scene as AS3 and look at how it configures it’s lights.

   

Jeds, Newbie
Posted: 29 June 2012 11:32 AM   Total Posts: 5   [ # 5 ]

Hi folks,

Thanks for the responses.

theMightyAtom, I used autoDeriveVertexNormals and autoDeriveVertexTangents but it seems it didn’t made any difference but your export to AWD2 from Prefad3D suggestion worked for me. I was meticulous to try the AWD2 export before because I was getting “unexpected end of file” messages during load the first time I used it. Although the texture export isn’t working yet, its I’m still grateful for Prefab3D to be able to export the geometry information.

I also tried to look at the AS3 code as Richard suggested, but I think the LightPicker from Prefab3D is not being included during export to AS3.

I also suggested to the 3D designer about cleaning up the geometry because of this article I found: http://www.3dbuzz.com/vbforum/showthread.php?157746-Tutorial-Bad-Geometry-?-How-to-find-and-fix-it although seems not needed as Richard said that the engine automatically does it. raspberry


I also hope that Prefab3D could implement animation/texture export for AWD2 sooner as I read was a more reliable format to carry out with away3D programs.

Thanks to both of you guys. I can now proceed to new level in learning this great flash 3D framework. More power to away3D community!

 

   

Avatar
Fabrice Closier, Administrator
Posted: 29 June 2012 11:53 AM   Total Posts: 1265   [ # 6 ]

Next update will have material.texture export (diffuse only). Once awd 2.1 specs will have normalmaps and specularMaps support, i’ll add it.
awd2 export with skeleton animation works and will also be in next update. Problem for me is to allow more skeleton anim inputs as Prefab is not yet able to generate these. Regarding lights, there is on light panel a tiny white away logo, if you press it it will spit the away code for you.
and finally, have you tried LightHelper?

AS3 export do not include lights yet… If I find some time, I may push it in the next update, otherwize the one after that.

   

Jeds, Newbie
Posted: 02 July 2012 05:15 AM   Total Posts: 5   [ # 7 ]

wow, that’s very good to know Fab. Thank you so much =)

Yes I used the LightHelper. It was very useful. That gave me hope to know that things can work apart from what I was getting in my code.

Once again, I thank you all for immediate responses. Greatly appreciated.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X