use of com.cas.sim.tis.anno.JmeThread in project TeachingInSimulation by ScOrPiOzzy.
the class TypicalCaseState method putDown.
/**
* 将一个元器件放置在电路板上
*/
@JmeThread
public void putDown() {
// 取消Holding的模型对鼠标透明
JmeUtil.setMouseVisible(holding, true);
try {
if (ElecComp.COMBINE_TOP == elecComp.getCombine()) {
// 需要底座的元器件不可直接加入电路板
Platform.runLater(() -> {
AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("alert.warning.base.need"));
});
holding.removeFromParent();
} else {
// 1、获取相应元器件
ElecCompDef elecCompDef = SpringUtil.getBean(ElecCompAction.class).parse(elecComp.getCfgPath());
elecCompDef.setElecComp(elecComp);
// 2、将元器件模型与元器件对象一起加入电路板中
circuitState.attachToCircuit(holding, elecCompDef);
}
} catch (Exception e) {
// 删除出错的模型
holding.removeFromParent();
LOG.error("初始化元器件{}时出现了一个错误:{}", elecComp.getModel(), e.getMessage());
e.printStackTrace();
} finally {
holding = null;
elecComp = null;
cameraState.setZoomEnable(true);
}
}
use of com.cas.sim.tis.anno.JmeThread in project TeachingInSimulation by ScOrPiOzzy.
the class ElecCompState method setElecComp.
@JmeThread
public void setElecComp(ElecComp elecComp) {
// clean up
cleanRoot();
// 加载模型(认知模块使用AnimPath的model)
Spatial model = loadAsset(new ModelKey(elecComp.getAnimPath()));
// PBR能在系统中被照亮
// MikktspaceTangentGenerator.generate(model);
// 将模型放大100倍
model.scale(100);
root.attachChild(model);
//
// 获取相应元器件
ElecCompDef elecCompDef = SpringUtil.getBean(ElecCompAction.class).parse(elecComp.getCfgPath());
// 找出元器件外壳模型名称
loadShell(elecCompDef.getParam(ElecCompDef.PARAM_KEY_SHELL));
// FIXME 这里应更为精准地设置为元器件模型。
elecCompDef.bindModel(root);
// 添加事件
Map<Spatial, String> nameMap = collectName(elecCompDef);
nameMap.entrySet().forEach(e -> addListener(e.getKey(), new MouseEventAdapter() {
@Override
public void mouseClicked(MouseEvent evt) {
if (!pickEnable) {
return;
}
// FilterUtil.showOutlineEffect(evt.getSpatial());
System.out.println("ElecCompState.setElecComp(...).new MouseEventAdapter() {...}.mouseClicked()");
Vector3f point = cam.getScreenCoordinates(evt.getContactPoint());
Platform.runLater(() -> ui.showName(e.getValue(), point.getX(), point.getY()));
}
}));
explode0();
}
Aggregations