aspose file tools*
The moose likes Game Development and the fly likes Picking With Java 3D Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "Picking With Java 3D" Watch "Picking With Java 3D" New topic
Author

Picking With Java 3D

Paul Menard
Greenhorn

Joined: Dec 03, 2008
Posts: 1
Ok here is a good one ... I want to develop an RTS with java 3d, I have everything going well except for one major factor ... how do I select objects in the scene ... here is what I mean. I built a few models with anim8or, I them load these objects into the scene graph, here is an example ...

Each object is loaded into a prop manager ... and each object is a subclass of Sprite3D which is a subclass of shape3D



Ok now the spite class




Now subclass Sprite3D to creat all kinds of objects ... for an example we load in a model of the earth ...



Ok I know this is long so bare with me, now in the main game class we load the object and a PicKMouseBehavior like so ...



Now here is the SelectObjectBehavior wich is a subclass of PickMouseBehavior



Ok here is my belema, I set the userdata() when the earth object is created, but when the object is clicked in 3d space the userdata() is null, why is this?? The object seems to no longer be a subclass of earth, so I have no access to variables such as name or population if I wanted to add them. If I pass a reference to the behavior then I can get access to the object but that doesn't help if I pick something other than earth. What is going on? I know this is a complicated subject so I hope someone out there can help, I've posted this in a few places and still after a week no help ... :-( Keep in mind the type of game I want to write ... its an RTS game Real Time Strategy ... games like command and conquer, world in conflict, game like that. I must be able to select an object and get the data from the class it is built from.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11498
    
  16

I doubt anyone is going to read your 800+ lines of code to debug your problem. is there any way you can simplify it, and only post the relevant portions?

You should probably read some of this, but in particular this one.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Brian Legg
Ranch Hand

Joined: Nov 07, 2008
Posts: 488
That's way to much code to dig through without me having anything to test it with, and I doubt anyone else will either. I'd recommend using a good debugger and adding break points in your code. Have a break point at the code that gets activated when you click on a unit. Go inside the variable and see what it's doing and why it's not returning what you thought was there. I would also add some print methods to the entire initialization so that you can see if your even adding units to the earth to begin with. I've had multi-week bugs myself and they are no fun, but you know the code better than anyone so you're the only one who can fix it.

SCJA
~Currently preparing for SCJP6
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Picking With Java 3D