Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (553)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2
1  Java Game APIs & Engines / Java 3D / Re: A shape's Perfect-fit Bounding Box? on: 2003-11-18 07:28:54
So should autoComputeBounds be true or false?  Ifodalai said earlier that "When you call getBounds() you always get a BoundingSphere if the bounds is autocomputed", but I'm not sure if that's what I want.
2  Java Game APIs & Engines / Java 3D / Re: A shape's Perfect-fit Bounding Box? on: 2003-11-18 04:13:31
"When you call getBounds() you always get a BoundingSphere if the bounds is autocomputed.

Is the properties of this sphere also the same each time? "


Well, as I mentioned in the post above this one, there maybe be a problem of me calling getBounds() on the wrong object.

I'm using Portfolio Loader to load dxf files, and I provided the code snippet for my code loader in the previous post.

What should I be calling getBounds on?
3  Java Game APIs & Engines / Java 3D / Re: Changing a Shape3D's color on: 2003-11-18 02:06:19
Hmm, I tried both of your suggestions and it didn't change the color.

BTW, when I tried using your code, it said my Box didn't have an appearance and so instead of doing "   Appearance tempAp = shape.getAppearance();
   Material material = tempAp.getMaterial(); ", which gave a null pointer exception, I just said tempAp = new Apperance and material = new Material();  Not sure if that's what's screwing it up.
4  Java Game APIs & Engines / Java 3D / Re: A shape's Perfect-fit Bounding Box? on: 2003-11-18 01:42:55
So Herkules, how did you get your 3ds models' bounding box?  If I can do it without a boundingsphere in between or getBounds(), that's fine.  I just want to know how to get the bounding box for the sakes of computing the dimensions of my model.

Also, I load up my model as follows:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
class ModelWrapper extends BranchGroup {
....

ModelLoader loader = new ModelLoader();
Scene scene = null;
try { scene = loader.load(filename);
        }
...

}


The ModelWrapper branchgroup is the child of a transformgroup, and that transformgroup is the child of another branchgroup.

Which group should I be computing my bounding box off of?  Or perhaps I compute it based off of scene?



Thanks.
5  Java Game APIs & Engines / Java 3D / A shape's Perfect-fit Bounding Box? on: 2003-11-16 22:13:23
Hi,

I was wondering how to get the bounding box for a model that fits that model perfectly.  It seems like everytime I do BoundingBox bbox = new BoundingBox(theModel.getBounds()), I get the same bounding box no matter what, which has lower point (-1,-1,-1) and upper point (1,1,1).  The bounding box always seems to be this size no matter how big or small the actual model is.  Is there a way to get the bounding box that fits the model perfectly?

The reason I ask this question is because I want to load some models into my scengraph, and I want to compute that model's width, length, and height.  I thought I could get it from the model's boundingbox, but as I mentioned previously, the bounding box never scales according to its model.

Thanks,
DAT
6  Java Game APIs & Engines / Java 3D / Changing a Shape3D's color on: 2003-11-14 21:06:52
Hi,

I'm running into some problems changing the color of a Shape3D.  My Shape3D is a simple rectangle, implemented like:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
public class Box extends Shape3D {
     public Box() {
          super();
          // Set capabilities.            
this.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
this.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);

           
         // Draw a rectangle.
  QuadArray array = new QuadArray(4,QuadArray.COORDINATES | QuadArray.COLOR_3);
   array.setCoordinate(0,new Point3d(-1,-1,0));
   array.setCoordinate(1,new Point3d(1,-1,0));
   array.setCoordinate(2,new Point3d(1,1,0));
   array.setCoordinate(3,new Point3d(-1,1,0));

   for (int i = 0; i < 3; i++) {
       array.setColor(i, navyblue);
   }
           
   this.setGeometry(array);

   }

}



With the above code, I've created a navy-blue box.  I've tried changing the color of the box to red by using this method:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
private void applyColor(Shape3D s3d, Color3f color) {
     Appearance ap;
     ap = new Appearance();
     ap.setCapability(Appearance.ALLOW_MATERIAL_READ);
     ap.setCapability(Appearance.ALLOW_MATERIAL_WRITE);
     ap.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
     ap.setCapability(Appearance.ALLOW_TEXTURE_ATTRIBUTES_WRITE);
     ap.setCapability(Appearance.ALLOW_TEXGEN_WRITE);

     Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
     Material m = new Material(color, black, color, black, 1.0f);
     m.setCapability(Material.ALLOW_COMPONENT_READ);
     ap.setMaterial(m);
     s3d.setAppearance(ap);
}



When I try to use this method by calling "applyColor(anInstanceOfTheBox, red);" however, the box doesn't change color and stays navy-blue.

Does anyone know what I'm leaving out or doing wrong?

