سؤال

وأنا أحاول رسم طائرة شفافة (X [0..100]، Y [0..100]، Z = 0) في جافا 3D، ولكن لا يمكن معرفة كيف. لقد ألقيت نظرة على الصفحة التعليمي، ولا تزال لا يمكن العثور على أي برامج العينة.

وأنا محاولة للعثور على "طائرة" الكائن باعتباره BranchGroup إضافة إلى بلدي TransformGroup القائمة، ولكن ليس هناك مثل هذا الكائن الطائرة. ما يجب أن استخدمها؟ وكيف يمكنني جعلها شفافة؟

هل كانت مفيدة؟

المحلول

وهذا هو مقتطف من شفرة اعتدت على الرسم البياني - وهذا قد عمل على متن طائرة مسطحة

.
private static void createAppearances() {
    normalAppearance = new Appearance();
    normalAppearance.setMaterial(normalMaterial);
    selectedAppearance = new Appearance();
    selectedAppearance.setMaterial(selectedMaterial);
    TransparencyAttributes ta = new TransparencyAttributes();

    ta.setTransparencyMode (TransparencyAttributes.BLENDED);
    ta.setTransparency (DEFAULT_HISTOGRAM_ALPHA);

    normalAppearance.setTransparencyAttributes (ta);
    selectedAppearance.setTransparencyAttributes(ta);
}

والمفتاح هو TransparencyAttributes إذا كنت أتذكر بشكل صحيح. أتمنى أن أقول لك أكثر ولكن لا أستطيع الحصول على هذا تجميع الآن (في عداد المفقودين بعض المكتبات القديمة التي لا تتعلق 3D).

نصائح أخرى

وحاول هذا الرمز ...

BranchGroup group = new BranchGroup();  //Content branch.
PolygonAttributes p = new PolygonAttributes();  //Not sure how to make it transparent/try code above.
Appearance planeAppearance = new Appearance();
planeAppearance.setPolygonAttributes (p);
Color3f planeColor = new Color3f (1.0f, 1.0f, 1.0f);  //This makes it white.
ColoringAttributes planeCA = new ColoringAttributes (planeColor, 1);
planeAppearance.setColoringAttributes(planeCA);
QuadArray plane = new QuadArray (4, QuadArray.COORDINATES);  //This makes the plane.
  plane.setCoordinate(0, new Point3f(-5f, -5f, -15f));  //You specify your own cornerpoints...
  plane.setCoordinate(1, new Point3f(5f, -5f, -15f));
  plane.setCoordinate(2, new Point3f(5f, 5f, -15f));
  plane.setCoordinate(3, new Point3f(-5f, 5f, -15f));
group.addChild(new Shape3D(plane, planeAppearance));  //Add plane to content branch.
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top