本文整理汇总了C++中Matrix44f::transformPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix44f::transformPoint方法的具体用法?C++ Matrix44f::transformPoint怎么用?C++ Matrix44f::transformPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix44f
的用法示例。
在下文中一共展示了Matrix44f::transformPoint方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
btSoftBody* SoftBody::createSoftMesh( btSoftBodyWorldInfo &info, const TriMesh &mesh, const Vec3f &scale,
const Vec3f &position, const Quatf &rotation )
{
Matrix44f transform;
transform.setToIdentity();
transform.translate( position );
transform.rotate( rotation.v );
transform.translate( position * -1.0f );
transform.translate( position );
btScalar* positions = new btScalar[ mesh.getNumVertices() * 3 ];
size_t i = 0;
for ( vector<Vec3f>::const_iterator iter = mesh.getVertices().begin(); iter != mesh.getVertices().end(); ++iter, i += 3 ) {
Vec3f position = transform.transformPoint( *iter );
positions[ i + 0 ] = position.x;
positions[ i + 1 ] = position.y;
positions[ i + 2 ] = position.z;
}
int* indices = new int[ mesh.getIndices().size() ];
i = 0;
for ( vector<size_t>::const_iterator iter = mesh.getIndices().begin(); iter != mesh.getIndices().end(); ++iter, ++i ) {
indices[ i ] = (int)*iter;
}
btSoftBody* body = btSoftBodyHelpers::CreateFromTriMesh( info, positions, indices, mesh.getNumTriangles() );
//body->scale( toBulletVector3( scale ) );
delete [] indices;
delete [] positions;
return body;
}
示例2: draw
// Render
void SkeletonApp::draw()
{
// Clear window
gl::setViewport( getWindowBounds() );
gl::clear( Colorf::gray( 0.1f ) );
// We're capturing
if ( mKinect->isCapturing() ) {
// Set up 3D view
gl::setMatrices( mCamera );
// Iterate through skeletons
uint32_t i = 0;
for ( vector<Skeleton>::const_iterator skeletonIt = mSkeletons.cbegin(); skeletonIt != mSkeletons.cend(); ++skeletonIt, i++ ) {
// Set color
Colorf color = mKinect->getUserColor( i );
// Iterate through joints
for ( Skeleton::const_iterator boneIt = skeletonIt->cbegin(); boneIt != skeletonIt->cend(); ++boneIt ) {
// Set user color
gl::color( color );
// Get position and rotation
const Bone& bone = boneIt->second;
Vec3f position = bone.getPosition();
Matrix44f transform = bone.getAbsoluteRotationMatrix();
Vec3f direction = transform.transformPoint( position ).normalized();
direction *= 0.05f;
position.z *= -1.0f;
// Draw bone
glLineWidth( 2.0f );
JointName startJoint = bone.getStartJoint();
if ( skeletonIt->find( startJoint ) != skeletonIt->end() ) {
Vec3f destination = skeletonIt->find( startJoint )->second.getPosition();
destination.z *= -1.0f;
gl::drawLine( position, destination );
}
// Draw joint
gl::drawSphere( position, 0.025f, 16 );
// Draw joint orientation
glLineWidth( 0.5f );
gl::color( ColorAf::white() );
gl::drawVector( position, position + direction, 0.05f, 0.01f );
}
}
}
}
示例3: createSoftCloth
btSoftBody* SoftBody::createSoftCloth( btSoftBodyWorldInfo &info, const Vec2f &size, const Vec2i &resolution,
int32_t corners, const Vec3f &position, const Quatf &rotation )
{
Matrix44f transform;
transform.setToIdentity();
transform.translate( position );
transform.rotate( rotation.v );
transform.translate( position * -1.0f );
transform.translate( position );
float h = size.y * 0.5f;
float w = size.x * 0.5f;
btSoftBody* body = btSoftBodyHelpers::CreatePatch(
info,
toBulletVector3( transform.transformPoint( Vec3f( -w, 0.0f, -h ) ) ),
toBulletVector3( transform.transformPoint( Vec3f( w, 0.0f, -h ) ) ),
toBulletVector3( transform.transformPoint( Vec3f( -w, 0.0f, h ) ) ),
toBulletVector3( transform.transformPoint( Vec3f( w, 0.0f, h ) ) ),
resolution.x, resolution.y,
corners, true
);
return body;
}
示例4: createCube
TriMesh MeshHelper::createCube( const Vec3i &resolution )
{
vector<uint32_t> indices;
vector<Vec3f> normals;
vector<Vec3f> positions;
vector<Vec2f> texCoords;
ci::TriMesh front = createSquare( Vec2i( resolution.x, resolution.y ) );
ci::TriMesh left = createSquare( Vec2i( resolution.z, resolution.y ) );
ci::TriMesh top = createSquare( Vec2i( resolution.x, resolution.z ) );
Vec3f normal;
Vec3f offset;
Matrix44f transform;
// Back
normal = Vec3f( 0.0f, 0.0f, -1.0f );
offset = normal * 0.5f;
transform.setToIdentity();
transform.translate( offset );
for ( vector<Vec3f>::iterator iter = front.getVertices().begin(); iter != front.getVertices().end(); ++iter ) {
positions.push_back( transform.transformPoint( *iter ) );
normals.push_back( normal );
}
for ( vector<Vec2f>::iterator iter = front.getTexCoords().begin(); iter != front.getTexCoords().end(); ++iter ) {
texCoords.push_back( *iter );
}
// Bottom
normal = Vec3f( 0.0f, -1.0f, 0.0f );
offset = normal * 0.5f;
transform.setToIdentity();
transform.translate( offset );
transform.rotate( Vec3f( -(float)M_PI * 0.5f, 0.0f, 0.0f ) );
transform.translate( offset * -1.0f );
transform.translate( offset );
for ( vector<Vec3f>::iterator iter = top.getVertices().begin(); iter != top.getVertices().end(); ++iter ) {
positions.push_back( transform.transformPoint( *iter ) );
normals.push_back( normal );
}
for ( vector<Vec2f>::iterator iter = top.getTexCoords().begin(); iter != top.getTexCoords().end(); ++iter ) {
texCoords.push_back( *iter );
}
normal = Vec3f( 0.0f, 0.0f, 1.0f );
offset = normal * 0.5f;
transform.setToIdentity();
transform.translate( offset );
for ( vector<Vec3f>::iterator iter = front.getVertices().begin(); iter != front.getVertices().end(); ++iter ) {
positions.push_back( transform.transformPoint( *iter ) );
normals.push_back( normal );
}
for ( vector<Vec2f>::iterator iter = front.getTexCoords().begin(); iter != front.getTexCoords().end(); ++iter ) {
texCoords.push_back( *iter );
}
normal = Vec3f( -1.0f, 0.0f, 0.0f );
offset = normal * 0.5f;
transform.setToIdentity();
transform.translate( offset );
transform.rotate( Vec3f( 0.0f, -(float)M_PI * 0.5f, 0.0f ) );
transform.translate( offset * -1.0f );
transform.translate( offset );
for ( vector<Vec3f>::iterator iter = left.getVertices().begin(); iter != left.getVertices().end(); ++iter ) {
positions.push_back( transform.transformPoint( *iter ) );
normals.push_back( normal );
}
for ( vector<Vec2f>::iterator iter = left.getTexCoords().begin(); iter != left.getTexCoords().end(); ++iter ) {
texCoords.push_back( *iter );
}
// Right
normal = Vec3f( 1.0f, 0.0f, 0.0f );
offset = normal * 0.5f;
transform.setToIdentity();
transform.translate( offset );
transform.rotate( Vec3f( 0.0f, (float)M_PI * 0.5f, 0.0f ) );
transform.translate( offset * -1.0f );
transform.translate( offset );
for ( vector<Vec3f>::iterator iter = left.getVertices().begin(); iter != left.getVertices().end(); ++iter ) {
positions.push_back( transform.transformPoint( *iter ) );
normals.push_back( normal );
}
for ( vector<Vec2f>::iterator iter = left.getTexCoords().begin(); iter != left.getTexCoords().end(); ++iter ) {
texCoords.push_back( *iter );
}
normal = Vec3f( 0.0f, 1.0f, 0.0f );
offset = normal * 0.5f;
transform.setToIdentity();
transform.translate( offset );
transform.rotate( Vec3f( (float)M_PI * 0.5f, 0.0f, 0.0f ) );
transform.translate( offset * -1.0f );
transform.translate( offset );
for ( vector<Vec3f>::iterator iter = top.getVertices().begin(); iter != top.getVertices().end(); ++iter ) {
positions.push_back( transform.transformPoint( *iter ) );
normals.push_back( normal );
}
for ( vector<Vec2f>::iterator iter = top.getTexCoords().begin(); iter != top.getTexCoords().end(); ++iter ) {
texCoords.push_back( *iter );
//.........这里部分代码省略.........
示例5: ap
void SecondStudy::TheApp::draw() {
// clear out the window with black
gl::clear(ColorAf(0.0f, 0.0f, 0.0f, 1.0f));
gl::color(0.0f, 0.0f, 0.0f);
gl::drawSolidRect(getWindowBounds());
gl::color(1.0f, 1.0f, 1.0f, 1.0f);
glLineWidth(5.0f);
gl::pushModelView();
Matrix44f st;
//st.scale(Vec2f(_screenZoom, _screenZoom));
//st.translate(Vec3f(_screenOffset));
//gl::multModelView(st);
_sequencesMutex.lock();
for(auto& s : _sequences) {
if(s.size() > 1) {
for(auto it = s.begin(); it != prev(s.end()); ++it) {
shared_ptr<MeasureWidget> a = *it;
shared_ptr<MeasureWidget> b = *(next(it));
Matrix44f at;
at.translate(Vec3f(a->position()));
at.rotate(Vec3f(0.0f, 0.0f, a->angle()));
Matrix44f bt;
bt.translate(Vec3f(b->position()));
bt.rotate(Vec3f(0.0f, 0.0f, b->angle()));
Vec3f ap3 = at.transformPoint(Vec3f(a->outletIcon().getCenter()));
Vec3f bp3 = bt.transformPoint(Vec3f(b->inletIcon().getCenter()));
Vec2f ap(ap3.x, ap3.y);
Vec2f bp(bp3.x, bp3.y);
gl::drawLine(ap, bp);
}
}
}
_sequencesMutex.unlock();
_widgetsMutex.lock();
for(auto w : _widgets) {
w->draw();
}
_widgetsMutex.unlock();
gl::popModelView();
// Let's draw the traces as they are being created
_tracesMutex.lock();
_groupsMutex.lock();
for(int i = 0; i < _groups.size(); i++) {
for(auto trace : _groups[i]) {
if(trace->isVisible) {
gl::color(1.0f, 1.0f, 1.0f, 0.25f);
} else {
float c = (trace->lifespan() / 10.0f) * 0.25f;
gl::color(1.0f, 1.0f, 1.0f, c);
}
if(trace->touchPoints.size() > 1) {
for(auto cursorIt = trace->touchPoints.begin(); cursorIt != prev(trace->touchPoints.end()); ++cursorIt) {
Vec2f a = tuioToWindow(cursorIt->getPos());
Vec2f b = tuioToWindow(next(cursorIt)->getPos());
gl::lineWidth(2.0f);
gl::drawLine(a, b);
}
}
if(trace->isVisible) {
gl::drawSolidCircle(tuioToWindow(trace->currentPosition()), 8.0f);
gl::drawSolidCircle(tuioToWindow(trace->currentPosition()), 50.0f);
} else {
gl::drawSolidCircle(tuioToWindow(trace->currentPosition()), 4.0f);
}
}
}
_groupsMutex.unlock();
_tracesMutex.unlock();
}
示例6: drawSkeleton
void TextTestApp::drawSkeleton(){
//if(mSkeletons.size()<1)
// {
// return;
// }
// We're capturing
if ( mKinect->isCapturing() ) {
// Set up 3D view
//gl::pushMatrices();
//gl::setMatrices( mCamera );
// Iterate through skeletons
uint32_t i = 0;
int skeletonCount = 0;
for ( vector<Skeleton>::const_iterator skeletonIt = mSkeletons.cbegin(); skeletonIt != mSkeletons.cend(); ++skeletonIt, i++ )
{
if (skeletonIt->size() > 0){
skeletonCount +=1;
}
if (significantInteractionTimer.isStopped()){
significantInteractionTimer.start();
}
if (activeUserPresent != true && significantInteractionTimer.getSeconds() > 3.0){
activeUserPresent = true;
//if we are in passive mode, tell the existing scene to exit.
currentScene->exitNow();
// clear any old references to this timer incase it doubles up
timeline().remove( mCue );
// TODO - should be an event given back from exit now. not a timer. for now this will do ill sort later.
mCue = timeline().add( boost::bind(&TextTestApp::beginActiveScene, this), timeline().getCurrentTime() + 2 );
}
// Set color
Colorf color = mKinect->getUserColor( i );
int boneIndex = 0;
// Iterate through joints
for ( Skeleton::const_iterator boneIt = skeletonIt->cbegin(); boneIt != skeletonIt->cend(); ++boneIt, boneIndex++ ) {
// Set user color
//gl::color( color );
// Get position and rotation
const Bone& bone = boneIt->second;
Vec3f position = bone.getPosition();
Matrix44f transform = bone.getAbsoluteRotationMatrix();
Vec3f direction = transform.transformPoint( position ).normalized();
direction *= 0.05f;
position.z *= -1.0f;
Vec3f destination = skeletonIt->at( bone.getStartJoint() ).getPosition();
Vec3f end = skeletonIt->at( bone.getEndJoint() ).getPosition();
//add the current bone position to the gesture tracker history
gestureTracker->addPoint(boneIndex,end);
Vec2f endScreen = Vec2f( mKinect->getSkeletonVideoPos( end ) );
Vec2f positionScreen = Vec2f( mKinect->getSkeletonVideoPos( position ) );
Vec2f destinationScreen = Vec2f( mKinect->getSkeletonVideoPos( destination ) );
//boneIt->first
//draw bone specific stuff here
repelClips[boneIndex].x = endScreen.x * 2;
repelClips[boneIndex].y = endScreen.y * 2;
repelClips[boneIndex].zDist = position.z;
float midPointDist = OutlineParams::getInstance()->getMidpointForIndex(boneIndex);
Vec2f midPoint = getPointOnLine(destinationScreen,endScreen,midPointDist );
if (midPointDist == 0){
//if the distance is 0, the joint doesn't need a midpoint.
repelClips[boneIndex+20].x = -200;
repelClips[boneIndex+20].y = -200;
repelClips[boneIndex+20].zDist = position.z;
//.........这里部分代码省略.........