Author Topic: Polylines  (Read 2268 times)

Offline AceGIS

  • byte
  • *
  • Posts: 32
    • View Profile
Polylines
« on: October 23, 2012, 12:29:07 am »
Hi All,

I'm thinking I may be able to derive polylines from my models? In the snippet below I am assigning multi textures via the polygon manager. Do you think it may be possible to use modulus to create the polylines at equal intervals? Something like : if (vertextHeight.z % 10 = 0), polylineVertexs.append(vertexHeight.x, vertextHeight.y, vertexHeight.z), new Polyline(polylineVertexs) ??

Code: [Select]
for (Object3D obj : models) {
PolygonManager objPolyManager = obj.getPolygonManager();

// for each polygon set texture according to normalised vertex elevations
for (int i = 0; i < objPolyManager.getMaxPolygonID(); i++) {
float u0 = 0, u1 = 0, u2 = 0;

for (int j = 0; j < 3; j++) {
SimpleVector vertexHeight = objPolyManager.getTransformedVertex(i, j);
float normalisedHeight = (vertexHeight.z - MIN_Z)/(MAX_Z - MIN_Z);

if (j == 0) {
u0 = normalisedHeight;
}
else if (j == 1) {
u1 = normalisedHeight;
}
else if (j == 2) {
u2 = normalisedHeight;
}
}

TextureInfo ti = new TextureInfo(tm.getTextureID("esri_color_scale"), u0, u0, u1, u1, u2, u2);
objPolyManager.setPolygonTexture(i, ti);
}
world.addObject(obj);
}

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Polylines
« Reply #1 on: October 23, 2012, 07:17:16 am »
I don't think that this will work very well. Apart from the fact that (vertexHeight.z % 10 = 0) almost never triggers because vertexHeight.z is a float, this will create some garbled line soup IMHO. You might want to skip that %10 condition and simply use every vertex to recreate the triangles as polylines...if that's worth it...

Offline AceGIS

  • byte
  • *
  • Posts: 32
    • View Profile
Re: Polylines
« Reply #2 on: October 28, 2012, 09:59:44 pm »
Hi Egon,

No. I'm not trying to create the polygons triangle boundary polylines but rather contour lines. What if I use the transformed vertex height before normalising? Convert the value to an int, then mod 10 = 0?

OR is it possible to have a texture with transparent pixels? Then I could use the transparent pixel for no display and the color pixel for the contour line?

OR any other suggestions?