1
0
Fork 0

- add marker for active object (toggle with c-key)

- make space-key toggle the model dialog for easier access  (was m-key)
- fix Coord class bug
This commit is contained in:
mfranz 2007-02-27 15:39:49 +00:00
parent 628a000472
commit 6bba354b30
3 changed files with 112 additions and 37 deletions

View file

@ -0,0 +1,40 @@
AC3Db
MATERIAL "red" rgb 1 0 0 amb 1 0 0 emis 1 0 0 spec 0 0 0 shi 0 trans 0.1
OBJECT world
kids 3
OBJECT poly
name "x"
numvert 2
10000 0 0
-10000 0 0
numsurf 1
SURF 0x02
mat 0
refs 2
0 0 0
1 0 0
kids 0
OBJECT poly
name "y"
numvert 2
0 10000 0
0 -10000 0
numsurf 1
SURF 0x02
mat 0
refs 2
0 0 0
1 0 0
kids 0
OBJECT poly
name "z"
numvert 2
0 0 10000
0 0 -10000
numsurf 1
SURF 0x02
mat 0
refs 2
0 0 0
1 0 0
kids 0

View file

@ -59,17 +59,13 @@
<desc>cycle through model list</desc>
</key>
<key>
<name>Ctrl + CurUp/Down/Left/Right</name>
<name>Ctrl + cursor/arrow keys</name>
<desc>move selected model(s) away/nearer/left/right</desc>
</key>
<key>
<name>backspace</name>
<desc>remove selected model(s)</desc>
</key>
<key>
<name>tab</name>
<desc>open/close cursor dialog</desc>
</key>
<key>
<name>d</name>
<desc>dump model data to terminal</desc>
@ -79,9 +75,13 @@
<desc>export model data</desc>
</key>
<key>
<name>m</name>
<name>space</name>
<desc>open/close model select dialog</desc>
</key>
<key>
<name>tab</name>
<desc>open/close cursor dialog</desc>
</key>
<line>Pre-select initial model (path relative to $FG_ROOT):</line>
<line>&#32;&#32;&#45;&#45;prop:cursor=Model/path.xml</line>
@ -116,6 +116,24 @@
</binding>
</key>
<key n="32">
<name>SPACE</name>
<desc>Show model select dialog</desc>
<binding>
<command>nasal</command>
<script>ufo.select_dialog.toggle()</script>
</binding>
</key>
<key n="99">
<name>c</name>
<desc>Toggle cursor</desc>
<binding>
<command>nasal</command>
<script>ufo.modelmgr.toggle_cursor()</script>
</binding>
</key>
<key n="100">
<name>d</name>
<desc>Dump coordinates</desc>
@ -134,15 +152,6 @@
</binding>
</key>
<key n="109">
<name>m</name>
<desc>Show model select dialog</desc>
<binding>
<command>nasal</command>
<script>ufo.select_dialog.toggle()</script>
</binding>
</key>
<key n="360">
<name>PageUp</name>
<desc>Increase throttle or autopilot autothrottle.</desc>

View file