Thanks,
DAT
7  Java Game APIs & Engines / Java 3D / Re: Mapping mouse location to universe location on: 2003-05-07 12:44:05
Yeah, is there any way for me to spawn an object "somewhere" along the projection?

I'm sure this has been done reasonably before.  That's what editor do right?  You click on an editor's 3d canvas and plop a shape down where you clicked.
8  Java Game APIs & Engines / Java 3D / re on: 2003-05-07 12:35:51
Hm, doing material.setLightingEnable(false) (sorry, forgot the exact syntax; not at my own computer now) doesn't solve it.  I wonder what's wrong...
9  Java Game APIs & Engines / Java 3D / Re: Mapping mouse location to universe location on: 2003-05-07 12:32:04
But the thing is, I am not clicking on any shape.  If I have a scenegraph with no shapes or geometries, I just want to be able to click somewhere on the scenegraph and have it tell me the world's coordinates of where I clicked.  Or perhaps I misunderstood you...?

My goal is to be able to click somewhere on the 3D canvas and be able to create, for instance, a sphere where I clicked.  That is why I am interested in getting the 3d world coordinates.  It seems like there should be a very easy way to do this, but I can't seem to figure it out.  :/
10  Java Game APIs & Engines / Java 3D / Re: Mapping mouse location to universe location on: 2003-05-07 00:57:13
I've been looking at PickCanvas and awt's MouseEvent, and I can't seem to figure out a fast and easy way to convert a 2D mouse click location into a 3D location without having to write a behavior for it.  PickCanvas takes in a MouseEvent.  How do I actually extract that MouseEvent, for instance, if I want to get "the next click"'s positions?  Can I do this without having to write a behavior?

I know this is an old post, but the basic question is that I am curious as to how to easily implement a way for me to click somewhere on a 3D Canvas and just simply System.out.println the x/y/z locations of the place I just clicked, even if the pickResult is null.  The 3D coordinates are all I want.
11  Java Game APIs & Engines / Java 3D / Re: Finished my tutorial - please check it on: 2003-05-01 17:04:16
This is a pretty cool tutorial!!!  However, your code is buggy.  Sometimes when I press "w" to walk, I get null pointer exceptions.  Also, when I try to close the window by clicking on the window frame's close button, your thing crashes.  There seems to be other bugs too...are these known issues?

--DAT
12  Java Game APIs & Engines / Java 3D / Re: Shape3D colors on: 2003-04-30 19:49:26
I set up my shape3d in this fashion:
1  
2  
3  
TriangleArray triangle = new TriangleArray(24, TriangleArray.COORDINATEE      | TriangleArray.COLOR_3);
triangle.setCoordinates(0, verts);
triangle.setColors(0, colors);      


This is basically the same thing they did in ColorCube.  I then use the triangle array to create a triangle shape class.

After creating an instance of the shape3d, I then set it to the following appearance properties:

1  
2  
3  
4  
5  
app = new Appearance();
m = new Material(Arena3D.magenta, Arena3D.black, Arena3D.magenta, Arena3D.white, 80.0f);
m.setLightingEnable(true);
app.setMaterial(m);
triangleInstance.setAppearance(app);


where Arena3D.color are colors I define (and they do work on primitives and such).
13  Java Game APIs & Engines / Java 3D / Behavior threads not turning off correctly? on: 2003-04-30 03:15:37
I'm using a bunch of behaviors, but I find that when I iterate through a large list of objects, each with a behavior attached to it, and say b.setEnable(false) for each one, I find that not all of them turn off.  I made a test button that iterates through the list, and even after 3 or 4 presses, not all of them sometimes turn off.

Has anyone ever had this issue before?  Is there a better way to turn off a behavior in such a way that you can still easily turn it back on at a later point?

--DAT
14  Java Game APIs & Engines / Java 3D / Re: Parallel Projection View Zoom-out? on: 2003-04-29 15:36:20
Hm actually....I tried my program on another computer, and even though I didn't change any code, the screen was a little more zoomed in than it was before.   I think this may be due to the fact that I'm using setScreenScale, and the other computer's monitor/res. is different from mine?  In any case, this is not good because I will have different behavior on different machines.  

Anyone know another way to scale the camera/view so I have consistent behavior across different platforms/machines?
15  Java Game APIs & Engines / Java 3D / Re: Parallel Projection View Zoom-out? on: 2003-04-29 04:55:29
Solved it by doing this:

View.setScreenScalePolicy( View . SCALE_EXPLICIT );
View.setScreenScale( x );

Smiley
16  Java Game APIs & Engines / Java 3D / Parallel Projection View Zoom-out? on: 2003-04-29 03:55:51
I've been messing around with View and ViewPlatform to try to see a *flat* XY view (viewing straight down the XY plane's normal in the negative z direction).  I think that Parallel Projection is supposed to do this, and that you can do it with
canvas3D.getView().setProjectionPolicy(View.PARALLEL_PROJECTION);

