Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (408)
games submitted by our members
Games in WIP (293)
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  
  Help me with my attempted shared TDSModel  (Read 503 times)
0 Members and 1 Guest are viewing this topic.
Offline itistoday

Junior Member




There's too much blood in my caffeine system.


« Posted 2004-11-11 22:38:18 »

Ok.  Without really reading all the 3DS loader code (it's rather difficult to follow and uncommented), I tried to "brute force" the creation of a sharedCopy TDSModel.  I'm using a slightly modified 3ds loader library, the changes being:

1) When you use the loader to load a 3DS file, now you have to put the calling class (this) into the constructor, like this:
1  
TDSLoader(this).load(file, true);

2) Various changes such as the changing of private varibles to public, and the creation of a Point3f object inside the TimedTransforms to allow me to copy them into the new TDSModel.
3) Creation of an Iterator in TDSModel.

The source is here.
The library is here.  You can just drag the library into one of your universal library folders (the java.ext.dirs property will show you where this is).
The library source with my modifications is here.
And an example animated model you could use is here.

I didn't sign the library, i hope that doesn't cause any problems...

The TDSModel has two things that need to be copied I think.  One is an ArrayList that contains all the transforms, and is used with the setTime() function, and the other are the actual children of the model.  That is why traverseTree() is called twice, and that is the reason for the arraylist parameter.  traverseTree() will go through either the ArrayList or the actual TDSModel, and add TransformGroups, Transform3D's, frames, and finally the Shape3D objects at the end to the model variable (the model that I'm trying to make into a sharedcopy).

Currently, the Ship class will make an identical looking copy of the TDSModel, but it WILL NOT ANIMATE!! ARG!! Smiley

My guess is that I'm forgetting to copy something else...

Somebody please help me out.

Offline kevglass
« League of Dukes »

JGO Kernel


Medals: 54
Projects: 20


Mentally unstable, best avoided.


« Reply #1 - Posted 2004-11-12 06:43:57 »

Since I have no computer to actually build this on at the moment I'm afraid this is from visual inspection:

The assumption that you only ever have one group inside another may be wrong..

The copying code would probably make more sense and need less public variables if you added copy() to TimedTransform and made it return a copy of itself. Then you could just have one special case for TimedTransforms (using an instanceof?)

I'm not 100%, but I think the reason it doesn't work is because your argument "arraylist" passed to "traverseTree" is never set to true? This means that while the TDSModel has the transforms added beneath it in the scenegraph they're not added to its internal list which is used to control the animation. The flag "arraylist" is actually redunant anyway since any TimedTransform you create should be added to the TDSModel with addTransform().

Kev

PS. Its still a really bad idea to be sticking libraries for stuff like this in your "universal library folders". Its not realistic to your eventual deployment.


Offline itistoday

Junior Member




There's too much blood in my caffeine system.


« Reply #2 - Posted 2004-11-12 19:03:02 »

Quote
Since I have no computer to actually build this on at the moment I'm afraid this is from visual inspection:

The assumption that you only ever have one group inside another may be wrong..

No, I'm used a modified version of the traverseTree function to print out the entire tree of the TDSModel, and it seems like the TDSModel itself has say, 4 children.  Then each of these will have only one child, which will only have one child, untill you have 4 children for the TDSModel, and each of these children will have one child totalling for a line of 4 children (if that makes sense).  Then the array list is a bit different, it has about 12 children (depending on the model), and each of these has a line ranging from like 4 to 2 children... but like the others, only one child per transform.

Quote
The copying code would probably make more sense and need less public variables if you added copy() to TimedTransform and made it return a copy of itself. Then you could just have one special case for TimedTransforms (using an instanceof?)

Probably, but this should still work, and I when I get this working, I might go the extra mile to add that to the library.

Quote
I'm not 100%, but I think the reason it doesn't work is because your argument "arraylist" passed to "traverseTree" is never set to true? This means that while the TDSModel has the transforms added beneath it in the scenegraph they're not added to its internal list which is used to control the animation. The flag "arraylist" is actually redunant anyway since any TimedTransform you create should be added to the TDSModel with addTransform().

No, it is set to true here:
1  
2  
3  
4  
5  
while(i.hasNext()) {
                  numtransforms++;
                  Object a = i.next();
                  traverseTree(a, temp, null, true);
            }

And they are added using with addTransform if it's from the arraylist.

Quote
Kev

PS. Its still a really bad idea to be sticking libraries for stuff like this in your "universal library folders". Its not realistic to your eventual deployment.

Meh, I prefer it this way while I'm developing, because it makes it much easier to compile things, and what if I end up not using this or that? Then I can easily change it without any problems.  Also, I could end up using this system on other systems buy using an installer.

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

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (142 views)
2013-05-17 21:29:12

alaslipknot (150 views)
2013-05-16 21:24:48

gouessej (181 views)
2013-05-16 00:53:38

gouessej (174 views)
2013-05-16 00:17:58

theagentd (184 views)
2013-05-15 15:01:13

theagentd (169 views)
2013-05-15 15:00:54

StreetDoggy (213 views)
2013-05-14 15:56:26

kutucuk (237 views)
2013-05-12 17:10:36

kutucuk (236 views)
2013-05-12 15:36:09

UnluckyDevil (241 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.11 seconds with 21 queries.