Showing posts with label Away3DLite Tutorial. Show all posts
Showing posts with label Away3DLite Tutorial. Show all posts

Wednesday, June 30, 2010

Tracking Vertices In Away3D Animated 3D Models

Tracking Vertex Positions In Away3D MovieMesh Class For Animated Models In Away3dLite (Jan. 28th 2010 )

**Useful for interchangeable handheld weapons for models to find attachment points**

Add MovieMesh Variable Declaration:
public var leftHandx:Number;

public var leftHandy:Number;

public var leftHandz:Number;


MovieMesh.onEnterFrame:

Place after "while(i--)" update of all vertices:

var tempOffset:int = 100;

leftHandx = _vertices[(tempOffset*3)];

leftHandy = _vertices[(tempOffset*3) + 1];

leftHandz = _vertices[(tempOffset*3) + 2];


Added to MyProject code:

mySphere = new Sphere();
mySphere.radius = 10;
mySphere.x = mySphere.y = mySphere.z = 0;
scene.addChild(mySphere);


MyProject.onEnterFrame:

//trace(mesh.leftHandx);
mySphere.x = mesh.leftHandx;
mySphere.y = mesh.leftHandy;
mySphere.z = mesh.leftHandz;

Fixing MD2 Model Animation Play In Away3dLite

Fixing MD2 Model Animation Play ( Away3dLite - Jan. 28th 2010 )

I made a note of this fix early in development of a project where the MD2 animation kept playing in entirety initially and then played the desired loop.

I haven't verified this %100 as an issue as I was using certain test models at the time and attempting proper Md2 generation simultaneously. The following code is my modification to correct this MovieMesh play error in AS3:

In class MovieMesh.onEnterFrame:

//CGG - January 28th 2010 - 11:31 pm

//Added this check and set to stop animation from

//playing through from beginning before finally

//entering desired loop animation


if(_otime == 0){

_otime = getTimer();

}

//end of CGG edit above

NOTE: I checked this out again and I can't see any differences with or without it... was it a frame name problem???

NOTE: I think I just confirmed that this actually is a problem but the best test case is with two animations each with a sizable length like 70 frames. I could barely notice the issue but I uncommented the hack and the problem went away.

The version of Away3DLite should have been the most current as of Jan. 28th 2010.

I wonder if anyone else saw this?

Real Position of Object from Inside a Moving Container in Away3DLite Tutorial

Real Position of a Sphere from Inside a Moving Container in Away3DLite Tutorial (Feb 24th 2010)

The position of an object inside a container is in the local space of the container. Using the current sceneMatrix transformation of the container parent on the contained primitive's position yeilds the absolute position to use as a reference in the overall scene.


This is how to get the real position of a sphere from inside a moving container:

myBasketball.x = PlayerContainer.sceneMatrix3D.transformVector(mySphere.position).x;

myBasketball.y = PlayerContainer.sceneMatrix3D.transformVector(mySphere.position).y;

myBasketball.z = PlayerContainer.sceneMatrix3D.transformVector(mySphere.position).z;


As you can image, if you place a 3D object at some point in an Objectcontainer like a sphere, then you can use these points for reference in placing things like other models, explosions or calculation of any distance from that reference sphere. Do note that a sphere is visible and handy for a while but a non-rendered object with a position member variable itself will do.

All kinds of things are possible using this!

Best regards.

Deactivate Visibility for Bounding Boxes in Away3DLite Tutorial

No Ability to Deactivate Visibility for Bounding Boxes in Away3DLite (Feb 24th 2010)

Ability in is in Base Class Object3D for newer Away3DLite release but needs to be overridden.

//Create Invisible WireframeMaterial for Bounding Boxes
// This Away3D Lite version hack needed until support is added for "visible".
var zeroAlphaMaterial = new WireframeMaterial(0xFFFFFF, 0);


From: http://www.mail-archive.com/away3d-dev@googlegroups.com/msg07411.html

> > I've found where is the problem with WireframeMaterial alpha property,
> > in WireframeMaterial.as the following line
>
> > _graphicsStroke.fill = new GraphicsSolidFill(_color);
>
> > should be changed with
>
> > _graphicsStroke.fill = new GraphicsSolidFill(_color,
> > _alpha);

There are two instances of the line to correct. The important one is in the constructor.

Cheers!