When I try that, it seems to work, but it makes my view zoom all the way in.  So I try the following to make my camera zoom out a bit (vpTG is the universe's ViewingPlatform's ViewPlatformTransform):

1  
2  
3  
4  
5  
Transform3D T3D = new Transform3D();
Vector3f translate = new Vector3f();
translate.set(10.0f, 10.0f, 60.0f);
T3D.setTranslation(translate);
vpTG.setTransform(T3D);


This seems to have no effect however.  Any suggestions on what I might be doing wrong?  Or perhaps a better way to zoom out (move my camera more toward the +z direction while still facing the XY plane)?

Thanks,
DAT
17  Java Game APIs & Engines / Java 2D / Keeping focus on a JFrame on: 2003-04-27 23:04:57
I'm working on a gui that has a main overall JFrame that contains several JPanels, and the JPanels themselves have other components and stuff.  I'm trying to implement basic keylistener functionality such that when I press a keyboard key, I will print out a System.out message.  The problem is, the JFrame itself always seems to lose focus.  When I press the key that I setup, nothing happens.  I know there's a FocusManager in Swing, but I was wondering if there are any suggestions or tips on this issue.  I think the problem might be solved if I keep focus on the JFrame the whole time, but I'm not sure how to do that.  Any suggestions would be greatly appreciated.

--DAT
18  Java Game APIs & Engines / Java 3D / How to get Bounding Box back after transforms on: 2003-04-27 20:13:13
When you rotate a TransformGroup that has a shape as a child, it seems like you rotate the BoundingBox of that shape as well.  As a result, you'll get something like this:
boundingbox's lower corner:  (5, 6, 7)
boundingbox's upper corner: (6, 5, 8 )

Note that the corner coordinates are gotten via LocalToVWorld.
In this case, the y coordinates of the corners got switched.  The problem is that (5,6,7) is no longer the smallest corner!  Is there anyway to fix this or get around this?

Thanks,
DAT
19  Java Game APIs & Engines / Java 3D / Shape3D colors on: 2003-04-26 22:35:03
Hi,

I created a new Shape3D in the exact same way that ColorCube is created (all I changed where the vertex locations).  However, even though I give it an assigned array of colors upon creation, when I do theNewShape.setAppearance(app), it doesn't change my shape's appearance; the color stays the same as it was before.  How do I fix this?  Any suggestions?

--DAT
20  Java Game APIs & Engines / Java 3D / Re: Normals causing collisions? on: 2003-04-19 02:47:15
Hm, well I don't think so, though I might be wrong.  For instance, if I wanted to draw a square that is flat on the xz plane, wouldn't I do something like this?

1  
2  
3  
4  
5  
QuadArray xzShadow = new QuadArray(4, QuadArray.COORDINATES);
xzShadow.setCoordinate(0, new Point3d(lp.x, 0.0, lp.z));
xzShadow.setCoordinate(1, new Point3d(up.x, 0.0,lp.z));
xzShadow.setCoordinate(2, new Point3d(up.x,0.0,up.z));
xzShadow.setCoordinate(3, new Point3d(lp.x, 0.0,up.z));      


, where lp and up are 2 opposite-cornered points?
21  Java Game APIs & Engines / Java 3D / Normals causing collisions? on: 2003-04-18 18:09:52
Is there anyway to turn off normals of GeometryArrays?  Right now I draw a QuadArray in the shape of a square on the xy plane, and another one on the yz plane.  When I place an object, like a cube, on either of the two shape's normals (i.e. in the "line-of-sight" of the squares), it says my cube detects a collision.  The strange thing is, if I only draw a square on one of the planes, I don't detect collisions.  Any clues as to what might be going on?

--DAT
22  Java Game APIs & Engines / Java 3D / Re: Bounding box position not updating? on: 2003-04-16 12:35:05
Thanks, that worked!
23  Java Game APIs & Engines / Java 3D / Converting to awt-style coordinates? on: 2003-04-16 12:34:46
Hi,

I was wondering if there was an easy way to flip all the components of a virtual universe from the usual coordinate system (origin at bottom left corner) to the awt-style system (origin at top left with z=0 out of the screen).  (0,0) at top left is such a standard for graphics APIs that it seems like there should be an easy way to do this in the case that someone wants to draw in the "traditional" coordinate system.  Is there?

Thanks,
DAT
24  Java Game APIs & Engines / Java 3D / Re: Bounding box position not updating? on: 2003-04-16 06:33:29
Hi, thanks for clearing that up.

However, I am confused as to how about getting for instance the lower and upper corner Point3ds of a bounding box in the virtual coordinate system.

