PDA

View Full Version : Expressions and Jetflares

SonicN2O
05-08-2011, 06:09 PM
To quote "Essential lightwave v9", page 895 paragraph 1:
"For instance, taking the movement of a spacecraft and relating it to the intensity of the engine glare..."
I want to do just that. Problem is I have absolutely no idea how; I'm pretty bad at expressions.

borkus
05-09-2011, 09:33 PM
I wish I could help you. I have researched this a bit, but feel this link will help you more then I can in volumes... Lightwave Expressions (http://lmgtfy.com/?q=lightwave+expressions)

falogfx
05-10-2011, 05:46 AM
I haven't got Lightwave available, but you could possibly make an expression something like this:

sqrt( ([Ship.Position.X, Frame] - [Ship.Position.X, Frame - 1]) * ([Ship.Position.X, Frame] - [Ship.Position.X, Frame - 1]) + ([Ship.Position.Y, Frame] - [Ship.Position.Y, Frame - 1]) * ([Ship.Position.Y, Frame] - [Ship.Position.Y, Frame - 1]) + ([Ship.Position.Z, Frame] - [Ship.Position.Z, Frame - 1]) * ([Ship.Position.Z, Frame] - [Ship.Position.Z, Frame - 1]) ) * 2 + 0.3

Where Ship is the name of your spacecraft object. Change it to the correct name.

The long sqrt expression gives the current speed of Ship (between current and last frame).

The number "2" is the factor that the speed is multplied with. Adjust to your liking. This value should probaly be much lower for a fast moving object, like 0.001.

The number "0.3" is the initial intensity of the glare when speed is zero.

Create the expression in graph editor and attach it to your intensity channel.

I hope I have done the math correctly, that it works and that I've made no typos. :)

DBMiller
05-10-2011, 07:25 AM
I wish I could help you. I have researched this a bit, but feel this link will help you more then I can in volumes... Lightwave Expressions (http://lmgtfy.com/?q=lightwave+expressions)

If this is the best answer you care to give someone asking for help then why bother?:devil:

OnlineRender
05-10-2011, 07:47 AM
yeah but now you need to teach Sonic excatly where and how to put it :) , so if you don't mind we need 8 video tutorials :) :rock: with colour coordinated pdfs

shrox
05-10-2011, 02:58 PM
For light lens flares, copy the envelope of the FOV or camera zoom, then paste that into the global lens flare graph. Use the scale tool, set the cursor at 0%, then scale the values until the first key is at 100%. It's hack, and kind of loses it at extreme zooms, but it works well enough.

SonicN2O
05-10-2011, 05:42 PM
If this is the best answer you care to give someone asking for help then why bother?:devil:

Actually, posting a link to a good tutorial IS a way to give someone help. thanks Borkus

OnlineRender, keep your comments to yourself.

OnlineRender
05-10-2011, 06:07 PM
Actually, posting a link to a good tutorial IS a way to give someone help. thanks Borkus

OnlineRender, keep your comments to yourself.

No comment,well maybe just one ............. you joking me the user falogfx just wrote you a wicked expression for FREE ....................I suggest you use it to your advantage and as for tutorials http://tinyurl.com/5t9gcpq

SonicN2O
05-10-2011, 06:11 PM
OK. Thank you. I just don't like it when you tease me.

SonicN2O
05-10-2011, 06:28 PM
The Expression works like a dream!

falogfx
05-11-2011, 02:00 AM
The Expression works like a dream!

Glad to hear that! I still haven't tested it myself :)

SonicN2O
05-11-2011, 05:00 PM
I wish I could help you. I have researched this a bit, but feel this link will help you more then I can in volumes... Lightwave Expressions (http://lmgtfy.com/?q=lightwave+expressions)

WAIT... That was lmgtfy? you know that's rude, right?

SonicN2O
05-22-2011, 07:51 AM
For that expression I'm using... Is there a way to make it so that the intensity doesn't go below zero? Also I have these thrusters that turn the ship sideways. I there a way to make an expression that plays the bank axis? sorry... I don't know much about expressions...

SonicN2O
05-22-2011, 07:53 AM
No comment,well maybe just one ............. you joking me the user falogfx just wrote you a wicked expression for FREE ....................I suggest you use it to your advantage and as for tutorials http://tinyurl.com/5t9gcpq

lmgtfy.com... right... THANKS, but i think I know how to use google.

falogfx
05-23-2011, 04:06 AM
For that expression I'm using... Is there a way to make it so that the intensity doesn't go below zero? Also I have these thrusters that turn the ship sideways. I there a way to make an expression that plays the bank axis? sorry... I don't know much about expressions...

I suppose you're talking about the expression I wrote for you earlier in this thread.
Because of how the ship's speed is calculated, the output value of that expression can not be below zero. That is, as long as you are using positive numbers for initial intensity and the multiplier. So I don't know why you are getting negative values.

Yes, you can make an expression that takes the bank axis as input. You will need two different expressions, one for each side.

You could write them something like this. Example for one side, try to figure the other side out yourself.

Name: TurnLeft
Expression:
( ([Ship.Rotation.B, Time]-[Ship.Rotation.B, Time - 0.1]) > 0 ? abs([Ship.Rotation.B, Time]-[Ship.Rotation.B, Time - 0.1])/360 * 2 : 0 ) + 0.3

How it works:
Let's simplify the expression to a more readable form...
( BankDifference > 0 ? abs(BankDifference) / 360 * 2 : 0 ) + 0.3

Gets difference (or speed) in bank rotation and checks if it is greater than zero. If it is, then we know that we are turning left and the absolute value of the difference is calulated, divided by 360 (degrees) and multiplied by 2 (or whatever value fits the desired intensity)

If the difference in rotation is zero or negative, set to 0 (../360 * 2 : 0).

0.3 is then added to the result to set the initial intensity. This can of course be another non negative value that suits your needs.

You could also try to use other time spans in the expressions to get delay effects. For example:
([Ship.Rotation.B, Time + 1]-[Ship.Rotation.B, Time + 0.9]) will make the thrusters start burning one second before the ship begins to turn, and also stop to burn one second before the ship stops turning.

Expressions are quite fun :)

Good luck!

SonicN2O
05-24-2011, 11:24 AM
I suppose you're talking about the expression I wrote for you earlier in this thread.
Because of how the ship's speed is calculated, the output value of that expression can not be below zero. That is, as long as you are using positive numbers for initial intensity and the multiplier. So I don't know why you are getting negative values.

Yeeeah... For the retro thruster, I just took the negative of the first expression and copied it. I'm such a noob:twak:

falogfx
05-24-2011, 03:00 PM
Good idea but unfortunately wrong ;)