@ -106,10 +106,10 @@ var Coord = {
set_alt : func(alt) { me._cupdate(); me._cdirty = 1; me._alt = alt; me },
set : func(c) {
arg[0]._pupdate();
me._lon = arg[0]._lon;
me._lat = arg[0]._lat;
me._alt = arg[0]._alt;
c._pupdate();
me._lon = c._lon;
me._lat = c._lat;
me._alt = c._alt;
me._cdirty = 1;
me._pdirty = 0;
me;
@ -377,6 +377,14 @@ var clock_loop = func {
clock_loop();
var ufo_position = func {
var lon = getprop("/position/longitude-deg");
var lat = getprop("/position/latitude-deg");
var alt = getprop("/position/altitude-ft") * FT2M;
Coord.new().set_lonlat(lon, lat, alt);
}
# class that maintains one adjustable model property (see src/Model/modelmgr.cxx)
#
var ModelValue = {
@ -443,14 +451,30 @@ var Model = {
clone : func(path) {
Model.new(path, me.pos, me.node);
},
direct_distance_to : func(dest) {
me.pos.direct_distance_to(dest);
move : func(pos) {
var v = me.visible;
me.unhide();
me.pos.set(pos);
me.lon.set(me.pos.lon());
me.lat.set(me.pos.lat());
me.alt.set(me.pos.alt() * M2FT);
v or me.hide();
},
raise : func (dist) {
var v = me.visible;
me.unhide();
me.pos.set_alt(me.pos.alt() + dist);
me.alt.set(me.pos.alt() * M2FT);
v or me.hide();
},
apply_course_distance : func(course, dist) {
me.pos.apply_course_distance(course, dist);
me.lon.set(me.pos.lon());
me.lat.set(me.pos.lat());
},
direct_distance_to : func(dest) {
me.pos.direct_distance_to(dest);
},
flash : func(v) {
me.loopid += 1;
if (v) {
@ -545,6 +569,8 @@ var ModelMgr = {
m.legendN.setValue("");
m.mouse_coord = ufo_position();
m.import();
m.cursor = Model.new("Aircraft/ufo/Models/marker.ac", Coord.new().set_xyz(0, 0, 0));
m.cursor.hide();
m.modelpath = path;
if (path != "Aircraft/ufo/Models/cursor.ac") {
@ -565,6 +591,7 @@ var ModelMgr = {
m.pos.set_alt(me.mouse_coord.alt());
m.selected and m.apply_course_distance(course, distance);
}
me.cursor.move(me.active.pos);
return;
}
@ -578,6 +605,7 @@ var ModelMgr = {
me.active = Model.new(me.modelpath, mouse_coord, me.sticky_data());
append(me.models, me.active);
me.display_status(me.modelpath);
me.cursor.move(me.active.pos);
if (KbdShift.getBoolValue()) {
foreach (var m; me.models) {
@ -589,6 +617,7 @@ var ModelMgr = {
select : func() {
if (!size(me.models)) {
me.active = nil;
me.cursor.move(Coord.new().set_xyz(0, 0, 0));
return;
}
var min_dist = 10 * ERAD;
@ -601,6 +630,7 @@ var ModelMgr = {
}
}
me.active.selected = 1;
me.cursor.move(me.active.pos);
foreach (var m; me.models) {
m.flash(m.selected);
}
@ -667,6 +697,9 @@ var ModelMgr = {
},
sticky_data : func {
var n = props.Node.new();
if (me.active == nil) {
return n;
}
var hdg = n.getNode("heading-deg", 1);
var pitch = n.getNode("pitch-deg", 1);
var roll = n.getNode("roll-deg", 1);
@ -700,7 +733,7 @@ var ModelMgr = {
}
},
import : func {
var active = nil;
me.active = nil;
var mandatory = ["path", "longitude-deg", "latitude-deg", "elevation-ft"];
foreach (var m; props.globals.getNode("models", 1).getChildren("model")) {
var ok = 1;
@ -710,19 +743,16 @@ var ModelMgr = {
}
}
if (ok) {
var tmp = props.Node.new({legend:"", "heading-deg":0, "pitch-deg":0, "roll-deg":0});
var tmp = props.Node.new({ legend:"", "heading-deg":0, "pitch-deg":0, "roll-deg":0 });
props.copy(m, tmp);
m.getParent().removeChild(m.getName(), m.getIndex());
var c = Coord.new().set_lonlat(
tmp.getNode("longitude-deg").getValue(),
tmp.getNode("latitude-deg").getValue(),
tmp.getNode("elevation-ft").getValue() * FT2M);
append(me.models, active = Model.new(tmp.getNode("path").getValue(), c, tmp));
append(me.models, me.active = Model.new(tmp.getNode("path").getValue(), c, tmp));
}
}
if (active != nil) {
me.active = active;
}
},
adjust : func(name, value, scale = 0) {
if (!size(me.models) or me.active == nil) {
@ -742,7 +772,7 @@ var ModelMgr = {
}
} elsif (name == "altitude") {
foreach (var m; me.models) {
m.selected and m.alt.set(m.alt.get() + value * dist);
m.selected and m.raise(value * dist * 0.4);
}
} elsif (name == "heading") {
foreach (var m; me.models) {
@ -757,6 +787,10 @@ var ModelMgr = {
m.selected and m.roll.set(m.roll.get() + value * 6);
}
}
me.cursor.move(me.active.pos);
},
toggle_cursor : func {
me.cursor.visible ? me.cursor.hide() : me.cursor.unhide();
},
};
@ -859,7 +893,7 @@ var print_data = func {
var export_data = func {
savexml = func(name, node) {
fgcommand("savexml", props.Node.new({"filename": name, "sourcenode": node}));
fgcommand("savexml", props.Node.new({ "filename": name, "sourcenode": node }));
}
var tmp = "save-ufo-data";
save = props.globals.getNode(tmp, 1);
@ -871,14 +905,6 @@ var export_data = func {
}
var ufo_position = func {
Coord.new().set_lonlat(
getprop("/position/longitude-deg"),
getprop("/position/latitude-deg"),
getprop("/position/altitude-ft") * FT2M);
}
# dialogs -----------------------------------------------------------------------------------------
var status_dialog = gui.Dialog.new("/sim/gui/dialogs/ufo/status/dialog", "Aircraft/ufo/Dialogs/status.xml");