Board index Roller Coaster Games NoLimits Coaster 2 A question about lights

A question about lights

All discussion relation to NoLimits Coaster 2 should be posted here. Purchase NoLimits Coaster from this page: nolimits-coaster-2-purchase-and-upgrade-links-t32524.html

Post January 16th, 2014, 9:20 am

Posts: 11
Points on hand: 101.00 Points
I've figured out how to get spot lights and such in my coasters and I've played around with colors and intensity and stuff as well, my question is regarding changing the angle of the light beam. Does anyone know how to do this. I want to get near vertical angles to light the structure from underneath and have it shine upwards. Also wondering if they can actually be placed on the structure itself. Any help would be appreciated.

Post January 16th, 2014, 12:23 pm

Posts: 1275
Points on hand: 3,816.00 Points
Location: Bay Area, CA

When you select the light object, you can move it pretty much anywhere in space. You may have seen the flood lights (modified spot lights) on my track "Devil's Slide" in the hardhat forum. I have these lights 'attached' to footers and at the lips of the tunnels. But you can move them anywhere, even underwater (too bad the water doesn't light up).

When selected (Make sure you have the Select/Modify button chosen) you will also notice "rings" around it. Mouse over one of the rings (should highlight white) and drag. That's how you can adjust the angle of the lighting. Hope that helps!

Image Insert:
Image
338.7 KB

You can change views and angle the light on the other axis as well. (Perspective view may be helpful for this)
Thrills by the Bay - Your #1 News Source for Bay Area Parks!
http://thrillsbythebay.blogspot.com

Post January 16th, 2014, 12:48 pm
gouldy User avatar
Premium Member
Premium Member

Posts: 7826
Points on hand: 2,833.00 Points
Bank: 25,088.00 Points
Location: WOLVERHAMPTON, England.

Originally posted by Angry_Gumball


Image Insert:
Image
338.7 KB


You're making the dueling coaster from RCT?

Post January 16th, 2014, 8:24 pm

Posts: 69
Points on hand: 671.00 Points
Location: Kings Lynn, Norfolk, United Kingdom
A further useful tip for that ultra accuracy is double click the selected light and you'll open the Scene Object Instance Properties window. This displays live cor-ordinates, so as you see visually the lamp is getting near what you like as vertical, you'll see Rot X/Y/Z value approach 90. At this point clear the box and type 90 in - bang on - sorted.

I used this method not only to get a set of vertical spots but also to ensure they were in a perfect straight line, and equally spaced. All easy using the live values displayed in the window.

Hope this helps.

Post January 16th, 2014, 8:57 pm

Posts: 2318
Points on hand: 4,657.00 Points
Bank: 6,667.00 Points
Location: pennsylvania, USA
So I might use this thread to ask my own lights question, How do I get lights onto the handrails of wooden coasters? I selected it the way you would for steel coasters and got nothing
What are these for?

Post January 16th, 2014, 9:09 pm

Posts: 11
Points on hand: 101.00 Points
I've been wondering the same thing about wooden coasters. Also thanks to all the above for the help works like a charm!

Post January 17th, 2014, 4:55 am

Posts: 568
Points on hand: 1,561.00 Points
Location: Hangzhou, Zhejiang, China
Agoraphobia & Claustrophobia in RCT1??????????????????

Post January 17th, 2014, 8:07 am

Posts: 69
Points on hand: 671.00 Points
Location: Kings Lynn, Norfolk, United Kingdom
Can we attach lights to moving objects - such as cars?

Post January 19th, 2014, 8:02 am

Posts: 69
Points on hand: 671.00 Points
Location: Kings Lynn, Norfolk, United Kingdom

Post January 19th, 2014, 2:37 pm

Posts: 2318
Points on hand: 4,657.00 Points
Bank: 6,667.00 Points
Location: pennsylvania, USA
There is a way with scripting, it was featured in a video update. How to do it however, I am not sure
What are these for?

Post January 19th, 2014, 4:47 pm

Posts: 69
Points on hand: 671.00 Points
Location: Kings Lynn, Norfolk, United Kingdom
Yes I remember now - some flashing LED panels IIRC.

Was hoping it might be simpler [;)]

