Start a new topic

Light Point System Creation

Original Post by: brianpow Mon Sep 8 19:41:20 2014


I am trying to generate a string with delta of runway edge lights between two vertices, the only Light Point creation I could find was mgExecute ("Create Light Point System", None).


I assume that I am supposed to create a paramBlock for this execution, but I don't know what handles to assign. Any help with this would be greatly appreciated!


Original Post by: brianpow Mon Sep 8 19:46:33 2014


I just found the method "mgLightPointAnimationSequenceSet", would this be a better function for delta string light points?

Original Post by: ChrisRogers Mon Sep 8 19:51:17 2014


Unfortunately the Create Light Point tool is not a available to Creator Script. The Create Light Point System tool is, but this is not what you want. The OpenFlight API Developer Guide Volume 1 has a section that discusses everything you need to know about light points. It gives you example c code to set up light points for a run way. This should be very easy to translate into OpenFlight Script and get what you need. Take a look at the section under:


OpenFlight API Developer Guide Volume 1 -> Node Records -> Node Types and Their Attributes -> fltLightPointNodes


See if that gets you off the ground. Once you get your script close, feel free to post it and we can help you with the finishing touches.


Hope this helps!


Chris.

Original Post by: brianpow Mon Sep 8 19:56:18 2014


Amazing! This is just what I needed.


-Brian

Original Post by: brianpow Thu Oct 2 16:20:05 2014


I had to take a bit of a break from this because of other work, but I feel like I am close.


I am fairly certain that I am not grabbing the color properly. Maybe someone could shed a little light on the example. (bad pun)

MG_NULL is not recognized by Creator's script editor (Python), is there a substitute value for MG_NULL?


The script successfully creates a light point entry when I remove the MG_NULL value, but there are no identifiable light points created.

I have currently commented out the section that makes light points into strings.


db = mgGetCurrentDb()


# LIGHT POINT ANIMATION INDICES

lpNoAnimation = -1

lpStrobeAnimation = 0

lpREILAnimation = 5


# LIGHT POINT APPEARANCE INDICES

lpRwyEdge = 103


# LIGHT POINT COLOR INDICES

lpColorWhite = 66687

lpColorAmber = 66431

lpColorRed = 65663

lpColorGreen = 67199

lpColorBlue = 67455


# LIGHT POINT SPACING

lpSpacingRwyEdge = 200

lpOffsetRwyEdge = 12


# GENERATE LIGHT POINT

# Group

grec = mgNewRec (fltGroup)

mgAttach (db, grec)

# Object

orec = mgNewRec (fltObject)

mgAttach (grec, orec)


# Light Point System

lightPoint = mgNewRec (fltLightPoint)


# Add Light Point to Object

mgAppend (orec, lightPoint)


# Add light point system

#xrec = mgNewRec (fltXmTranslate)

#mgSetCoord3d (xrec, fltXmTranslateFrom, 0.0, 0.0, 0.0)

#mgSetCoord3d (xrec, fltXmTranslateDelta, 0.0, lpSpacingRwyEdge*2.0, 0.0)

#mgAppend (lightPoint, xrec)

# end system


vrec = mgNewRec (fltVertex)

mgSetAttList (vrec, fltVColor, lpColorAmber, fltVIntensity, 5, MG_NULL)

mgSetCoord3d (vrec, fltCoord3d, 0.0, 0.0, 0.0)

mgSetVtxNormal (vrec, 0.0, -1.0, 0.0);

mgAttach (lightPoint, vrec)

Original Post by: SteveThompson Thu Oct 2 16:52:06 2014


MG_NULL is not recognized by Creator’s script editor (Python), is there a substitute value for MG_NULL?

In the context of mgGetAttList and mgSetAttList you do not need to NULL terminate the var args in Python. It does not hurt to include MG_NULL (or its substitute None) but you don't have to. See reference page for these functions for more information and PYTHON NOTES.


I am fairly certain that I am not grabbing the color properly. Maybe someone could shed a little light on the example. (bad pun)


In your code:


lpColorAmber = 66431

mgSetAttList (vrec, fltVColor, lpColorAmber, fltVIntensity, 5)


You are setting a "Creator Color Index" (66431) when you should be setting a simple "Color Index". Color Indices in the OpenFlight API are in the range 0..1023. That index, combined with the Color Intensity make the "Creator Color Index" which is in the range 0..((1024*128)-1]. The difference in the two "color spaces" is explained in the OpenFlight API Reference FAQ titled:


What is the difference between Color Index/Intensity and Creator Color Index attributes?


Creator Color Index 66431 would be API Color Index 518 I believe (66431/128).


To set the proper color on the vertex, you could use either:


Set the color by "Creator Color Index" (in which case you DO NOT set intensity as intensity is rolled into Creator Color Index):

mgSetAttList (vrec, fltVCreatorColor, lpColorAmber)


or Set the color by Color Index and Color Intensity:


mgSetAttList (vrec, fltVColor, 518, fltVIntensity, 5)


You can't mix the two color spaces.


The script successfully creates a light point entry when I remove the MG_NULL value, but there are no identifiable light points created.

Hmmm... I ran this script in Creator and see a light point created. Am I missing something?

Original Post by: SteveThompson Thu Oct 2 17:00:17 2014


FYI...


This "Creator Color Index" vs "Color Index" topic was recently discussed on this other API Forum Post


support/discussions/topics/2120


The FAQ and this topic should help you understand the two color spaces better.

Original Post by: brianpow Fri Oct 3 13:59:46 2014


Terrific, I think I understand the color issue I was having now. You aren't missing anything, the light point is still created, but the script editor throws NameError: name 'MG_NULL' is not defined



What about changing the light point appearance? Can I just use a light point palette index number? How do I change the appearance?

Original Post by: SteveThompson Fri Oct 3 16:15:13 2014


What about changing the light point appearance? Can I just use a light point palette index number? How do I change the appearance?

You are on the right track. The appearance (and animation) of light points are defined in the palette and referenced through index by the light points. You create an appearance using mgNewLightPointAppearance and assign it attributes using mgSetAttList. Also assign light point appearance index to light point using mgSetAttList.

Original Post by: brianpow Fri Oct 3 16:34:25 2014


So I could just do mgSetAttList? Would that go like:


mgSetAttList (lightPoint, fltLpAppearanceIndex, 103)


Or should I target the vertex?

Original Post by: SteveThompson Fri Oct 3 17:46:21 2014


So I could just do mgSetAttList? Would that go like:


mgSetAttList (lightPoint, fltLpAppearanceIndex, 103)


Or should I target the vertex?

The OpenFlight Data Dictionary tells you this (which attributes belong to which node types). In this case the appearance index attribute belongs to the light point node type. Check the data dictionary to convince yourself of this ;-)

Original Post by: brianpow Fri Oct 3 18:51:13 2014


Thank you, I've got it building perfect strings with correct light point apperances and animations now!

Login to post a comment