Link:INB Home|INB English| INB русский язык|INB العربية|INB Türkiye|INB فارسی|INB Español|INB Français|INB Português|INB Deutsch|INB 國語|INB 中文|INB 日本语|INB 한국어|INB ภาษาไทย|INB tiếng Việt||Tutorials LightWave 3D Expression Physics: Projectile Trajectory
INB Português Fórum
BEM - vindo a indústria nativa e "boffin") Da era industrial, aqui está cheio de espírito de Luta, Ambos através Da rede espaço biológico nativo espírito "boffin" VEIO a mad labs.Casa inbforum.com, Nome Definitivo: inb-english.forumotion.com
INB Português Fórum
BEM - vindo a indústria nativa e "boffin") Da era industrial, aqui está cheio de espírito de Luta, Ambos através Da rede espaço biológico nativo espírito "boffin" VEIO a mad labs.Casa inbforum.com, Nome Definitivo: inb-english.forumotion.com
INB Português Fórum

BEM - vindo a indústria nativa e boffin) Da era industrial, aqui está cheio de espírito de Luta, Ambos através Da rede espaço biológico nativo espírito boffin VEIO a mad labs.Casa inbforum.com, Nome Definitivo: inb-english.forumotion.com


Você não está conectado. Conecte-se ou registre-se

《《《《《《《上一页INBforum   Ir para baixo

上一页INBforum》》》》》》》Ver o tópico anterior Ver o tópico seguinte Ir para baixo  Mensagem [Página 1 de 1]

1Tutorials LightWave 3D Expression Physics: Projectile Trajectory Empty Tutorials LightWave 3D Expression Physics: Projectile Trajectory Qua Jan 26, 2011 2:24 am

Admin

Admin
Admin
Download source
files here.
Tutorials LightWave 3D Expression Physics: Projectile Trajectory Pixel_black


A virtual environment like LightWave 3D® is
great for doing simulation work. It's even better
for somebody who can do a little programming,
because you can bring physical things to life.
That's what we'll do in this tutorial. We'll
convert some physics equations for projectile
motion into LightWave Expressions.

The branch of physics that
deals with motion is known as mechanics.
Projectile motion falls within this branch. The
physics equations we'll need to simulate the
phyiscal motion of a projectile are:
<blockquote>
x = v0 cosθ0 t
y = v0 sinθ0 t
- ½gt²

</blockquote>

Some of the elements of these
formidable-looking equations are v0 (V-naught),
which represents the initial velocity of the
projectile, θ0 (Theta-naught)
which indicates the initial angle of elevation
from the horizontal, t for the time
index, and g for the acceleration due
to gravity (which, for the Earth, is approximately
9.8 m/s²).

Let's talk a little first about
converting these physics equations into something
usable.

Converting the Equations

Converting these equations into
LightWave Expressions is a simple matter of performing
a step-by-step substitution of the the components
previously described with the values we need.
For instance, if we selected an initial velocity
of 10 m/s for the projectile, this value will
go into both equations as a direct replacement
for v0:
<blockquote>
x = 10 * cosθ0 t
y = 10 * sinθ0 t
- ½gt²

</blockquote>

Next, for θ0,
we will use the banking angle of an object in
the scene called "Cannon". We will use the Expressions
channel syntax to acquire the initial angle of
the equation based upon the banking of the scene
object:
<blockquote>
x = 10 * cos([Cannon.Rotation.B,0.0]) t
y = 10 * sin([Cannon.Rotation.B,0.0]) t
- ½gt²

</blockquote>

A minor problem with using
this angle measurement directly is that the sin()
and cos() functions expect angles to be in radian
measurement, while the channel expressions used
above return them in degrees. So, we must wrap
each channel reference in a call to rad() to
convert to the correct units:
<blockquote>
x = 10 * cos(rad([Cannon.Rotation.B,0.0])) t
y = 10 * sin(rad([Cannon.Rotation.B,0.0])) t - ½gt²
</blockquote>

The t element in each
equation can be substituted rather neatly using
the Expressions Time variable:
<blockquote>
x = 10 * cos(rad([Cannon.Rotation.B,0.0]))
* Time
y = 10 * sin(rad([Cannon.Rotation.B,0.0]))
* Time - ½g(Time)²
</blockquote>

And g can be replaced
directly with the acceleration value for the
Earth's gravity, 9.8 m/s²:
<blockquote>
x = 10 * cos(rad([Cannon.Rotation.B,0.0]))
* Time
y = 10 * sin(rad([Cannon.Rotation.B,0.0]))
* Time - ½ * 9.8 * (Time)²
</blockquote>

Some final fix-ups on the equations
for proper evaluation order will give us the
initial expressions we can use in LightWave to
simulate the ballistic path of a projectile in
Earth's gravity:
<blockquote>
x = 10 * cos(rad([Cannon.Rotation.B,0.0]))
* Time
y = (10 * sin(rad([Cannon.Rotation.B,0.0]))
* Time) - (0.5 * 9.8 * (Time * Time))
</blockquote>

