mianwo's blog

Be careful with "stop()" method

This topic is related to AS2.0 .

Recently I made a discovery after a research on a very strange "return value missing" problem.
The situation is like this:

I have a class A which extends MovieClip and calls "stop()" method to stop the play head in its construction method. Everything seems normal except I can't get return value from any method who create instance of A.
For example, I have the following code:

In file A.as:

class A extends MovieClip{
  function A(){
    stop();
  }
}

In file test.fla:

If you can not access this site recently, please try "dobbee.com"

I received several email from my domain registrar recently saying that there will be a major internet service inspection during 2008 Olympic games, and any domain that has no record in Chinese internet administration could be shut down without notice. So if you found you cannot access this site, please try another domain "dobbee.com". They are both pointing to the same site.

BTW: Dobbee is the name of my dog. Here is his photo:

Rolling balls -- new progresses of RigidAPE

Since last release of RigidParticle, I've been working on it's restructuring.
And now there's finally some new progress I can share with you.

These are major updates:

  • Hit point detection has been moved to CollisionDetector. I think that makes more sense to me.
  • Collision resolve of rigid body have been moved to a new class -- RigidCollisionResolver. And the collision resolve and rotation calculation has been completely rewrote. In last demo, The RigidParticle is just "looks like" a rigid body, but now, it is a real rigid body.
  • RigidParticle has been removed. And there's 3 new classes -- RigidItem, RigidRectangle and RigidCircle -- taking its place. RigidItem is the root of all rigid bodies in this new framework, It provides common operations for all kinds of rigid bodies. RigidRectangle is just like the original RigidParticle, It simulates a rigid body in rectangle shape. RigidCircle is new, It simulates a circular rigid body. Maybe you think a circular object doesn't need to be a rigid body, You will see from this demo, a particle can never do that...

The new framework has weaknesses, rigid body can not interact with particles rightnow, and friction still has problems.

Flash 3D engine with "obj" file support


This 3D engine can load models in a standard "obj" file, and display it in real 3D.
Many 3D tools can export "obj" file format. I'm using SketchUp pro.
My 3D car simulation application was based on this engine.

Originally it was an open source 3D engine writen in AS1.0, I found it years ago, then I rewrote it in 2.0, and added some new feature to it. Different from other 3D engines use pixels graphics to draw polygons, This 3D engine use vector graphics to display polygons. This method is suitable for flash player 7, since it doesn't have bitmap abillity. And it's more good looking, because vector graphics are naturally anti-aliased by the player.
For flash player 8 or later, a pixel engine is a better choice.

The hidden surface removal is buggy, because most hidden surface removal method are not designed for vector graphics. So I took a shortcut. Although it's a buggy method, but you still can get perfect result if you spend some time refine your model. Load the model house.obj, you can see the engine is working very well on this model.

3D Car simulation


This is the 3D version of Car dynamics experiment.
They share the same rigid body engine (The rigid body engine uses 3D vectors), only this one is displayed in 3D.

Car dynamics experiment

This application simulates movements of a car.
There's a special physics system in this application. It's based on particles but you can use several particles to form a rigid body.
Every particle has its mass, and when they were formed into a rigid body, the system calculates the center of gravity and moment of inertia for the rigid body. When a force was applyed to a particle, the physics system calculates acceleration and rotational acceleration for the whole rigid body and make it move.
To simulate the car, I used 4 particles (one for each wheel) to form the car rigid body. Thrusts and frictions were applyed to these wheels.
The friction calculation is special. Since wheels have direction. In the same direction of their rotation, they are free to move. But on the perpendicular direction of their rotation, they tends to stop the movement (Actually it's this friction that makes the car turns).

RigidParticle for APE -- IT'S WORKING!!!

This is an extension of RectangleParticle class for APE engine.
It added angular velocity and caculates the rotation movements for a RectangleParticle when collision happens. The particle now acts like a real box.
Here is the sample:
No constraint were used in this sample, all objects are particle.

Updated on 9/23:
Rewrote the hitpoint finding method, No more sudden spinning now...
Press UP key to add more boxes to the scene. you can see it's power.

the source code is here.

Syndicate content