billiards-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Billiards-devel] Programming experiments with Billiards


From: Dimitris Papavasiliou
Subject: Re: [Billiards-devel] Programming experiments with Billiards
Date: Thu, 21 Jan 2010 10:36:40 +0200

Hello,

Currently there is one big issue, namely that sometimes the balls just
won't stop for a very long time (30s or more) and very very slowly move
forward.
This effect can be observed with your experiment.lua setup and I find it
to be quite undeterministic. Sometimes they step right after the shot
and sometimes it takes more than half minute.

However, this only appears on my Fedora 11 with custom compiled ODE. I
was following the comment posted on Linux Game Tome and used the
following configure options:
%configure --enable-shared --disable-static --disable-asserts
--with-trimesh=opcode --enable-double-precision

Jure has Ubuntu 9.10 and doesn't observe the issue so I'm guessing it
has something to do with the different underlying ODE package. He's
using stock Ubuntu packages for ODE (I'll have to check their configure
options).

Do you have any idea what's wrong?

Normally I'd say that you're maybe not using double precision but if you've compiled ODE yourself with the configuration above then that's not the case.  Are you sure that the custom ODE library is the only installed one?  Maybe you've also installed the Fedora package and the runtime linker defaults to that?  You can see which version the binary has linked against by running:

ldd /usr/local/lib/techne/techne.
bin
 
A way to avoid this would be to have a hook triggered every 0.1s and
check if the balls moved for less that epsilon and end the shot.
 
There are also hooks associated with each node, with each ball for example.  During each frame the tree is traversed multiple times.  There's the transform pass, the prepare pass, the traverse pass and the cleanup pass firing in this order and each has a hook that runs custom code if needed.  So to solve you're problem the way you describe you'd write somting like:

for _, ball in pairs (bodies.ballls) do
    ball.prepare = function (self)
        if math.length (ball.velocity) < epsilon_1 and
           math.length (ball.spin) < epsilon_2 then
            ball.velocity = {0, 0, 0}
            ball.spin = {0, 0, 0}
         end
     end
end

This is how Billiards itself more or less decides whether the shot has ended.  You'll find the relevant code I think in game.lua and billiard.lua.  Look for "isstable" and "isresting".  Maybe tweaking the code there can fix the problem.  Finally one more option would be to dampen the ball's velocity and spin once it has crossed a threshold so as to make it stop artificially.  There was a body parameter to do just that but because the relevant functionality was only available in ODE 0.11 I commented out and I don't remeber if I commented it back in again or what it's name was for that matter.  Come to think of it there is a parameter called 'lethargy'.  It's a parameter of body nodes, and it controls the autodisable parameters of an ODE body.  Look in the ODE manual for what autodisable is and what the parameters mean.  The balls lethargy values are set in billiard.lua or game.lua I think.  Tweaking those could help as well.  Just make sure the balls don't get too lethargic and fall asleep too soon.

I have three more things I want to ask you:
1) How can I automatically save the .svg picture of the shot at the end
of the shot?

Again I can't be sure as I can't try it out right now but you can see inside httpd.lua where it defines:

if options.pool then
   network.pages["/drawtable"] = resources.readfile "billiards/pages/drawpool.lua"
elseif options.billiards then
   network.pages["/drawtable"] = resources.readfile "billiards/pages/drawbilliards.lua"
end

network.mime["/drawtable"] = "image/svg+xml"
 
This defines a page in Techne's http server, by default accesible at http://localhost:29176/drawtable and with content of type "image/svg+xml" created by "billiards/pages/drawpool.lua".  So in order to get the page I suggest you write some sort of script that telnets to localhost:29176 and sends a GET http command then writes the reply to a file.  You can then call this script during your logging hook.

2) The shot picture seems to be mirrored across the x-axis. How can I
fix this?

Ummm, i don't mean to get technical but, well technically it can't be mirrored since the table's in-game orientation depends on the viewer.  Anyway may I suggest you switch the initial position of the balls and cue?  Alternatively you can use some external postprocessing tool to flip the images.
 
3) Using -c option to specify my own lua script for Billiards doesn't
work:
address@hidden billiards-0.3.1]$ billiards -c
~/workspace/Billiards1/src/my_experiment.lua
Greetings fellow user, this is Techne 0.1.

Let's see what kind of junk we're dealing with here.
The graphics renderer is a 'ATI Mobility Radeon HD 3650 2.1.9026'.
The framebuffer configuration is [8, 8, 8, 8, 24, 8].
The rendering context is direct.
The audio renderer is 'Software 1.1'.

We're up and running!
Reading the configuration script.
Hmmm, I just got this unprotected error from the Lua interpreter:
"...ome/tadej/workspace/Billiards1/src/my_experiment.lua:102: attempt to
index global 'billiards' (a nil value)"
No point in prolonging this dreary existence I suppose...

I'm attaching my custom my_experiment.lua script.

I couldn't see anything wrong with your script yesterday, although I could only examine it in vitro, as I didn't have any input files to run it with.  Weren't you able to run custom scripts with the -c option before?  When did the problem first arise?  Were you able to run my initial version of experiment.lua, the one I sent you together with 0.3.1?  If so try commenting out your changes one by one up to the line you get the error until you get back to the initial version.  It should theoretically run then and in the process you should find out which of your changes is causing the trouble.

But this is strange.  It either means that Techne runs your script before running Billiards and I can't see why this would happen all of a sudden.  The other possibility is that you somehow either overwrite the billiards table or change the whole global environemt but I can't see that happening in your code either.

Maybe I'll be able to give you a more educated guess when you answer some of the questions above.
 
BTW, I'm also Fedora packager and was thinking about packaging up Techne
and Billiards. What do you think about this?

I think it would be great!  There are a lot of Fedora users that are having trouble compiling Billiards I think mostly due to the fact that library packages there don't include pkg-config configuration information which my configuration script depends upon.  In any case I'll try to have 0.3.1 ready by the end of the week so when that is released you can package that.  There's also an upcoming new release of Techne with a lot of fixes but no new features as far as I remember but I don't know when that will be ready.  Maybe I'll wait until the networking code I'm working on is ready.
 
There are 2 small bugs in configure.ac of both Techne and Billiards,
which are exposed on Fedora:
The line with:
  AC_CHECK_PROGS(LUAC, [luac5.1 luac51 luac]])
should be replaced with:
  AC_CHECK_PROGS(LUAC, [luac5.1 luac51 luac])

Thanks for pointing that out.  It'll be corrected in 0.3.1 and the next release of Techne but what is the second bug?  Or did you mean there's one in each script so a total of two?

Dimitris

PS:  Also let me know if you have any other ideas/requests for 0.3.1 I should consider.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]