Post January 19th, 2014, 5:02 pm

Posts: 86
Points on hand: 2,891.00 Points
Location: Rapid City, South Dakota, USA
Originally posted by alanr

Can we attach lights to moving objects - such as cars?


Lights are a property of scenery object (.nl2sco) files. Therefore lights can only be attached to scenery objects. But those objects can be attached to trains using a script.

The following script will attach an object to the lead car on a coaster. It needs to be assigned to the scenery object file containing the light, and then the scenery object placed within 5 meters of the train.

import com.nolimitscoaster.*;
import nlvm.math3d.*;

public class attach_object extends Script
{
private SceneObject sco; // Scenery object handle.
private Train train; // Train handle.
private static final float range = 5; // Defines a range (in meters) within which the scenery object will attach to a train.
private Vector3f posOut = new Vector3f(0,0,0); // Will store the scenery object's position based on the car's position.
private Vector3f pitchHeadBankOut = new Vector3f(0,0,0); // Will store the scenery object's orientation based on the car's orientation.
private Matrix4x4f carOrientation = new Matrix4x4f(); // Will store the car's orientation.

//**************************************************************************************
// onInit is called when the scene object is loaded. Use this for initialization.
// onInit should return true if initialization succeeds, else false.
// If onInit returns false then the script will be disabled automatically and onNextFrame will never be called.
//**************************************************************************************
public bool onInit()
{
// ********************************************
// Get the scene object handle.
// ********************************************
sco = sim.getSceneObjectForEntityId(getParentEntityId());
if (sco == null)
{
System.err.println("Not a scene object.");
return false;
}

// ********************************************
// Determine whether there is a track within range of the scenery object.
// ********************************************
TrackPos trackPos = sim.findNearestCoasterTrack(sco.getTranslation(), range);
if (trackPos == null)
{
System.err.println("No track found within a range of " + range + " meters.");
return false;
}

// ********************************************
// Determine whether there is a train within range of the scenery object.
// ********************************************
Coaster coaster = trackPos.getCoaster();
train = coaster.findNearestTrain(sco.getTranslation(), range);
if (train == null)
{
System.err.println("No train found within a range of " + range + " meters.");
return false;
}

return true;
}


public void onNextFrame(float tick)
{
// ********************************************
// Obtain the orientation of the first car
// ********************************************
train.getCarMatrix(0, carOrientation);

// ********************************************
// Convert the matrix obtained from getCarMatrix()
// to the Euler angle vector used in setRotation()
// ********************************************
Tools.matrixToPitchHeadBankPos(carOrientation, pitchHeadBankOut, posOut);

// ********************************************
// Update the scene object's rotation and
// position for this frame.
// ********************************************
sco.setRotation(pitchHeadBankOut);
sco.setTranslation(posOut);
}
}


1. In the NL2SCO Editor, create a new .nl2sco object with a light. Save it with whatever name and in whatever location you like.
2. Create a plain text file named attach_object.nlvm
3. Copy/Paste the code above into the text file.
4. Save the script in the same directory as your .nl2sco file.
5. Back in the Scripts tab of the NL2SCO Editor, assign the script to the .nl2sco object (using the "Script Class" input)
6. Import the .nl2sco object into the scene and place near a train.

It should work out of the box with any object.

Post January 20th, 2014, 1:03 pm

Posts: 69
Points on hand: 671.00 Points
Location: Kings Lynn, Norfolk, United Kingdom
Wow - thank you - works as you say straight out of the box, and I've coloured it yellow and added shadows for realism, but then hit a snag.

The light is set so low it passes through the track ties and thus flashes rather annoyingly. How do I adjust the position of the object WRT the car, esp the Y axis, so I can raise it up a bit?

Tried all sorts of things, but only seem able to affect the way the beam shines (backwards did look odd), but not its position WRT the car it stuck to.

I have to admit achieving headlights was easier than expected - Thanks again.

Post January 21st, 2014, 1:24 am

