void AxisymUpdatedLagrangianElement::CalculateKinematics(GeneralVariables& rVariables, const double& rPointNumber) { KRATOS_TRY //Get the parent coodinates derivative [dN/d£] const GeometryType::ShapeFunctionsGradientsType& DN_De = rVariables.GetShapeFunctionsGradients(); //Get the shape functions for the order of the integration method [N] const Matrix& Ncontainer = rVariables.GetShapeFunctions(); //Parent to reference configuration rVariables.StressMeasure = ConstitutiveLaw::StressMeasure_Cauchy; //Calculating the inverse of the jacobian and the parameters needed [d£/dx_n] Matrix InvJ; MathUtils<double>::InvertMatrix( rVariables.J[rPointNumber], InvJ, rVariables.detJ); //Compute cartesian derivatives [dN/dx_n] noalias( rVariables.DN_DX ) = prod( DN_De[rPointNumber], InvJ ); //Set Shape Functions Values for this integration point rVariables.N=row( Ncontainer, rPointNumber); //Calculate IntegrationPoint radius CalculateRadius (rVariables.CurrentRadius, rVariables.ReferenceRadius, rVariables.N); //Current Deformation Gradient [dx_n+1/dx_n] CalculateDeformationGradient (rVariables.DN_DX, rVariables.F, rVariables.DeltaPosition, rVariables.CurrentRadius, rVariables.ReferenceRadius); //Determinant of the deformation gradient F rVariables.detF = MathUtils<double>::Det(rVariables.F); //Calculating the inverse of the jacobian and the parameters needed [d£/dx_n+1] Matrix Invj; MathUtils<double>::InvertMatrix( rVariables.j[rPointNumber], Invj, rVariables.detJ); //overwrites detJ //Compute cartesian derivatives [dN/dx_n+1] rVariables.DN_DX = prod( DN_De[rPointNumber], Invj ); //overwrites DX now is the current position dx //Determinant of the Deformation Gradient F0 rVariables.detF0 = mDeterminantF0[rPointNumber]; rVariables.F0 = mDeformationGradientF0[rPointNumber]; //Compute the deformation matrix B CalculateDeformationMatrix(rVariables.B, rVariables.DN_DX, rVariables.N, rVariables.CurrentRadius); KRATOS_CATCH( "" ) }
void LineLoadAxisym2DCondition::CalculateKinematics(GeneralVariables& rVariables, const double& rPointNumber) { KRATOS_TRY //Get the shape functions for the order of the integration method [N] const Matrix& Ncontainer = rVariables.GetShapeFunctions(); //get first vector of the plane rVariables.Tangent1[0] = rVariables.j[rPointNumber](0, 0); // x_1,e rVariables.Tangent1[1] = rVariables.j[rPointNumber](1, 0); // x_2,e rVariables.Normal[0] = -rVariables.j[rPointNumber](1, 0); //-x_2,e rVariables.Normal[1] = rVariables.j[rPointNumber](0, 0); // x_1,e //Jacobian to the deformed configuration rVariables.Jacobian = norm_2(rVariables.Normal); //Compute the unit normal and weighted tangents if(rVariables.Jacobian>0){ rVariables.Normal /= rVariables.Jacobian; rVariables.Tangent1 /= rVariables.Jacobian; } //Jacobian to the last known configuration rVariables.Tangent2[0] = rVariables.J[rPointNumber](0, 0); // x_1,e rVariables.Tangent2[1] = rVariables.J[rPointNumber](1, 0); // x_2,e rVariables.Jacobian = norm_2(rVariables.Tangent2); //Set Shape Functions Values for this integration point rVariables.N =row( Ncontainer, rPointNumber); //Get domain size rVariables.DomainSize = GetGeometry().Length(); //Calculate radius CalculateRadius ( rVariables.CurrentRadius, rVariables.ReferenceRadius, rVariables.N); KRATOS_CATCH( "" ) }
void CEntityMng::Initialize( float visibleDist ) { worldentity_t *entity; int i; m_frameFlag = 0; m_visibleDist = visibleDist; m_MDLMng->ClearWorldUseFlag(); m_linked = NULL; m_currCameraPathEntity = NULL; m_currPathEntity = NULL; m_numActivator = 0; entity = &m_entities[0]; for( i = 0 ; i < m_numEntities ; i++ , entity++ ) { entity->linkedCluster = m_world->FindCluster( entity->origin ); if( entity->linkedCluster < 0 ) { entity->inuse = false; continue; } entity->targetEntity = SearchTarget( entity->target ); if( entity->targetEntity ) entity->targetEntity->prevEntity = entity; entity->inuse = false; switch( entity->classType ) { case GTH_WORLD_ENTITY_TYPE_PLAYER_POS : break; case GTH_WORLD_ENTITY_TYPE_MODEL : entity->idxMDLEntity = m_MDLMng->AddWorldEntity( entity->itemName , entity->origin , entity->angles ); if( entity->idxMDLEntity < 0 ) break; if( !m_MDLMng->GetMDLWorldClassBoundBox( entity->idxMDLEntity , entity->mins , entity->maxs ) ) { VectorClear( entity->mins ); VectorClear( entity->maxs ); } entity->radius = CalculateRadius( entity->mins , entity->maxs ); AddLink( entity ); entity->inuse = true; break; case GTH_WORLD_ENTITY_TYPE_TELEPORT : if( !entity->target ) break; entity->idxMDLEntity = m_MDLMng->AddWorldEntity( entity->itemName , entity->origin , entity->angles ); if( entity->idxMDLEntity < 0 ) break; if( !m_MDLMng->GetMDLWorldClassBoundBox( entity->idxMDLEntity , entity->mins , entity->maxs ) ) { VectorClear( entity->mins ); VectorClear( entity->maxs ); } AddLink( entity ); entity->inuse = true; break; case GTH_WORLD_ENTITY_TYPE_ACTIVATOR : if( !entity->targetEntity ) break; AddLink( entity ); entity->inuse = true; break; case GTH_WORLD_ENTITY_TYPE_DEACTIVATOR : if( !entity->targetEntity ) break; AddLink( entity ); entity->inuse = true; break; case GTH_WORLD_ENTITY_TYPE_DOOR : AddLink( entity ); entity->activator = GetNewActivator(); entity->inuse = true; break; case GTH_WORLD_ENTITY_TYPE_PATH : AddLink( entity ); entity->activator = GetNewActivator(); entity->inuse = false; break; case GTH_WORLD_ENTITY_TYPE_CAMERA_PATH : AddLink( entity ); entity->activator = GetNewActivator(); entity->inuse = false; break; case GTH_WORLD_ENTITY_TYPE_SOUND : AddLink( entity ); entity->activator = GetNewActivator(); entity->inuse = true; break; default: break; } } }
S3DModel* CAssParser::Load(const std::string& modelFilePath) { LOG_S(LOG_SECTION_MODEL, "Loading model: %s", modelFilePath.c_str() ); const std::string modelPath = FileSystem::GetDirectory(modelFilePath); const std::string modelName = FileSystem::GetBasename(modelFilePath); //! LOAD METADATA //! Load the lua metafile. This contains properties unique to Spring models and must return a table std::string metaFileName = modelFilePath + ".lua"; if (!CFileHandler::FileExists(metaFileName, SPRING_VFS_ZIP)) { //! Try again without the model file extension metaFileName = modelPath + '/' + modelName + ".lua"; } LuaParser metaFileParser(metaFileName, SPRING_VFS_MOD_BASE, SPRING_VFS_ZIP); if (!CFileHandler::FileExists(metaFileName, SPRING_VFS_ZIP)) { LOG_S(LOG_SECTION_MODEL, "No meta-file '%s'. Using defaults.", metaFileName.c_str()); } else if (!metaFileParser.Execute()) { LOG_SL(LOG_SECTION_MODEL, L_ERROR, "'%s': %s. Using defaults.", metaFileName.c_str(), metaFileParser.GetErrorLog().c_str()); } //! Get the (root-level) model table const LuaTable& metaTable = metaFileParser.GetRoot(); if (metaTable.IsValid()) { LOG_S(LOG_SECTION_MODEL, "Found valid model metadata in '%s'", metaFileName.c_str()); } //! LOAD MODEL DATA //! Create a model importer instance Assimp::Importer importer; //! Create a logger for debugging model loading issues Assimp::DefaultLogger::create("",Assimp::Logger::VERBOSE); const unsigned int severity = Assimp::Logger::Debugging|Assimp::Logger::Info|Assimp::Logger::Err|Assimp::Logger::Warn; Assimp::DefaultLogger::get()->attachStream( new AssLogStream(), severity ); //! Give the importer an IO class that handles Spring's VFS importer.SetIOHandler( new AssVFSSystem() ); //! Speed-up processing by skipping things we don't need importer.SetPropertyInteger(AI_CONFIG_PP_RVC_FLAGS, aiComponent_CAMERAS|aiComponent_LIGHTS|aiComponent_TEXTURES|aiComponent_ANIMATIONS); #ifndef BITMAP_NO_OPENGL //! Optimize VBO-Mesh sizes/ranges GLint maxIndices = 1024; GLint maxVertices = 1024; glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &maxIndices); glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &maxVertices); //FIXME returns not optimal data, at best compute it ourself! (pre-TL cache size!) importer.SetPropertyInteger(AI_CONFIG_PP_SLM_VERTEX_LIMIT, maxVertices); importer.SetPropertyInteger(AI_CONFIG_PP_SLM_TRIANGLE_LIMIT, maxIndices/3); #endif //! Read the model file to build a scene object LOG_S(LOG_SECTION_MODEL, "Importing model file: %s", modelFilePath.c_str() ); const aiScene* scene = importer.ReadFile( modelFilePath, ASS_POSTPROCESS_OPTIONS ); if (scene != NULL) { LOG_S(LOG_SECTION_MODEL, "Processing scene for model: %s (%d meshes / %d materials / %d textures)", modelFilePath.c_str(), scene->mNumMeshes, scene->mNumMaterials, scene->mNumTextures ); } else { LOG_SL(LOG_SECTION_MODEL, L_ERROR, "Model Import: %s", importer.GetErrorString()); } SAssModel* model = new SAssModel; model->name = modelFilePath; model->type = MODELTYPE_ASS; model->scene = scene; //model->meta = &metaTable; //! Gather per mesh info CalculatePerMeshMinMax(model); //! Assign textures //! The S3O texture handler uses two textures. //! The first contains diffuse color (RGB) and teamcolor (A) //! The second contains glow (R), reflectivity (G) and 1-bit Alpha (A). if (metaTable.KeyExists("tex1")) { model->tex1 = metaTable.GetString("tex1", "default.png"); } else { //! Search for a texture std::vector<std::string> files = CFileHandler::FindFiles("unittextures/", modelName + ".*"); for(std::vector<std::string>::iterator fi = files.begin(); fi != files.end(); ++fi) { model->tex1 = FileSystem::GetFilename(*fi); break; //! there can be only one! } } if (metaTable.KeyExists("tex2")) { model->tex2 = metaTable.GetString("tex2", ""); } else { //! Search for a texture std::vector<std::string> files = CFileHandler::FindFiles("unittextures/", modelName + "2.*"); for(std::vector<std::string>::iterator fi = files.begin(); fi != files.end(); ++fi) { model->tex2 = FileSystem::GetFilename(*fi); break; //! there can be only one! } } model->flipTexY = metaTable.GetBool("fliptextures", true); //! Flip texture upside down model->invertTexAlpha = metaTable.GetBool("invertteamcolor", true); //! Reverse teamcolor levels //! Load textures LOG_S(LOG_SECTION_MODEL, "Loading textures. Tex1: '%s' Tex2: '%s'", model->tex1.c_str(), model->tex2.c_str()); texturehandlerS3O->LoadS3OTexture(model); //! Load all pieces in the model LOG_S(LOG_SECTION_MODEL, "Loading pieces from root node '%s'", scene->mRootNode->mName.data); LoadPiece(model, scene->mRootNode, metaTable); //! Update piece hierarchy based on metadata BuildPieceHierarchy( model ); //! Simplified dimensions used for rough calculations model->radius = metaTable.GetFloat("radius", model->radius); model->height = metaTable.GetFloat("height", model->height); model->relMidPos = metaTable.GetFloat3("midpos", model->relMidPos); model->mins = metaTable.GetFloat3("mins", model->mins); model->maxs = metaTable.GetFloat3("maxs", model->maxs); //! Calculate model dimensions if not set if (!metaTable.KeyExists("mins") || !metaTable.KeyExists("maxs")) CalculateMinMax( model->rootPiece ); if (model->radius < 0.0001f) CalculateRadius( model ); if (model->height < 0.0001f) CalculateHeight( model ); //! Verbose logging of model properties LOG_SL(LOG_SECTION_MODEL, L_DEBUG, "model->name: %s", model->name.c_str()); LOG_SL(LOG_SECTION_MODEL, L_DEBUG, "model->numobjects: %d", model->numPieces); LOG_SL(LOG_SECTION_MODEL, L_DEBUG, "model->radius: %f", model->radius); LOG_SL(LOG_SECTION_MODEL, L_DEBUG, "model->height: %f", model->height); LOG_SL(LOG_SECTION_MODEL, L_DEBUG, "model->mins: (%f,%f,%f)", model->mins[0], model->mins[1], model->mins[2]); LOG_SL(LOG_SECTION_MODEL, L_DEBUG, "model->maxs: (%f,%f,%f)", model->maxs[0], model->maxs[1], model->maxs[2]); LOG_S(LOG_SECTION_MODEL, "Model %s Imported.", model->name.c_str()); return model; }