Frame3D initialization
You don't need to call Frame3D#setCapability. Frame3D#setActive has been renamed to changeActivity and setVisible has been renamed to chaneVisible.
// in 0.6.1
frame.setCapabilities();
frame.setActive(true);
frame.setVisible(true);
// in 0.6.2
frame.changeEnabled(true);
frame.changeVisible(true);
Frame3D disposing
You can use Frame3D#changeEnable instead of Frame3D#changeActivity.
// in 0.6.1
frame.changeActivity(false);
// in 0.6.2
frame.changeEnabled(flase);
Size of Component3D is indicated by PreferredSize instead of Size
Getting size of Component3D object:
// in 0.6.1
comp.getWidth();
comp.getHeight();
comp.getDepth();
// in 0.6.2
Vector3f v = new Vector3f();
v = comp.getPreferredSize(v);
v.x // width
v.y // height
v.z // depth
Setting size of Component3D object:
// in 0.6.1
comp.setSize(0.1f, 0.2f, 0.3f);
// in 0.6.2
Vector3f v = new Vector3f(0.1f, 0.2f, 0.3f);
comp.setPreferredSize(v);
Frame3D moving, getting focus
SceneManager implements the default actions to move, fluctuate, highlight and scale frame.
You don't need to write these actions such as ComponentMover.
// in 0.6.1
new ComponentMover(frame);
new MouseEnteredEventAdapter(frame,
new ActionBoolean() {
public void performAction(LgEventSource source,
boolean flag) {
frame.requestHighlight(flag);
}
});
frame.setRotationAxis(0.0f, 1.0f, 0.0f);
new MouseDraggedEventAdapter(frame,
new Float2Splitter(
new FloatDiffer(
new FloatScaler(500f, (float)Math.toRadians(30),
new ResilientRotateAction(frame, 1500))),
null));
new MouseClickedEventAdapter(frame,
new GenericEventPostAction(Frame3DToFrontEvent.class, frame));
// in 0.6.2
// No code
Event Model
You can use AWT/Swing style event model.
It makes us to write program easily.
// in 0.6.1
new MouseClickedEventAdapter(component,
new ActionNoArg() {
public void performAction(LgEventSource source) {
frame.changeActive(false);
}
});
// in 0.6.2
component.addListener(
new MouseClickedEventAdapter(
new ActionNoArg() {
public void performAction(LgEventSource source) {
frame.changeEnabled(false);
}
}));
Another example:
// in 0.6.1
new MouseEnteredEventAdapter(component,
new ScaleAction(component, 1.2f, 100));
// in 0.6.2
component.addListener(
new MouseEnteredEventAdapter(
new ScaleActionBoolean(component, 1.2f, 100)));
MouseWheelEventAdapter class
Change the argument of MouseWheelEventAdapter constructor from ActionFloat3 to ActionInt.
// in 0.6.1
new MouseWheelEventAdapter(
component,
new ActionFloat3() {
public void performAction(LgEventSource source, float x, float y, float z) {
// z : rotation value
...
}
});
// in 0.6.2
component.addListener(
new MouseWheelEventAdapter(
new ActionInt() {
public void performAction(LgEventSource source, int value) {
// value : rotation value
...
}
}));
ScaleAction class and RotationAction class
ScaleAction devides to two classes: ScaleActionBoolean and ScaleActionFloat.
In same way, RotationAction to RotationActionBoolean and RotateAcionFloat.
// in 0.6.1
new MouseEnteredEventAdapter(component,
new ScaleAction(component, 1.2f, 100));
// in 0.6.2
component.addListener(
new MouseEnteredEventAdapter(
new ScaleActionBoolean(component, 1.2f, 100)));
Adding Component3D to scene graph
When adding Component3D object to scene graph after calling Frame3D#changeVisible(true), no need to call Component3D#setCapabilities().
// in 0.6.1
comp.setCapabilities();
container.addChild(comp);
// in 0.6.2
cintainer.addChild(comp);
No need to use XXChanger
Component3D now has the functions of ScaleChanger, RotationChanger, ColorAlphaChanger and TranslationChanger.
// in 0.6.1
ScaleChanger changer = new ScaleChanger(comp, new NaturalFloatSmoother(1L));
changer.changeTo(1.0f);
// in 0.6.2
comp.changeScale(1.0f);
note:
-
Component3D#setXXXX : update immediatly without animation.
-
Component3D#changeXXXX : update with animation.
Animation
NarutralMotionComponent3D is substituted by Component3D#setAnimation().
Most of the case, you would need to set animation (NaturalMotionAnimation).
Otherwise the 'comp' object performs the default animation, which is no animation.
// in 0.6.1
public class XXXComponent extends NaturalMotionComponent3D {
...
}
// in 0.6.2
component.setAnimation(new NaturalMotionAnimation(500));
Thumbnail
Thumbnail consited of GlassyPanel is used by defaults.
If you want to make your own thumbnail, you make a derived class of Thumbnail.
// in 0.6.1
public class MyThumbnail extends Component3D {
...
}
frame.setThumbnail(new MyThumbnail());
// in 0.6.2
public class MyThumbnail extends Thumbnail {
...
}
frame.setThumbnail(new MyThumbnail());
Why Lg3dHelp? ported to 0.6.2 is much smaller?
A large portion of the code that performs the followings have been moved to the 'SceneManager'.
So, an app doesn't need to do those by itself.
- Allowing the user to move the position (using 'ComponentMover').
- Changing the cursor to the 'MoveCursor' when the cursor is over the part where the user can drag the app.
- Click to raise (bring to front) action.
- Iconify animation implementation.
- Thumbnail behavior implementation.
Cannot find 'Frame3D#setActive()'
The setActive() method has been renamed to changeEnabled()
Note that there is setEnabled() method, but this doesn't cause any transition animation.
App developers are encouraged always to use changeEnabled().
Doesn't perform iconify animation/app close animation
For consistency with other operations, Component3D#changeVisible()
and Frame3D#changeEnabled() have been introduced. And the behavior
of the set***() versions have been changed to perform the action immediately
without transition animation.
App developers are encouraged to use the change***() versions
so that the app performs the transition animation.
Cannot find 'Component3D#setSize()' method
Renamed to setPreferredSize() in order to avoid possible confusion.
What it sets is merely a size hint for the Scene Manager.
It doesn't change the application size at all.
Cannot find 'Component3D#setCapabilities()' method
The capabilities are set automatically when needed.
You don't need to call it anymore (even for a dynamically added component).
Can I keep using deprecated methods?
No. Those will be removed in future, so please don't use any of them.
// in 0.6.1
frame3d.setSize(0.06f, 0.10f, 0.08f);
frame3d.setCapabilities();
frame3d.setActive(true);
frame3d.setVisible(true);
// in 0.6.2
frame3d.setPreferredSize(new Vector3f(0.06f, 0.10f, 0.08f));
frame3d.changeEnabled(true);
frame3d.changeVisible(true);
Cannot find 'EventAdapter' constructor that takes 'Component3D' as the event source
The way to register an event adapter (which is an event listener) has been changed.
Use Component3D#addListener() method for registration.
There is no 'ScaleAction' nor 'RotateAction'
Those used to implement two Actions, 'ActionBoolean' and 'ActionFloat',
but this integration can cause some confusion. These are separated out
to two classes, like 'ScaleActionBoolean' and 'ScaleActinoFloat'.
Action classes like 'ScaleActionBoolean' doesn't perform smooth animation
Animation configuraiton has been made pluggable, and the default configuration is no animation
(i.e. the visual gets updated immediately).
If you want to see smooth motion, you need to set an instance of 'NaturalMotionAnimation'
to the Component3D? object by using Component3D#setAnimation()
My app's mouse cursor changes automatically to the move cursor and I can move it by grabbing. How I can control where can be grabbed?
Since 0.6.2, the Scene Manager implements the default action to move apps.
It also change the cursor to the move cursor when the cursor is on a component
which the user can move (i.e. against which the Scene Manager takes the default action).
Default action is activated by mouse events propagated to the Scene Manager.
The Scene Manager resides somewhere upper in the scene graph.
A mouse event propagates upward following the scene graph path from the
event source component to the scene graph root.
If a mouse event is not consumed by the app, it eventually reaches the Scene Manager,
which results in the default action.
If you set a listener to a component, however, mouse events fired against the component
will be consumed and won't be propagated to the Scene Manager
(thus, no default action will be taken place).
This event consumption is a new behavior introduced in 0.6.2.
For the info how to control the default action, please see the next item.
I cannot move my app. The default Scene Manager action doesn't work for my app.
If you set a listener to your app (or a component used in your app) mouse events
fired against it (and its children components) will be consumed by the app (or the component) by default.
So, the mouse events won't be propagated to the Scene Manager.
This prevents the Scene Manager from performing the default action.
If you want the Scene Manager to perform the default action for your app
(i.e. let the mouse events propagated upwards beyond your app),
you can call Component3D#setMouseEventPropagatable()
(with true as the argument)
against the component that has an event listener.
As an example, please check out the Tutorial3 class.
The earthComp object has a listener but no
setMouseEventPropagatable(ture) is invoked.
So, you cannot move the app by grabbing the earth shape.
On the other hand, the handleComp has a listener
and setMouseEventPropagatable(true) is invoked,
so you can grab it and move the app.
// in 0.6.1
Component3D handleComp = new Component3D();
handleComp.addChild(handle);
handleComp.setCursor(Cursor3D.MOVE_CURSOR);
handleComp.setTranslation(0.0f, 0.05f, 0.0f);
new MouseEnteredEventAdapter(handleComp,
new ScaleAction(handleComp, 1.5f, 200));
top.addChild(handleComp);
// in 0.6.2
Component3D handleComp = new Component3D();
handleComp.setAnimation(new NaturalMotionAnimation(200));
handleComp.addChild(handle);
handleComp.setTranslation(0.0f, 0.05f, 0.0f);
handleComp.addListener(
new MouseEnteredEventAdapter(
new ScaleActionBoolean(handleComp, 1.5f)));
// NOTE: the duration has been set by the argument to the constructor of
// NaturalMotionAnimation(). It specifies the default duration. So, I didn't
// need to specify it here again.
handleComp.setMouseEventPropagatable(true);
top.addChild(handleComp);
Don't we need to say 'Shape3D.GEOMETRY_NOT_SHARED' when creating a shape like Shpere or Box?
Not anymore. An issue regarding a shared geometry when setting capabilities has been fixed.
So, we don't need to specify GEOMETRY_NOT_SHARED anymore.
Please feel free to add entries for your porting issues
And please help us by providing answers and fixing mistakes too!