Пример #1
0
void TransformManipulator::spin(const Vector3F & d)
{
	Matrix44F ps;
	parentSpace(ps);
	Matrix44F invps = ps;
	invps.inverse();
	
	const Vector3F worldP = ps.transform(translation());
	const Vector3F rotUp = ps.transformAsNormal(hitPlaneNormal());
	
	Vector3F toa = m_currentPoint - worldP;
	Vector3F tob = toa + d;
	
	toa.normalize();
	tob.normalize();
	float ang = toa.angleBetween(tob, toa.cross(rotUp).reversed());
	
	Vector3F angles;
	
	if(m_rotateAxis == AY) angles.set(0.f, ang, 0.f);
	else if(m_rotateAxis == AZ) angles.set(0.f, 0.f, ang);
	else angles.set(ang, 0.f, 0.f);
	
	m_subject->rotate(angles);
	setRotationAngles(m_subject->rotationAngles());
}
Пример #2
0
const Vector3F &Turret::getCompassRotation (void)
{
	static Vector3F rot;

	rot.set (0, 0, turretRotation + getRot().z);

	return rot;
}
Пример #3
0
Ray ProxyViz::getRayDisplace(Vector3F & v0, Vector3F & v1,
			short start_x, short start_y, short last_x, short last_y)
{
	useActiveView();
	MPoint toNear, toFar;
	_viewport.viewToWorld ( last_x, last_y, toNear, toFar );
	
	MPoint fromNear, fromFar;
	_viewport.viewToWorld ( start_x, start_y, fromNear, fromFar );
	
	MVector dispNear = toNear - fromNear;
	MVector dispFar = toFar - fromFar;
	
	Vector3F a(toNear.x, toNear.y, toNear.z);
	Vector3F b(toFar.x, toFar.y, toFar.z);
	Ray r(a, b);
	v0.set(dispNear.x, dispNear.y, dispNear.z);
	v1.set(dispFar.x, dispFar.y, dispFar.z);
	return r;
}
Пример #4
0
TEST(Vector3, SetMethods) {
    Vector3F vec;
    vec.set(4.f, 2.f, 8.f);
    EXPECT_FLOAT_EQ(4.f, vec.x);
    EXPECT_FLOAT_EQ(2.f, vec.y);
    EXPECT_FLOAT_EQ(8.f, vec.z);

    vec.set(Vector2F(1.f, 3.f), 10.f);
    EXPECT_FLOAT_EQ(1.f, vec.x);
    EXPECT_FLOAT_EQ(3.f, vec.y);
    EXPECT_FLOAT_EQ(10.f, vec.z);

    auto lst = {0.f, 5.f, 6.f};
    vec.set(lst);
    EXPECT_FLOAT_EQ(0.f, vec.x);
    EXPECT_FLOAT_EQ(5.f, vec.y);
    EXPECT_FLOAT_EQ(6.f, vec.z);

    vec.set(Vector3F(9.f, 8.f, 2.f));
    EXPECT_FLOAT_EQ(9.f, vec.x);
    EXPECT_FLOAT_EQ(8.f, vec.y);
    EXPECT_FLOAT_EQ(2.f, vec.z);
}
Пример #5
0
void SahWorldInterface::createTestMesh(SahTetrahedronSystem * mesh)
{ 
	std::cout<<"test mesh num points "<<TetraNumVertices<<"\n";
	std::cout<<"num tetrahedrons "<<TetraNumTetrahedrons<<"\n";
	
	mesh->create(TetraNumTetrahedrons+100, TetraNumVertices+400);
	
	unsigned i;
	Vector3F p;
	for(i=0; i<TetraNumVertices; i++) {
	    p.set(TetraP[i][0], TetraP[i][1], TetraP[i][2]);
	    mesh->addPoint(&p.x);
	}
	
	for(i=0; i<TetraNumTetrahedrons; i++)
	    mesh->addTetrahedron(TetraIndices[i][0], TetraIndices[i][1], TetraIndices[i][2], TetraIndices[i][3]);
	
	mesh->setAnchoredPoint(89, 0);
	mesh->setAnchoredPoint(63, 20);
	mesh->setAnchoredPoint(71, 9);
	mesh->setAnchoredPoint(95, 78);
}
Пример #6
0
void MlUVView::drawBindVectors(MlFeather * f)
{
	GeoDrawer * dr = getDrawer();
	const Vector3F baseP(f->baseUV());
	
	glPushMatrix();
    Matrix44F s;
	s.setTranslation(baseP);
	
	float * quill = f->getQuilly();
	Vector3F b;
	for(short i=0; i < f->numSegment(); i++) {
	    dr->useSpace(s);
		
		for(short j=0; j < f->numBind(i); j++) {
			DeformableFeather::BindCoord *bind = f->getBind(i, j);
			dr->arrow(Vector3F(0.f, 0.f, 0.f), bind->_objP * 32.f);
		}
		
		b.set(0.f, quill[i], 0.f);
		s.setTranslation(b);
	}
	glPopMatrix();
}