Applying the Expressions

In a clean scene, we'll first
add a Null object, and give it the name "Cannon".
In addition, we'll also load an object that will
server as our projectile:

Tutorials LightWave 3D Expression Physics: Projectile Trajectory Projectile_001

For the purposes of interactivity,
be sure that your "Auto Key" setting is turned
on.

Tutorials LightWave 3D Expression Physics: Projectile Trajectory Projectile_002

Now open the Graph Editor.
Make sure you have the the X channel of the projectile
selected, and add a new expression:

Tutorials LightWave 3D Expression Physics: Projectile Trajectory Projectile_003

Take the expression we developed
previously for the X channel value, paste it
into the expression "Value" area, and select "Apply":

Tutorials LightWave 3D Expression Physics: Projectile Trajectory Projectile_004
Follow the same steps for the Y channel expression:

Tutorials LightWave 3D Expression Physics: Projectile Trajectory Projectile_005

Back in the main LightWave
window, select the "Cannon" object, and adjust
its Bank angle value to 26.5 degrees:

Tutorials LightWave 3D Expression Physics: Projectile Trajectory Projectile_006

Pressing the play button will
cause the projectile to launch away from the "Cannon" object
at an initial elevation of 26.5 degrees, and
an initial velocity setting of 10 m/s:

Tutorials LightWave 3D Expression Physics: Projectile Trajectory Projectile_007

By changing the Bank angle
of the "Cannon" object, the projectile object
will automatically change its trajectory without
any further changes to the expressions controlling
it:

Tutorials LightWave 3D Expression Physics: Projectile Trajectory Projectile_008
Adding More Control

The existing system is useful
as it is, however, we can make it a bit more
interactive by allowing the user to adjust some
of the operational values within the active expressions
through the user interface. For instance, we
can allow the user to adjust the initial velocity
of the projectile by adding a new Null object
to the scene (call it "Vo"), and mapping the
X position of this Null object to the initial
velocity setting in the expressions.
First, we add a new Null and call it "Vo".
We give it an initial X position of 1 meter:

Tutorials LightWave 3D Expression Physics: Projectile Trajectory Projectile_009

Next, we adjust the expressions
we developed earlier by using the X position
of the "Vo" Null object to control the initial
velocity of the projectile. In order keep us
from having to run the velocity object off the
screen, we will scale its X position value by
10 (so that each meter of its position equals
10 m/s of initial velocity).
<blockquote>
x = (10 * [Vo.Position.X,0.0]) *
cos(rad([Cannon.Rotation.B,0.0])) * Time
y = ((10 * [Vo.Position.X,0.0]) *
sin(rad([Cannon.Rotation.B,0.0])) * Time) -
(0.5 * 9.8 * (Time * Time))
</blockquote>

Another adjustment we can make
is to keep the projectile from falling below
the level of the "Cannon" object. In the current
expressions, this can happen after the projectile
falls back to the ground level defined by the "Cannon" object:

Tutorials LightWave 3D Expression Physics: Projectile Trajectory Projectile_010

We can apply the clamp() function
to the Y expression to prevent the projectile
from falling below the level of the "Cannon" object's
Y position. In the clamp() function, we set the
lower level (minimum) value to be the "Cannon" object's
Y position, and the uppper level (maximum) value
to be some arbitrarily high number:
<blockquote>
clamp(((10 * [Vo.Position.X,0.0])
* sin(rad([Cannon.Rotation.B,0.0])) * Time)
- (0.5 * 9.8 * (Time * Time)),[Cannon.Position.Y,0.0],50000.0)
</blockquote>

Tutorials LightWave 3D Expression Physics: Projectile Trajectory Projectile_011
Going Beyond...

The expressions we just created
represent pretty much the limit of what we can
accomplish with them within LightWave®'s
Expressions system. A great deal more can be
done (for instance, adding an arbitrary floor
for the projectile to land upon) by controlling
the projectile through an LScript. Now that the
equations have been converted for you, as a personal
exercise you may want to try writing your own
LScript (Item Motion) that reproduces the actions
of the these expressions, and then add more features
to it.
]

http://pt.inbforum.com

上一页INBforum   Ir para baixo

上一页INBforumVer o tópico anterior Ver o tópico seguinte Ir para o topo  Mensagem [Página 1 de 1]

Permissões neste sub-fórum
Não podes responder a tópicos

Copyright ©2009-2010 LTD Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

IT:SINGLESERVGoogle谷歌翻译TranslateFORUMSOFTLAYERGoogle谷歌广告联盟AdSenseAsia

 

Forumeiros.com | ©phpBB | Fórum gratuito de ajuda | Denunciar um abuso | Fórum grátis