Posts: 86
Points on hand: 2,891.00 Points
Location: Rapid City, South Dakota, USA
In the last line where it says "sco.setTranslation(posOut);", posOut contains the positional XYZ offsets for the scenery object. You can add to the Y component of posOut like this...

posOut.y += 0.5f;
sco.setTranslation(posOut);


Play with the value to see what height works best. You can use negative values as well. And you can do it on the X and Z parameters the same way to shift left/right, front/back.

Hope that helps!

Post January 21st, 2014, 5:03 pm

Posts: 69
Points on hand: 671.00 Points
Location: Kings Lynn, Norfolk, United Kingdom
Mmmm - sort of - thanks - but what happens now is that the light appears to be related to something other than the bogies or chassis. Watching it using fly-by mode and its moving all over the place. On a straight track the light appears centred (I have at this stage only altered y axis to raise it) but when the train steers to the right (on board view) the light swings out to the left, and vice versa. When the train comes over the top of a hill the light rises, and when the train bottoms out on a dip the light falls.

When I apply no changes to posOut the light stays locked to the bogies (front at least) and also flies exactly along the centre spline of the track, so not exactly sure what its locked to. Only when you apply a bias to x,y or z does it seem to lock to something that is neither the bogies nor the track.

I am using Classic Steel Looping Coaster if that sheds any further light.

Seem so close yet so far.....

Post January 21st, 2014, 6:24 pm

Posts: 86
Points on hand: 2,891.00 Points
Location: Rapid City, South Dakota, USA
Please post your code and I will take a look. I am guessing that you have changed something else in the script because the solution is tested and working.

Post January 21st, 2014, 9:01 pm

Posts: 69
Points on hand: 671.00 Points
Location: Kings Lynn, Norfolk, United Kingdom
Sure - here we go

---------------------------------------------
import com.nolimitscoaster.*;
import nlvm.math3d.*;

public class attach_object extends Script
{
private SceneObject sco; // Scenery object handle.
private Train train; // Train handle.
private static final float range = 5; // Defines a range (in meters) within which the scenery object will attach to a train.
private Vector3f posOut = new Vector3f(0,0,0); // Will store the scenery object's position based on the car's position.
private Vector3f pitchHeadBankOut = new Vector3f(0,0,0); // Will store the scenery object's orientation based on the car's orientation.
private Matrix4x4f carOrientation = new Matrix4x4f(); // Will store the car's orientation.

//**************************************************************************************
// onInit is called when the scene object is loaded. Use this for initialization.
// onInit should return true if initialization succeeds, else false.
// If onInit returns false then the script will be disabled automatically and onNextFrame will never be called.
//**************************************************************************************
public bool onInit()
{
// ********************************************
// Get the scene object handle.
// ********************************************
sco = sim.getSceneObjectForEntityId(getParentEntityId());
if (sco == null)
{
System.err.println("Not a scene object.");
return false;
}

// ********************************************
// Determine whether there is a track within range of the scenery object.
// ********************************************
TrackPos trackPos = sim.findNearestCoasterTrack(sco.getTranslation(), range);
if (trackPos == null)
{
System.err.println("No track found within a range of " + range + " meters.");
return false;
}

// ********************************************
// Determine whether there is a train within range of the scenery object.
// ********************************************
Coaster coaster = trackPos.getCoaster();
train = coaster.findNearestTrain(sco.getTranslation(), range);
if (train == null)
{
System.err.println("No train found within a range of " + range + " meters.");
return false;
}

return true;
}


public void onNextFrame(float tick)
{
// ********************************************
// Obtain the orientation of the first car
// ********************************************
train.getCarMatrix(0, carOrientation);

// ********************************************
// Convert the matrix obtained from getCarMatrix()
// to the Euler angle vector used in setRotation()
// ********************************************
Tools.matrixToPitchHeadBankPos(carOrientation, pitchHeadBankOut, posOut);

// ********************************************
// Update the scene object's rotation and
// position for this frame.
// ********************************************
sco.setRotation(pitchHeadBankOut);
posOut.y += 0.2f; // raise up Y axis by 0.2m
posOut.x += 0.2f; // move forward
sco.setTranslation(posOut);
}
}
---------------------------------------------------

