示例#1
0
void ApplinkExporter::ExportChannel(BaseDocument* document, BaseFile* file, BaseMaterial& material, LONG shaderId, LONG colorId, const String s)
{
	String str = s + " ";

	// get texture strength and base colour
	Vector color = getParameterVector(material, colorId);

	str += RealToString(color.x, NULL, 6) + " " + RealToString(color.y, NULL, 6) + " " + RealToString(color.z, NULL, 6) + "\n";
	this->WriteString(str, file);

	// fetch bitmap shader, if available
	BaseList2D* bitmapLink = ApplinkExporter::getParameterLink(material, shaderId, Xbitmap);

	if(bitmapLink)
	{
		// if we are here, we've got a bitmap shader -> let's create an imagemap texture
		Filename bitmapPath = ApplinkExporter::getParameterFilename(*bitmapLink, BITMAPSHADER_FILENAME);
		Filename fullBitmapPath;
		GenerateTexturePath(document->GetDocumentPath(), bitmapPath, Filename(), &fullBitmapPath);

		str = "map_" + s + " ";
		str += fullBitmapPath.GetString() + "\n";
		this->WriteString(str, file);
	}
}
示例#2
0
void ApplinkExporter::WriteUVWTag(BaseFile* objfile, ExportObject& mObject, LONG pcnt, const CPolygon* padr)
{	
	//GePrint("Length UV: " + RealToString(pUV->GetLength()));
/*	for(t = 0; t < pcnt*4; t++)
	{
		GePrint(LongToString(t) + ": " + RealToString(pUV[t].x) + ", " + RealToString(pUV[t].y) );
	}*/

	String str = "# begin " + LongToString(mObject.Vt.GetCount()) + " texture vertices\n";
	this->WriteString(str, objfile);

	for(LONG t = 0, y=0; t < pcnt; t++)
	{							
		str = "vt " + RealToString(mObject.Vt[y].x, NULL, 6) + " " + RealToString( 1 - mObject.Vt[y].y, NULL, 6) + " " + RealToString(mObject.Vt[y].z, NULL, 6) + "\n";
		this->WriteString(str, objfile);
		str = "vt " + RealToString(mObject.Vt[y+1].x, NULL, 6) + " " + RealToString(1 - mObject.Vt[y+1].y, NULL, 6) + " " + RealToString(mObject.Vt[y+1].z, NULL, 6) + "\n";
		this->WriteString(str, objfile);
		str = "vt " + RealToString(mObject.Vt[y+2].x, NULL, 6) + " " + RealToString(1 - mObject.Vt[y+2].y, NULL, 6) + " " + RealToString(mObject.Vt[y+2].z, NULL, 6) + "\n";
		this->WriteString(str, objfile);
		if(mObject.Fpvnb[t] == 4)
		{
			str = "vt " + RealToString(mObject.Vt[y+3].x, NULL, 6) + " " + RealToString(1 - mObject.Vt[y+3].y, NULL, 6) + " " + RealToString(mObject.Vt[y+3].z, NULL, 6) + "\n";
			this->WriteString(str, objfile);
		}
		y += mObject.Fpvnb[t];
	}

	str = "# end " + LongToString(mObject.Vt.GetCount()) + " texture vertices\n";
	this->WriteString(str, objfile);
	this->WriteEndLine(objfile);
}
示例#3
0
void ApplinkExporter::WriteVertexPositions(BaseFile* objfile, ExportObject& mObject, LONG vcnt)
{
	String str = "# begin " + LongToString(vcnt) + " vertices\n";
	this->WriteString(str, objfile);	

	//GePrint("Fv count: " + LongToString(Fv.GetCount()));
	//for (p = 0; p < Fv.GetCount(); p++)
	//{
	//	GePrint(LongToString(Fv[p]));
	//}

	for (LONG p = 0; p < mObject.Vp.GetCount(); p++)
	{
		str = "v " + RealToString(mObject.Vp[p].x, NULL, 6) + " " + RealToString(mObject.Vp[p].y, NULL, 6) + " " + RealToString(mObject.Vp[p].z, NULL, 6) + "\n";
		this->WriteString(str, objfile);
	}

	str = "# end " + LongToString(vcnt) + " vertices\n";
	this->WriteString(str, objfile);	
	this->WriteEndLine(objfile);
}
示例#4
0
SplineObject* Voxelify::ComputeSpline(BaseThread* bt, vector<VGrid> grids, LONG longestPercent, GeDynamicArray<GeDynamicArray<Vector> > &splinesAtPoint){
    SplineObject* parentSpline = SplineObject::Alloc(0, SPLINETYPE_BSPLINE);
    
    std::vector<SplinePair >splinePairs;
    
    Real avSplineSize = 0.0, avSplineLength = 0.0;
    GeDynamicArray<GeDynamicArray<LONG> > validPoints(grids.size());
    for (LONG k=0; k < grids.size(); k++){
        validPoints[k] = GeDynamicArray<LONG>(grids[0].points.size());
        validPoints[k].Fill(0,grids[0].points.size(),1);
    }
    
    GeDynamicArray<LONG> indxs;

    for (LONG i = 0; i < grids[0].points.size(); i++) {
        if (grids[0].indices[i] == -1) continue;
        GeDynamicArray<Vector> rawSpline;
        Vector point(grids[0].points[i][0], grids[0].points[i][1], grids[0].points[i][2]);
        indxs.Push(i);
        rawSpline.Push(point);
        splinesAtPoint.Push(rawSpline);
    }

    Real distMin = std::numeric_limits<float>::max();
    Real distMax = 0.;
    AutoAlloc<SplineHelp> splineHelp;
    LONG i, o;
    for (i = 0; i < splinesAtPoint.GetCount(); i++){//iterate points
        bool lastPointCaptured = true;
        LONG indx = indxs[i];
        for (o=0; o < grids.size()-1; o++){ // for each point iterate objects and collect nearest points
            LONG closestIndx = grids[o+1].indices[indx];
            if ( closestIndx == -1){
                GePrint("error finding neighbor "+LongToString(o)+"/"+LongToString(i));
                if (o == grids.size()-1){
                    lastPointCaptured = false;
                }
                continue;
            }
            vector<float> point = grids[o].points[indx];
            vector<float> point1 = grids[o+1].points[indx];
            Real dist = hypot(point[0] - point1[0], hypot(point[1] - point1[1], point[2] - point1[2]));
            distMin = distMin < dist ? distMin : dist;
            distMax = distMax > dist ? distMax : dist;
            
            if (o != grids.size()-1) {
                //if (dist > maxSeg || dist < minSeg) {
                //    continue;
                //}
            }
            validPoints[o][i] = 0;

            Vector clsst(point1[0],point1[1],point1[2]);
            
            if (splinesAtPoint[i].Find(clsst) == NOTOK){
                splinesAtPoint[i].Push(clsst);
            }
        }
        
        if (!lastPointCaptured) continue;
        SplineObject* spline=SplineObject::Alloc(splinesAtPoint[i].GetCount(),SPLINETYPE_BSPLINE);
        if (!spline) continue;
        
        spline->GetDataInstance()->SetBool(SPLINEOBJECT_CLOSED, FALSE);
        
        Vector *padr = spline->GetPointW();
        for (LONG l = 0; l < splinesAtPoint[i].GetCount(); l++){
            padr[l] = splinesAtPoint[i][l];
        }
        
        splineHelp->InitSpline(spline);
        Real splnLength = splineHelp->GetSplineLength();
        if (splnLength > 0.0){
            splinePairs.push_back(SplinePair(spline, splnLength));
            avSplineLength += splnLength;
            avSplineSize += splinesAtPoint[i].GetCount();
        } else {
            SplineObject::Free(spline);
        }
        
        if (i % 5 == 0){
            LONG progress = 10 + (90*i)/splinesAtPoint.GetCount();
            StatusSetBar(progress);
            StatusSetText(LongToString(progress)+"%");
            if (bt && bt->TestBreak()){
                //break; //this break seems to be kicking in randomly killing the loop
            }
        }
    }
    
    LONG splnSize = splinePairs.size();
    GePrint(LongToString(i)+" points "+LongToString(splnSize)+" splines");
    if (splnSize > 0) {
        LONG limit =  splnSize * longestPercent / 100;
        limit = limit == 0 ? 1 : limit;
        
        std::sort(splinePairs.begin(), splinePairs.end(),comparator);
        
        for (int s = 0; s < limit; s++){
            avSplineLength += splinePairs[s].second;
            splinePairs[s].first->InsertUnder(parentSpline);
        }
        
        String sizeAvg = splinesAtPoint.GetCount() == 0? "Nan":RealToString(avSplineSize/splinesAtPoint.GetCount());
        
        GePrint("d="+RealToString(distMin)+" : "+RealToString(distMax)+" avSpln="+RealToString(avSplineLength/avSplineSize));
    }
	StatusSetText(LongToString(i)+" points "+LongToString(splnSize)+" splines");
    
    if (splnSize == 0) return NULL;
    return parentSpline;
}