本文整理汇总了Java中com.jme.math.Vector3f类的典型用法代码示例。如果您正苦于以下问题:Java Vector3f类的具体用法?Java Vector3f怎么用?Java Vector3f使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vector3f类属于com.jme.math包,在下文中一共展示了Vector3f类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HingeControlPoint
import com.jme.math.Vector3f; //导入依赖的package包/类
public HingeControlPoint(HingePosition type, boolean controlLeft) {
super();
this.controlLeft = controlLeft;
this.type = type;
controlSphere = new Sphere("ControlSphere", new Vector3f(), 6, 6, radius);
controlSphere.setCullMode(SceneElement.CULL_ALWAYS);
facadeSphere = new SharedMesh("ControlSphereFacade",baseSphere);
facadeSphere.setIsCollidable(false);
this.visualNode.getNode().attachChild(controlSphere);
this.visualNode.getNode().attachChild(facadeSphere);
//tie these together
facadeSphere.setLocalRotation(controlSphere.getLocalRotation());
facadeSphere.setLocalScale(controlSphere.getLocalScale());
facadeSphere.setLocalTranslation(controlSphere.getLocalTranslation());
this.visualNode.getSpatial().updateGeometricState(0, true);
this.visualNode.getSpatial().updateRenderState();
this.visualNode.getSpatial().setModelBound(new BoundingSphere());
this.visualNode.getSpatial().updateModelBound();
this.visualNode.getSpatial().updateWorldBound();
orientation = new OrientationInfo();
}
示例2: AvatarTestPanel
import com.jme.math.Vector3f; //导入依赖的package包/类
/** Creates new form AvatarTestPanel */
public AvatarTestPanel() {
initComponents();
expressionCB.removeAllItems();
expressionCB.addItem(TriggerNames.Smile);
expressionCB.addItem(TriggerNames.Frown);
expressionCB.addItem(TriggerNames.Scorn);
motionListener = new CharacterMotionListener() {
public void transformUpdate(Vector3f translation, PMatrix rotation) {
StringBuffer buf = new StringBuffer();
buf.append(floatFormat.format(translation.x));
buf.append(", "+floatFormat.format(translation.y));
buf.append(", "+floatFormat.format(translation.z));
locationTF.setText(buf.toString());
}
};
setAvatarCharacter(null);
}
示例3: Brick
import com.jme.math.Vector3f; //导入依赖的package包/类
private Brick(double x, double y, Environment ev) {
super(x,y,ev);
this.category = Constants.categoryBRICK;
x1 = x;
y1 = y;
x2 = x;
y2 = y;
//System.out.println("***coords of initial point: x= " + x + " and y= " + y);
float dx = (float) (getX2() - getX1()) / 10;
float dy = (float) (getY2() - getY1()) / 10;
box = new Box("Brick_" + System.currentTimeMillis(), new Vector3f(), dx / 2, 2.0f, dy / 2);
sf = new ThingShapeFactory(x,y,this);
affordances = new ArrayList<Integer>();
affordances.add(Constants.Affordance__VIEWABLE);
affordances.add(Constants.Affordance__HIDEABLE);
affordances.add(Constants.Affordance__UNHIDEABLE);
}
示例4: setSpinners
import com.jme.math.Vector3f; //导入依赖的package包/类
/**
* Set the spinners to the rotation, translation and scale local coords of
* this node
* @param node
*/
private void setSpinners(Node modelBG, Node rootBG) {
Vector3f translation = rootBG.getLocalTranslation();
Quaternion quat = modelBG.getLocalRotation();
float[] angles = quat.toAngles(new float[3]);
Vector3f scale = modelBG.getLocalScale();
translationXTF.setValue(translation.x);
translationYTF.setValue(translation.y);
translationZTF.setValue(translation.z);
rotationXTF.setValue((float) Math.toDegrees(angles[0]));
rotationYTF.setValue((float) Math.toDegrees(angles[1]));
rotationZTF.setValue((float) Math.toDegrees(angles[2]));
scaleTF.setValue(scale.x);
importedModel.setTranslation(translation);
importedModel.setOrientation(new Vector3f(
(float) Math.toDegrees(angles[0]),
(float) Math.toDegrees(angles[1]),
(float) Math.toDegrees(angles[2])));
importedModel.setScale(new Vector3f(scale.x, scale.x, scale.x));
}
示例5: getTetrahedronProperties
import com.jme.math.Vector3f; //导入依赖的package包/类
/**
* The centroid of a tetrahedron (or any other simplex) is just the average of each point.
* The volume of the tetrahedron is given by this formula, where a, b, c and d are the four vertices, in any order:
* V = abs[(a-d) dot ((b-d)cross(c-d))]/6
*
* See:
* http://en.wikipedia.org/wiki/Tetrahedron
* http://en.wikipedia.org/wiki/Centroid
* @param v1
* @param v2
* @param v3
* @param v4
* @param store
* @return
*/
private float getTetrahedronProperties(Vector3f v1, Vector3f v2,Vector3f v3,Vector3f v4, Vector3f store)
{
_aMinusD.set(v1).subtractLocal(v4);
_bMinusD.set(v2).subtractLocal(v4);
_cMinusD.set(v3).subtractLocal(v4);
Vector3f crossProduct = _bMinusD.crossLocal(_cMinusD);
float volume = FastMath.abs(_aMinusD.dot(crossProduct))/6f;
store.set(v1);
store.addLocal(v2);
store.addLocal(v3);
store.addLocal(v4);
store.divideLocal(4);
if (debugMode)
drawTetrahedron(v1.subtract(object.getSpatial().getWorldTranslation()),v2.subtract(object.getSpatial().getWorldTranslation()),v3.subtract(object.getSpatial().getWorldTranslation()),v4.subtract(object.getSpatial().getWorldTranslation()));
return volume;
}
示例6: showBounds
import com.jme.math.Vector3f; //导入依赖的package包/类
private void showBounds() {
if (boundsViewerEntity != null) {
boundsViewerEntity.dispose();
boundsViewerEntity = null;
}
if (showBoundsCheckBox.isSelected() == false) {
return;
}
boundsViewerEntity = new BoundsViewerEntity(editor.getCell());
if (useCellBoundsRadioButton.isSelected()) {
boundsViewerEntity.showBounds(editor.getCell().getLocalBounds());
} else {
boundsViewerEntity.showBounds(
new BoundingSphere((Float) extentRadiusSpinner.getValue(), new Vector3f()));
}
}
示例7: refresh
import com.jme.math.Vector3f; //导入依赖的package包/类
public void refresh() {
updateModel();
// centerModels();
float radius = leftAxle.getLocalScale().x/2f;
float offset = ((rightAxle.getLocalTranslation().x + leftAxle.getLocalTranslation().x)/2f) ;
Vector3f translate = new Vector3f(offset,0,0);
interpreter.getLocalRotation().multLocal(translate);
interpreter.getLocalTranslation().addLocal(translate);
interpreter.setJointRadius(radius);
interpreter.setJointDistance(leftAxle.getLocalTranslation().subtract(rightAxle.getLocalTranslation()).length() - radius*2f);
HydraulicStructure.this.refresh();
}
示例8: attachPreservingWorld
import com.jme.math.Vector3f; //导入依赖的package包/类
/**
* Attach a model to a parent model, preserving the world translation,rotation, and scale of the model in the process.
* @param toAttach
* @param attachTo
*/
public static void attachPreservingWorld(Model toAttach, ParentModel attachTo)
{
toAttach.updateWorldData();
attachTo.updateWorldData();
Vector3f worldTranslation = new Vector3f(toAttach.getWorldTranslation());
// Vector3f worldScale = new Vector3f(toAttach.getWorldScale());//do later
Quaternion worldRotation = new Quaternion(toAttach.getWorldRotation());
attachTo.addChild(toAttach);
toAttach.updateWorldData();
attachTo.worldToLocal(worldTranslation, toAttach.getLocalTranslation());
toAttach.getLocalRotation().set(attachTo.getWorldRotation().inverse()).multLocal(worldRotation);
toAttach.updateWorldData();
}
示例9: focus
import com.jme.math.Vector3f; //导入依赖的package包/类
public void focus()
{
if (primarySelection == null)
{
StateManager.getToolPool().getCameraTool().standardFocus();
}else
{
try{
Vector3f center = ((FocusInformation)primarySelection.getActionable().getAction(Action.FOCUS)).getCenterVector();
StateManager.getToolPool().getCameraTool().focus(center);
}catch(ActionTypeException ex)
{
StateManager.getToolPool().getCameraTool().standardFocus();
}
}
}
示例10: componentViewChanged
import com.jme.math.Vector3f; //导入依赖的package包/类
protected void componentViewChanged(HUDComponent2D component) {
if (logger.isLoggable(Level.FINEST)) {
logger.fine("changing HUD component view: " + component);
}
HUDComponentState state = (HUDComponentState) hudStateMap.get(component);
if (state == null) {
return;
}
HUDView2D view = state.getView();
if (component.getDisplayMode().equals(DisplayMode.HUD)) {
// moving to HUD
view.setLocationOrtho(new Vector2f(component.getX(), component.getY()), false);
view.setOrtho(true);
} else {
// moving to world
// position HUD in x, y
Vector3f worldLocation = component.getWorldLocation();
view.setOffset(new Vector2f(worldLocation.x, worldLocation.y));
view.applyDeltaTranslationUser(worldLocation);
view.setOrtho(false);
}
}
示例11: Tetrahedron
import com.jme.math.Vector3f; //导入依赖的package包/类
/**
*
* @param name The name of the scene element. This is required for identification and comparision purposes.
* @param vertices A list of the 4 vertices of the Tetrahedron.
* @param centerVertices Whether or not to adjust the provided vertices so that the center of this TriMesh is at 0,0,0 (in local coordinates).
*/
public Tetrahedron(String name, Vector3f[] vertices, boolean centerVertices)
{
super(name);
this.vertices = vertices;
if (centerVertices)
{
adjustToCenter();
setVertexData();
setNormalData();
setTextureData();
setIndexData();
}else
{
calculateCenter();
setVertexData();
setNormalData();
setTextureData();
setIndexData();
}
}
示例12: buildHinge
import com.jme.math.Vector3f; //导入依赖的package包/类
private void buildHinge(PhysicsNode physicsNode1,PhysicsCollisionGeometry axle1,PhysicsNode physicsNode2, PhysicsCollisionGeometry axle2, OdePhysicsEnvironment compiledEnvironment)
{
if (physicsNode1 == physicsNode2)
return;
boolean universal = interpreter.isUniversalJoint();
Vector3f hingeCenter = new Vector3f().set( interpreter.getLocalTranslation());
if (!physicsNode1.isStatic())
{
if (!physicsNode2.isStatic())
{
makeJoint((DynamicPhysicsNode)physicsNode1,axle1,(DynamicPhysicsNode) physicsNode2,axle2,hingeCenter,universal,compiledEnvironment);
//makeJoint(coJoint,this);
}else
makeStaticJoint((DynamicPhysicsNode)physicsNode1,axle1,axle2, true,hingeCenter,universal,compiledEnvironment);
}else
{
if (!physicsNode2.isStatic())
makeStaticJoint((DynamicPhysicsNode)physicsNode2,axle2,axle1,false,hingeCenter,universal,compiledEnvironment);
else
return;//no action
}
}
示例13: getSetupBounds
import com.jme.math.Vector3f; //导入依赖的package包/类
/**
* Given the JME BoundingVolume object, returns the bounds used in the cell
* setup information.
*
* @param bounds The JME bounds object
* @return The PositionComponentServerState.Bounds object
*/
public static PositionComponentServerState.Bounds getSetupBounds(BoundingVolume bounds) {
PositionComponentServerState.Bounds cellBounds = new PositionComponentServerState.Bounds();
if (bounds instanceof BoundingSphere) {
cellBounds.type = BoundsType.SPHERE;
cellBounds.x = ((BoundingSphere)bounds).getRadius();
return cellBounds;
}
else if (bounds instanceof BoundingBox) {
cellBounds.type = BoundsType.BOX;
Vector3f extent = new Vector3f();
((BoundingBox)bounds).getExtent(extent);
cellBounds.x = extent.x;
cellBounds.y = extent.y;
cellBounds.z = extent.z;
return cellBounds;
}
/* This should never happen, but in case it does... */
throw new RuntimeException("Unsupported bounds type " + bounds.getClass().getName());
}
示例14: buildSpatial
import com.jme.math.Vector3f; //导入依赖的package包/类
@Override
protected Spatial buildSpatial() {
Vector3f[] vertices = new Vector3f[2];
vertices[0] = new Vector3f(0,0,0);
vertices[1] = new Vector3f(1,0,0);
Vector3f[] normals = new Vector3f[]{Vector3f.UNIT_Y,Vector3f.UNIT_Y};
Vector2f[] textureCoords = new Vector2f[2];
textureCoords[0] = new Vector2f(0,0);
textureCoords[1] = new Vector2f(1,1);
ColorRGBA[] colors = null;// new ColorRGBA[]{startColor,endColor};
line = new Line("Grapple Beam",vertices,normals, colors,textureCoords);
line.setLineWidth(4f);
line.setCullMode(SceneElement.CULL_NEVER);
line.updateRenderState();
line.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
line.setLightCombineMode(LightState.OFF);
line.setTextureCombineMode(TextureState.REPLACE);
line.setModelBound(new BoundingBox());
return line;
}
示例15: loadCancelled
import com.jme.math.Vector3f; //导入依赖的package包/类
/**
* Called when the user cancels the load
*/
void loadCancelled(ImportedModel model) {
if (editingRow >= 0 && imports.contains(model)) {
// Restore Position of model
final ImportedModel imp = model; //imports.get(editingRow);
final Node tg = imp.getRootBG();
final Vector3f rot = imp.getOrientation();
RenderUpdater renderUpdater = new RenderUpdater() {
public void update(Object arg0) {
tg.setLocalRotation(
calcRotationMatrix(rot.x, rot.y, rot.z));
tg.setLocalTranslation(imp.getTranslation());
ClientContextJME.getWorldManager().addToUpdateList(tg);
}
};
ClientContextJME.getWorldManager().addRenderUpdater(
renderUpdater, null);
}
if (model != null) {
ClientContextJME.getWorldManager().removeEntity(model.getEntity());
}
}