Skip to content

Instantly share code, notes, and snippets.

@motoishmz
Created July 21, 2014 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save motoishmz/0d7975971a69d5deeb20 to your computer and use it in GitHub Desktop.
Save motoishmz/0d7975971a69d5deeb20 to your computer and use it in GitHub Desktop.
//
// testApp.cpp - RAMDanceToolkit
//
// Copyright 2012-2013 YCAM InterLab, Yoshito Onishi, Satoru Higa, Motoi Shimizu, and Kyle McDonald
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "testApp.h"
#include "ofxBt.h"
ofxBt::SoftBodyWorld world;
ofxBt::SoftBody rope;
ofxBt::RigidBody box;
ofxBt::RigidBody box2;
bool b = false;
ofVec3f p;
#pragma mark - oF methods
//--------------------------------------------------------------
void testApp::setup()
{
ofSetFrameRate(60);
ofSetVerticalSync(true);
/// ram setup
// ------------------
ramInitialize(10000);
ofBackground(30);
world.setup(ofVec3f(0, -980, 0));
world.addPlane(ofVec3f(0, 1, 0), ofVec3f(0, 0, 0));
box = world.addBox(ofVec3f(100, 100, 100), ofVec3f(0, 300, 0));
box.setMass(5.5);
rope = world.addRope(ofVec3f(0, 500, 0), ofVec3f(50, 300, 50), 50);
rope.setMass(7);
rope.setFixedAt(0);
// rope.attachRigidBodyAt(rope.getNumNode()-1, box);
rope.setStiffness(1, 1, 1);
ramGetGUI().load("settings.xml");
}
//--------------------------------------------------------------
void testApp::update()
{
world.update();
p.x = sin(ofGetElapsedTimef()) * 100;
p.y = mouseY;
p.z = cos(ofGetElapsedTimef()) * 100;
rope.setNodePositionAt(0, p);
rope.setNodePositionAt(rope.getNumNode()-1, p/2);
}
//--------------------------------------------------------------
void testApp::draw()
{
ramBeginCamera();
ofDrawSphere(p, 10);
world.draw();
ramEndCamera();
}
#pragma mark - ram methods
//--------------------------------------------------------------
void testApp::drawActor(const ramActor &actor)
{
}
//--------------------------------------------------------------
void testApp::drawRigid(const ramRigidBody &rigid)
{
}
#pragma mark - ram Events
//--------------------------------------------------------------
void testApp::onActorSetup(const ramActor &actor)
{
}
//--------------------------------------------------------------
void testApp::onActorExit(const ramActor &actor)
{
}
//--------------------------------------------------------------
void testApp::onRigidSetup(const ramRigidBody &rigid)
{
}
//--------------------------------------------------------------
void testApp::onRigidExit(const ramRigidBody &rigid)
{
}
#pragma mark - oF Events
//--------------------------------------------------------------
void testApp::keyPressed(int key)
{
b ^= true;
}
//--------------------------------------------------------------
void testApp::keyReleased(int key)
{
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y)
{
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button)
{
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button)
{
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button)
{
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h)
{
}
//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg)
{
}
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo)
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment