簡體   English   中英

Java 3D 應用程序與已加載的 Maya 場景產生空白黑屏

[英]Java 3D Application With a Loaded Maya Scene Produces an Empty Black Screen

我使用 Maya 2011 制作了 3D model,並且我使用加載器訪問了 Java6246AA96BFABEZZ76AA96BFABE80Java626AA96369ADABBE8Z76AA96369ADABBA8E 應用程序。 我已將文件導出為 OBJ 文件,並在我的 class 中使用了 OBJ 文件加載器。 但是,當我運行該應用程序時,我得到的只是一個空白的黑屏。

這是我的代碼:

import com.sun.j3d.loaders.objectfile.ObjectFile;
com.sun.j3d.loaders.ParsingErrorException;
import com.sun.j3d.loaders.IncorrectFormatException;
import com.sun.j3d.loaders.Scene;
import java.applet.Applet;
import java.awt.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.ColorCube;
import javax.media.j3d.*;
import javax.vecmath.*;
import java.io.*;

public class ObjLoad extends Applet {

    public ObjLoad() {

        setLayout(new BorderLayout());
        GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
        Canvas3D canvas3D = new Canvas3D(config);
        add("Center", canvas3D);

        BranchGroup scene = createSceneGraph();
        scene.compile();    

        // SimpleUniverse is a Convenience Utility class
        SimpleUniverse simpleU = new SimpleUniverse(canvas3D);

        // This moves the ViewPlatform back a bit so the
        // objects in the scene can be viewed.
        simpleU.getViewingPlatform().setNominalViewingTransform();
        simpleU.addBranchGraph(scene);
    } // end of ObjLoad (constructor)

    public BranchGroup createSceneGraph() {

        // Create the root of the branch graph
        BranchGroup objRoot = new BranchGroup();

        String filename = "C:/Users/myName/Documents/maya/projects/GettingStarted/scenes/temple.obj";

        ObjectFile f = new ObjectFile();
        Scene s = null;
        try {
            s = f.load(filename);
        }
        catch (FileNotFoundException e) {
            System.err.println(e);
            System.exit(1);
        }
        catch (ParsingErrorException e) {
                System.err.println(e);
            System.exit(1);
        }
        catch (IncorrectFormatException e) {
            System.err.println(e);
            System.exit(1);
        }

        objRoot.addChild(s.getSceneGroup());
        return objRoot;
    } // end of createSceneGraph method

    // The following allows this to be run as an application
    // as well as an applet

    public static void main(String[] args) {

        Frame frame = new MainFrame(new ObjLoad(), 500, 500);
    } // end of main (method of ObjLoad)
} // end of class ObjLoad

我將不勝感激任何幫助。

您的場景是否包含任何照明? 嘗試將環境光設置為中等灰色。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM