当前位置: 首页>>代码示例>>Java>>正文


Java Spatial.getUserData方法代码示例

本文整理汇总了Java中com.jme3.scene.Spatial.getUserData方法的典型用法代码示例。如果您正苦于以下问题:Java Spatial.getUserData方法的具体用法?Java Spatial.getUserData怎么用?Java Spatial.getUserData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jme3.scene.Spatial的用法示例。


在下文中一共展示了Spatial.getUserData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: clickedOn

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
@Override
public void clickedOn( Spatial target, Vector3f vector3f, Vector2f cursorPosition ) {
	if ( System.currentTimeMillis() - lastClick > 500 ) {

		Object[] directHandler = target.getUserData( ClickMe.class.getSimpleName() );

		if ( directHandler != null )
			( (ClickMe) directHandler[ 0 ] ).clicked( vector3f );

		lastClick = System.currentTimeMillis();
	}
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:13,代码来源:FacadeTool.java

示例2: collision

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
/**
 * Handle collision between player characters and course points.
 * @see PhysicsCollisionListener#collision(PhysicsCollisionEvent)
 */
public void collision(PhysicsCollisionEvent event) {
  Spatial nodeA = event.getNodeA();
  Spatial nodeB = event.getNodeB();

  Spatial player = null;
  Spatial coursePoint = null;
  // Determine which node is the player.
  if (nodeA != null
      && nodeA.getUserData(PlayerManager.IS_PLAYER_ATTR) != null
      && (Boolean) nodeA.getUserData(PlayerManager.IS_PLAYER_ATTR)) {
    player = nodeA;
  } else if (nodeB != null
             && nodeB.getUserData(PlayerManager.IS_PLAYER_ATTR) != null
             && (Boolean) nodeB.getUserData(PlayerManager.IS_PLAYER_ATTR)) {
    player = nodeB;
  }
  // Determine which node is the course point.
  if (nodeA != null
      && nodeA.getUserData(CoursePath.COURSE_ORDER_ATTR) != null) {
    coursePoint = nodeA;
  } else if (nodeB != null
             && nodeB.getUserData(CoursePath.COURSE_ORDER_ATTR) != null) {
    coursePoint = nodeB;
  }
  // If collision is player and course point, check if the course
  // point is the player's target.
  if (player != null && coursePoint != null) {
    int playerTarget
        = player.getUserData(CoursePath.PLAYER_TARGET_POINT_ATTR);
    int courseOrder = coursePoint.getUserData(CoursePath.COURSE_ORDER_ATTR);
    if (playerTarget == courseOrder) {
      // Target reached. Set next target.
      int totalCoursePoints = coursePath.getCoursePoints().length;
      player.setUserData(CoursePath.PLAYER_TARGET_POINT_ATTR,
                         (playerTarget + 1) % totalCoursePoints);
      player.setUserData(CoursePath.PLAYER_ON_COURSE_ATTR, true);
    }
  }
}
 
开发者ID:meoblast001,项目名称:seally-racing,代码行数:44,代码来源:CoursePointCollisionListener.java

示例3: update

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
/**
 * Check that players are following the course and, if not, return them to the
 * previous course point.
 */
public void update() {
  for (Spatial player : players) {
    int targetPointIdx = player.getUserData(PLAYER_TARGET_POINT_ATTR);
    if (targetPointIdx < 0 || targetPointIdx >= coursePoints.length) {
      continue;
    }
    Spatial targetPoint = coursePoints[targetPointIdx];
    Spatial previousPoint = targetPointIdx == 0
        ? coursePoints[coursePoints.length - 1]
        : coursePoints[targetPointIdx - 1];

    // Distance between previous course point and player may not exceed
    // distance between previous and next course points by more than the given
    // margin.
    float previousToPlayer = player.getWorldTranslation()
        .distance(previousPoint.getWorldTranslation());
    float previousToTarget = targetPoint.getWorldTranslation()
        .distance(previousPoint.getWorldTranslation());
    if (previousToPlayer > previousToTarget + PLAYER_TARGET_PASS_MARGIN) {
      // If the player is not on the course, going to the previous point could
      // be a jump ahead in the race. Therefore go to target.
      Spatial returnPoint
          = player.getUserData(PLAYER_ON_COURSE_ATTR)
          ? previousPoint : targetPoint;
      player.setLocalTransform(returnPoint.getWorldTransform());
    }
  }
}
 
开发者ID:meoblast001,项目名称:seally-racing,代码行数:33,代码来源:CoursePath.java

示例4: validate

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
/**
 * Validate the input paramaters.
 *
 * @param vars the input paramaters.
 * @return true if all is ok.
 */
@FXThread
private boolean validate(@NotNull final VarTable vars) {
    if(!vars.has(PROPERTY_NAME)) return false;

    final String name = vars.getString(PROPERTY_NAME);

    final TreeNode<?> node = getNode();
    final Spatial element = (Spatial) node.getElement();

    return !StringUtils.isEmpty(name) && element.getUserData(name) == null;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:18,代码来源:AddUserDataAction.java

示例5: clickedOn

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
@Override
public void clickedOn( Spatial target, Vector3f vector3f, Vector2f cursorPosition ) {
	if ( System.currentTimeMillis() - lastClick > 500 ) {

		
		do {
			
			Object[] directHandler = target.getUserData( ClickMe.class.getSimpleName() );

			if ( directHandler != null ) {
				( (ClickMe) directHandler[ 0 ] ).clicked( vector3f );
				break;
			}

			target = target.getParent();
			
		} while ( target != null );
		
		lastClick = System.currentTimeMillis();
	}
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:22,代码来源:SelectTool.java

示例6: clickedOn

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
@Override
	public void clickedOn( Spatial target, Vector3f loc, Vector2f cursorPosition )  {
		
		if (System.currentTimeMillis() - lastClick > 500) {
			
			System.out.println( target + " " +loc );
			
			Vector3f locs[];
			Object[] gens = target.getUserData( Gen.class.getSimpleName() );
			
			if (gens != null && gens[0] instanceof MiniGen) {
					locs = alignMarkers;
					toAlign = (MiniGen) gens[0];
					
					System.out.println("loc1 "+loc);
					
					toAlign.gNode.getLocalTransform().transformInverseVector( loc, loc );
//					loc = m.mult(loc);
					
					System.out.println("loc2 "+loc);
			}
			else
				locs = otherMarkers;
			
			int toMove = -1;
			
			for (int i = 0; i < locs.length; i++) {
				if (locs[i] == null) {
					toMove = i;
					break;
				}
				if (toMove == -1 || locs[i].distance(loc) < locs[toMove].distance( loc ) )
					toMove = i;
			}
			
			locs[toMove] = loc;

			
			if (
					alignMarkers[0] != null && alignMarkers[1] != null && 
					otherMarkers[0] != null && otherMarkers[1] != null    )
				doAlign();
			
			showMarkers();
			
			lastClick = System.currentTimeMillis();
		}
		
	}
 
开发者ID:twak,项目名称:chordatlas,代码行数:50,代码来源:AlignTool.java

示例7: getLayer

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
/**
 * Get a layer of a spatial.
 *
 * @param spatial the spatial.
 * @return the layer or null.
 */
public static @Nullable SceneLayer getLayer(@NotNull final Spatial spatial) {
    return spatial.getUserData(KEY);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder-extension,代码行数:10,代码来源:SceneLayer.java


注:本文中的com.jme3.scene.Spatial.getUserData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。