本文整理汇总了C++中ofVec3f类的典型用法代码示例。如果您正苦于以下问题:C++ ofVec3f类的具体用法?C++ ofVec3f怎么用?C++ ofVec3f使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ofVec3f类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: disturbMidpoint
void disturbMidpoint(ofVec3f & midPoint, ofVec3f const & bottomLeft, ofVec3f const & topLeft, ofVec3f const & topRight, ofVec3f const & bottomRight) {
//if (std::rand() % 2 == 0) {
// return;
//}
midPoint[2] += (topLeft.distance(bottomRight) + topRight.distance(bottomLeft)) * randomValue();
if (midPoint[2] < minHeight) {
minHeight = midPoint[2];
}
if (midPoint[2] > maxHeight) {
maxHeight = midPoint[2];
}
}
开发者ID:elchan,项目名称:Terrain_Generation,代码行数:14,代码来源:Terrain.hpp
示例2: approximatePlane
// needs improvement. right now it just looks for the biggest cross product
void approximatePlane(const vector<ofVec3f>& points, int iterations, ofVec3f& center, ofVec3f& normal)
{
int n = points.size();
for(int i = 0; i < n; i++)
{
center += points[i];
}
center /= n;
float maxLength = 0;
for(int i = 0; i < n; i++)
{
ofVec3f side1 = points[i] - center;
for(int j = i + 1; j < n; j++)
{
ofVec3f side2 = points[j] - center;
ofVec3f curNormal = side1.getCrossed(side2);
if(curNormal.z < 0) {
curNormal *= -1;
}
float length = curNormal.length();
if(length > maxLength)
{
normal = curNormal;
maxLength = length;
}
}
}
normal.normalize();
}
开发者ID:DanielTillett,项目名称:OpenFit,代码行数:30,代码来源:Geometry.cpp
示例3: floor
void ball::update(ofVec3f hand, ofVec3f prev_hand, ofVec3f handVel){
//Trigger the average tracking
//80 is the threshold!
if (handVel.length() > 80 && hand.z < prev_hand.z && movementCount == 0) {
currentFood = floor((ofRandom(7)));
isTracking = true;
cout << "threw!" << endl;
}
//else if (handVel.length() < 10) {
else if (movementCount > 60) {
//Throws!
//isTracking = false;
//vel /= movementCount;
movementCount = 0;
pos = ofVec3f (2000, 2000, 0);
vel.set (0, 0, 0);
}
//Tracks
if(isTracking){
pos = hand;
vel = (handVel/3);
//movementCount ++;
movementCount = 1;
isTracking = false;
}else if (movementCount > 0){
pos += vel;
//movementCount = 1;
movementCount++;
}
}
开发者ID:huynj316,项目名称:foodFight-1,代码行数:35,代码来源:ball.cpp
示例4: findNormal
ofVec3f findNormal(ofVec3f a, ofVec3f b, ofVec3f ref) {
a = a - ref;
b = b - ref;
ofVec3f v = a.cross(b);
v.normalize();
return v;
}
开发者ID:,项目名称:,代码行数:7,代码来源:
示例5: GrainViewTransform
ofVec3f GrainViewTransform(ofVec3f InPutPoint, ofVec3f Eye, ofVec3f Target, ofVec3f UpVec){
// Transform the cordinates of a point InPutPoint. For a camera placed at Eye and looking at target with Up vector UpVec
ofMatrix4x4 ViewMat;
ofVec3f zaxis(Target - Eye);
zaxis.normalize();
ofVec3f xaxis = UpVec.getCrossed(zaxis);
xaxis.normalize();
ofVec3f yaxis = zaxis.getCrossed(xaxis);
// translate vect
InPutPoint -= Eye;
// project on each axis
ofVec3f Outpos;
Outpos.x = -xaxis.dot(InPutPoint);
Outpos.y = -yaxis.dot(InPutPoint);
Outpos.z = zaxis.dot(InPutPoint);
return Outpos;
}
开发者ID:JavierVillegas,项目名称:GranAutomatic,代码行数:25,代码来源:testAppDirections.cpp
示例6: drawForceArrow
void AbstractPhysicsBehavior::drawForceArrow(ofVec3f position,
ofVec3f force) {
ofDrawArrow(position,
position + force * 20.0f,
ofClamp(force.length() * 2.0f,
0,
6.0f));
}
开发者ID:t3kt,项目名称:memory,代码行数:8,代码来源:PhysicsBehavior.cpp
示例7: makeRotate
// Make a rotation Quat which will rotate vec1 to vec2
// Generally take adot product to get the angle between these
// and then use a cross product to get the rotation axis
// Watch out for the two special cases of when the vectors
// are co-incident or opposite in direction.
void ofQuaternion::makeRotate_original( const ofVec3f& from, const ofVec3f& to ) {
const float epsilon = 0.0000001f;
float length1 = from.length();
float length2 = to.length();
// dot product vec1*vec2
float cosangle = from.dot(to) / (length1 * length2);
if ( fabs(cosangle - 1) < epsilon ) {
//osg::notify(osg::INFO)<<"*** Quat::makeRotate(from,to) with near co-linear vectors, epsilon= "<<fabs(cosangle-1)<<std::endl;
// cosangle is close to 1, so the vectors are close to being coincident
// Need to generate an angle of zero with any vector we like
// We'll choose (1,0,0)
makeRotate( 0.0, 0.0, 0.0, 1.0 );
} else
if ( fabs(cosangle + 1.0) < epsilon ) {
// vectors are close to being opposite, so will need to find a
// vector orthongonal to from to rotate about.
ofVec3f tmp;
if (fabs(from.x) < fabs(from.y))
if (fabs(from.x) < fabs(from.z)) tmp.set(1.0, 0.0, 0.0); // use x axis.
else tmp.set(0.0, 0.0, 1.0);
else if (fabs(from.y) < fabs(from.z)) tmp.set(0.0, 1.0, 0.0);
else tmp.set(0.0, 0.0, 1.0);
ofVec3f fromd(from.x, from.y, from.z);
// find orthogonal axis.
ofVec3f axis(fromd.getCrossed(tmp));
axis.normalize();
_v[0] = axis[0]; // sin of half angle of PI is 1.0.
_v[1] = axis[1]; // sin of half angle of PI is 1.0.
_v[2] = axis[2]; // sin of half angle of PI is 1.0.
_v[3] = 0; // cos of half angle of PI is zero.
} else {
// This is the usual situation - take a cross-product of vec1 and vec2
// and that is the axis around which to rotate.
ofVec3f axis(from.getCrossed(to));
float angle = acos( cosangle );
makeRotate( angle, axis );
}
}
开发者ID:terminalB,项目名称:openFrameworks,代码行数:51,代码来源:ofQuaternion.cpp
示例8: moveback
//--------------------------------------------------------------
ofVec3f ofApp::moveback(ofVec3f fltPos, ofVec3f aggPos,float aggRadius, float fltRadius){
float disAct = fltPos.distance(aggPos);
float disShould = aggRadius + fltRadius;
ofVec3f tpmoveBack = fltPos - aggPos;
tpmoveBack.normalize();
tpmoveBack = tpmoveBack * (disShould - disAct);
fltPos = fltPos + tpmoveBack;
return fltPos;
}
开发者ID:Artrustee,项目名称:SHANGHAI_2015_FALL_STUDENTS,代码行数:10,代码来源:ofApp.cpp
示例9: transform
ofVec3f ofCairoRenderer::transform(ofVec3f vec){
if(!b3D) return vec;
vec = modelView.preMult(vec);
vec = projection.preMult(vec);
//vec.set(vec.x/vec.z*viewportRect.width*0.5-ofGetWidth()*0.5-viewportRect.x,vec.y/vec.z*viewportRect.height*0.5-ofGetHeight()*0.5-viewportRect.y);
vec.set(vec.x/vec.z*ofGetWidth()*0.5,vec.y/vec.z*ofGetHeight()*0.5);
return vec;
}
开发者ID:AppleToolbox,项目名称:openFrameworks,代码行数:9,代码来源:ofCairoRenderer.cpp
示例10: getPanTiltForTargetInObjectSpace
//----------
ofVec2f MovingHead::getPanTiltForTargetInObjectSpace(const ofVec3f & objectSpacePoint, float tiltOffset) {
auto pan = atan2(objectSpacePoint.z, objectSpacePoint.x) * RAD_TO_DEG - 90.0f;
if (pan < -180.0f) {
pan += 360.0f;
}
auto tilt = acos(-objectSpacePoint.y / objectSpacePoint.length()) * RAD_TO_DEG; // will always produce positive tilt
return ofVec2f(pan, tilt + tiltOffset);
}
开发者ID:arturoc,项目名称:ofxRulr,代码行数:10,代码来源:MovingHead.cpp
示例11: mouse
//--------------------------------------------------------------
void testApp::update(){
ofVec3f diff ; //Difference between particle and mouse
float dist ; //distance from particle to mouse ( as the crow flies )
float ratio ; //Ratio of how strong the effect is = 1 + (-dist/maxDistance) ;
const ofVec3f mousePosition = ofVec3f( mouseX , mouseY , 0 ) ; //Allocate and retrieve mouse values once.
const ofVec3f origin = ofVec3f(0,0,0);
//Create an iterator to cycle through the vector
std::vector<Particle>::iterator p ;
for ( p = particles.begin() ; p != particles.end() ; p++ )
{
ratio = 1.0f ;
p->velocity *= friction ;
//reset acceleration every frame
p->acceleration = ofVec3f() ;
diff = mousePosition - p->position ;
dist = mousePosition.distance( p->position ) ;
//If within the zone of interaction
if ( dist * .5 < forceRadius )
{
ratio = -1 + dist / forceRadius ;
//Repulsion
if ( cursorMode == 0 )
p->acceleration -= ( diff * ratio) ;
//Attraction
else
p->acceleration += ( diff * ratio ) ;
}
if ( springEnabled )
{
//Move back to the original position
p->acceleration += springFactor * (p->spawnPoint - p->position );
}
p->velocity += p->acceleration * ratio ;
p->position += p->velocity ;
}
if ( ofGetFrameNum() % 300 == 0 )
{
curImageIndex++ ;
setupParticles() ;
}
}
开发者ID:benMcChesney,项目名称:PixelForces3D,代码行数:45,代码来源:testApp.cpp
示例12: center
//----------------------------------------
void ofxViewportCam::frameBoundingBox(const ofVec3f &minCorner,
const ofVec3f &maxCorner)
{
ofVec3f center((minCorner + maxCorner) * 0.5f);
setTargetPosition(center);
this->distance = minCorner.distance(maxCorner);
setPosition(target.getGlobalPosition());
dolly(this->distance);
}
开发者ID:clinthidinger,项目名称:ofxPickableScene,代码行数:11,代码来源:ofxViewportCam.cpp
示例13: push
void CorrelateXYZtoXY::push(ofVec3f &xyz, ofVec2f &xy) {
if (xyz.length() < 0.1)
return;
++nPoints;
this->xyz.push_back(toCv(xyz));
this->xy.push_back(toCv(xy));
xyzPreview.addVertex(xyz);
}
开发者ID:mimetikxs,项目名称:projectorCalibration,代码行数:10,代码来源:CorrelateXYZtoXY.cpp
示例14: rotateToNormal
//--------------------------------------------------------------
void rotateToNormal(ofVec3f normal) {
normal.normalize();
float rotationAmount;
ofVec3f rotationAngle;
ofQuaternion rotation;
ofVec3f axis(0, 0, 1);
rotation.makeRotate(axis, normal);
rotation.getRotate(rotationAmount, rotationAngle);
ofRotateDeg(rotationAmount, rotationAngle.x, rotationAngle.y, rotationAngle.z);
}
开发者ID:2bbb,项目名称:openFrameworks,代码行数:13,代码来源:ofApp.cpp
示例15: lookAt
//----------------------------------------
void ofNode::lookAt(const ofVec3f& lookAtPosition, ofVec3f upVector) {
if(parent) upVector = upVector * ofMatrix4x4::getInverseOf(parent->getGlobalTransformMatrix());
ofVec3f zaxis = (getGlobalPosition() - lookAtPosition).normalized();
ofVec3f xaxis = upVector.getCrossed(zaxis).normalized();
ofVec3f yaxis = zaxis.getCrossed(xaxis);
ofMatrix4x4 m;
m._mat[0].set(xaxis.x, xaxis.y, xaxis.z, 0);
m._mat[1].set(yaxis.x, yaxis.y, yaxis.z, 0);
m._mat[2].set(zaxis.x, zaxis.y, zaxis.z, 0);
setGlobalOrientation(m.getRotate());
}
开发者ID:,项目名称:,代码行数:14,代码来源:
示例16: axis
void Graphics2552::rotateToNormal(ofVec3f normal) {
normal.normalize();
float rotationAmount;
ofVec3f rotationAngle;
ofQuaternion rotation;
ofVec3f axis(0, 0, 1);
rotation.makeRotate(axis, normal);
rotation.getRotate(rotationAmount, rotationAngle);
logVerbose("ofRotate " + ofToString(rotationAmount));
ofRotate(rotationAmount, rotationAngle.x, rotationAngle.y, rotationAngle.z);
}
开发者ID:shavmark,项目名称:MainSketch,代码行数:13,代码来源:2552software.cpp
示例17: RotateAux
ofVec3f RotateAux(ofVec3f input, float latitud, float azimuth, ofVec3f pivot){
ofVec3f theOut = input.getRotated(azimuth, ofVec3f(1, 0, 0));
theOut = theOut.getRotated(latitud, ofVec3f(0, 1, 0));
theOut += pivot;
return theOut;
}
开发者ID:JavierVillegas,项目名称:GranAutomatic,代码行数:13,代码来源:testAppDirections.cpp
示例18: AccumulateForce
//--------------------- AccumulateForce ----------------------------------
//
// This function calculates how much of its max steering force the
// vehicle has left to apply and then applies that amount of the
// force to add.
//------------------------------------------------------------------------
bool SteeringBehaviors::AccumulateForce(ofVec3f &RunningTot, ofVec3f ForceToAdd)
{
float MagnitudeSoFar = RunningTot.length();
double MagnitudeRemaining = m_Vehicle->MaxForce() - MagnitudeSoFar;
if (MagnitudeRemaining <= 0.0) return false;
float MagnitudeToAdd = ForceToAdd.length();
//if the magnitude of the sum of ForceToAdd and the running total
//does not exceed the maximum force available to this vehicle, just
//add together. Otherwise add as much of the ForceToAdd vector is
//possible without going over the max.
if (MagnitudeToAdd < MagnitudeRemaining)
{
RunningTot += ForceToAdd;
}
else
{
RunningTot += (ForceToAdd.getNormalized() * MagnitudeRemaining);
}
return true;
}
开发者ID:Fraps77,项目名称:CityStart,代码行数:29,代码来源:SteeringBehaviors.cpp
示例19: getWrappedIndex
//--------------------------------------------------
void ofPolyline::calcData(int index, ofVec3f &tangent, float &angle, ofVec3f &rotation, ofVec3f &normal) const {
int i1 = getWrappedIndex(index - 1);
int i2 = getWrappedIndex(index);
int i3 = getWrappedIndex(index + 1);
ofPoint p1(points[i1]);
ofPoint p2(points[i2]);
ofPoint p3(points[i3]);
ofVec3f v1(p1 - p2); // vector to previous point
ofVec3f v2(p3 - p2); // vector to next point
v1.normalize();
v2.normalize();
tangent = (v2 - v1);
tangent.normalize();
rotation = v1.getCrossed(v2);
angle = 180 - ofRadToDeg(acos(ofClamp(v1.x * v2.x + v1.y * v2.y + v1.z * v2.z, -1, 1)));
normal = rightVector.getCrossed(tangent);
normal.normalize();
}
开发者ID:EverydayElk,项目名称:openFrameworks,代码行数:24,代码来源:ofPolyline.cpp
示例20: getTranslationAndOrientation
void ofxARToolkitPlus::getTranslationAndOrientation(int markerIndex, ofVec3f &translation, ofMatrix4x4 &orientation) {
ARToolKitPlus::ARMarkerInfo marker = tracker->getDetectedMarker(markerIndex);
getTransMat( &marker, c, m34 );
// Translation
translation.set(m34[0][3], m34[1][3], m34[2][3]);
// Orientation
orientation.set(m34[0][0], m34[0][1], m34[0][2], 0,
m34[1][0], m34[1][1], m34[1][2], 0,
m34[2][0], m34[2][1], m34[2][2], 0,
0, 0, 0, 1);
}
开发者ID:Meach,项目名称:ofxARtoolkitPlus,代码行数:15,代码来源:ofxARToolkitPlus.cpp
注:本文中的ofVec3f类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论