use of com.cas.circuit.vo.Magnetism in project TeachingInSimulation by ScOrPiOzzy.
the class BaseElectricCompLogic method initialize.
public void initialize(Node elecCompMdl) {
// XXX for test
// System.out.println("BaseElectricCompLogic.initialize()" + Thread.currentThread().getName());
// log.log(Level.INFO, "加载元器件{0},用时{1}", new Object[] { elecComp.getPO().getTagName(), System.currentTimeMillis() });
this.elecCompMdl = elecCompMdl;
// 读取元器件铭牌信息
readNameplateInfo();
// elecCompMdl = (Node) MdlMapUtil.loadMdlWithAbbr(getElecComp().getDef().getPO().getMdlRef(), app.getAssetManager());
// elecCompMdl = (Node) parentMdl.getChild(getElecComp().getDef().getPO().getMdlRef());
// elecCompMdl = (Node) parentMdl.getChild(getElecComp().getPO().getMdlName());
// elecCompMdl = parentMdl;
// registerEvent();
// elecCompMdl.setLocalTranslation(getElecComp().getLocation());
// elecCompMdl.rotate(getElecComp().getRotation()[0], getElecComp().getRotation()[1], getElecComp().getRotation()[2]);
// elecCompMdl.setUserData(BaseElectricCompLogic.ELECCOMP_STATE, BaseElectricCompLogic.this);
Spatial tempSpatial = null;
// 遍历元气件中所有插座
Collection<Jack> jacks = getElecComp().getDef().getJackMap().values();
for (Jack jack : jacks) {
tempSpatial = getChild(elecCompMdl, jack.getPO().getMdlName(), jack);
jack.setModel(tempSpatial);
}
// 遍历元气件中所有连接头
Collection<Terminal> terminals = getElecComp().getDef().getTerminalMap().values();
for (Terminal terminal : terminals) {
tempSpatial = getChild(elecCompMdl, terminal.getPO().getMdlName(), terminal);
if (tempSpatial == null) {
log.warn(elecComp.getDef().getPO().getName() + "未找到模型名为" + terminal.getPO().getMdlName() + "的端子模型!");
continue;
}
terminal.setModel(tempSpatial);
// FIXME 端子连接数量的标签
String numStr = ((Node) tempSpatial).getChild(0).getUserData("num");
if (Util.isNumeric(numStr)) {
terminal.setNum(Integer.parseInt(numStr));
} else {
terminal.setNum(1);
}
}
// 遍历元器件中所有气口
Collection<GasPort> gasPorts = getElecComp().getDef().getGasPortMap().values();
for (GasPort gasPort : gasPorts) {
tempSpatial = getChild(elecCompMdl, gasPort.getPO().getMdlName(), gasPort);
gasPort.setModel(tempSpatial);
}
// TODO 加入元气件按钮开关...
ElecCompDef compDef = getElecComp().getDef();
List<Magnetism> magnetisms = compDef.getMagnetisms();
for (Magnetism magnetism : magnetisms) {
// 遍历磁环静中所有按钮
for (ControlIO controlIO : magnetism.getControlIOs()) {
tempSpatial = getChild(elecCompMdl, controlIO.getPO().getMdlName(), controlIO);
controlIO.setModel(tempSpatial);
}
// 遍历磁环静中所有指示灯
for (LightIO lightIO : magnetism.getLightIOs()) {
tempSpatial = getChild(elecCompMdl, lightIO.getPO().getMdlName(), lightIO);
lightIO.setModel(tempSpatial);
}
}
// 遍历元气件中所有指示灯
for (LightIO lightIO : compDef.getLightIOs()) {
tempSpatial = getChild(elecCompMdl, lightIO.getPO().getMdlName(), lightIO);
lightIO.setModel(tempSpatial);
}
}
use of com.cas.circuit.vo.Magnetism in project TeachingInSimulation by ScOrPiOzzy.
the class VS10N051CLogic method initialize.
@Override
public void initialize(Node elecCompMdl) {
super.initialize(elecCompMdl);
List<Magnetism> magnetisms = elecComp.getDef().getMagnetisms();
for (Magnetism magnetism : magnetisms) {
List<ControlIO> controlIOs = magnetism.getControlIOs();
for (ControlIO controlIO : controlIOs) {
button = controlIO;
break;
}
}
// 添加碰撞监听control
control = new VS10N051CControl(button);
elecCompMdl.addControl(control);
}
use of com.cas.circuit.vo.Magnetism in project TeachingInSimulation by ScOrPiOzzy.
the class SensorLogic method initialize.
@Override
public void initialize(Node elecCompMdl) {
super.initialize(elecCompMdl);
Magnetism magnetism = elecComp.getDef().getMagnetisms().iterator().next();
if (magnetism == null) {
log.error("传感器配置有问题");
}
sensorIO = magnetism.getSensorIOs().iterator().next();
if (sensorIO == null) {
log.error("传感器配置有问题");
}
elecCompMdl.addControl(this);
try {
start = elecCompMdl.getChild("start");
end = elecCompMdl.getChild("end");
Vector3f origin = start.getWorldTranslation();
Vector3f goal = end.getWorldTranslation();
// spatial.getUserData("limit");
limit = FastMath.abs(goal.distance(origin));
// 标准化方向,保证与射线碰撞点的距离计算正确
Vector3f direction = goal.add(origin.negate()).normalize();
ray = new Ray(origin, direction);
ray.setLimit(limit);
// // FIXME 创建Line
// Line line = new Line(origin, goal);
// line.setLineWidth(1);
// final Geometry geometry = new Geometry("Line", line);
// JmeUtil.setTranslucent(geometry, true);
// Material material = new Material(Dispatcher.getIns().getMainApp().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
// material.setColor("Color", ColorRGBA.Green);
// geometry.setMaterial(material);
// Dispatcher.getIns().getMainApp().enqueue(new Runnable() {
// @Override
// public void run() {
// rootNode.attachChild(geometry);
// }
// });
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
Aggregations