Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (481)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Status of behaviors in Xith3D  (Read 1434 times)
0 Members and 1 Guest are viewing this topic.
Offline Planner1

Senior Newbie





« Posted 2003-12-18 17:58:47 »

Can anyone update me on the use of Behaviors in Xith3D? I noticed some of the default Behaviors available in Java3D are not available in Xith yet but is the present implementation of Behaviors at a usable level? I've written a simple behavior based on a sample in Java3D but it does not work, the initialization method is never called. Having never used behaviors before, I'm not sure if I am just doing something wrong or that the implementation is incomplete at this time. Here's some code snippets explaining how I've set this up:

This code creates a quad, establishes its appearance and adds it to the scene. That works fine, as expected. The code also creates a SimpleBehavior that should initialize and print something every 2000ms.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
    Geometry node1 = createNode();
                                                                                                                                                             
    Appearance appearance = new Appearance();
    ColoringAttributes colorAttribs = new ColoringAttributes(new Color3f(1,0,0), ColoringAttributes.SHADE_GOURAUD);
    appearance.setColoringAttributes(colorAttribs);
    Shape3D node1Shape = new Shape3D(node1, appearance);
                                                                                                                                                             
    SimpleBehavior behavior = new SimpleBehavior(node1Shape, 2000);
    BoundingSphere sphere = new BoundingSphere(new Point3f(0,0,0), 2000.0f);
    behavior.setSchedulingBounds(sphere);
                                                                                                                                                             
    scene.addChild(node1Shape);
    scene.addChild(behavior);


And here is my SimpleBehavior class. All I wanted it to do was print out the statements seen there every time the wakeup was called. The result of these two sets of code is that nothing is printed out.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
public class SimpleBehavior extends Behavior {
                                                                                                                                                             
  WakeupCondition wakeUpCond;
                                                                                                                                                             
  public SimpleBehavior(Shape3D shape, int elapsedTime) {
    // save the WakeupCriterion for the behavior
   wakeUpCond = new WakeupOnElapsedTime(elapsedTime);
  }
                                                                                                                                                             
  public void initialize() {
    System.out.println("Initializing...");
    wakeupOn(wakeUpCond);
  }
                                                                                                                                                             
  public void processStimulus(java.util.Enumeration criteria) {
    System.out.println("Stimulating...");
    wakeupOn(wakeUpCond);
  }
                                                                                                                                                             
}


I'd appreciate any guidance towards making this work.

Ben
Offline Jens

Senior Member




Java for games!


« Reply #1 - Posted 2003-12-18 18:43:04 »

Behaviors are currently not implemented. Does anyone currently work on Behaviors? I think one of the problems for the things you want to do is the absence of a high-res-timer in Java.

Xith3D Getting Started Guide (PDF,HTML,Source)
Offline whome

Junior Member




Carte Noir Java


« Reply #2 - Posted 2003-12-18 19:12:53 »

Hires timer in JDK1.4.x
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=share;action=display;num=1066194528
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #3 - Posted 2003-12-18 20:40:44 »

Quote


That timer is not in JDK 1.4.x!  The package name is sun.misc and is not part of the spec.  There will be a hires timer in 1.5 as we all know however.

Xith3D used to use that timer for some profiling stuff and it caused many windows users strife so it was removed.  

Xith3D now has a TimerInterface which all such code should use - anyone wanting timer stuff has to implement TimerInterface (be it sun.misc.Pref or something else) which is a very good idea until we have an official timer.

Sorry if I sound pedantic - but it's wrong to say that it is in the JDK.

Will.

Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #4 - Posted 2003-12-19 05:09:20 »

As I wrote some time ago, I have parts of running Behavior code (at least Interpolator-style behaviors work). These behaviors, besides of they are compiler-compatible with Java3D, not used as a part of scenegraph, and I use them separately. by calling behavior schedulting method between rendering frames from rendering thread.

Yuri

Yuri Vl. Gushchin
JProof Group
Offline Planner1

Senior Newbie





« Reply #5 - Posted 2003-12-19 12:31:04 »

Without a full implementation of Behaviors, how are other projects in Xith managing their animation timings with regard to the scenegraph? The project I'm working on is currently written in GL4Java and doesn't support animation. I'd like to port it to Xith (for the rendering independence) and implement animation and timing loops so that rendered elements of the program can react to stimuli in the environment or display themselves in certain ways over time. Yuri mentioned his implementation outside of the scenegraph. I'd like to hear additional ideas.
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #6 - Posted 2003-12-19 17:09:07 »

Hi
 I have my game loop controll it all. it calls update on my data model, that knows the time since it was last called and that goes round and updates each object. Then I call renderOnce() on view, and repeat, more or less

HTH

Endolf

Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #7 - Posted 2003-12-20 04:34:01 »

Generally, I see two major ways how to do this: either Xith3D/Java3D takes control over animations/behaviors, or application will be responsible for that. Having contadictonary experience with Java3D behaviors, I prefer to have full control on what is happening with my scenegraph. From the other side, I see great benefit from convenience/utility scene modification libraries, such as behaviors, physics, animators, etc.

Yuri

Yuri Vl. Gushchin
JProof Group
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (26 views)
2014-08-19 09:29:53

Tekkerue (24 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (14 views)
2014-08-16 06:20:21

Tekkerue (21 views)
2014-08-16 06:12:11

Rayexar (60 views)
2014-08-11 02:49:23

BurntPizza (38 views)
2014-08-09 21:09:32

BurntPizza (30 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!