Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
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  
  Which math library do you recommend?  (Read 2737 times)
0 Members and 1 Guest are viewing this topic.
Offline theagentd
« Posted 2012-02-08 12:00:51 »

I'm working on cleaning up my skeletal animation test program. I had planned to stop using LWJGL's built-in matrix and vector classes but I just haven't bothered to do so, but when I started with animation I realized how many lacking features there were, especially in the Quaternion class. Now I'm out hunting for a good math library.

Here is a list of features that I need. Functions in red are missing from LWJGL's math lib.
 - Matrix4x4 operations: translate by vector, multiply, invert.
 - Vector4 functions: transform by matrix
 - Quaternion functions: quat-quat multiplication, rotate vector by quaternion, slerp, quaternion to matrix conversion.

Performance related features:
 - No allocations. I'll be doing a lot of math for each bone, so being forced to allocate new objects all the time is going to increase GC stuttering quite a bit.
 - Everything is going into FloatBuffers in the end, so something similar to LWJGL's Matrix4f.load(floatBuffer) would be nice but not necessary.
 - I only need float precision these classes. Double precision would reduce performance and double the GPU bandwidth needed for an unnoticeable increase in precision.

Obviously I can survive with the LWJGL math lib, but I'd really like to start using a better one if possible. What do you guys use and recommend?

Myomyomyo.
Offline Roquen
« Reply #1 - Posted 2012-02-08 12:22:37 »

I know of none I consider usable for gaming purposes.  I'd publish mine, but even I hate it.  I can give you sketches of the missing functionality if you desire (hey you already have direct rot vector by quat!)  WRT: SLERP - there are multiple ways to implement depending on how it's going to be used. Also I assume that by "quat to matrix" conversion that you really mean "quat rotation function to matrix".  Also exp & log are very useful for design purposes if you want to play around with curves in quaternion space (used for blending between animations...say walk -> run, etc.)

WRT: Bones I'd consider using quaternion/vector pairs...in that manner you can choose to perform the rotation in the most efficient manner depending on the number of attachments at a given joint.  Also (maybe not worth the effort) one degree of freedom joints have a simpler quaternion formulation.  It's possible to use dual-quaternions (AKA Study quaternions, normalize Plucker coordinates) for generalized screw motions, wrenches, etc.  Or better yet find a working library (and tell me about it Wink )
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 74
Projects: 15


★★★★★


« Reply #2 - Posted 2012-02-08 12:44:13 »

The javax.vecmath isn't a bad choice.

javadoc
http://download.java.net/media/java3d/javadoc/1.5.0/javax/vecmath/package-summary.html

binary builds
http://java3d.java.net/binary-builds.html
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Roquen
« Reply #3 - Posted 2012-02-08 12:50:51 »

javax quaternions are pretty broken, both for performance and accuracy...don't recall about the other types.
Offline Danny02
« Reply #4 - Posted 2012-02-08 13:43:39 »

why not build our own math libary, just copy past available code from different packages and make one big math libary for games.
I have published my math code in the showcase section, which has some more functions then the lwjgl libary but isn't that good on some other aspects.

We could just think of some best practises we what to have in our libary, like useing floatbuffers and having not many object allocations and so on and refactor exsiting code.
Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #5 - Posted 2012-02-08 14:03:37 »

libgdx Cheesy
It is actively developed. Everyone can always contribute to improve it!

Offline theagentd
« Reply #6 - Posted 2012-02-08 14:51:46 »

Thanks for the suggestions everyone! I'll have to check up the ones you suggested more thoroughly before I make a decision though...

How is libgdx a math library? Does it have an util library that I can add to my game?

Myomyomyo.
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 74
Projects: 15


★★★★★


« Reply #7 - Posted 2012-02-08 15:11:06 »

How is libgdx a math library? Does it have an util library that I can add to my game?
It has a maths package which can easily be ripped out, seems really neat and clean too.

Another option you could try is OpenMaLi (Open Math Library) used by engines like Xith3D.
Offline lhkbob

JGO Knight


Medals: 32



« Reply #8 - Posted 2012-02-08 16:41:32 »

My math library avoids allocations and took its quaternion implementation from Bullet.  ATM it might have too many abstraction layers to allow for read-only types, but I'm considering changing it to have public fields and no interface/abstract types to emphasize performance.

Link is here: http://code.google.com/p/ferox-gl/source/browse/#svn%2Ftrunk%2Fferox-math

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.

CogWheelz (15 views)
2014-07-30 21:08:39

Riven (21 views)
2014-07-29 18:09:19

Riven (14 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (32 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!