|
Gordon, Newbie
Posted: 12 March 2012 07:43 PM Total Posts: 17
Hi all,
as our work with AWAY3D slowly progresses, we encountered a new problem: after loading the model into the engine, it looks like it won’t receive any light, though there is a lightsource in the scene and it even casts shadows:
http://kunden.flashgressive.de/gordonstrauch/away3d/Basic_Load3DS.html
Any ideas? Anyone? Bueller?
|
Fabrice Closier, Administrator
Posted: 12 March 2012 10:09 PM Total Posts: 1265
[ # 1 ]
and how have you defined which material is affected by a given light or set of lights?
Previously in the alpha state where you needed to say something
like material.lights = [mylight];
You need now to define a StaticLightPicker;
The line becomes material.lightPicker = myLightPicker;
The lightPicker can at this state only hold no more than 3 lights.
You can have only one LightPicker per material
|
Gordon, Newbie
Posted: 13 March 2012 12:31 PM Total Posts: 17
[ # 2 ]
Fabrice Closier - 12 March 2012 10:09 PM and how have you defined which material is affected by a given light or set of lights?
Previously in the alpha state where you needed to say something
like material.lights = [mylight];
You need now to define a StaticLightPicker;
The line becomes material.lightPicker = myLightPicker;
The lightPicker can at this state only hold no more than 3 lights.
You can have only one LightPicker per material
We have done exactly what you stated above, but still with no success,
the model remains the same with no light.
Can anybody help please?
|
view, Newbie
Posted: 13 March 2012 01:11 PM Total Posts: 12
[ # 3 ]
i had a similar issue earlier when playing with directional lights and spots lights, i found th edefault directional light was pointing away from my model, which was a loaded obj file which i assume has some different x,y,z settings. i traced the position of the object and reset the light. here is how I did it (it may be wrong but it works)
add the light
private function initLights():void {
light2 = new DirectionalLight(); light2.ambient=1; light2.specular=0.25 //light2.y=500; scene.addChild(light2); lightPicker= new StaticLightPicker([light2]); light2.direction = new Vector3D(0,1,-2); trace("DIRECT",light2.direction); }
add light to mesh
primitiveMaterial = new ColorMaterial(colours[i]); primitiveMaterial.bothSides=true; primitiveMaterial.diffuseLightSources = LightSources.LIGHTS; primitiveMaterial.ambientColor = colours[i]; primitiveMaterial.ambient = 1; primitiveMaterial.specular = .2; //primitiveMaterial.addMethod(new OutlineMethod(0xffffff, 2,true,true)); primitiveMaterial.alpha=1; primitiveMaterial.lightPicker=lightPicker;
w
|
ripe, Newbie
Posted: 13 March 2012 01:44 PM Total Posts: 7
[ # 4 ]
view - 13 March 2012 01:11 PM i had a similar issue earlier when playing with directional lights and spots lights, i found th edefault directional light was pointing away from my model, which was a loaded obj file which i assume has some different x,y,z settings. i traced the position of the object and reset the light. here is how I did it (it may be wrong but it works)
add the light
private function initLights():void {
light2 = new DirectionalLight(); light2.ambient=1; light2.specular=0.25 //light2.y=500; scene.addChild(light2); lightPicker= new StaticLightPicker([light2]); light2.direction = new Vector3D(0,1,-2); trace("DIRECT",light2.direction); }
add light to mesh
primitiveMaterial = new ColorMaterial(colours[i]); primitiveMaterial.bothSides=true; primitiveMaterial.diffuseLightSources = LightSources.LIGHTS; primitiveMaterial.ambientColor = colours[i]; primitiveMaterial.ambient = 1; primitiveMaterial.specular = .2; //primitiveMaterial.addMethod(new OutlineMethod(0xffffff, 2,true,true)); primitiveMaterial.alpha=1; primitiveMaterial.lightPicker=lightPicker;
w
SOLVED!
that did the trick. thanks a million!!
|
Fabrice Closier, Administrator
Posted: 13 March 2012 02:22 PM Total Posts: 1265
[ # 5 ]
K, so here’s a tip:
Always start light with a PointLight, and let it with Number.MaxValue for its fallOff and radius.
Then when you are set material wize, move on to directional lights.
Prefab should soon help you fine tune these things. As you can see on the pict, you can define a direction runtime by simply placing your mouse on the direction picker (the white line), and there is also a trace feature for the awaycode equivalent…
|
ripe, Newbie
Posted: 13 March 2012 02:24 PM Total Posts: 7
[ # 6 ]
thanks, fabrice. that looks really promising!
|
view, Newbie
Posted: 13 March 2012 02:34 PM Total Posts: 12
[ # 7 ]
cheers, prefab is sweet, however when i used it i couldn’t get it the awd file to work when exported, so just saved as obj (probably me being a newb as normal) is awd file likely to be faster or have any additional benefits?
|
Fabrice Closier, Administrator
Posted: 13 March 2012 02:58 PM Total Posts: 1265
[ # 8 ]
awd works just like obj export in Prefab 1.x
But if you load it into away4, you need to tell the api to use the awd parser.
Prefab 1.x exports awd 1 format, the first ascii based version of our format.
Prefab 2.x exports both 1 and 2. V2 is obviously way more efficient but you still can use awd1 if you need to publish to older flash player version, or want to make a parser for javascript/webgl. It is slightly smaller than obj format.
|