Cilindro en Java 3D
Necesito crear un cilindor en Java 3D, aunque ya existe la clase Cylinder no he encontrado la forma de que se extienda por todo el eje X y no sobre el eje Y,,, alguien tiene algun ejemplo??? sabe de algun codigo que necesite????' se agradece mucho la ayuda,,,,,
Bueno,, ,ya le encontre la solucion,, aki esta el codigo:
private Group createCyl(double escala, Vector3d pos)
{
//private Transform3D t3d = new Transform3D();
Transform3D t3Rot = new Transform3D();
TransformGroup rotTG = new TransformGroup(t3d);
t3d.set(escala,pos);
float fRadio = 0.03f;
float fLongitud = 2.1f;
rotTG.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
rotTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
Appearance ap = new Appearance();
Color3f color = new Color3f(0.8f,0.2f,1.0f);
Color3f cNegro = new Color3f(0.0f,0.0f,0.0f);
ap.setMaterial(new Material(color,cNegro,color,cNegro,80.0f));
Cylinder shape = new Cylinder(fRadio,fLongitud,
Primitive.GENERATE_NORMALS |
Primitive.GENERATE_TEXTURE_COORDS,ap);
rotTG.addChild(shape);
Appearance app = shape.getAppearance();
ColoringAttributes ca = new ColoringAttributes();
ca.setColor(0.6f,0.3f,0.0f);
app.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE);
app.setColoringAttributes(ca);
//Rotar el cilindro de Vertical a Horizontal
t3Rot.rotZ(Math.toRadians(90));
//Hubicar en x,y,z en el plano el cilindro
t3Rot.setTranslation(pos);
rotTG.setTransform(t3Rot);
return rotTG;
}
ademas de star rotado esta trasladado del origen a un aposicion diferente,,,,,
gracias a todos los interesados!!!!!
private Group createCyl(double escala, Vector3d pos)
{
//private Transform3D t3d = new Transform3D();
Transform3D t3Rot = new Transform3D();
TransformGroup rotTG = new TransformGroup(t3d);
t3d.set(escala,pos);
float fRadio = 0.03f;
float fLongitud = 2.1f;
rotTG.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
rotTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
Appearance ap = new Appearance();
Color3f color = new Color3f(0.8f,0.2f,1.0f);
Color3f cNegro = new Color3f(0.0f,0.0f,0.0f);
ap.setMaterial(new Material(color,cNegro,color,cNegro,80.0f));
Cylinder shape = new Cylinder(fRadio,fLongitud,
Primitive.GENERATE_NORMALS |
Primitive.GENERATE_TEXTURE_COORDS,ap);
rotTG.addChild(shape);
Appearance app = shape.getAppearance();
ColoringAttributes ca = new ColoringAttributes();
ca.setColor(0.6f,0.3f,0.0f);
app.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE);
app.setColoringAttributes(ca);
//Rotar el cilindro de Vertical a Horizontal
t3Rot.rotZ(Math.toRadians(90));
//Hubicar en x,y,z en el plano el cilindro
t3Rot.setTranslation(pos);
rotTG.setTransform(t3Rot);
return rotTG;
}
ademas de star rotado esta trasladado del origen a un aposicion diferente,,,,,
gracias a todos los interesados!!!!!
