Monday, August 25, 2008

papervision 3d

Have loaded a complex model using the as3 geom exporter, which compiles the model information on export, embedding it with the flash swf, avoids parsing the file later on like collada.
Also coded 3d camera movement around the object. I had the object rotating, but want later on to rotate the parts of the object separately. Had trouble finding examples of even camera movement around the object.
It might take a moment to load, will build that in later

Here is the example with markers to show your how the sin() works
also learnt how to UVW unwrap on the way, this example is a box unwrap, hence the shadows. There are not lights in this scene so it needs baked on lights to show the form.
here is the code for the camera movement

sh = stage.stageWidth;
Pi = Math.PI/180;
mY = ((mouseY/sh)*180) * Pi;
mX = ((mouseX/(sh/2))*180) * Pi;
radY1 =mY+1.8;
radY2 =mY+3.2;
radX1 =mX+1.8;
radZ =mX+3.3;


closY1 = 100*Math.sin(radY1);
closY2 = 100*Math.sin(radY2);
closX1 = 100*Math.sin(radX1);
closZ = 100*Math.sin(radZ);

camX = (1*(closX1 * ((-closY2)/100)));
camZ = closZ* ((-closY2)/100);
///


default_camera.x=camX;
default_camera.y=closY1;
default_camera.z=camZ

default_camera.lookAt (objectArray[0]);

No comments: