Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
games submitted by our members
Games in WIP (500)
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  
  Using Behaviors without a canvas  (Read 778 times)
0 Members and 1 Guest are viewing this topic.
Offline Conzar

Junior Member




There is nothing common about common sense


« Posted 2003-11-27 18:41:17 »

Ok.  So does anyone know how to use a Behavior without using a View that is attached to a Canavs3D object?

I ask this because I am implementing AI and do not need to see what the thing is doing b/c it sends its updates to a server (that sends to other players).  So theoretically I shouldn't need to create a ViewPlatform, View, nore Canvas3D; however, I dug around a bit in the Behavior documentation and found that 1 of the requirements for Behavior activation is an intersection of bounds between the Behavior and ViewPlatform.  

This is fine, because I can add a ViewPlatform without the need of a canvas3D object.  But it looks like the ViewPlatform needs a View object to do its activation stuff???  You can build a View object w/out a Canvas3D object (which I did) but the behavior never wakes up.

Any Suggestions?

Ubuntu
Offline endolf

JGO Knight


Medals: 7
Projects: 1


Current project release date: sometime in 3003


« Reply #1 - Posted 2003-11-27 20:36:11 »

Hi
 It sounds like the client just uses the scenegraph as a data representation of the server, and you then want to run behaviors in this, correct?, just trying to get some more info on what you are actually trying to do here.

Cheers

Endolf

Offline Conzar

Junior Member




There is nothing common about common sense


« Reply #2 - Posted 2003-11-27 22:23:33 »

Yep thats right.  In fact, the client is the same for both the computer controlled opponent as it is for a human player (minus the canvas3d stuff).

Ubuntu
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Breakfast

Senior Member




for great justice!


« Reply #3 - Posted 2003-11-28 09:30:21 »

I don't think behaviours have to be associated with the view at all- they just need to be added to the scenegraph.
Offline Conzar

Junior Member




There is nothing common about common sense


« Reply #4 - Posted 2003-11-28 16:51:42 »

Ok, so I wrote a smiple test program to show what is happening - sort-of.  
TestBehavior.java has two confingurations, one with a canvas3D that I created and one with just a simple universe called with an empty constructor.  (note, in my previous question I  DO NOT use SimpleUnivrse but it is easier to show my problem here with SU).  

So to execute the code do thsi
java TestBehavior 1
or
java TestBeahavior 2

1 means to use the canvas3D I created and 2 means to use empty constructor.
The program works fine w/ the empty constructor; however, it does not work with 1.  There is something wrong with the bounds intersection and this is what I suspect is my problem (conserning my post above).   Any suggestions?

Code below ...



1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
============== TestBehavior ===========
import java.awt.*;
import javax.swing.*;
import javax.media.j3d.*;
import com.sun.j3d.utils.universe.*;
                                                                                                             
class TestBehavior{
                                                                                                             
   //3D INFORMATION
  SimpleUniverse simpleU;
   BranchGroup rootBG;
   Transform3D saberTrans;
   JPanel panel;
                                                                                                             
   Canvas3D canvas3D;
                                                                                                             
   /**
    * Create a new model 3D.
    */

   public TestBehavior(boolean doView){
      if(doView){
         panel = new JPanel();
         panel.setLayout(new BorderLayout());
         GraphicsConfiguration config =          SimpleUniverse.getPreferredConfiguration();
         canvas3D = new Canvas3D(config);
         panel.add(canvas3D,BorderLayout.CENTER);
                                                                                                             
         simpleU = new SimpleUniverse(canvas3D);
      }
      else{
         simpleU = new SimpleUniverse();
      }                                            
      rootBG = new BranchGroup();                                                                                                        
      TestB testB = new TestB();
      testB.setSchedulingBounds(new BoundingSphere());
                                                                                                             
      rootBG.addChild(testB);
                                                                                                             
      simpleU.addBranchGraph(rootBG);
   }
                                                                                                             
   public static void main (String []args){
                                                                                                             
      if(args.length != 1){
System.out.println("useage 1 or 2");
      }
      else if(args[0].equals("1")){
         TestBehavior tb = new TestBehavior(true);
      }
      else{
         TestBehavior tb = new TestBehavior(false);
      }
   }
}


======== TestB ===========
import javax.media.j3d.*;
import java.util.*;
                                                                                                             
class TestB extends Behavior{
                                                                                                             
   WakeupOnElapsedTime timeEvt;
                                                                                                             
   public TestB(){
   }
                                                                                                             
   public void initialize(){
      timeEvt = new WakeupOnElapsedTime(120);
System.out.println("[TestB] initializing Behavior");
      this.wakeupOn(timeEvt);
   }
                                                                                                             
   public void processStimulus(Enumeration enumerate){
System.out.println("[TestB] doing behavio");
      this.wakeupOn(timeEvt);
   }
}




Ubuntu
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.

xsi3rr4x (42 views)
2014-04-15 18:08:23

BurntPizza (38 views)
2014-04-15 03:46:01

UprightPath (54 views)
2014-04-14 17:39:50

UprightPath (36 views)
2014-04-14 17:35:47

Porlus (53 views)
2014-04-14 15:48:38

tom_mai78101 (75 views)
2014-04-10 04:04:31

BurntPizza (134 views)
2014-04-08 23:06:04

tom_mai78101 (234 views)
2014-04-05 13:34:39

trollwarrior1 (195 views)
2014-04-04 12:06:45

CJLetsGame (203 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!