[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Billiards-devel] Programming experiments with Billiards
From: |
Tadej Janež |
Subject: |
Re: [Billiards-devel] Programming experiments with Billiards |
Date: |
Tue, 19 Jan 2010 12:41:09 +0100 |
Hi,
just a quick reply because I'm currently stuck...
I'll reply to the other parts later.
On Wed, 2010-01-13 at 14:33 +0200, Dimitris Papavasiliou wrote:
> Ok, perfect. This is what I needed.
>
> Now, I tried setting observer's position with something like:
> bodies.observer.longitude = -1.42
> bodies.observer.latitude = -0.71
> bodies.observer.radius = 0.4
> bodies.observer.elevation = math.pi / 2 -
> bodies.cue.elevation -
> math.rad (5)
>
>
> but it didn't work. Basically, I want to change observer's
> direction
> like you do with holding down the left mouse in the looking
> mode.
> Anyway your problem is probably caused by the fact that one of my own
> hooks fires after yours and resets the observer heading back to the
> way *I* like it. Pretty annoying innit? You'll have to sort that
> out... :)
Ok, I think I found the "offending" code in game.lua, lines 177-178. Now
I can set the observer longitude and latitude.
I also managed to set the observer's azimuth with this code
local oldnewshot = billiards.looking.newshot
billiards.looking.newshot = function ()
-- First call the old function to setup the default
-- behavior we don't want to change.
oldnewshot()
-- Now change what we don't like.
bodies.observer.azimuth = math.rad(90)
bodies.observer.elevation = math.rad(45)
bodies.observer.longitude = bodies.cueball.position[1]
bodies.observer.latitude = bodies.cueball.position[2]
end
> Well it calculates the length or magnitude of a vector. So this would
> result in the speed of the ball in m/s regardless of its direction of
> motion.
Aha, thanks for explaining that.
> There's currently no mechanism I know of that allows you to switch
> modes programmatically. It shouldn't be hard to improvise one though.
> If you look inside ball.lua you'll see that there are some event nodes
> linked under each ball (with switch or button nodes on top of them)
> which catch the mouse clicks on the balls and either switch the active
> cue ball or enter aiming mode if the clicked ball already is the cue
> ball. Just put the code that enters aiming mode in a function of your
> own and call it from wihtin your script to get rid of the need to
> manually click the ball. Next move the cue as you already do to shoot
> the ball and then wait until you no longer are in waiting mode.
> Lather, rinse, repeat. I'm not sure if this will work but it seems
> likely. I'll have to try it out myself when I get the time.
Ok, I tried to implement the transition between looking and aiming mode
with the following:
if options.experiment2 then
billiards.looking.experiment2 = function ()
for i, ball in ipairs (bodies.balls) do
local x = ball.position[1]
local y = ball.position[2]
if i == 1 then
print (string.format ("White ball position: (%f, %f)", x,
y))
elseif i == 2 then
print (string.format ("Black ball position: (%f, %f)", x,
y))
end
end
print ("Entering aiming mode...")
bodies.observer.islooking = false
bodies.observer.isaiming = true
end
billiards.aiming.experiment2 = function ()
print ("Stepping into function 'billiards.aiming.experiment2'")
joints.arm.motor = {arm_velocity, 1000}
end
end
but it doesn't work. The console output shows the text:
"Stepping into function 'billiards.aiming.experiment2'", but the balls
don't move.
Can you help me with this?
Greetings,
Tadej
--
Tadej Janež <address@hidden>
Fakulteta za računalništvo in informatiko
- [Billiards-devel] Programming experiments with Billiards, Tadej Janež, 2010/01/11
- Re: [Billiards-devel] Programming experiments with Billiards, Dimitris Papavasiliou, 2010/01/14
- Message not available
- Message not available
- Re: [Billiards-devel] Programming experiments with Billiards, Dimitris Papavasiliou, 2010/01/15
- Re: [Billiards-devel] Programming experiments with Billiards,
Tadej Janež <=
- Re: [Billiards-devel] Programming experiments with Billiards, Dimitris Papavasiliou, 2010/01/19
- Re: [Billiards-devel] Programming experiments with Billiards, Tadej Janež, 2010/01/19
- Re: [Billiards-devel] Programming experiments with Billiards, Dimitris Papavasiliou, 2010/01/19
- Re: [Billiards-devel] Programming experiments with Billiards, Tadej Janež, 2010/01/20
- Re: [Billiards-devel] Programming experiments with Billiards, Dimitris Papavasiliou, 2010/01/21