Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (120)
games submitted by our members
Games in WIP (577)
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  
  Newdawn MD2 loader: way to swap appearance of an MD2 on the fly?  (Read 4571 times)
0 Members and 1 Guest are viewing this topic.
Offline 5parrowhawk

Senior Newbie




Java games rock!


« Posted 2005-11-14 06:28:11 »

Does anyone have a hack/workaround which allows me to set the Appearance of an MD2Model (from the Newdawn MD2 loader) after the model has been loaded? It looks like that isn't possible with the stock version of the loader.
Also, is it possible to set the Appearance for individual MD2ModelInstances or only for the base model and, if the latter, will it affect all the Instances of that model?

Thanks in advance.

- 5parrow
Offline kevglass

JGO Kernel


Medals: 188
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2005-11-14 09:26:29 »

As with most of the loaders the scene tree reported back is that which is found in the model. The best way I've found to change the appearance at runtime is to seach the scene tree finding the nodes you want to change and reset the appearance. Given that the shape of the tree will always be the same this should be pretty simple.

However, since the source is provided (and there arn't going to be any maintainence updates on the MD2 Loader for a while) you could just change the MD2ModelInstance node to have direct accessors on it.

Kev

Offline 5parrowhawk

Senior Newbie




Java games rock!


« Reply #2 - Posted 2005-11-15 06:04:08 »

Thanks. I'll see about dumping the tree out and fiddling with it. Smiley

Edit: Yes, it seems to work. Thank you!

Do you mind if I ask about something else? Now it seems like the surface normals on my model are completely borked. All of them seem to be set to (x=0,y=1,z=0) or something like that, because when the model is facing towards the light, the whole thing lights up, but when it's facing away, the whole thing goes dark. This behaviour occurs when I use the stock model (tris.md2) provided with the loader as well. Do I need to do something to make it recalculate the surface normals every frame, or something else?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

JGO Kernel


Medals: 188
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #3 - Posted 2005-11-15 09:04:28 »

Actually, thats really interesting with MD2s.. Quake 2 had a whole set of pregenerated normals and they were just selected from. In Java3D I applied the normal generator - in Xith3D there was no equivilent, but it was planned so I left it in preperation for that.

If you use this class:

http://www.cokeandcode.com/code/src/render/org/newdawn/render/models/md2/MD2Normals.java

And modify the loader slightly so that where its setting the normals, instead of just applying (0,1,0) it selects one from this list based on the index it read from the file you should find all is happy. Smiley

If you make the mod - it'd be good to submit back it to the toolkit. Not using Xith3D personally at the moment it'd be a bit of an overhead for me to setup CVS access etc.

Hope that helps,

Kev

Offline 5parrowhawk

Senior Newbie




Java games rock!


« Reply #4 - Posted 2005-11-16 05:19:00 »

Thanks again! I'll give it a shot, but don't have CVS myself  Tongue

The best I can do is post the source here if/when I actually manage to make it work... I'll see about that.

Edit: Yes, I can see what needs to be done. A question about best practices, though: since I'm more or less an armchair coder, what's the best way to go about this?

- rebuild the original package, retaining the name org.newdawn.*,
- build a new package, with a different name, that depends on the original xith-md2 package (might be messy to do it this way),
- build a new package, borrowing from the existing code and giving appropriate credit, and call it something else,
- something completely different?

Thanks.
Offline kevglass

JGO Kernel


Medals: 188
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #5 - Posted 2005-11-16 10:50:59 »

I believe the MD2 loader have migrated into the Xith-Tk repository (William?) and hence the package has probably already changed on the latest version.

If it'd still been under my maintainence, I'd say submit a patch and I'd make the update on the original code. However, since the loader is in Xith-Tk now the right thing to do would be to get access to that CVS and make the changes to the base.

Of course, you can at the end of the day, do as you choose Smiley

Kev

Offline arne

Senior Duke




money is the worst drug- we should not let it rule


« Reply #6 - Posted 2005-11-16 11:43:25 »

yup it's in the xith-tk.

I think the latest build of the xith-tk already contains it. So, if you don't want to work with the cvs simply post what you've changed in the loader (it's probably only in one single file) and then someone with developer-status will commit it.

I believe the cvs for the loader didn't change since then, but you could make sure, by simply downloading the file your changing by going to xith-tk.dev.java.net -> CVS.

:: JOODE :: Xith3d :: OdeJava ::
Offline Amos Wenger

Senior Duke




Everything's possible, but not everything's fun...


« Reply #7 - Posted 2005-11-16 16:09:10 »

By the way, who have the developer access on the Xith3D core ? William put aside, I don't know any...
Maybe the Xith3D project should be more open, it would help it to be more active..

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline arne

Senior Duke




money is the worst drug- we should not let it rule


« Reply #8 - Posted 2005-11-16 18:20:23 »

Quote
By the way, who have the developer access on the Xith3D core ? William put aside, I don't know any...
Maybe the Xith3D project should be more open, it would help it to be more active..

We were talking about the xith-tk here - but I haven't got developer acess for the xith-tk either.

But I think Will would approve your request for a developer role, if you would request one.

Edit: croft probably has developer-role (at least for the xith-tk)

:: JOODE :: Xith3d :: OdeJava ::
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #9 - Posted 2005-11-17 12:38:13 »

Anyone is welcome to become a member of the Xith-tk project, it's very open.

We only ask that you respect other people's work and don't break the standards that are in place.

Read this info:  http://xith.org/XithToolkitContributions and the linked governance page (which also explains why the TK project exists and why it is good)


arne, Magic Spark, kevglass, please feel free to apply and I will approve the requests ASAP.

Cheers,

Will.

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

Senior Duke




Everything's possible, but not everything's fun...


« Reply #10 - Posted 2005-11-17 17:48:32 »

Quote
By the way, who have the developer access on the Xith3D core ? William put aside, I don't know any...
Maybe the Xith3D project should be more open, it would help it to be more active..

We were talking about the xith-tk here - but I haven't got developer acess for the xith-tk either.

But I think Will would approve your request for a developer role, if you would request one.

Edit: croft probably has developer-role (at least for the xith-tk)
I know we were talking about xith-tk. But I'm talking about xith core. I have developer access for Xith-tk, thanks William, but I think there are things that cannot be put in the xith-tk, such as different culling methods (that are currently only implemented by shape3D), or other optimizations.. I'll pay more attention to these techniques in the future, because actually with the pre-version of the game I'm working on, they are really useless. But I think having them for making a game with very large maps (e.g. a FPS or a MMORPG) could be required.
I don't need to have a xith core developer status for now, but maybe in the future. If frustum culling and occlusion culling can be implemented as a separate package, then I'll put them in the Gamma project.
(@arne : do you still follow the Gamma project ? maybe it seems to you it's dead, but we've changed the repository.. we now have a private repository that uses SVN. I'll give you more infos if you're stil interested)

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline arne

Senior Duke




money is the worst drug- we should not let it rule


« Reply #11 - Posted 2005-11-17 18:00:47 »

Quote
we now have a private repository that uses SVN. I'll give you more infos if you're stil interested)

give me those infos and I'll look if I have time (depending on how much has changed since)

:: JOODE :: Xith3d :: OdeJava ::
Offline Amos Wenger

Senior Duke




Everything's possible, but not everything's fun...


« Reply #12 - Posted 2005-11-18 16:57:12 »

I'll send you by PM.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #13 - Posted 2005-11-19 03:15:43 »

Sorry, I'm confused.

Re the core, Yuri and I are the two main people with commit access.  Most changes that are submitted are committed (e.g. TextureLoader2), however there is a quality process to keep the core clean.

If you would like to make a change to the core, please submit an issue on IssueZilla with either changed files or a diff, the community can review it and I will commit it in.

Cheers,

Will.

Offline Amos Wenger

Senior Duke




Everything's possible, but not everything's fun...


« Reply #14 - Posted 2005-11-19 08:51:33 »

Sorry, I'm confused.

Re the core, Yuri and I are the two main people with commit access.  Most changes that are submitted are committed (e.g. TextureLoader2), however there is a quality process to keep the core clean.

If you would like to make a change to the core, please submit an issue on IssueZilla with either changed files or a diff, the community can review it and I will commit it in.

Cheers,

Will.

Okay, I see.
No problem, then.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline 5parrowhawk

Senior Newbie




Java games rock!


« Reply #15 - Posted 2005-11-22 08:16:11 »

I am pleased to report that the new normal modification actually seems to work.

I'm afraid that my modification does raise the RAM load per model quite a bit (approx. 1 extra byte per vertex per frame, plus extra vector arrays to hold the normal data), and I'll have to go over the code and clean it up before submitting. Also, I didn't do a proper normal-interpolation for the frame interpolation as I couldn't figure a fast way to do it, so I just averaged the normals and threw in a quick and dirty hack to prevent it from crashing out if it encountered a zero normal. In the modifications I have attempted as much as possible to privilege speed over memory usage (memory's cheap).

Sorry - like I said, I'm an armchair coder and hence not that well-versed with the use of CVS, etc. Would it be acceptable to just compress up the changed files (5 changed, 1 completely new) and send them to somebody? If so, who? If not, what's the best format for submitting the changes? Is the output from a diff acceptable, and if so which switches should be used for ease of review?

Thanks for all the support and help.
Offline arne

Senior Duke




money is the worst drug- we should not let it rule


« Reply #16 - Posted 2005-11-22 18:08:00 »

Nice work Smiley

I'm afraid that my modification does raise the RAM load per model quite a bit (approx. 1 extra byte per vertex per frame, plus extra vector arrays to hold the normal data), and I'll have to go over the code and clean it up before submitting. Also, I didn't do a proper normal-interpolation for the frame interpolation as I couldn't figure a fast way to do it, so I just averaged the normals and threw in a quick and dirty hack to prevent it from crashing out if it encountered a zero normal. In the modifications I have attempted as much as possible to privilege speed over memory usage (memory's cheap).

Why don't you make something like a flag "turn_normals_on"  then you would have all advantages with no drawbacks?
Because then if it is not set, your code doesn't get executed.

Arne

:: JOODE :: Xith3d :: OdeJava ::
Offline 5parrowhawk

Senior Newbie




Java games rock!


« Reply #17 - Posted 2005-11-23 06:34:06 »

Thanks. Have implemented that, but only for loading the MD2Model directly with load() - in other words the load() methods that return a Scene automatically default to loading the version with normal data. I believe that should - hopefully - be sufficient.

I've zipped up the new files, the original files (.old), and diff output (.diff). (MD2Normals.java doesn't have .old or .diff info 'cause it wasn't in the previous version.) Since I don't have write-access to the TK filesharing page, I've uploaded it here:

http://steel.lcc.gatech.edu/~nng/files/MD2_Loader_Mods.zip
Offline kevglass

JGO Kernel


Medals: 188
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #18 - Posted 2005-11-23 15:07:05 »

Nice work chap!

Kev

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #19 - Posted 2005-11-30 12:28:01 »

Hi,

You should have dev access to the Xith-TK CVS now, please feel free to commit your changes in (assuming from what I've read that they shouldn't break people's existing code) so others can easily benefit.

Thanks,

Will.

Offline arne

Senior Duke




money is the worst drug- we should not let it rule


« Reply #20 - Posted 2005-12-04 16:11:11 »

because it still wasn't commited, I now looked at the code, checked, if it manages everything fine, also with normals turned off, without changing code. I've found nothing to complain about, so I've committed it for 5parrowhawk.
Enjoy the changes Smiley

:: JOODE :: Xith3d :: OdeJava ::
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #21 - Posted 2005-12-05 11:37:34 »

Thanks arne!

Will.

Offline 5parrowhawk

Senior Newbie




Java games rock!


« Reply #22 - Posted 2005-12-13 15:43:46 »

Oh, I'm sorry. I hadn't been checking the forums for awhile - mea culpa. Sad Thanks for helping me to commit it, arne.
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.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (43 views)
2014-10-16 15:22:06

Norakomi (33 views)
2014-10-16 15:20:20

lcass (37 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (66 views)
2014-10-14 00:35:47

TehJavaDev (59 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (86 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!