Feature: added an option to blender key that allows user to set the

width of edges unattached to any faces in the mesh.
experimental
jmekaelthas 10 years ago
parent dd7ea3d2a7
commit 6dc8ff521a
  1. 26
      jme3-blender/src/main/java/com/jme3/asset/BlenderKey.java
  2. 6
      jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/TemporalMesh.java

@ -126,6 +126,8 @@ public class BlenderKey extends ModelKey {
protected AnimationMatchMethod animationMatchMethod = AnimationMatchMethod.AT_LEAST_ONE_NAME_MATCH;
/** The size of points that are loaded and do not belong to any edge of the mesh. */
protected float pointsSize = 1;
/** The width of edges that are loaded from the mesh and do not belong to any face. */
protected float linesWidth = 1;
/**
* Constructor used by serialization mechanisms.
@ -475,6 +477,22 @@ public class BlenderKey extends ModelKey {
this.pointsSize = pointsSize;
}
/**
* @return the width of edges that are loaded from the mesh and do not belong to any face
*/
public float getLinesWidth() {
return linesWidth;
}
/**
* Sets the width of edges that are loaded from the mesh and do not belong to any face.
* @param linesWidth
* the width of edges that are loaded from the mesh and do not belong to any face
*/
public void setLinesWidth(float linesWidth) {
this.linesWidth = linesWidth;
}
/**
* This mehtod sets the name of the WORLD data block taht should be used during file loading. By default the name is
* not set. If no name is set or the given name does not occur in the file - the first WORLD data block will be used
@ -532,6 +550,7 @@ public class BlenderKey extends ModelKey {
oc.write(optimiseTextures, "optimise-textures", false);
oc.write(animationMatchMethod, "animation-match-method", AnimationMatchMethod.AT_LEAST_ONE_NAME_MATCH);
oc.write(pointsSize, "points-size", 1);
oc.write(linesWidth, "lines-width", 1);
}
@Override
@ -555,6 +574,7 @@ public class BlenderKey extends ModelKey {
optimiseTextures = ic.readBoolean("optimise-textures", false);
animationMatchMethod = ic.readEnum("animation-match-method", AnimationMatchMethod.class, AnimationMatchMethod.AT_LEAST_ONE_NAME_MATCH);
pointsSize = ic.readFloat("points-size", 1);
linesWidth = ic.readFloat("lines-width", 1);
}
@Override
@ -580,7 +600,8 @@ public class BlenderKey extends ModelKey {
result = prime * result + (skyGeneratedTextureShape == null ? 0 : skyGeneratedTextureShape.hashCode());
result = prime * result + skyGeneratedTextureSize;
result = prime * result + (usedWorld == null ? 0 : usedWorld.hashCode());
result = prime * result + (int)pointsSize;
result = prime * result + (int) pointsSize;
result = prime * result + (int) linesWidth;
return result;
}
@ -662,6 +683,9 @@ public class BlenderKey extends ModelKey {
if (pointsSize != other.pointsSize) {
return false;
}
if (linesWidth != other.linesWidth) {
return false;
}
return true;
}

@ -101,10 +101,11 @@ public class TemporalMesh extends Geometry {
*/
protected TemporalMesh(Structure meshStructure, BlenderContext blenderContext, boolean loadData) throws BlenderFileException {
this.blenderContext = blenderContext;
name = meshStructure.getName();
this.meshStructure = meshStructure;
if (loadData) {
name = meshStructure.getName();
MeshHelper meshHelper = blenderContext.getHelper(MeshHelper.class);
meshHelper.loadVerticesAndNormals(meshStructure, vertices, normals);
@ -178,6 +179,7 @@ public class TemporalMesh extends Geometry {
public TemporalMesh clone() {
try {
TemporalMesh result = new TemporalMesh(meshStructure, blenderContext, false);
result.name = name;
for (Vector3f v : vertices) {
result.vertices.add(v.clone());
}
@ -534,7 +536,7 @@ public class TemporalMesh extends Geometry {
meshBuffers.append(vertices.get(index), normals.get(index));
}
Mesh mesh = new Mesh();
mesh.setPointSize(2);
mesh.setLineWidth(blenderContext.getBlenderKey().getLinesWidth());
mesh.setMode(Mode.LineStrip);
if (meshBuffers.isShortIndexBuffer()) {
mesh.setBuffer(Type.Index, 1, (ShortBuffer) meshBuffers.getIndexBuffer());

Loading…
Cancel
Save