Esempio n. 1
0
//Nachoptimierung ohne random elemente
void Docking::NachoptimierungEigen(Protein* p,int score,Vector3 v, System s1){
	
	Protein copy1(*p, true);
	Protein* copy = &copy1;
	
	TranslationProcessor translation;
	Vector3 vneg = v*(-1);
	translation.setTranslation(vneg);
	
	copy->apply(translation);
		
	Matrix4x4 Matrix;
	
	//nachoptimierung nur minimal da score schon gut
	
	float winkel = 7;
	
	Angle angle(winkel, false);
	
	//Random Vektor als rotationsaxe
	Vector3 axe(1,1,1);
	
	Matrix.setRotation(angle,axe);
	
	TransformationProcessor EigenTransformation(Matrix);
	copy->apply(EigenTransformation);
	
	
	TranslationProcessor translation2;
	
	translation2.setTranslation(v);
	
	copy->apply(translation2);
	
	
	vector<Vector3> pos = data.savePositions(copy);
	float newscore = scoring(pos);
	//nur wenn der score höher ist interessierr er uns
	if(newscore>score){
		System opt;
		opt.insert(*copy);
		int id = 1111; // zum erkennen dass es nachoptimiert wurde mit eigen
		data.writeFinalComplex(s1, opt, id, newscore);
	}
	
	

}
void PhysicRigidBody::init(PhysicShapeBase *shapeData, PhysicDebug *debugShape, float mass, float *pos, float *quat, void *userPoint, int collisionflag)
{
	if(m_pWorld != NULL)
	{
		btTransform trans;
		trans.setIdentity();
		trans.setRotation(*((btQuaternion *)quat));
		trans.setOrigin(*((btVector3 *)pos));
		m_pDebug = debugShape;
		m_pShapeData = shapeData;
		switch(m_pShapeData->getType())
		{
		case ePhysicShapeBox:
			m_pShapes = new btBoxShape(btVector3(
				m_pShapeData->getData(PhysicShapeBox::SIZE_X),
				m_pShapeData->getData(PhysicShapeBox::SIZE_Y),
				m_pShapeData->getData(PhysicShapeBox::SIZE_Z)
				));
			break;
		case ePhysicShapeCone:
			{
				btVector3 axe(m_pShapeData->getData(PhysicShapeCone::AXE_X),
					m_pShapeData->getData(PhysicShapeCone::AXE_Y),
					m_pShapeData->getData(PhysicShapeCone::AXE_Z));
				if (axe == BT_UNIT_Y)
					m_pShapes = new btConeShape (btScalar (m_pShapeData->getData(PhysicShapeCone::RADIUS)), 
													btScalar (m_pShapeData->getData(PhysicShapeCone::HEIGHT))
													);
				else if (axe == BT_UNIT_X)
					m_pShapes = new btConeShapeX (btScalar (m_pShapeData->getData(PhysicShapeCone::RADIUS)), 
													btScalar (m_pShapeData->getData(PhysicShapeCone::HEIGHT)));
				else
					m_pShapes = new btConeShapeZ (btScalar (m_pShapeData->getData(PhysicShapeCone::RADIUS)), 
													btScalar (m_pShapeData->getData(PhysicShapeCone::HEIGHT)));
			}
			break;
		case ePhysicShapeCylinder:
			{
				btVector3 axe(m_pShapeData->getData(PhysicShapeCylinder::AXE_X),
					m_pShapeData->getData(PhysicShapeCylinder::AXE_Y),
					m_pShapeData->getData(PhysicShapeCylinder::AXE_Z));
				btVector3 halfExtents(m_pShapeData->getData(PhysicShapeCylinder::HALF_X),
					m_pShapeData->getData(PhysicShapeCylinder::HALF_Y),
					m_pShapeData->getData(PhysicShapeCylinder::HALF_Z));
				if (axe == BT_UNIT_X)
					m_pShapes = new btCylinderShapeX(halfExtents);
				else if (axe == BT_UNIT_Y)
					m_pShapes = new btCylinderShape (halfExtents);
				else if (axe == BT_UNIT_Z)
					m_pShapes = new btCylinderShapeZ(halfExtents);
			}
			break;
		case ePhysicShapeSphere:
			m_pShapes = new btSphereShape(btScalar (m_pShapeData->getData(PhysicShapeSphere::RADIUS)));
			break;
		default:
			break;
		}
		m_pBodies = localCreateRigidBody(mass, trans, m_pShapes, userPoint, collisionflag);
	}
}