本文整理匯總了Java中com.jme3.math.Vector2f.getX方法的典型用法代碼示例。如果您正苦於以下問題:Java Vector2f.getX方法的具體用法?Java Vector2f.getX怎麽用?Java Vector2f.getX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.jme3.math.Vector2f
的用法示例。
在下文中一共展示了Vector2f.getX方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: change
import com.jme3.math.Vector2f; //導入方法依賴的package包/類
/**
* Notify about wanting to change height of a point.
*
* @param point the point.
*/
protected void change(@NotNull final Vector2f point) {
final Terrain terrain = (Terrain) notNull(copiedTerrain);
final Node terrainNode = (Node) notNull(getEditedModel());
final Vector3f scale = terrainNode.getWorldScale();
final int halfSize = terrain.getTerrainSize() / 2;
final int x = Math.round((point.x / scale.x) + halfSize);
final int z = Math.round((point.y / scale.z) + halfSize);
final HeightPoint heightPoint = new HeightPoint(point.getX(), point.getY(), x, z);
final ObjectDictionary<HeightPoint, Float> originalHeight = getOriginalHeight();
if(originalHeight.containsKey(heightPoint)) return;
final float height = terrain.getHeightmapHeight(point);
originalHeight.put(heightPoint, height);
}
示例2: getAngle
import com.jme3.math.Vector2f; //導入方法依賴的package包/類
/**
* Get the angle between these points.
*
* @param center the center.
* @param first the first point.
* @param second the second point.
* @return the angle between these points.
*/
@FromAnyThread
public static float getAngle(@NotNull final Vector2f center, @NotNull final Vector2f first,
@NotNull final Vector2f second) {
final float x = center.getX();
final float y = center.getY();
final float ax = first.getX() - x;
final float ay = first.getY() - y;
final float bx = second.getX() - x;
final float by = second.getY() - y;
final float delta = (float) ((ax * bx + ay * by) / Math.sqrt((ax * ax + ay * ay) * (bx * bx + by * by)));
if (delta > 1.0) {
return 0.0F;
} else if (delta < -1.0) {
return 180.0F;
}
return (float) toDegrees(acos(delta));
}
示例3: Sprite
import com.jme3.math.Vector2f; //導入方法依賴的package包/類
public Sprite(final String name, final Texture texture, Vector2f size, final boolean transparent, final Vector3f rotation,
final Vector3f translation, final AssetManager assetManager) {
super(name, new Quad(size.getX(), size.getY()));
final Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
setMaterial(material);
if (texture != null) {
setTexture(texture);
}
material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
material.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);
if (transparent) {
setQueueBucket(Bucket.Transparent);
} else {
setQueueBucket(Bucket.Opaque);
}
if (rotation != null) {
rotate(rotation.getX() * FastMath.DEG_TO_RAD, rotation.getY() * FastMath.DEG_TO_RAD, rotation.getZ()
* FastMath.DEG_TO_RAD);
}
if (translation != null) {
setLocalTranslation(translation);
}
}
示例4: scaleTextureCoordinates
import com.jme3.math.Vector2f; //導入方法依賴的package包/類
/**
* Scales the texture coordinate buffer on this mesh by the given
* scale factor.
* <p>
* Note that values above 1 will cause the
* texture to tile, while values below 1 will cause the texture
* to stretch.
* </p>
*
* @param scaleFactor The scale factor to scale by. Every texture
* coordinate is multiplied by this vector to get the result.
*
* @throws IllegalStateException If there's no texture coordinate
* buffer on the mesh
* @throws UnsupportedOperationException If the texture coordinate
* buffer is not in 2D float format.
*/
public void scaleTextureCoordinates(Vector2f scaleFactor){
VertexBuffer tc = getBuffer(Type.TexCoord);
if (tc == null)
throw new IllegalStateException("The mesh has no texture coordinates");
if (tc.getFormat() != VertexBuffer.Format.Float)
throw new UnsupportedOperationException("Only float texture coord format is supported");
if (tc.getNumComponents() != 2)
throw new UnsupportedOperationException("Only 2D texture coords are supported");
FloatBuffer fb = (FloatBuffer) tc.getData();
fb.clear();
for (int i = 0; i < fb.capacity() / 2; i++){
float x = fb.get();
float y = fb.get();
fb.position(fb.position()-2);
x *= scaleFactor.getX();
y *= scaleFactor.getY();
fb.put(x).put(y);
}
fb.clear();
tc.updateData(fb);
}
示例5: convertTexCoords2D
import com.jme3.math.Vector2f; //導入方法依賴的package包/類
private static void convertTexCoords2D(FloatBuffer input, Buffer output){
if (output.capacity() < input.capacity())
throw new RuntimeException("Output must be at least as large as input!");
input.clear();
output.clear();
Vector2f temp = new Vector2f();
int vertexCount = input.capacity() / 2;
ShortBuffer sb = null;
IntBuffer ib = null;
if (output instanceof ShortBuffer)
sb = (ShortBuffer) output;
else if (output instanceof IntBuffer)
ib = (IntBuffer) output;
else
throw new UnsupportedOperationException();
for (int i = 0; i < vertexCount; i++){
BufferUtils.populateFromBuffer(temp, input, i);
if (sb != null){
sb.put( (short) (temp.getX()*Short.MAX_VALUE) );
sb.put( (short) (temp.getY()*Short.MAX_VALUE) );
}else{
int v1 = (int) (temp.getX() * ((float)(1 << 16)));
int v2 = (int) (temp.getY() * ((float)(1 << 16)));
ib.put(v1).put(v2);
}
}
}
示例6: getValueAsString
import com.jme3.math.Vector2f; //導入方法依賴的package包/類
/**
* Returns the material parameter value as it would appear in a J3M
* file. E.g.<br/>
* <code>
* MaterialParameters {<br/>
* ABC : 1 2 3 4<br/>
* }<br/>
* </code>
* Assuming "ABC" is a Vector4 parameter, then the value
* "1 2 3 4" would be returned by this method.
* <br/><br/>
* @return material parameter value as it would appear in a J3M file.
*/
public String getValueAsString() {
switch (type) {
case Boolean:
case Float:
case Int:
return value.toString();
case Vector2:
Vector2f v2 = (Vector2f) value;
return v2.getX() + " " + v2.getY();
case Vector3:
Vector3f v3 = (Vector3f) value;
return v3.getX() + " " + v3.getY() + " " + v3.getZ();
case Vector4:
// can be either ColorRGBA, Vector4f or Quaternion
if (value instanceof Vector4f) {
Vector4f v4 = (Vector4f) value;
return v4.getX() + " " + v4.getY() + " "
+ v4.getZ() + " " + v4.getW();
} else if (value instanceof ColorRGBA) {
ColorRGBA color = (ColorRGBA) value;
return color.getRed() + " " + color.getGreen() + " "
+ color.getBlue() + " " + color.getAlpha();
} else if (value instanceof Quaternion) {
Quaternion quat = (Quaternion) value;
return quat.getX() + " " + quat.getY() + " "
+ quat.getZ() + " " + quat.getW();
} else {
throw new UnsupportedOperationException("Unexpected Vector4 type: " + value);
}
case Texture2D:
case Texture3D:
case TextureArray:
case TextureBuffer:
case TextureCubeMap:
Texture texVal = (Texture) value;
TextureKey texKey = (TextureKey) texVal.getKey();
String ret = "";
if (texKey.isFlipY()) {
ret += "Flip ";
}
if (texVal.getWrap(Texture.WrapAxis.S) == WrapMode.Repeat) {
ret += "Repeat ";
}
return ret + texKey.getName();
default:
return null; // parameter type not supported in J3M
}
}