I watch the light housing using Fly-By and its all over the place with that above script, yet when I comment out the 2 additional lines preceeding the setTranslation call - the light stays rock solid to the bogie & track.

Am I being too critical in expecting the light fitting to appear bolted to the car?

Thanks for your help.

Post January 22nd, 2014, 12:49 am

Posts: 86
Points on hand: 2,891.00 Points
Location: Rapid City, South Dakota, USA
MY FAULT! :( I thought everything looked right when I tested it but apparently I did not look closely enough. I consulted with a much better programmer than myself and we came up with this. Change the offset in the parameters at the top of the script.

import com.nolimitscoaster.*;
import nlvm.math3d.*;

public class attach_object extends Script
{
private SceneObject sco; // Scenery object handle.
private Train train; // Train handle.
private static final float range = 5; // Defines a range (in meters) within which the scenery object will attach to a train.
private Vector3f posOut = new Vector3f(0,0,0); // Will store the scenery object's position based on the car's position.
private Vector3f pitchHeadBankOut = new Vector3f(0,0,0); // Will store the scenery object's orientation based on the car's orientation.
private Matrix4x4f carOrientation = new Matrix4x4f(); // Will store the car's orientation.

private static final float xOffset = 0;
private static final float yOffset = -1.5f;
private static final float zOffset = 0;

//**************************************************************************************
// onInit is called when the scene object is loaded. Use this for initialization.
// onInit should return true if initialization succeeds, else false.
// If onInit returns false then the script will be disabled automatically and onNextFrame will never be called.
//**************************************************************************************
public bool onInit()
{
// ********************************************
// Get the scene object handle.
// ********************************************
sco = sim.getSceneObjectForEntityId(getParentEntityId());
if (sco == null)
{
System.err.println("Not a scene object.");
return false;
}

// ********************************************
// Determine whether there is a track within range of the scenery object.
// ********************************************
TrackPos trackPos = sim.findNearestCoasterTrack(sco.getTranslation(), range);
if (trackPos == null)
{
System.err.println("No track found within a range of " + range + " meters.");
return false;
}

// ********************************************
// Determine whether there is a train within range of the scenery object.
// ********************************************
Coaster coaster = trackPos.getCoaster();
train = coaster.findNearestTrain(sco.getTranslation(), range);
if (train == null)
{
System.err.println("No train found within a range of " + range + " meters.");
return false;
}

return true;
}


public void onNextFrame(float tick)
{
// ********************************************
// Obtain the orientation of the last car
// ********************************************
train.getCarMatrix(0, carOrientation);

// ********************************************
// Convert the matrix obtained from getCarMatrix()
// to the Euler angle vector used in setRotation()
// ********************************************
Tools.matrixToPitchHeadBankPos(carOrientation, pitchHeadBankOut, posOut);

// ********************************************
// Update the scene object's rotation and
// position for this frame.
// ********************************************
Matrix4x4f matrix = new Matrix4x4f();
matrix.initTrans(xOffset, yOffset, zOffset);
carOrientation.multRight(matrix);

Tools.matrixToPitchHeadBankPos(carOrientation, pitchHeadBankOut, posOut);

sco.setRotation(pitchHeadBankOut);
sco.setTranslation(posOut);
}
}

Post January 22nd, 2014, 10:00 am

Posts: 69
Points on hand: 671.00 Points
Location: Kings Lynn, Norfolk, United Kingdom
Well - this is what it looked like - altho I suspect yu seen much the same when you looked again :)



and this is what it looks like now



so well done and thank you - whatever you got wrong last time has been sorted - and I don't have a clue what the new stuff does (and I've tried to understand it) but clearly it does what we wanted. Sorted!!

Thank you for your time - much appreciated - gives an insight into how powerful NL2 is - but it can be addictive - a major downside [:D]


Return to NoLimits Coaster 2

 


  • Related topics
    Replies
    Views
    Last post
cron