コード例 #1
0
  public void setup() {
    _myArcball = new CCArcball(this);

    final List<CCForce> myForces = new ArrayList<CCForce>();
    myForces.add(_myViscousDrag = new CCViscousDrag(0.3f));
    myForces.add(_myForceField);
    myForces.add(_myTargetForce = new CCGPUMultiTargetForce(700, 700));
    myForces.add(_myGravity = new CCGravity(new CCVector3f()));

    _myParticles = new CCParticles(g, myForces, new ArrayList<CCGPUConstraint>(), 700, 700);
    _myEmitter = new CCGPUIndexParticleEmitter(_myParticles);
    _myQuad =
        new CCQuad3f(
            new CCVector3f(-250, -250, 0),
            new CCVector3f(250, -250, 0),
            new CCVector3f(250, 250, 0),
            new CCVector3f(-250, 250, 0));
    _myTargetSetup = new CCGPUTargetQuadSetup(_myQuad, CCGPUTargetQuadCreationMode.RANDOM);
    _myTargetForce.targetSetup(_myTargetSetup);

    for (int i = 0; i < 700 * 700; i++) {
      _myEmitter.emit(new CCVector3f(0, 0, 0), CCVecMath.random3f(10), 10, true);
    }

    addControls("app", "app", this);
    fixUpdateTime(1 / 30f);
    _myTileSaver = new CCTileSaver(g);
    addUpdateListener(_myTileSaver);
    addPostListener(_myTileSaver);
  }
コード例 #2
0
 @Override
 public void keyPressed(final CCKeyEvent theEvent) {
   switch (theEvent.keyCode()) {
     case VK_S:
       _myTileSaver.init("export_tile3/" + frameCount + ".png", 5);
       g.pointSize(10);
       //			CCScreenCapture.capture("export/"+frameCount+".png", width, height);
       break;
     case VK_R:
       g.pointSize(1);
       //			_myBasicShader.reload();
       //			_myColorScaleShader.reload();
       break;
     case VK_D:
       g.pointSize(1);
       _myParticles.reset();
       for (int i = 0; i < 700 * 700; i++) {
         _myEmitter.emit(new CCVector3f(0, 0, 0), CCVecMath.random3f(10), 10, true);
       }
       break;
     default:
   }
 }
  @Override
  public void setup() {
    addControls("app", "app", this);

    _myArcball = new CCArcball(this);

    CCColladaLoader myColladaLoader = new CCColladaLoader("humanoid.dae");

    CCColladaScene myScene = myColladaLoader.scenes().element(0);
    CCColladaSkinController mySkin = myColladaLoader.controllers().element(0).skin();

    CCColladaSkeleton mySkeleton = new CCColladaSkeleton(mySkin, myScene.node("bvh_import/Hips"));

    if (USE_SKELETON_SENDER) {
      _myReceiver = new CCSkeletonReceiver(new CCUDPIn<>(new CCNetXMLCodec(), "127.0.0.1", 9000));
      _mySkeletonManager = new CCSkeletonManager(this, mySkeleton, _myReceiver);
      _myReceiver.start();
    } else {
      _myOpenNI = new CCOpenNI(this);
      _myOpenNI.openFileRecording("SkeletonRec.oni");
      _myUserGenerator = _myOpenNI.createUserGenerator();
      _myOpenNI.start();
      _mySkeletonManager =
          new CCSkeletonManager(this, mySkeleton, new CCOpenNISkeletonProvider(_myUserGenerator));
    }

    _myTouchInteractionManager =
        new CCSkeletonTouchInteractionManager(
            this, CCSkeletonJointType.LEFT_HAND, CCSkeletonJointType.RIGHT_HAND);

    _mySkeletonManager.events().add(_myTouchInteractionManager);
    _myTouchInteractionManager.createMouseSource();

    CCSkeletonTouchLocationListener myListener =
        new CCSkeletonTouchLocationListener() {

          @Override
          public void onOver(CCSkeletonTouchLocation theLocation) {
            //				CCLog.info("ON OVER:" + theLocation.name());
          }

          @Override
          public void onOut(CCSkeletonTouchLocation theLocation) {
            //				CCLog.info("ON OUT:" + theLocation.name());
          }

          @Override
          public void onSelect(CCSkeletonTouchLocation theLocation) {
            //				CCLog.info("ON SELECT:" + theLocation.name());
          }

          @Override
          public void onDeselect(CCSkeletonTouchLocation theLocation) {
            //				CCLog.info("ON DESELECT:" + theLocation.name());
          }
        };

    for (int i = 0; i < 100; i++) {
      CCSkeletonTouchLocation myLocation =
          new CCSkeletonTouchLocation("loc:" + i, CCVecMath.random3f(300));
      myLocation.events().add(myListener);
      _myTouchInteractionManager.locations().add(myLocation);
    }
  }