I can in 2d, but in 3d not working (after setting ECS by 3dface)...
Any idea?
Thanks.
Pepa
Solved! Go to Solution.
Solved by PEPANOVAK. Go to Solution.
Solved by owenwengerd. Go to Solution.
As a suggestion: another approach is to implement a custom entity and use the mesh function in your world or viewport draw where you can manage faces and edges
pMode->geometry().mesh(...)
Certainly more efficient than a lot of AcDbHatch.
Regards,
I have a TIN created just as custom entity ( pW->geometry().shell(numVerts, pVerts, faceListSize, pFaceList); ), but there (AcGiFaceData) can not be used gradient color?
No, I guess it's not possible, but you can define materials on each face. If you want a gradient color on all your "solid", I guess you need to change the color on each face depending on its "level".
Regards,
Here is the code for 3D gradient hatches. This works...
...
// elev is difference min Z and max Z TIN
double base = 1.0 / elev;
for (Adesk::UInt32 i=0; i < numFaces; i++) {
trig=sezT[i];
A=trig.pointA;
B=trig.pointB;
C=trig.pointC;
AcGePlane planeTarget(A, B, C);
AcGeVector3d vecNormal = planeTarget.normal();
// return Point with min/max Z coords
minB=minDoublePoint(A,B,C);
maxB=maxDoublePoint(A,B,C);
uhel=atan2(vecNormal.y,vecNormal.x);
if (fabs(minB.z-maxB.z) < EPSILON) {
uhel=0.0001;
}
geoCOLOR iC1,iC2;
float value1, value2;
// minZ and maxZ are min/max Z coords TIN
value1 = 1 - (base * (maxZ - minB.z));
value2 = 1 - (base * (maxZ - maxB.z));
// interpolating 2 color
iC1=interpolate(c1, c2, value1);
iC2=interpolate(c1, c2, value2);
// wrong, only positives value
//double dElevation = AcGePoint3d::kOrigin.distanceTo(AcGePoint3d::kOrigin.orthoProject(planeTarget));
double vzd;
// my function for distance
distancePointPlane(A,B,C,AcGePoint3d::kOrigin,vzd);
AcDbHatch* pHatch = new AcDbHatch();
pHatch->setDatabaseDefaults();
Acad::ErrorStatus es = pHatch->setElevation(vzd); assert(es==Acad::eOk);
es = pHatch->setNormal(vecNormal); assert(es==Acad::eOk);
AcGePoint2dArray rpt2Loop;
AcGeMatrix3d mxECS;
pHatch->getEcs(mxECS);
mxECS.invert();
AcGePoint2d pt2A = A.transformBy(mxECS).convert2d(AcGePlane::kXYPlane);
AcGePoint2d pt2B = B.transformBy(mxECS).convert2d(AcGePlane::kXYPlane);
AcGePoint2d pt2C = C.transformBy(mxECS).convert2d(AcGePlane::kXYPlane);
rpt2Loop.append(pt2A);
rpt2Loop.append(pt2B);
rpt2Loop.append(pt2C);
rpt2Loop.append(pt2A);
es = pHatch->appendLoop(AcDbHatch::kExternal, rpt2Loop, AcGeDoubleArray() ); assert(es==Acad::eOk);
pHatch->setLayer(hladinaPom);
AcCmColor colors[2];
colors[0].setRGB(iC1.red,iC1.green,iC1.blue);
colors[1].setRGB(iC2.red,iC2.green,iC2.blue);
float ff[2] = {0.0, 1.0};
pHatch->setHatchObjectType(AcDbHatch::kGradientObject);
pHatch->setGradient(AcDbHatch::kPreDefinedGradient,_T("LINEAR"));
pHatch->setGradientColors(2,colors,ff);
pHatch->setGradientOneColorMode(Adesk::kFalse);
// calculation angle
double rotAngle = uhel + (PI/2.0-vecNormal.angleOnPlane(AcGePlane::kXYPlane));
pHatch->setGradientAngle((rotAngle));
es = pHatch->evaluateHatch(); assert(es==Acad::eOk);
addToModelSpace(eId,pHatch);
}
...
Pepa