YSRESULT Parser::Parse(const YsWString &wstr) { CleanUp(); if(YSOK!=Decompose(wstr)) { return YSERR; } return YSOK; }
void float3x3::Decompose(Quat &rotate, float3 &scale) const { assume(this->IsOrthogonal()); float3x3 r; Decompose(r, scale); rotate = Quat(r); // Test that composing back yields the original float3x3. assume(float3x3::FromRS(rotate, scale).Equals(*this, 0.1f)); }
void float3x4::Decompose(float3 &translate, Quat &rotate, float3 &scale) const { assume(this->IsColOrthogonal()); float3x3 r; Decompose(translate, r, scale); rotate = Quat(r); // Test that composing back yields the original float3x4. assume(float3x4::FromTRS(translate, rotate, scale).Equals(*this, 0.1f)); }
void WaveletStack3D::CreateStack(float* data, int levels) { int max_levels = static_cast<int>(log(float(mResX)) / log(2.0f)); if (levels < 0 || levels > max_levels) levels = max_levels; if (levels > static_cast<int>(mStack.size())) { mStack.resize(static_cast<size_t>(levels), nullptr); mCoeff.resize(static_cast<size_t>(levels), nullptr); } memcpy(mBufferInput, data, static_cast<size_t>(mResX*mResY*mResZ)*sizeof(float)); int currentXRes = mResX; int currentYRes = mResY; int currentZRes = mResZ; // Create the image stack for (size_t x = 0; x < static_cast<size_t>(levels); x++) { const size_t curr_elem_cnt = static_cast<size_t>(currentXRes*currentYRes*currentZRes); if (mStack[x] == nullptr) mStack[x] = new float[curr_elem_cnt]; if (mCoeff[x] == nullptr) mCoeff[x] = new float[curr_elem_cnt]; Decompose(mBufferInput, mBufferLowFreq, mBufferHighFreq, mBufferHalfSize, currentXRes, currentYRes, currentZRes); // Save downsampled image to _coeffs and _stack memcpy(mCoeff[x], mBufferHighFreq, curr_elem_cnt * sizeof(float)); memcpy(mStack[x], mBufferHighFreq, curr_elem_cnt * sizeof(float)); // copy leftovers to input for next iteration memcpy(mBufferInput, mBufferHalfSize, curr_elem_cnt * sizeof(float)); // upsample the image and save it to stack int doubleX = currentXRes; int doubleY = currentYRes; int doubleZ = currentZRes; for (size_t y = 0; y < x; y++) { DoubleSize(mStack[x], doubleX, doubleY, doubleZ); doubleX *= 2; doubleY *= 2; doubleZ *= 2; } currentXRes /= 2; currentYRes /= 2; currentZRes /= 2; } }
bool nglZipPath::Decompose(const nglPath& rPath, std::list<nglPath>& rList) { nglPath parent(rPath.GetParent()); nglString tmp = rPath.GetNodeName(); nglPath node(tmp.IsNull()? nglString::Empty : tmp); if (parent == rPath) return true; rList.push_front(node); return Decompose(parent, rList); return true; }
void WaveletStack3D::CreateSingleLayer(float* data) { if (1 > mStack.size()) { mStack.resize(1, nullptr); } const size_t elem_cnt = static_cast<size_t>(mResX*mResY*mResZ); if (mStack[0] == nullptr) mStack[0] = new float[elem_cnt]; Decompose(data, mBufferLowFreq, mBufferHighFreq, mBufferHalfSize, mResX, mResY, mResZ); // Save downsampled image to the stack memcpy(mStack[0], mBufferHighFreq, elem_cnt*sizeof(float)); }
SocketDescriptor GenmeshAsset::GetSocketTransform(const char* socketName) { SocketDescriptor desc; iSkeletonSocket* sock = skeleton->FindSocket (socketName); if (!sock) return desc; csString str; desc["Name"] = TypeValue("String", sock->GetName()); iSkeletonBone* bone = sock->GetBone(); desc["Bone"] = TypeValue("String", bone->GetName()); csVector3 offset = sock->GetTransform().GetOrigin(); desc["Offset"] = TypeValue("Vector3", str.Format("%.2f, %.2f, %.2f", offset.x, offset.y, offset.z).GetData()); csVector3 rot = Decompose(sock->GetTransform().GetO2T()); desc["Rotation"] = TypeValue("Vector3", str.Format("%.2f, %.2f, %.2f", rot.x, rot.y, rot.z).GetData()); return desc; }
SocketDescriptor AnimeshAsset::GetSocketTransform(const char* socketName) { SocketDescriptor desc; uint sockf = animeshsprite->FindSocket(socketName); if (sockf == (uint)~0) return desc; CS::Mesh::iAnimatedMeshSocket* sock = animeshstate->GetSocket(sockf); if (!sock) return desc; csString str; desc["Name"] = TypeValue("String", sock->GetName()); desc["Bone"] = TypeValue("String", str.Format("%zu", sock->GetBone()).GetData()); //csVector3 offset = sock->GetFactory()->GetTransform().GetOrigin(); csVector3 offset = sock->GetTransform().GetOrigin(); desc["Offset"] = TypeValue("Vector3", str.Format("%.2f, %.2f, %.2f", offset.x, offset.y, offset.z).GetData()); //csVector3 rot = Decompose(sock->GetFactory()->GetTransform().GetO2T()); csVector3 rot = Decompose(sock->GetTransform().GetO2T()); desc["Rotation"] = TypeValue("Vector3", str.Format("%.2f, %.2f, %.2f", rot.x, rot.y, rot.z).GetData()); return desc; }
int createOctTree(octNode * root,const geBitmap_Info * Info,const void * Bits,geBoolean doYUV) { int nLeaves; int w,h,xtra,bpp,x,y; gePixelFormat Format; const gePixelFormat_Operations * ops; int R,G,B,A; gePixelFormat_Decomposer Decompose; assert(Bits); nLeaves = 0; Format = Info->Format; w = Info->Width; h = Info->Height; xtra = Info->Stride - Info->Width; bpp = gePixelFormat_BytesPerPel(Format); ops = gePixelFormat_GetOperations(Format); assert(ops); Decompose = ops->DecomposePixel; assert(Decompose); // pushTSC(); if ( doYUV ) { switch(bpp) { default: case 0: return GE_FALSE; case 1: { const uint8 *ptr; ptr = Bits; for(y=h;y--;) { for(x=w;x--;) { Decompose(*ptr++,&R,&G,&B,&A); RGBi_to_YUVi(R,G,B,&R,&G,&B); addOctNode(root,R,G,B,&nLeaves); } ptr += xtra; } break; } case 2: { const uint16 *ptr; uint32 R,G,B,A; ptr = Bits; for(y=h;y--;) { for(x=w;x--;) { Decompose(*ptr++,&R,&G,&B,&A); RGBi_to_YUVi(R,G,B,&R,&G,&B); addOctNode(root,R,G,B,&nLeaves); } ptr += xtra; } break; } case 3: { const uint8 *ptr; uint32 R,G,B,A,Pixel; ptr = Bits; xtra *= 3; switch(Format) { case GE_PIXELFORMAT_24BIT_RGB : for(y=h;y--;) { for(x=w;x--;) { RGBb_to_YUVi(ptr,&R,&G,&B); ptr += 3; addOctNode(root,R,G,B,&nLeaves); } ptr += xtra; } break; case GE_PIXELFORMAT_24BIT_BGR : for(y=h;y--;) { for(x=w;x--;) { B = *ptr++; G = *ptr++; R = *ptr++; RGBi_to_YUVi(R,G,B,&R,&G,&B); addOctNode(root,R,G,B,&nLeaves); } ptr += xtra; } break; default: // can't get here now for(y=h;y--;) { for(x=w;x--;) { Pixel = (ptr[0]<<16) + (ptr[1]<<8) + ptr[2]; ptr += 3; Decompose(Pixel,&R,&G,&B,&A); RGBi_to_YUVi(R,G,B,&R,&G,&B); addOctNode(root,R,G,B,&nLeaves); } ptr += xtra; } break; } break; // Thanks Bobtree } case 4: { const uint32 *ptr; uint32 R,G,B,A; ptr = Bits; for(y=h;y--;) { for(x=w;x--;) { Decompose(*ptr++,&R,&G,&B,&A); RGBi_to_YUVi(R,G,B,&R,&G,&B); addOctNode(root,R,G,B,&nLeaves); } ptr += xtra; } break; } } } else { switch(bpp) { default: case 0: return GE_FALSE; case 1: { const uint8 *ptr; ptr = Bits; for(y=h;y--;) { for(x=w;x--;) { Decompose(*ptr++,&R,&G,&B,&A); addOctNode(root,R,G,B,&nLeaves); } ptr += xtra; } break; } case 2: { const uint16 *ptr; uint32 R,G,B,A; ptr = Bits; for(y=h;y--;) { for(x=w;x--;) { Decompose(*ptr++,&R,&G,&B,&A); addOctNode(root,R,G,B,&nLeaves); } ptr += xtra; } break; } case 3: { const uint8 *ptr; uint32 R,G,B,A,Pixel; ptr = Bits; xtra *= 3; switch(Format) { case GE_PIXELFORMAT_24BIT_RGB : for(y=h;y--;) { for(x=w;x--;) { R = *ptr++; G = *ptr++; B = *ptr++; addOctNode(root,R,G,B,&nLeaves); } ptr += xtra; } break; case GE_PIXELFORMAT_24BIT_BGR : for(y=h;y--;) { for(x=w;x--;) { B = *ptr++; G = *ptr++; R = *ptr++; addOctNode(root,R,G,B,&nLeaves); } ptr += xtra; } break; default: // can't get here now for(y=h;y--;) { for(x=w;x--;) { Pixel = (ptr[0]<<16) + (ptr[1]<<8) + ptr[2]; ptr += 3; Decompose(Pixel,&R,&G,&B,&A); addOctNode(root,R,G,B,&nLeaves); } ptr += xtra; } break; } break; // Thanks Bobtree } case 4: { const uint32 *ptr; uint32 R,G,B,A; ptr = Bits; for(y=h;y--;) { for(x=w;x--;) { Decompose(*ptr++,&R,&G,&B,&A); addOctNode(root,R,G,B,&nLeaves); } ptr += xtra; } break; } } } // showPopTSC("create Pal OctTree"); return nLeaves; }
int dCollideBR(dxGeom* RayGeom, dxGeom* BoxGeom, int Flags, dContactGeom* Contacts, int Stride){ const dVector3& Position = *(const dVector3*)dGeomGetPosition(BoxGeom); const dMatrix3& Rotation = *(const dMatrix3*)dGeomGetRotation(BoxGeom); dVector3 Extents; dGeomBoxGetLengths(BoxGeom, Extents); Extents[0] /= 2; Extents[1] /= 2; Extents[2] /= 2; Extents[3] /= 2; dVector3 Origin, Direction; dGeomRayGet(RayGeom, Origin, Direction); dReal Length = dGeomRayGetLength(RayGeom); dVector3 Diff; Diff[0] = Origin[0] - Position[0]; Diff[1] = Origin[1] - Position[1]; Diff[2] = Origin[2] - Position[2]; Diff[3] = Origin[3] - Position[3]; Direction[0] *= Length; Direction[1] *= Length; Direction[2] *= Length; Direction[3] *= Length; dVector3 Rot[3]; Decompose(Rotation, Rot); dVector3 TransOrigin; TransOrigin[0] = dDOT(Diff, Rot[0]); TransOrigin[1] = dDOT(Diff, Rot[1]); TransOrigin[2] = dDOT(Diff, Rot[2]); TransOrigin[3] = REAL(0.0); dVector3 TransDirection; TransDirection[0] = dDOT(Direction, Rot[0]); TransDirection[1] = dDOT(Direction, Rot[1]); TransDirection[2] = dDOT(Direction, Rot[2]); TransDirection[3] = REAL(0.0); dReal T[2]; T[0] = 0.0f; T[1] = dInfinity; bool Intersect = FindIntersection(TransOrigin, TransDirection, Extents, T[0], T[1]); if (Intersect){ if (T[0] > REAL(0.0)){ dContactGeom* Contact0 = CONTACT(Flags, Contacts, 0, Stride); Contact0->pos[0] = Origin[0] + T[0] * Direction[0]; Contact0->pos[1] = Origin[1] + T[0] * Direction[1]; Contact0->pos[2] = Origin[2] + T[0] * Direction[2]; Contact0->pos[3] = Origin[3] + T[0] * Direction[3]; //Contact0->normal = 0; Contact0->depth = 0.0f; Contact0->g1 = RayGeom; Contact0->g2 = BoxGeom; dContactGeom* Contact1 = CONTACT(Flags, Contacts, 1, Stride); Contact1->pos[0] = Origin[0] + T[1] * Direction[0]; Contact1->pos[1] = Origin[1] + T[1] * Direction[1]; Contact1->pos[2] = Origin[2] + T[1] * Direction[2]; Contact1->pos[3] = Origin[3] + T[1] * Direction[3]; //Contact1->normal = 0; Contact1->depth = 0.0f; Contact1->g1 = RayGeom; Contact1->g2 = BoxGeom; return 2; } else{ dContactGeom* Contact = CONTACT(Flags, Contacts, 0, Stride); Contact->pos[0] = Origin[0] + T[1] * Direction[0]; Contact->pos[1] = Origin[1] + T[1] * Direction[1]; Contact->pos[2] = Origin[2] + T[1] * Direction[2]; Contact->pos[3] = Origin[3] + T[1] * Direction[3]; //Contact->normal = 0; Contact->depth = 0.0f; Contact->g1 = RayGeom; Contact->g2 = BoxGeom; return 1; } } else return 0; }