|
Josh Strike, Newbie
Posted: 07 October 2011 11:43 PM Total Posts: 11
Hey all. I haven’t gotten into 4.0 yet, but could anyone help me out with a couple migration questions?
1. ShadingColorMaterial—what’s the replacement? Is there a flat material w/ diffuse, specular and transparency built into the new engine?
2. ScreenVertex—I noticed in the docs that the output of Camera3D.screen() is now a Point. Which in most cases is fine, but screen() no longer seems to take the argument as a Vertex/Vector3D relative to the mesh or object it’s part of, which could be a problem in some use cases. Does that mean it’s assuming the local position of the Vector3D that’s passed into it now? Or is it assuming a point in global view space?
Thanks for any help. To anyone interested, I’ve had away3d (v.1.x) running since 2005 or so at joshstrike.com ...it’s also in use for various games at my new site StrikeSapphire.com (not available in the US). There’s a new game I’m about to roll out that averages only about 200 polygons and a point light, but requires very fast blitting, gimble-lock-free rotations with quaternions, and a lot of vertex comparisons for parsing gestures, and it’s pushing the limits (it’s also running in a demanding environment, side by side with 5 other games). I want to force our users to upgrade to Flash 11 ASAP so this draws off the GPU, but it relies on the two points above for its speed and accuracy, in that order.
|
Richard Olsson, Administrator
Posted: 08 October 2011 02:13 AM Total Posts: 1192
[ # 1 ]
1. Yes. Just use ColorMaterial and enable shading by setting myMaterial.lights = [ mylight1, mylight2 ]. Tweak the shading using the diffuse and specular properties and shading methods.
2. What is the problem here? ScreenVertex was always a point in screen space, and since screen space is 2D we’re now using Point to represent it. If you could clarify the problem you’re experiencing with the current solution we might be able to help.
Cheers
/R
|
Josh Strike, Newbie
Posted: 08 October 2011 12:26 PM Total Posts: 11
[ # 2 ]
Ah, thanks for the material info.
I guess I asked my question badly about the Camera3D.screen function. Is Camera3D.project supposed to be the replacement for screen?
ScreenVertex (edit: or the Vector3D that was returned by screen() in 3.6) was a 3D point, not a 2D point. Sometimes that depth information (distance from camera) was very useful, e.g. depth of field blurs. Also, you sent screen() an object3d and a vertex, so you didn’t have to convert the vertex to a vector3d in global space first.
What’s the recommended method for getting the lensed 3D coordinates of a Vertex from the Camera’s POV, in 4.0?
|
Richard Olsson, Administrator
Posted: 08 October 2011 03:56 PM Total Posts: 1192
[ # 3 ]
Use project, and make sure that the vector you pass in is in scene space. If you are getting the position from a vertex in a mesh, use that mesh’s sceneTransform to get it into scene space.
|
Josh Strike, Newbie
Posted: 08 October 2011 05:35 PM Total Posts: 11
[ # 4 ]
Thanks
But, assuming it’s a vertex in a mesh, how would I get its distance from the camera? Tell me if I’m right… so far, to replicate the behavior of Camera3D.screen(), it would be:
public function screen(obj:ObjectContainer3D,vertex:Vertex):Vector3D {
var screenpos:Vector3D = obj.sceneTransform.transformVector(new Vector3D(vertex.x,vertex.y,vertex.z));
this.project(screenpos); //but suppose I want this to include a z coordinate. How do I get the distance of the point from the camera?
return (screenpos);
}
|
Josh Strike, Newbie
Posted: 09 October 2011 06:39 PM Total Posts: 11
[ # 5 ]
Sorry for asking again, but I still don’t get it: How would you get the 3D coordinates of a vertex in screen space (x, y and depth from the camera), relative to the camera’s lens, without Camera3D.screen() ? Is there a clean way to do it?
|
Josh Strike, Newbie
Posted: 10 October 2011 09:24 PM Total Posts: 11
[ # 6 ]
|