For instance, if I had something like:
1  
2  
3  
4  
5  
6  
7  
boundingBox = new BoundingBox();
someSphere.setBoundsAutoCompute(false);
someSphere.setBounds(boundingBox);
boundingBox.setLower(-3.0, -3.0, -3.0);
boundingBox.setUpper(3.0, 3.0, 3.0);
boundingBoxLeaf = new BoundingLeaf(boundingBox);
boundingBoxLeaf.setCapability(Node.ALLOW_LOCAL_TO_VWORLD_READ);


I would be able to get the position of the boundingBox by saying
Vector3d pos = new Vector3d();
Transform3D T3D = new Transform3D();
boundingBoxBorderLeaf.getLocalToVworld(T3D);
T3D.get(pos);


However, that only gives me the position of the bounding leaf's center (correct me if I'm wrong)....how can I actually get the virtual world coordinate positions of the upper and lower corners of the bounding box within the bounding leaf?
25  Java Game APIs & Engines / Java 3D / Bounding box position not updating? on: 2003-04-16 02:20:12
I have a BoundingBox around an object and I'm drawing it graphically.  When I drag the object around, the BoundingBox moves with the object.  However, when I System.out.println(the bounding box), the lower and upper corner point locations never seem to change.  Are those points' coordinates relative to the center of the object?  How do I get the corner's positions relative to the axes?

--DAT
26  Java Game APIs & Engines / Java 3D / Mapping mouse location to universe location on: 2003-04-14 19:28:59
I know that pickObject has a pickAll(x,y) behavior that shoots a ray from your screen's plane into a 3d universe and returns a scene branch graph.  I was wondering if there was anyway to do the opposite:
For instance, I want to click anywhere on the canvas3d and a new object will be created/drawn where i just clicked.  MouseEvent can easily be used to give me the X and Y position of the place I just clicked in terms of screen coordinates, but how can I convert that into the XYZ coordinates of the universe so I can spawn an object at the place I clicked?


Thanks again for the help.  I'm just getting the hang of Java3d, and it has been fun so far.  I try to figure out problems on my own, but I figure it doesn't hurt to ask the messageboard too.

Thanks!
DAT
27  Java Game APIs & Engines / Java 2D / Dragging an object from one panel to another on: 2003-04-14 17:46:19
Hi,

I'm trying to make a JFrame that consists of 2 JPanels.  The left panel has a list of buttons the user can press, and the right panel is a canvas for drawing graphics.  Let's say one of the buttons on the left panel is "place a square" such that if I press the button, I should be able to then move my mouse over to the canvas panel, and the moment my mouse enters the canvas panel region, a pre-drawn square will follow my mouse around.  I can then move my mouse and left-click to "drop" the square on the location of the panel I want.

I know there are mouse motion listeners available, but I was wondering if anyone had any tips, advice, or links to demos with source code that implements this functionality.

Thanks!
DAT
28  Java Game APIs & Engines / Java 2D / "Snap-to-grid" functionality on: 2003-04-14 17:39:26
Hi,

I was wondering if anyone had any tips, advice of objects "snapping" to a grid so that they are aligned along some grid lines/etc.  For instance, if I have a square grid and am dragging around a square and want it to only position along the grid lines.

Thanks,
DAT
29  Java Game APIs & Engines / Java 3D / "Snap-to-grid", projections on: 2003-04-13 19:58:16
Hi,

1) I was wondering if anyone had some demos of objects "snapping" to a grid so that they are aligned along some grid lines/etc.  

2) I was also wondering if there were any demos where when an object is being dragged around in space, it projects its image onto a grid wall.



Thanks again,
--DAT
30  Java Game APIs & Engines / Java 3D / getting the location of a transform group on: 2003-04-13 01:33:22
Hi.  Sorry to bother this messageboard again with more newbie questions, but I find that it has been a great resource (and pretty active) too.

1) I have a couple of objects that are in the same TransformGroup, and I've
given the TransformGroup pick behaviors so that I can drag it around.
My question is, how do I get the x/y/z position of the TransformGroup's
current position?  For instance, if I drag it somewhere and want to print
out it's new position.  I've looked at TransformGroup and Transform3D and I
haven't found anything useful....any help would be greatly appreciated.

2)I was wondering if there is a quick and easy way to switch the buttons
assigned to the default MouseBehaviors.  The default is left-button rotate,
right-button translate, third-button zoom.  Is there an easy way to just
swap these around without having to rewrite a whole set of mouse behaviors?


3) Instead of dragging objects around, I was thinking maybe I could make it such that I could click it once and it'll follow my mouse around.  Then when I click it again, I set it down to its new position.  Should I be writing a new PickBehavior for this or a new MouseBehavior to get this sort of functionality?  Or should I be manually extracting the mouse's position and tracking it somehow?


Thanks again,
DAT
Pages: [1] 2
 

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

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (24 views)
2014-08-22 19:31:30

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

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

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

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

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

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

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

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

Norakomi (42 views)
2014-08-06 19:49:38
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!