void SkinnedMeshNode::SerializeIn( std::ifstream& stream ) { // 이미 앞에서 타입은 읽었다. unsigned short ver = 0; unsigned char count =0 ; //scene stream.read((char*)&ver,sizeof(ver)); ReadString(stream,m_strNodeName); ReadString(stream,m_strParentName); ReadMatrix(stream,m_nodeTM); stream.read((char*)&m_materialRefIndex,sizeof(m_materialRefIndex)); stream.read((char*)&m_materialSubIndex,sizeof(m_materialSubIndex)); stream.read((char*)&m_primitiveCount,sizeof(m_primitiveCount)); stream.read((char*)&m_startIndex,sizeof(m_startIndex)); ReadBool(stream,m_bInstancingEnable); // mesh SerializeInMesh(stream); // child stream.read((char*)&count,sizeof(count)); for ( int i=0 ; i<count ; i++ ) { SCENETYPE type; stream.read((char*)&type,sizeof(type)); cSceneNode* pNode = CreateNode(type); pNode->SetRootNode(m_pRootNode); pNode->SetParentNode(this); pNode->SetParentName(m_strNodeName.c_str()); AttachChildNode(pNode); pNode->SerializeIn(stream); } }
int main(int argc, char **argv) { int i, j, nrows; int **matrix; FILE *infile; infile = fopen(argv[1], "r"); if (infile == NULL) { printf("Can't open the file\n."); // ver TASC, p. 457, pdf. exit(1); } nrows = GetNrows(infile); fclose(infile); matrix = GetBlock(nrows); infile = fopen(argv[1], "r"); if (infile == NULL) { printf("Can't open the file\n."); // ver TASC, p. 457, pdf. exit(1); } //ver necessidade de fechar e abrir de novo ReadMatrix(infile, matrix); for (i = 0; i < nrows; i++) for (j = i + 1; j < nrows; j++) printf("%d", matrix[i][j]); fclose(infile); }
void WrapDeterminant (TomVM& vm) { // Fetch matrix if (!ReadMatrix (vm, vm.GetIntParam (1), m1)) return; // Return result vm.Reg ().RealVal () = Determinant (m1); }
void DoScaleMatrix (TomVM& vm, vmReal scale, int matrixIndex) { // Read in matrix if (!ReadMatrix (vm, matrixIndex, m1)) return; // Scale matrix ScaleMatrix (m1, scale); // Create new matrix and assign to register vm.Reg ().IntVal () = FillTempRealArray2D (vm.Data (), vm.DataTypes (), 4, 4, m1); }
void WrapOrthonormalize (TomVM& vm) { // Fetch matrix if (!ReadMatrix (vm, vm.GetIntParam (1), m1)) return; // Orthonormalize Orthonormalize (m1); // Create new matrix and assign to register vm.Reg ().IntVal () = FillTempRealArray2D (vm.Data (), vm.DataTypes (), 4, 4, m1); }
void WrapRTInvert (TomVM& vm) { // Fetch matrix if (!ReadMatrix (vm, vm.GetIntParam (1), m1)) return; // RTInvert RTInvert (m1, m2); // Create new matrix and assign to register vm.Reg ().IntVal () = FillTempRealArray2D (vm.Data (), vm.DataTypes (), 4, 4, m2); }
int ext6c(char *aname, double *b, double *c) { double a[3]; int k, m, n; ReadMatrix(aname, &m, &n, a); /* [m,n]=size(a) here m=1 n=3 */ for (k = 0; k < n; ++k) { c[k] = a[k] + b[k] * 2.; } return (0); }
void ForceTorqueCtrl::ReadCalibrationMatrix() { Eigen::VectorXf vCoef(6); //Read Fx coefficients ReadMatrix(0, vCoef); m_v3FXGain = vCoef; //Read Fy coefficients ReadMatrix(1, vCoef); m_v3FYGain = vCoef; //Read Fz coefficients ReadMatrix(2, vCoef); m_v3FZGain = vCoef; //Read Tx coefficients ReadMatrix(3, vCoef); m_v3TXGain = vCoef; //Read Ty coefficients ReadMatrix(4, vCoef); m_v3TYGain = vCoef; //Read Tz coefficients ReadMatrix(5, vCoef); m_v3TZGain = vCoef; SetCalibMatrix(); }
int ext5c(double *b, double *c) { static double a[3]; static int k, m, n; ReadMatrix("Amatrix", &m, &n, a); /*******************************/ /* [m,n]=size(Amatrix) here m=1 n=3, a=Amatrix which must exist in Scilab*/ for (k = 0; k < n; ++k) { c[k] = a[k] + b[k] * 2.; } return (0); }
/*------------------------------------------------------------*/ static int first_example(void) { static double A[]={1,2,3,4}; int mA=2,nA=2; static double b[]={4,5}; int mb=2,nb=1; printf("\nExample 1:\n"); printf("Some simple computations\n"); /* Create Scilab matrices A and b */ WriteMatrix("A", &mA, &nA, A); WriteMatrix("b", &mb, &nb, b); SendScilabJob("disp('A=');"); SendScilabJob("disp(A);"); SendScilabJob("disp('b=');"); SendScilabJob("disp(b);"); SendScilabJob("disp('x=A\\b');"); if ( SendScilabJob("A,b,x=A\\b;") != 0) { fprintf(stdout,"Error occured during scilab execution (SendScilabJob)\n"); } else { double *cxtmp=NULL; int m,n,lp,i; /* Get m and n */ GetMatrixptr("x", &m, &n, &lp); cxtmp=(double*)malloc((m*n)*sizeof(double)); ReadMatrix("x", &m, &n, cxtmp); for(i=0;i<m*n;i++) { fprintf(stdout,"x[%d] = %5.2f\n",i,cxtmp[i]); } if (cxtmp) { free(cxtmp); cxtmp=NULL; } } return 0; }
UI32 CSWF::ReadPlaceObject2(PLACEOBJECT2 *lppoPlace) { UI32 ulTagLength=bsInFileStream.GetByteOffset(); memset(lppoPlace,0,sizeof(PLACEOBJECT2)); memcpy(&lppoPlace->rhTagHeader,&rhTagHeader,sizeof(RECORDHEADER)); UI8 ulFlags=bsInFileStream.ReadUI8(); lppoPlace->fPlaceFlagHasClipActions=ulFlags & 0x80; lppoPlace->fPlaceFlagHasClipDepth=ulFlags & 0x40; lppoPlace->fPlaceFlagHasName=ulFlags & 0x20; lppoPlace->fPlaceFlagHasRatio=ulFlags & 0x10; lppoPlace->fPlaceFlagHasColorTransform=ulFlags & 0x08; lppoPlace->fPlaceFlagHasMatrix=ulFlags & 0x04; lppoPlace->fPlaceFlagHasCharacter=ulFlags & 0x02; lppoPlace->fPlaceFlagMove=ulFlags & 0x01; lppoPlace->usDepth=bsInFileStream.ReadUI16(); if(lppoPlace->fPlaceFlagHasCharacter) lppoPlace->usCharacterID=bsInFileStream.ReadUI16(); if(lppoPlace->fPlaceFlagHasMatrix) ReadMatrix(&lppoPlace->mMatrix); if(lppoPlace->fPlaceFlagHasColorTransform) ReadCXForm(&lppoPlace->cxfwaColorTransform,true); if(lppoPlace->fPlaceFlagHasRatio) lppoPlace->usRatio=bsInFileStream.ReadUI16(); if(lppoPlace->fPlaceFlagHasName) bsInFileStream.ReadString(lppoPlace->szName); if(lppoPlace->fPlaceFlagHasClipDepth) lppoPlace->usClipDepth=bsInFileStream.ReadUI16(); if(lppoPlace->fPlaceFlagHasClipActions) ReadClipActions(&lppoPlace->caClipActions); ulTagLength=bsInFileStream.GetByteOffset()-ulTagLength; return ulTagLength; }
void FDSMesh::SetKnotValuesFromFile(const std::string &filename) { ///open File (reading) std::ifstream pFile(filename); if (pFile) { std::vector<std::string> strVec; std::string line; ///skip two lines std::getline(pFile, line); std::getline(pFile, line); std::getline(pFile, line); //std::cout << line << std::endl; /// to avoid multiple reading of the header and mesh setting //if (statHeaderRead==false) //{ /// read header strVec = split2(line,',', strVec); double cellsize = std::stod(strVec[0]); double xmin = std::stod(strVec[2]); double xmax = std::stod(strVec[3]); double ymin = std::stod(strVec[4]); double ymax = std::stod(strVec[5]); strVec.clear(); //std::cout << "xmin=" << xmin << " , xmax=" << xmax << " , ymin=" << ymin << ", ymax=" << ymax << " , dx=" << cellsize << std::endl; SetUpMesh(xmin,ymin,xmax,ymax,cellsize); //statHeaderRead=true; //} //Read matrix ReadMatrix(line, pFile); } else { Log->Write("ERROR:\tCould not open FDS slicefile: %s",filename.c_str()); //return false; exit(EXIT_FAILURE); } }
UI32 CSWF::ReadPlaceObject(PLACEOBJECT *lppoPlace) { UI32 ulTagLength=bsInFileStream.GetByteOffset(); memset(lppoPlace,0,sizeof(PLACEOBJECT)); memcpy(&lppoPlace->rhTagHeader,&rhTagHeader,sizeof(RECORDHEADER)); lppoPlace->usCharacterID=bsInFileStream.ReadUI16(); lppoPlace->usDepth=bsInFileStream.ReadUI16(); ReadMatrix(&lppoPlace->mMatrix); /*Read CXFORM*/ if(lppoPlace->rhTagHeader.ulLength>ulTagLength) ReadCXForm(&lppoPlace->cxfColorTransform,false); ulTagLength=bsInFileStream.GetByteOffset()-ulTagLength; return ulTagLength; }
void OpMatrixVec (TomVM& vm) { // Matrix at reg2. Vector at reg. // Read in matrix if (!ReadMatrix (vm, vm.Reg2 ().IntVal (), m1)) return; // Read in vector int size = ReadVec (vm, vm.Reg ().IntVal (), v1); if (size < 0) return; // Calculate resulting vector vmReal result [4]; MatrixTimesVec (m1, v1, result); // Return as temporary vector vm.Reg ().IntVal () = FillTempRealArray (vm.Data (), vm.DataTypes (), size, result); }
// 进行矩阵乘法计算 int MatrixProduct() { int A[N][N], B[N][N], C[N][N]; int i, j, k; if(ReadMatrix(A, B)) return 1; for (i = 0; i < N; i++){ for (j = 0; j < N; j++){ // 注意一定初始化,否则一定出错 C[i][j] = 0; for (k = 0; k < N; k++){ C[i][j] += A[i][k] * B[k][j]; } //printf("C[%d][%d] = %d\t", i, j, C[i][j]); } //printf("\n"); } outputMatrix(C); return 0; }
int main(int argc, char **argv) { char *input_filename = NULL, *output_filename = NULL; if (!parse_args(argc, argv, &input_filename, &output_filename)) { help(argv[0]); exit(-1); } FILE *fout = NULL; if (!(fout = fopen(output_filename,"w"))) fout = stdout; Matrix *m1 = NULL, *covariance; m1 = ReadMatrix(input_filename); covariance = Covariance(m1); WriteMatrix(fout, covariance); if (!(fout == stdout)) { printf("Output was written in %s\n", output_filename); fclose(fout); } DestroyMatrix(m1); DestroyMatrix(covariance); return 0; }
int main(int argc, char *argv[]) { FILE *input_file, *output_file, *time_file; if (argc < 4) { fprintf(stderr, "Invalid input parameters\n"); fprintf(stderr, "Usage: %s inputfile outputfile timefile \n", argv[0]); exit(1); } else { input_file = fopen(argv[1], "r"); output_file = fopen(argv[2], "w"); time_file = fopen(argv[3], "w"); if (!input_file || !output_file || !time_file) exit(1); } MM_typecode matcode; if (mm_read_banner(input_file, &matcode) != 0) { printf("Could not process Matrix Market banner.\n"); exit(1); } if (!mm_is_matrix(matcode) || !mm_is_real(matcode) || !mm_is_coordinate(matcode)) { printf("Sorry, this application does not support "); printf("Market Market type: [%s]\n", mm_typecode_to_str(matcode)); exit(1); } mtxMatrix inputMatrix, fullMatrix, LMatrix, UMatrix, UMatrixTranspose, MMatrix; ReadMatrix(inputMatrix, input_file); Timer timer; getRowIndex(&inputMatrix, inputMatrix.RowIndex); inputMatrix.RowIndex[inputMatrix.N] = inputMatrix.NZ; int diagNum = 0; for (int i = 0; i < inputMatrix.N; i++) { for (int j = inputMatrix.RowIndex[i]; j < inputMatrix.RowIndex[i + 1]; j++) { if (i == inputMatrix.Col[j]) diagNum++; } } if (mm_is_symmetric(matcode)) { InitializeMatrix(inputMatrix.N, 2 * inputMatrix.NZ - diagNum, fullMatrix); TriangleToFull(&inputMatrix, &fullMatrix); FreeMatrix(inputMatrix); } else { fullMatrix = inputMatrix; } int *diag = new int[fullMatrix.N]; for (int i = 0; i < fullMatrix.N; i++) { for (int j = fullMatrix.RowIndex[i]; j < fullMatrix.RowIndex[i + 1]; j++) { if (i == fullMatrix.Col[j]) diag[i] = j; } } // for (int i = 0; i < fullMatrix.N + 1; i++) { // printf("RowIndex[%i] = %i\n", i, fullMatrix.RowIndex[i]); // } // // // for (int i = 0; i < fullMatrix.N; i++) { // printf("input[%i]= %lf\n", i, fullMatrix.Value[inputMatrix.RowIndex[i]]); // } // // for (int i = 0; i < fullMatrix.N; i++) { // printf("diag[%i]= %d\n", i, diag[i]); // } timer.start(); ilu0(fullMatrix, fullMatrix.Value, diag); LUmatrixSeparation(fullMatrix, diag, LMatrix, UMatrix); Transpose(UMatrix, UMatrixTranspose); Multiplicate(LMatrix, UMatrixTranspose, MMatrix); timer.stop(); std::ofstream timeLog; timeLog.open(argv[3]); timeLog << timer.getElapsed(); WriteFullMatrix(MMatrix, output_file, matcode); FreeMatrix(fullMatrix); return 0; }
/*--------------------------------------------------------------------------*/ static int example2(void) { int code = 0; char **JOBS = NULL; const int SizeJOBS = 5; int i = 0; int m = 0, n = 0; double *cxtmp = NULL; JOBS = (char**)malloc(sizeof(char**) * SizeJOBS); for (i = 0; i < SizeJOBS; i++) { JOBS[i] = (char*)malloc(sizeof(char*) * 1024); } strcpy(JOBS[0], "A=1 .."); strcpy(JOBS[1], "+3;"); strcpy(JOBS[2], "B = 8;"); strcpy(JOBS[3], "+3;"); strcpy(JOBS[4], "C=A+B;"); /* C = 12 */ for (i = 0; i < SizeJOBS; i++) { printf("JOBS[%d] = %s\n", i, JOBS[i]); } code = SendScilabJobs(JOBS, SizeJOBS); if (code) { char lastjob[4096]; // bsiz in scilab 4096 max if (GetLastJob(lastjob, 4096)) { printf("Error %s\n", lastjob); } } m = 1; n = 1; cxtmp = (double*)malloc((m * n) * sizeof(double)); ReadMatrix("C", &m, &n, cxtmp); printf("Result :\n"); for (i = 0; i < m * n; i++) { fprintf(stdout, "C[%d] = %5.2f\n", i, cxtmp[i]); } for (i = 0; i < SizeJOBS; i++) { if (JOBS[i]) { free(JOBS[i]); JOBS[i] = NULL; } } return 1; }
double FileReader::ShowSolution() { std::ifstream m_solutionFile; m_solutionFile.open(m_fileName + ".opt.tour"); bool ReadAhead = false; std::vector<int> strVector; double distance = 0; if(m_solutionFile.is_open()) { m_solutionFile.setf(ios::skipws); while(!m_solutionFile.eof() && m_solutionFile.good()) { //we need to read up to the newline getline(m_solutionFile , sInput , '\n'); if(ReadAhead) { //split up the input into tokens of whit spaces Tk ti(sInput.c_str() , TokenFinder(" ")); // find white spaces while( ti != Tk()) // skip the first as format in "place" , distance , distance , dont need the first { //convert the string to a double int position = std::stoi(*ti,&sz); if(position == -1) { ReadAhead = false; break; } strVector.push_back(position - 1); //our arrays start at 0 ++ti; } //m_strVector.push_back(sInput); } //start of the COORDS in the TSP format , so read the coords from here.... if(sInput == "TOUR_SECTION") { ReadAhead = true; } } m_solutionFile.close(); // strVector 1 14 13 12 7 6 15 5 11 9 10 16 3 2 4 8 //int lastNode = strVector[0]; //int next = strVector[1]; int i, start, end; for(unsigned int i = 1; i < strVector.size() ; i++) { start = strVector[i-1]; end = strVector[i]; distance += ReadMatrix(start , end); } distance += ReadMatrix(end, strVector[0]); } printf("Shortest tour found: distance =%.2f \n" , distance); for (int j=0; j<strVector.size(); j++) printf("%i|",strVector[j]+1); return distance; }
rom::ROM rom::ROMFromFile(const std::string& filepath) { Eigen::MatrixXd res; std::ifstream myfile (filepath.c_str()); std::string line; double maxRadius_; int size_; double minx, miny, minz; double maxx, maxy, maxz; int axe1, axe2 , axe3; if (myfile.is_open()) { if(myfile.good()) { char r[255]; getline (myfile, line); sscanf(line.c_str(),"%s",r); maxRadius_ = (double) (strtod (r, NULL)); } else { std::string errmess("In file: " + filepath + "; file ended before finding radius"); throw(new ROMException(errmess)); } if(myfile.good()) { char s[255]; getline (myfile, line); sscanf(line.c_str(),"%s",s); size_ = (int) (strtod (s, NULL)); getline (myfile, line); if(line.size()> 0) { line = remplacerVirgule(line); char caxe1[255],caxe2[255],caxe3[255]; sscanf(line.c_str(),"%s %s %s",caxe1, caxe2, caxe3); axe1 = (int) strtod (caxe1, NULL); axe2 = (int) strtod (caxe2, NULL); axe3 = (int) strtod (caxe3, NULL); } getline (myfile, line); if(line.size()> 0) { line = remplacerVirgule(line); char cminx[255],cminy[255],cminz[255]; char cmaxx[255],cmaxy[255],cmaxz[255]; sscanf(line.c_str(),"%s %s %s %s %s %s",cminx, cmaxx, cminy, cmaxy, cminz, cmaxz); minx = (double) strtod (cminx, NULL); miny = (double) strtod (cminy, NULL); minz = (double) strtod (cminz, NULL); maxx = (double) strtod (cmaxx, NULL); maxy = (double) strtod (cmaxy, NULL); maxz = (double) strtod (cmaxz, NULL); } } res = ReadMatrix(size_, myfile); myfile.close(); } else { std::string errmess("file not found: " + filepath); throw(new ROMException(errmess)); } Eigen::MatrixXd A_ = res.block(0,0,size_,3); Eigen::VectorXd b_ = res.block(0,3,size_,1); return ROM(A_,b_,maxRadius_,minx, miny, minz, maxx, maxy, maxz, axe1, axe2, axe3); }
int main(int argc, char *argv[]) { if (argc < 3) { printf("Invalid input parameters\n"); return 1; } int N = atoi(argv[1]); int NZ = atoi(argv[2]); char *mtxFileName = NULL; char *vecFileName = NULL; if (argc > 3 && argc < 6) { mtxFileName = argv[3]; vecFileName = argv[4]; } if ((NZ > N) || (N <= 0) || (NZ <= 0)) { printf("Incorrect arguments of main\n"); return 1; } crsMatrix A; double *x, *b, *bm; double timeM=0, timeM1=0, diff=0; if (ReadMatrix(A, mtxFileName) != 0) { GenerateRegularCRS(1, N, NZ, A); WriteMatrix(A, "mtx.txt"); } if (ReadVector(&x, N, vecFileName) != 0) { GenerateVector(2, N, &x); WriteVector(x, N, "vec.txt"); } InitializeVector(N, &b); Multiplicate(A, x, b, timeM); InitializeVector(N, &bm); SparseMKLMult(A, x, bm, timeM1); CompareVectors(b, bm, N, diff); if (diff < EPSILON) printf("OK\n"); else printf("not OK\n"); printf("%d %d\n", A.N, A.NZ); printf("%.3f %.3f\n", timeM, timeM1); FreeMatrix(A); FreeVector(&b); FreeVector(&bm); FreeVector(&x); return 0; }
bool RSObject::Load(FILE *file,RSMaterialManager *pMM) { int i,j,k; fread(&m_Header,sizeof(m_Header),1,file); if((m_Header.RSMID!=HEADER_RSMID)||(m_Header.Build!=HEADER_BUILD)) { rslog("Incorrect file format. rsm build #%d. #%d required.\n",m_Header.Build,HEADER_BUILD); return false; } m_pMM=pMM; fread(&m_bbox,sizeof(rboundingbox),1,file); m_bbox.Minz=m_bbox.Miny=m_bbox.Minx=100000000; m_bbox.Maxz=m_bbox.Maxy=m_bbox.Maxx=-100000000; ReadInt(nMaterial); materials=new RSMaterial*[nMaterial+1]; // rslog("[ load object :%d mtrl_num %d ]\n",g_obj_cnt,nMaterial); materials[0]=&RSDefaultMaterial; for (i=0;i<nMaterial;i++) { char buf[256]; {int l=fgetc(file);buf[l]=0;if(l) fread(buf,l,1,file);} RSMaterial *pmat=pMM->GetMaterial(buf); materials[i+1]=pmat ? pmat : &RSDefaultMaterial; // rslog("\t-mtrl :%d name %s \n",i,buf); } nMaterial++; // for default material; ReadInt(nMesh); CMesh *mesh=meshes=new CMesh[nMesh]; // rslog("\n\t-mesh num :%d \n\n",nMesh); for(i=0;i<nMesh;i++) { ReadString(mesh->name);strlwr(mesh->name); ReadMatrix(mesh->mat); fread(&mesh->m_bbox,sizeof(rboundingbox),1,file); mesh->m_bbox.Minz=mesh->m_bbox.Miny=mesh->m_bbox.Minx=100000000; mesh->m_bbox.Maxz=mesh->m_bbox.Maxy=mesh->m_bbox.Maxx=-100000000; mesh->center=rvector(0,0,0); ReadInt(mesh->nFaces); CFaces *faces=mesh->faceshead=mesh->nFaces?new CFaces[mesh->nFaces]:NULL; // rslog("\t-mesh face num :%d \n",mesh->nFaces); for(j=0;j<mesh->nFaces;j++) { ReadInt(faces->iMaterial);faces->iMaterial++; // convert to 1-base index ReadInt(faces->nv); faces->tnlvertices=new VERTEX[faces->nv]; fread(faces->tnlvertices,sizeof(VERTEX),faces->nv,file); for(k=0;k<faces->nv;k++) { rvector *pv=(rvector*)(&faces->tnlvertices[k].x); m_BoundingSphereRadius=max(m_BoundingSphereRadius,pv->GetMagnitude()); m_BoundingSphereRadiusXY=max(m_BoundingSphereRadiusXY,rvector(pv->x,pv->y,0).GetMagnitude()); mesh->m_bbox.Minx=min(mesh->m_bbox.Minx,pv->x); mesh->m_bbox.Maxx=max(mesh->m_bbox.Maxx,pv->x); mesh->m_bbox.Miny=min(mesh->m_bbox.Miny,pv->y); mesh->m_bbox.Maxy=max(mesh->m_bbox.Maxy,pv->y); mesh->m_bbox.Minz=min(mesh->m_bbox.Minz,pv->z); mesh->m_bbox.Maxz=max(mesh->m_bbox.Maxz,pv->z); } // rslog("\t\t-mesh face v num :%d \n",faces->nv); if(fgetc(file)==1) { faces->indicies_original=new WORD[faces->nv]; fread(faces->indicies_original,sizeof(WORD),faces->nv,file); } else { ReadInt(faces->ni); faces->indicies=new WORD[faces->ni]; fread(faces->indicies,sizeof(WORD),faces->ni,file); } faces++; } if(strstr(mesh->name,ALIGN_POINT_STRING)) mesh->m_align=RS_ALIGNSTYLE_POINT; else if(strstr(mesh->name,ALIGN_LINE_STRING)) mesh->m_align=RS_ALIGNSTYLE_LINE; else mesh->m_align=RS_ALIGNSTYLE_NONE; MergeBoundingBox(&m_bbox,&mesh->m_bbox); mesh++; } m_ShadowTexture.Create(file); /*// save test { char buf[256]; ReplaceExtension(buf,name,"bmp"); m_ShadowTexture.SaveAsBMP(buf); } //*/ m_hShadowTexture=RSCreateTexture( m_ShadowTexture.GetWidth(),m_ShadowTexture.GetHeight(), (char*)m_ShadowTexture.GetData(),NULL,true,"Object:ShadowTexture"); /* rtexture temp;temp.Create(file); CreateShadowTexture(); */ ReadInt(nAnimSet); if(nAnimSet) { for(i=0;i<nAnimSet;i++) { RSAnimationInfo *ai=new RSAnimationInfo; ai->Load(file); AnimationList.Add(ai); } } GenerateVertexBuffers(); // rslog("\t-mesh ani num :%d \n",nAnimSet); // g_obj_cnt++; return true; }
void MULTIPLAY::ReadState(Uint8 * s, int slot) { //read a state //allocate function sync memory loadstates[slot].fnum = fnums[slot]; //set the number of funcs if (loadstates[slot].funcmem != NULL) //clear old func data { delete [] loadstates[slot].funcmem; loadstates[slot].funcmem = NULL; } //now, read the state int len = 0; Uint8 tempchar; len = GetFromData(s, &tempchar, sizeof(Uint8), len); if (tempchar != replay.Get_FuncStateInfo()) { if (NET_DEBUG) cout << "net: ReadState: packet is not a state" << endl; return; } len = GetFromData(s, &loadstates[slot].time, sizeof(double), len); //tplen = AddToData(tp, &GetCurState(0)->time, sizeof(double), tplen); //fwrite(&time, sizeof(double), 1, fout); len = ReadVector(loadstates[slot].chassispos, s, len); len = ReadMatrix(loadstates[slot].chassisorientation, s, len); len = ReadVector(loadstates[slot].chassisvel, s, len); len = ReadVector(loadstates[slot].chassisangvel, s, len); int i; for (i = 0; i < 4; i++) { len = GetFromData(s, &loadstates[slot].suspdisp[i], sizeof(double), len); len = GetFromData(s, &loadstates[slot].suspcompvel[i], sizeof(double), len); len = ReadVector(loadstates[slot].whlangvel[i], s, len); len = GetFromData(s, &loadstates[slot].tirespeed[i], sizeof(double), len); } len = GetFromData(s, &loadstates[slot].gear, sizeof(int), len); len = GetFromData(s, &loadstates[slot].enginespeed, sizeof(double), len); len = GetFromData(s, &loadstates[slot].clutchspeed, sizeof(double), len); len = GetFromData(s, &loadstates[slot].enginedrag, sizeof(double), len); len = GetFromData(s, &loadstates[slot].segment, sizeof(int), len); //read the function state block len = GetFromData(s, &(fnums[slot]), sizeof(int), len); loadstates[slot].funcmem = new FUNCTION_MEMORY_SYNC [fnums[slot]]; //allocate func data //len = AddToData(tp, &(fnums[0]), sizeof(int), tplen); if (MP_DEBUG) cout << "net: ReadState: " << fnums[slot] << " functions, active: "; for (i = 0; i < fnums[slot]; i++) { //fwrite(&(funcmem[i]), sizeof(struct FUNCTION_MEMORY_SYNC), 1, fout); //tplen = AddToData(tp, &(GetFuncMem(0)[i]), sizeof(struct FUNCTION_MEMORY_SYNC), tplen); len = GetFromData(s, &loadstates[slot].funcmem[i], sizeof(struct FUNCTION_MEMORY_SYNC), len); if (MP_DEBUG && loadstates[slot].funcmem[i].active) cout << GetFuncMem(slot)[i].func_name << "(" << i << ") "; } if (MP_DEBUG) cout << endl; }