com.jme3.scene.Spatial.addMatParamOverride()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中com.jme3.scene.Spatial.addMatParamOverride()方法的一些代码示例,展示了Spatial.addMatParamOverride()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Spatial.addMatParamOverride()方法的具体详情如下:
包路径:com.jme3.scene.Spatial
类名称:Spatial
方法名:addMatParamOverride

Spatial.addMatParamOverride介绍

[英]Adds a local material parameter override.
[中]添加局部材质参数替代。

代码示例

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Override
public void setSpatial(Spatial spatial) {
  Spatial oldSpatial = this.spatial;
  super.setSpatial(spatial);
  updateTargetsAndMaterials(spatial);
  if (oldSpatial != null) {
    oldSpatial.removeMatParamOverride(numberOfJointsParam);
    oldSpatial.removeMatParamOverride(jointMatricesParam);
  }
  if (spatial != null) {
    spatial.removeMatParamOverride(numberOfJointsParam);
    spatial.removeMatParamOverride(jointMatricesParam);
    spatial.addMatParamOverride(numberOfJointsParam);
    spatial.addMatParamOverride(jointMatricesParam);
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Override
public void setSpatial(Spatial spatial) {
  Spatial oldSpatial = this.spatial;
  super.setSpatial(spatial);
  updateTargetsAndMaterials(spatial);
  
  if (oldSpatial != null) {
    oldSpatial.removeMatParamOverride(numberOfBonesParam);
    oldSpatial.removeMatParamOverride(boneMatricesParam);
  }
  
  if (spatial != null) {
    spatial.removeMatParamOverride(numberOfBonesParam);
    spatial.removeMatParamOverride(boneMatricesParam);
    spatial.addMatParamOverride(numberOfBonesParam);
    spatial.addMatParamOverride(boneMatricesParam);
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Override
public void read(JmeImporter im) throws IOException {
  super.read(im);
  InputCapsule in = im.getCapsule(this);
  skeleton = (Skeleton) in.readSavable("skeleton", null);
  
  numberOfBonesParam = (MatParamOverride) in.readSavable("numberOfBonesParam", null);
  boneMatricesParam = (MatParamOverride) in.readSavable("boneMatricesParam", null);
  
  if (numberOfBonesParam == null) {
    numberOfBonesParam = new MatParamOverride(VarType.Int, "NumberOfBones", null);
    boneMatricesParam = new MatParamOverride(VarType.Matrix4Array, "BoneMatrices", null);
    getSpatial().addMatParamOverride(numberOfBonesParam);
    getSpatial().addMatParamOverride(boneMatricesParam);
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Override
public void read(JmeImporter im) throws IOException {
  super.read(im);
  InputCapsule in = im.getCapsule(this);
  armature = (Armature) in.readSavable("armature", null);
  numberOfJointsParam = (MatParamOverride) in.readSavable("numberOfBonesParam", null);
  jointMatricesParam = (MatParamOverride) in.readSavable("boneMatricesParam", null);
  if (numberOfJointsParam == null) {
    numberOfJointsParam = new MatParamOverride(VarType.Int, "NumberOfBones", null);
    jointMatricesParam = new MatParamOverride(VarType.Matrix4Array, "BoneMatrices", null);
    getSpatial().addMatParamOverride(numberOfJointsParam);
    getSpatial().addMatParamOverride(jointMatricesParam);
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Test
public void testOverrides_IdenticalNames() {
  Node scene = createDummyScene();
  scene.getChild("A").addMatParamOverride(mpoInt("val", 5));
  scene.getChild("C").addMatParamOverride(mpoInt("val", 7));
  validateScene(scene);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Test
public void testOverrides_CloningScene_DoesntCloneMPO() {
  Node originalScene = createDummyScene();
  originalScene.getChild("A").addMatParamOverride(mpoInt("int", 5));
  originalScene.getChild("A").addMatParamOverride(mpoBool("bool", true));
  originalScene.getChild("A").addMatParamOverride(mpoFloat("float", 3.12f));
  Node clonedScene = originalScene.clone(false);
  validateScene(clonedScene);
  validateScene(originalScene);
  List<MatParamOverride> clonedOverrides = clonedScene.getChild("A").getLocalMatParamOverrides();
  List<MatParamOverride> originalOverrides = originalScene.getChild("A").getLocalMatParamOverrides();
  assertNotSame(clonedOverrides, originalOverrides);
  assertEquals(clonedOverrides, originalOverrides);
  for (int i = 0; i < clonedOverrides.size(); i++) {
    assertNotSame(clonedOverrides.get(i), originalOverrides.get(i));
    assertEquals(clonedOverrides.get(i), originalOverrides.get(i));
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Test
public void testOverrides_AddAfterAttach() {
  Node scene = createDummyScene();
  scene.updateGeometricState();
  Node root = new Node("Root Node");
  root.updateGeometricState();
  root.attachChild(scene);
  scene.getChild("A").addMatParamOverride(mpoInt("val", 5));
  validateScene(root);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Test
public void testOverrides_AddBeforeAttach() {
  Node scene = createDummyScene();
  scene.getChild("A").addMatParamOverride(mpoInt("val", 5));
  scene.updateGeometricState();
  Node root = new Node("Root Node");
  root.updateGeometricState();
  root.attachChild(scene);
  validateScene(root);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Test
public void testOverrides_RemoveAfterAttach() {
  Node scene = createDummyScene();
  scene.updateGeometricState();
  Node root = new Node("Root Node");
  root.updateGeometricState();
  scene.getChild("A").addMatParamOverride(mpoInt("val", 5));
  root.attachChild(scene);
  validateScene(root);
  scene.getChild("A").clearMatParamOverrides();
  validateScene(root);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Test
public void testOverrides_RemoveBeforeAttach() {
  Node scene = createDummyScene();
  scene.updateGeometricState();
  Node root = new Node("Root Node");
  root.updateGeometricState();
  scene.getChild("A").addMatParamOverride(mpoInt("val", 5));
  validateScene(scene);
  scene.getChild("A").clearMatParamOverrides();
  validateScene(scene);
  root.attachChild(scene);
  validateScene(root);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Test
public void testOverrides_SaveAndLoad_KeepsMPOs() {
  MatParamOverride override = mpoInt("val", 5);
  Node scene = createDummyScene();
  scene.getChild("A").addMatParamOverride(override);
  AssetManager assetManager = TestUtil.createAssetManager();
  Node loadedScene = BinaryExporter.saveAndLoad(assetManager, scene);
  Node root = new Node("Root Node");
  root.attachChild(loadedScene);
  validateScene(root);
  validateScene(scene);
  assertNotSame(override, loadedScene.getChild("A").getLocalMatParamOverrides().get(0));
  assertEquals(override, loadedScene.getChild("A").getLocalMatParamOverrides().get(0));
}

代码示例来源:origin: org.jmonkeyengine/jme3-core

@Override
public void setSpatial(Spatial spatial) {
  Spatial oldSpatial = this.spatial;
  super.setSpatial(spatial);
  updateTargetsAndMaterials(spatial);
  
  if (oldSpatial != null) {
    oldSpatial.removeMatParamOverride(numberOfBonesParam);
    oldSpatial.removeMatParamOverride(boneMatricesParam);
  }
  
  if (spatial != null) {
    spatial.removeMatParamOverride(numberOfBonesParam);
    spatial.removeMatParamOverride(boneMatricesParam);
    spatial.addMatParamOverride(numberOfBonesParam);
    spatial.addMatParamOverride(boneMatricesParam);
  }
}

代码示例来源:origin: org.jmonkeyengine/jme3-core

@Override
public void read(JmeImporter im) throws IOException {
  super.read(im);
  InputCapsule in = im.getCapsule(this);
  skeleton = (Skeleton) in.readSavable("skeleton", null);
  
  numberOfBonesParam = (MatParamOverride) in.readSavable("numberOfBonesParam", null);
  boneMatricesParam = (MatParamOverride) in.readSavable("boneMatricesParam", null);
  
  if (numberOfBonesParam == null) {
    numberOfBonesParam = new MatParamOverride(VarType.Int, "NumberOfBones", null);
    boneMatricesParam = new MatParamOverride(VarType.Matrix4Array, "BoneMatrices", null);
    getSpatial().addMatParamOverride(numberOfBonesParam);
    getSpatial().addMatParamOverride(boneMatricesParam);
  }
}

相关文章

Spatial类方法