To accomplish what you're after you will need to know which direction the ship is facing (both heading and pitch, since we're in space) and you will also need to know the direction of the current motion vector. That would, I presume, involve quite a bit more complicated calcs than what I've previously tried to show here.

I think you will need to compare the rotation of the ship with the current direction of the motion. If the angles are the same then the ship is going forwards, if the angles are 180° apart the ship is going backwards. You will then need to feed all that into expressions with conditional statements that takes care of the ignition of each thruster.
I'm not even going to try that one right now!

I am really interested in hearing other ideas on this one. Maybe there is some simpler way to do it.

SonicN2O
05-26-2011, 06:00 PM
I did a quick test with the ship moving forward and turning left, I'm puzzled by the outcome...
95522

falogfx
05-27-2011, 03:30 AM
Can you be more specific about what your problem is?
If the problem is that both turning thrusters are glowing, then you just need to set the "0.3" constant in the turning expressions to zero (or delete it).

Mind also that you must make two different expressions for the two thrusters. As I think you have already figured out, the expression for the turn right thruster should look like this:

Name: TurnRight
Expression:
( ([Ship.Rotation.B, Time]-[Ship.Rotation.B, Time - 0.1]) < 0 ? abs([Ship.Rotation.B, Time]-[Ship.Rotation.B, Time - 0.1])/360 * 2 : 0 ) + 0.3 (change this last constant to zero or whatever you need)

Notice that the comparison operator is now "less than" (<) instead of "greater than" (>). That is the only difference!

Going a little deeper into expressions I could mention the ability to use sub expressions. That means you can use an already created expression within another expression. That way you can reuse calculations that you are doing many times, and it can also make your expression code more readable. You could try to do this for the thruster expressions:

1. Create an expression for the difference in bank rotation:
Name: BankDiff
Expression: [Ship.Rotation.B, Time]-[Ship.Rotation.B, Time - 0.1]

2. Reuse it in thruster expressions:
Name: TurnLeft
Expression: ( [BankDiff] > 0 ? abs([BankDiff])/360 * 2 : 0 ) + 0.3

Name: TurnRight
Expression: ( [BankDiff] < 0 ? abs([BankDiff])/360 * 2 : 0 ) + 0.3

SonicN2O
05-27-2011, 07:03 PM
Oops, I had the anaglyph filter on. It's fixed.