本文整理汇总了Java中com.jme3.math.Vector3f类的典型用法代码示例。如果您正苦于以下问题:Java Vector3f类的具体用法?Java Vector3f怎么用?Java Vector3f使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Vector3f类属于com.jme3.math包,在下文中一共展示了Vector3f类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addObject
import com.jme3.math.Vector3f; //导入依赖的package包/类
@Override
protected Spatial addObject(Entity e) {
Vector3f loc = e.get(PhysicsPosition.class).getLocation();
Mesh mesh = MeshFactory.createSphere(0.25f);
Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
material.setColor("Color", ColorRGBA.Orange);
TextureKey key = new TextureKey("Interface/grid-shaded.png");
key.setGenerateMips(true);
Texture texture = assetManager.loadTexture(key);
texture.setWrap(Texture.WrapMode.Repeat);
material.setTexture("ColorMap", texture);
Geometry geometry = new Geometry("PhysicsPosition: "+e.getId(), mesh);
geometry.setMaterial(material);
geometry.setLocalTranslation(loc);
rootNode.attachChild(geometry);
return geometry;
}
示例2: updateModel
import com.jme3.math.Vector3f; //导入依赖的package包/类
/**
* Update position and rotation of a model.
*/
@JMEThread
public void updateModel() {
final Node model = getModel();
if (model == null) return;
final LocalObjects local = LocalObjects.get();
final Vector3f positionOnCamera = local.nextVector();
positionOnCamera.set(getLocalTranslation())
.subtractLocal(camera.getLocation())
.normalizeLocal()
.multLocal(camera.getFrustumNear() + 0.4f)
.addLocal(camera.getLocation());
model.setLocalTranslation(positionOnCamera);
model.setLocalRotation(getLocalRotation());
}
示例3: finishEditing
import com.jme3.math.Vector3f; //导入依赖的package包/类
@Override
public void finishEditing(@NotNull final Vector3f contactPoint) {
final EditingInput currentInput = notNull(getCurrentInput());
switch (currentInput) {
case MOUSE_PRIMARY:
case MOUSE_SECONDARY: {
paintTexture(currentInput, contactPoint);
commitChanges();
break;
}
}
super.finishEditing(contactPoint);
}
示例4: getEditableProperties
import com.jme3.math.Vector3f; //导入依赖的package包/类
@Override
public @NotNull List<EditableProperty<?, ?>> getEditableProperties() {
final List<EditableProperty<?, ?>> result = new ArrayList<>();
result.add(new SimpleProperty<>(INTEGER, "Quality size", this,
makeGetter(this, int.class, "getSize"),
makeSetter(this, int.class, "setSize")));
result.add(new SimpleProperty<>(FLOAT, "Radius", this,
makeGetter(this, float.class, "getRadius"),
makeSetter(this, float.class, "setRadius")));
result.add(new SimpleProperty<>(NODE_FROM_SCENE, "Env scene", this,
makeGetter(this, Node.class, "getEnvironmentScene"),
makeSetter(this, Node.class, "setEnvironmentScene")));
result.add(new SimpleProperty<>(NODE_FROM_SCENE, "PBR Scene", this,
makeGetter(this, Node.class, "getPbrScene"),
makeSetter(this, Node.class, "setPbrScene")));
result.add(new SimpleProperty<>(VECTOR_3F, "Position", this,
makeGetter(this, Vector3f.class, "getLocation"),
makeSetter(this, Vector3f.class, "setLocation")));
result.add(new SimpleProperty<>(ENUM, "Generation type", this,
makeGetter(this, GenerationType.class, "getGenerationType"),
makeSetter(this, GenerationType.class, "setGenerationType")));
return result;
}
示例5: createControl
import com.jme3.math.Vector3f; //导入依赖的package包/类
@Override
@FXThread
protected @NotNull Control createControl(@NotNull final Spatial parent) {
final MotionPath motionPath = new MotionPath();
motionPath.addWayPoint(Vector3f.ZERO.clone());
motionPath.addWayPoint(new Vector3f(0f, 1f, 0f));
motionPath.addWayPoint(new Vector3f(1f, 0f, 1f));
final MotionEvent control = new MotionEvent();
control.setLookAt(Vector3f.UNIT_Z, Vector3f.UNIT_Y);
control.setRotation(Quaternion.IDENTITY);
control.setPath(motionPath);
return control;
}
示例6: updateEditing
import com.jme3.math.Vector3f; //导入依赖的package包/类
@Override
public void updateEditing(@NotNull final Vector3f contactPoint) {
final EditingInput editingInput = notNull(getCurrentInput());
switch (editingInput) {
case MOUSE_PRIMARY: {
modifyHeight(contactPoint);
break;
}
case MOUSE_SECONDARY: {
baseMarker.setLocalTranslation(contactPoint);
break;
}
case MOUSE_SECONDARY_WITH_CTRL: {
targetMarker.setLocalTranslation(contactPoint);
break;
}
}
}
示例7: getClicked
import com.jme3.math.Vector3f; //导入依赖的package包/类
private CollisionResult getClicked() {
CollisionResults results = new CollisionResults();
Vector2f click2d = inputManager.getCursorPosition();
Vector3f click3d = cam.getWorldCoordinates(
new Vector2f(click2d.x, click2d.y), 0f).clone();
Vector3f dir = cam.getWorldCoordinates(
new Vector2f(click2d.x, click2d.y), 1f).subtractLocal(click3d).normalizeLocal();
Ray ray = new Ray(click3d, dir);
rootNode.collideWith(ray, results);
if (results.size() > 0)
return results.getClosestCollision();
else
return null;
}
示例8: barycentric
import com.jme3.math.Vector3f; //导入依赖的package包/类
private static float[] barycentric(Vector3f p, Vector3f a, Vector3f b, Vector3f c )
{
Vector3f v0 = b.subtract( a ),
v1 = c.subtract( a ),
v2 = p.subtract( a );
float d00 = v0.dot(v0);
float d01 = v0.dot(v1);
float d11 = v1.dot(v1);
float d20 = v2.dot(v0);
float d21 = v2.dot(v1);
float denom = d00 * d11 - d01 * d01;
float v = (d11 * d20 - d01 * d21) / denom,
w = (d00 * d21 - d01 * d20) / denom,
u = 1.0f - v - w;
return new float[] {u, v, w};
}
示例9: startEditing
import com.jme3.math.Vector3f; //导入依赖的package包/类
@Override
public void startEditing(@NotNull final EditingInput editingInput, @NotNull final Vector3f contactPoint) {
super.startEditing(editingInput, contactPoint);
switch (editingInput) {
case MOUSE_PRIMARY: {
startChange();
modifyHeight(contactPoint);
break;
}
case MOUSE_SECONDARY: {
levelMarker.setLocalTranslation(contactPoint);
break;
}
}
}
示例10: reload
import com.jme3.math.Vector3f; //导入依赖的package包/类
@Override
@FXThread
protected void reload() {
super.reload();
final Vector3f value = getPropertyValue();
final FloatTextField xField = getXField();
xField.setValue(value == null ? 0 : value.getX());
final FloatTextField yField = getYField();
yField.setValue(value == null ? 0 : value.getY());
final FloatTextField zField = getZField();
zField.setValue(value == null ? 0 : value.getZ());
}
示例11: getSurfaceSelected
import com.jme3.math.Vector3f; //导入依赖的package包/类
private Vector3f getSurfaceSelected(float dist) {
CollisionResult cr = getClicked();
Vector3f pos = null;
if (cr != null)
pos = cr.getContactPoint();
if (pos == null) {
Vector3f dir = cam.getWorldCoordinates( getInputManager().getCursorPosition(), -dist );
dir.subtractLocal( cam.getLocation() );
new Ray( cam.getLocation(), dir ).intersectsWherePlane( new Plane(Jme3z.UP, 0), pos = new Vector3f() );
}
return pos;
}
示例12: startEditing
import com.jme3.math.Vector3f; //导入依赖的package包/类
@Override
public void startEditing(@NotNull final EditingInput editingInput, @NotNull final Vector3f contactPoint) {
super.startEditing(editingInput, contactPoint);
switch (editingInput) {
case MOUSE_PRIMARY: {
startChange();
modifyHeight(contactPoint);
break;
}
case MOUSE_SECONDARY: {
baseMarker.setLocalTranslation(contactPoint);
break;
}
case MOUSE_SECONDARY_WITH_CTRL: {
targetMarker.setLocalTranslation(contactPoint);
break;
}
}
}
示例13: buildForDirectionLight
import com.jme3.math.Vector3f; //导入依赖的package包/类
@FXThread
private void buildForDirectionLight(@NotNull final DirectionalLight light, @NotNull final VBox container,
@NotNull final ModelChangeConsumer changeConsumer) {
final Vector3f direction = light.getDirection().clone();
final DirectionLightPropertyControl<DirectionalLight> directionControl =
new DirectionLightPropertyControl<>(direction, Messages.MODEL_PROPERTY_DIRECTION, changeConsumer);
directionControl.setApplyHandler(DirectionalLight::setDirection);
directionControl.setSyncHandler(DirectionalLight::getDirection);
directionControl.setEditObject(light);
FXUtils.addToPane(directionControl, container);
buildSplitLine(container);
}
示例14: updateVector
import com.jme3.math.Vector3f; //导入依赖的package包/类
/**
* Update the vector.
*
* @param event the event
*/
@FXThread
protected void updateVector(@Nullable final KeyEvent event) {
if (isIgnoreListener() || (event != null && event.getCode() != KeyCode.ENTER)) return;
final FloatTextField xField = getXField();
final float x = xField.getValue();
final FloatTextField yFiled = getYFiled();
final float y = yFiled.getValue();
final FloatTextField zField = getZField();
final float z = zField.getValue();
final Vector3f oldValue = getPropertyValue() == null ? Vector3f.ZERO : getPropertyValue();
final Vector3f newValue = new Vector3f();
newValue.set(x, y, z);
changed(newValue, oldValue.clone());
}
示例15: simpleInitApp
import com.jme3.math.Vector3f; //导入依赖的package包/类
@Override
public void simpleInitApp() {
//Same setup as in BasicExample
EntityId plane = entityData.createEntity();
entityData.setComponents(plane,
new RigidBody(false, 0),
new CustomShape(new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y.clone(), 0))));
EntityId box = entityData.createEntity();
entityData.setComponents(box,
new WarpPosition(new Vector3f(0,0,0), Quaternion.DIRECTION_Z.clone()),
new RigidBody(false, 10),
new BoxShape());
//Add two custom impulses. They are only applied once. You could play with the values..
entityData.setComponent(box, new CombinedImpulses(new Vector3f(100, 0,0), new Vector3f()));
//for the second one we have to update the CombinedImpulses component.
entityData.setComponent(box, entityData.getComponent(box, CombinedImpulses.class).addImpulse(new Vector3f(-150, 0, 0), new Vector3f()));
ESBulletState esBulletState = stateManager.getState(ESBulletState.class);
esBulletState.onInitialize(() -> {
BulletDebugAppState debugAppState = new BulletDebugAppState(esBulletState.getPhysicsSpace());
getStateManager().attach(debugAppState);
});
}