本文整理汇总了Java中com.jme3.shader.VarType类的典型用法代码示例。如果您正苦于以下问题:Java VarType类的具体用法?Java VarType怎么用?Java VarType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VarType类属于com.jme3.shader包,在下文中一共展示了VarType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: convert
import com.jme3.shader.VarType; //导入依赖的package包/类
/**
* Convert material parameter type to editable property type.
*
* @param varType the material parameter type.
* @return the editable property type or null.
*/
@FXThread
protected @Nullable EditablePropertyType convert(@NotNull final VarType varType) {
switch (varType) {
case Boolean:
return EditablePropertyType.BOOLEAN;
case Float:
return EditablePropertyType.FLOAT;
case Int:
return EditablePropertyType.INTEGER;
case Vector4:
return EditablePropertyType.COLOR;
case Vector3:
return EditablePropertyType.VECTOR_3F;
case Vector2:
return EditablePropertyType.VECTOR_2F;
case Texture2D:
return EditablePropertyType.TEXTURE_2D;
}
return null;
}
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:29,代码来源:MaterialPropertyBuilder.java
示例2: refreshTextures
import com.jme3.shader.VarType; //导入依赖的package包/类
/**
* Refresh textures in a material.
*
* @param material the material.
* @param textureKey the texture key.
*/
private static void refreshTextures(@NotNull final Material material, @NotNull final String textureKey) {
final AssetManager assetManager = EDITOR.getAssetManager();
final Collection<MatParam> params = material.getParams();
params.forEach(matParam -> {
final VarType varType = matParam.getVarType();
final Object value = matParam.getValue();
if (varType != VarType.Texture2D || value == null) return;
final Texture texture = (Texture) value;
final TextureKey key = (TextureKey) texture.getKey();
if (key != null && StringUtils.equals(key.getName(), textureKey)) {
final Texture newTexture = assetManager.loadAsset(key);
matParam.setValue(newTexture);
}
});
}
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:29,代码来源:MaterialUtils.java
示例3: updateTo
import com.jme3.shader.VarType; //导入依赖的package包/类
/**
* Update the first material to the second material.
*
* @param toUpdate the material for updating.
* @param material the target material.
*/
private static void updateTo(@NotNull final Material toUpdate, @NotNull final Material material) {
final Collection<MatParam> oldParams = new ArrayList<>(toUpdate.getParams());
oldParams.forEach(matParam -> {
final MatParam param = material.getParam(matParam.getName());
if (param == null || param.getValue() == null) {
toUpdate.clearParam(matParam.getName());
}
});
final Collection<MatParam> actualParams = material.getParams();
actualParams.forEach(matParam -> {
final VarType varType = matParam.getVarType();
final Object value = matParam.getValue();
toUpdate.setParam(matParam.getName(), varType, value);
});
final RenderState additionalRenderState = toUpdate.getAdditionalRenderState();
additionalRenderState.set(material.getAdditionalRenderState());
}
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:31,代码来源:MaterialUtils.java
示例4: checkSetParam
import com.jme3.shader.VarType; //导入依赖的package包/类
private String checkSetParam(VarType type, String name) {
MatParam paramDef = def.getMaterialParam(name);
String newName = name;
if (paramDef == null && name.startsWith("m_")) {
newName = name.substring(2);
paramDef = def.getMaterialParam(newName);
if (paramDef == null) {
throw new IllegalArgumentException("Material parameter is not defined: " + name);
} else {
logger.log(Level.WARNING, "Material parameter {0} uses a deprecated naming convention use {1} instead ", new Object[]{name, newName});
}
}else if (paramDef == null){
throw new IllegalArgumentException("Material parameter is not defined: " + name);
}
if (type != null && paramDef.getVarType() != type) {
logger.logp(Level.WARNING, "Material parameter being set: {0} with "
+ "type {1} doesn't match definition type {2}",
name, type.name(), paramDef.getVarType());
}
return newName;
}
开发者ID:mleoking,项目名称:PhET,代码行数:25,代码来源:Material.java
示例5: setTextureParam
import com.jme3.shader.VarType; //导入依赖的package包/类
/**
* Set a texture parameter.
*
* @param name The name of the parameter
* @param type The variable type {@link VarType}
* @param value The texture value of the parameter.
*
* @throws IllegalArgumentException is value is null
*/
public void setTextureParam(String name, VarType type, Texture value) {
if (value == null) {
throw new IllegalArgumentException();
}
name = checkSetParam(type, name);
MatParamTexture val = getTextureParam(name);
if (val == null) {
paramValues.put(name, new MatParamTexture(type, name, value, nextTexUnit++));
} else {
val.setTextureValue(value);
}
if (technique != null) {
technique.notifySetParam(name, type, nextTexUnit - 1);
}
// need to recompute sort ID
sortingId = -1;
}
开发者ID:mleoking,项目名称:PhET,代码行数:30,代码来源:Material.java
示例6: read
import com.jme3.shader.VarType; //导入依赖的package包/类
public void read(JmeImporter im) throws IOException {
InputCapsule ic = im.getCapsule(this);
type = ic.readEnum("varType", VarType.class, null);
name = ic.readString("name", null);
ffBinding = ic.readEnum("ff_binding", FixedFuncBinding.class, null);
switch (getVarType()) {
case Boolean:
value = ic.readBoolean("value_bool", false);
break;
case Float:
value = ic.readFloat("value_float", 0f);
break;
case Int:
value = ic.readInt("value_int", 0);
break;
default:
value = ic.readSavable("value_savable", null);
break;
}
}
开发者ID:mleoking,项目名称:PhET,代码行数:21,代码来源:MatParam.java
示例7: updateUniformParam
import com.jme3.shader.VarType; //导入依赖的package包/类
void updateUniformParam(String paramName, VarType type, Object value, boolean ifNotOwner) {
Uniform u = shader.getUniform(paramName);
// if (ifNotOwner && u.getLastChanger() == owner)
// return;
switch (type) {
case Texture2D: // fall intentional
case Texture3D:
case TextureArray:
case TextureCubeMap:
case Int:
u.setValue(VarType.Int, value);
break;
default:
u.setValue(type, value);
break;
}
// u.setLastChanger(owner);
}
开发者ID:mleoking,项目名称:PhET,代码行数:21,代码来源:Technique.java
示例8: readParam
import com.jme3.shader.VarType; //导入依赖的package包/类
private void readParam() throws IOException{
String word = scan.next();
VarType type;
if (word.equals("Color")){
type = VarType.Vector4;
}else{
type = VarType.valueOf(word);
}
word = readString("[\n;(//)(\\})]");
FixedFuncBinding ffBinding = null;
if (word.contains(":")){
// contains fixed func binding
String[] split = word.split(":");
word = split[0].trim();
try {
ffBinding = FixedFuncBinding.valueOf(split[1].trim());
} catch (IllegalArgumentException ex){
throw new IOException("FixedFuncBinding '" +
split[1] + "' does not exist!");
}
}
// TODO: add support for default vals
materialDef.addMaterialParam(type, word, null, ffBinding);
}
开发者ID:mleoking,项目名称:PhET,代码行数:27,代码来源:J3MLoader.java
示例9: readDefine
import com.jme3.shader.VarType; //导入依赖的package包/类
private void readDefine(){
// stops at either next statement or colon
// ways to end a statement:
/*
Block {
Statement<new line>
Statement;
Statement //comment
Statement }
*/
String defineName = readString("[\n;:(//)(\\})]");
if (defineName.equals(""))
return;
String matParamName = null;
if (scan.hasNext(":")){
scan.next();
// this time without colon
matParamName = readString("[\n;(//)(\\})]");
// add define <-> param mapping
technique.addShaderParamDefine(matParamName, defineName);
}else{
// add preset define
technique.addShaderPresetDefine(defineName, VarType.Boolean, true);
}
}
开发者ID:mleoking,项目名称:PhET,代码行数:27,代码来源:J3MLoader.java
示例10: setColor
import com.jme3.shader.VarType; //导入依赖的package包/类
/**
* 给指定的spatial指定一个颜色,该方法主要改变spatial的material的Color
* 属性,当没有该属性时会偿试添加一个,这要求该material的原形必须有一
* 个"Color"属性的定义,该属性的verType必须是vector4.
* @param spatial
* @param color
*/
public static void setColor(Spatial spatial, final ColorRGBA color) {
spatial.depthFirstTraversal(new SceneGraphVisitorAdapter() {
@Override
public void visit(Geometry geom) {
// 存在Color属性时更改颜色。
Material mat = geom.getMaterial();
if (mat != null) {
MatParam colorParam = mat.getParam("Color");
if (colorParam != null && colorParam.getVarType() == VarType.Vector4) {
((ColorRGBA)colorParam.getValue()).set(color);
return;
}
// 不存在Color颜色时先看是否有Color属性的定义,如果有则添加该属性。
MatParam colorDef = mat.getMaterialDef().getMaterialParam("Color");
if (colorDef != null && colorDef.getVarType() == VarType.Vector4) {
// 这里需要重新创建一个,否则会引用同一个实例。
mat.setColor("Color", new ColorRGBA(color));
}
}
}
});
}
开发者ID:huliqing,项目名称:LuoYing,代码行数:30,代码来源:GeometryUtils.java
示例11: convertToGrassMaterial
import com.jme3.shader.VarType; //导入依赖的package包/类
private Material convertToGrassMaterial(Material originMat
, boolean swaying, float swayFrequency, float swayVariation, float swayDistance, Vector2f wind) {
Material grassMat = new Material(LuoYing.getAssetManager(), AssetConstants.MATERIAL_GRASS);
grassMat.setName("Grass Material");
transferMatParam(originMat, grassMat, "AlphaDiscardThreshold", VarType.Float);
transferMatParam(originMat, grassMat, "UseMaterialColors", VarType.Boolean);
transferMatParam(originMat, grassMat, "UseVertexColor", VarType.Boolean);
transferMatParam(originMat, grassMat, "Ambient", VarType.Vector4);
transferMatParam(originMat, grassMat, "Diffuse", VarType.Vector4);
transferMatParam(originMat, grassMat, "Specular", VarType.Vector4);
transferMatParam(originMat, grassMat, "Shininess", VarType.Float);
transferMatParam(originMat, grassMat, "DiffuseMap", VarType.Texture2D);
transferMatParam(originMat, grassMat, "NormalMap", VarType.Texture2D);
transferMatParam(originMat, grassMat, "SpecularMap", VarType.Texture2D);
grassMat.setTransparent(true);
grassMat.getAdditionalRenderState().setDepthWrite(true);
grassMat.getAdditionalRenderState().setDepthTest(true);
grassMat.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
grassMat.setBoolean("Swaying", swaying);
grassMat.setVector3("SwayData", new Vector3f(swayFrequency, swayVariation, swayDistance));
grassMat.setVector2("Wind", wind);
return grassMat;
}
开发者ID:huliqing,项目名称:LuoYing,代码行数:27,代码来源:PlantEntity.java
示例12: convertToGrassMat
import com.jme3.shader.VarType; //导入依赖的package包/类
private Material convertToGrassMat(Material originMat) {
Material grassMat = new Material(getAssetManager(), "LuoYingSys/Assets/MatDefs/Grass/Grass.j3md");
grassMat.setName("Grass Material");
transferMatParam(originMat, grassMat, "AlphaDiscardThreshold", VarType.Float);
transferMatParam(originMat, grassMat, "UseMaterialColors", VarType.Boolean);
transferMatParam(originMat, grassMat, "UseVertexColor", VarType.Boolean);
transferMatParam(originMat, grassMat, "Ambient", VarType.Vector4);
transferMatParam(originMat, grassMat, "Diffuse", VarType.Vector4);
transferMatParam(originMat, grassMat, "Specular", VarType.Vector4);
transferMatParam(originMat, grassMat, "Shininess", VarType.Float);
transferMatParam(originMat, grassMat, "DiffuseMap", VarType.Texture2D);
transferMatParam(originMat, grassMat, "NormalMap", VarType.Texture2D);
transferMatParam(originMat, grassMat, "SpecularMap", VarType.Texture2D);
grassMat.setTransparent(true);
grassMat.getAdditionalRenderState().setDepthWrite(true);
grassMat.getAdditionalRenderState().setDepthTest(true);
grassMat.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);
grassMat.setBoolean("Swaying", true);
grassMat.setVector3("SwayData", new Vector3f(1.5f, 0, 1));
grassMat.setVector2("Wind", new Vector2f(1f, 1f));
return grassMat;
}
开发者ID:huliqing,项目名称:LuoYing,代码行数:26,代码来源:GrassTest.java
示例13: controlRenderHardware
import com.jme3.shader.VarType; //导入依赖的package包/类
private void controlRenderHardware() {
offsetMatrices = skeleton.computeSkinningMatrices();
for (Material m : materials) {
MatParam currentParam = m.getParam("BoneMatrices");
if (currentParam != null) {
if (currentParam.getValue() != offsetMatrices) {
// Check to see if other SkeletonControl
// is operating on this material, in that case, user
// is sharing materials between models which is NOT allowed
// when hardware skinning used.
// throw new UnsupportedOperationException(
// "Material instances cannot be shared when hardware skinning is used. " +
// "Ensure all models use unique material instances : " + m.getName()
// );
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Material instances cannot be shared when hardware skinning is used. " +
"Ensure all models use unique material instances : " + m.getName());
}
}
m.setParam("BoneMatrices", VarType.Matrix4Array, offsetMatrices);
}
}
开发者ID:xbuf,项目名称:jme3_xbuf,代码行数:22,代码来源:SkeletonControl_31.java
示例14: setMaterialParameters
import com.jme3.shader.VarType; //导入依赖的package包/类
/**
* This method is called once per frame and is responsible for setting any material parameters that subclasses may
* need to set on the post material.
*
* @param material the material to use for the post shadow pass
*/
protected void setMaterialParameters(Material material) {
material.setInt("TOTALSHADOWMAPS", directionalShadowLights * shadowMapsPerDirectionalLight + pointShadowLights * 6 + spotShadowLights);
material.setInt("LIGHTS", maxLightsPerPass);
material.setParam("ShadowLightViewProjectionMatrix", VarType.Matrix4Array, lightViewProjectionsMatrices);
if (directionalShadowLights > 0) {
material.setParam("DirectionalShadowMaps", VarType.TextureArray, directionalShadowTextures);
material.setFloat("DIRECTIONALSHADOWMAP_SIZE", directionalShadowMapSize);
material.setInt("MAXDIRECTIONALSHADOWLIGHTS", directionalShadowLights);
material.setParam("Splits", VarType.Vector4Array, splits);
material.setInt("ActiveDirectionalShadows", directionalLights.size());
}
if (pointShadowLights > 0) {
material.setParam("PointShadowMaps", VarType.TextureArray, pointShadowTextures);
material.setFloat("POINTSHADOWMAP_SIZE", pointShadowMapSize);
material.setInt("MAXPOINTSHADOWLIGHTS", pointShadowLights);
material.setInt("ActivePointShadows", pointLights.size());
material.setParam("PointLightPosition", VarType.Vector3Array, pointLightPosition);
}
if (spotShadowLights > 0) {
material.setParam("SpotShadowMaps", VarType.TextureArray, spotShadowTextures);
material.setFloat("SPOTSHADOWMAP_SIZE", spotShadowMapSize);
material.setInt("MAXSPOTSHADOWLIGHTS", spotShadowLights);
material.setInt("ActiveSpotShadows", spotLights.size());
}
}
开发者ID:Perjin,项目名称:PreFrameShadowRenderer,代码行数:32,代码来源:ShadowRenderer.java
示例15: checkSetParam
import com.jme3.shader.VarType; //导入依赖的package包/类
private String checkSetParam(VarType type, String name) {
MatParam paramDef = def.getMaterialParam(name);
String newName = name;
if (paramDef == null && name.startsWith("m_")) {
newName = name.substring(2);
paramDef = def.getMaterialParam(newName);
if (paramDef == null) {
throw new IllegalArgumentException("Material parameter is not defined: " + name);
} else {
logger.log(Level.WARNING, "Material parameter {0} uses a deprecated naming convention use {1} instead ", new Object[]{name, newName});
}
} else if (paramDef == null) {
throw new IllegalArgumentException("Material parameter is not defined: " + name);
}
if (type != null && paramDef.getVarType() != type) {
logger.log(Level.WARNING, "Material parameter being set: {0} with "
+ "type {1} doesn''t match definition types {2}", new Object[]{name, type.name(), paramDef.getVarType()} );
}
return newName;
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:24,代码来源:Material.java
示例16: setParam
import com.jme3.shader.VarType; //导入依赖的package包/类
public void setParam(int paramIndex, VarType type, Object value) {
MatParam val = paramValues.getValue(paramIndex);
// if (technique != null) {
// technique.notifySetParam(name, type, value);
// }
val.setValue(value);
Object value2 = val.multiData != null ? val.multiData : value;
if (techniqueArray == null) {
setTechniqueArray();
}
paramValues.getValue(0);
for(Technique tech : techniqueArray) {
tech.notifySetParam(paramIndex, type, value2);
}
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:17,代码来源:Material.java
示例17: validate
import com.jme3.shader.VarType; //导入依赖的package包/类
@Override
@FXThread
protected void validate(@NotNull final Label warningLabel, @Nullable final ResourceElement element) {
final ComboBox<String> comboBox = getTextureParamNameComboBox();
final ObservableList<String> items = comboBox.getItems();
items.clear();
final Path file = element == null ? null : element.getFile();
if (file != null && !Files.isDirectory(file)) {
final AssetManager assetManager = EDITOR.getAssetManager();
final Path assetFile = getAssetFile(file);
if (assetFile == null) {
throw new RuntimeException("AssetFile can't be null.");
}
final MaterialKey materialKey = new MaterialKey(toAssetPath(assetFile));
final Material material = assetManager.loadAsset(materialKey);
final MaterialDef materialDef = material.getMaterialDef();
final Collection<MatParam> materialParams = materialDef.getMaterialParams();
materialParams.stream()
.filter(param -> param.getVarType() == VarType.Texture2D)
.filter(matParam -> material.getTextureParam(matParam.getName()) != null)
.forEach(filtred -> items.add(filtred.getName()));
final SingleSelectionModel<String> selectionModel = comboBox.getSelectionModel();
if (!items.isEmpty()) {
selectionModel.select(0);
} else {
selectionModel.select(null);
}
}
super.validate(warningLabel, element);
}
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:41,代码来源:ParticlesAssetEditorDialog.java
示例18: containsTexture
import com.jme3.shader.VarType; //导入依赖的package包/类
/**
* Check a material on containing a texture.
*
* @param material the material.
* @param assetPath the path of the texture.
* @return true if the material definition contains the texture.
*/
private static boolean containsTexture(@NotNull final Material material, @NotNull final String assetPath) {
final Collection<MatParam> materialParams = material.getParams();
for (final MatParam materialParam : materialParams) {
if (materialParam.getVarType() != VarType.Texture2D) continue;
final Texture value = (Texture) materialParam.getValue();
final TextureKey textureKey = value == null ? null : (TextureKey) value.getKey();
if (textureKey != null && StringUtils.equals(textureKey.getName(), assetPath)) {
return true;
}
}
return false;
}
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:22,代码来源:MaterialUtils.java
示例19: saveIfNeedTextures
import com.jme3.shader.VarType; //导入依赖的package包/类
/**
* Save if need textures of a material.
*
* @param material the material.
*/
public static void saveIfNeedTextures(@NotNull final Material material) {
final Collection<MatParam> params = material.getParams();
params.stream().filter(matParam -> matParam.getVarType() == VarType.Texture2D)
.map(MatParam::getValue)
.map(Texture.class::cast)
.forEach(MaterialUtils::saveIfNeedTexture);
}
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:13,代码来源:MaterialUtils.java
示例20: updateMaterialParams
import com.jme3.shader.VarType; //导入依赖的package包/类
private final void updateMaterialParams() {
for (Material material : materials) {
material.setParam("LightsColors", VarType.Vector4Array, lightsColors);
material.setParam("LightsCount", VarType.Int, Integer.valueOf(lightsCount));
material.setParam("LightsDirections", VarType.Vector3Array, lightsDirections);
material.setParam("LightsTypes", VarType.IntArray, lightsTypes);
}
}
开发者ID:quadracoatl,项目名称:quadracoatl,代码行数:9,代码来源:LightingState.java
注:本文中的com.jme3.shader.VarType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论