Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (808)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (872)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Create a simple box with a texture !!!  (Read 2878 times)
0 Members and 1 Guest are viewing this topic.
Offline davidave

Senior Newbie





« Posted 2014-11-21 16:05:44 »

Hey guys !

I really dont know whats wrong with ME or with my code ...but i cant manage it to add a simple box with a texture  -.-

what is wrong here ? i mean..im new to java3d did i forget to add something or whats wrong? i think the important part begins in line 85


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
public class World  implements KeyListener   {
   
        JFrame frame = new JFrame();
   TransparencyAttributes objTransp;
   
   
   GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
   Canvas3D c = new Canvas3D(config);
   SimpleUniverse u = new SimpleUniverse(c);
   
   ObjectFile f = new ObjectFile(ObjectFile.RESIZE);
   Scene s = null;
   TransformGroup ViewTG = u.getViewingPlatform().getViewPlatformTransform();
   
   
   Transform3D ViewT3D = new Transform3D();
   
     

   
   public World(){
       
       
         PhysicalEnvironment environment = u.getViewer().getPhysicalEnvironment();
         AudioDevice device = new JavaSoundMixer(environment);
         device.initialize();
         environment.setAudioDevice(device);
       
        frame.add("Center",c);
        frame.addKeyListener(this);
   frame.setFocusable(true);
     
      OrbitBehavior ob = new OrbitBehavior(c);
   
      u.addBranchGraph(createSceneGraph());
      u.addBranchGraph(addObjects());
      u.getViewer().getView().setFrontClipDistance(0.001);
      Light(u);
     
   
      try
          {
            s = f.load("Geist3.obj");
          }
          catch (Exception e)
          {
            System.out.println("File loading failed:" + e);
          }
     
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setSize(1600, 850);
      frame.setVisible(true);
     
      ob.setSchedulingBounds(new BoundingSphere(new Point3d(0.0,0.0,0.0),Double.MAX_VALUE));
      u.getViewingPlatform().setViewPlatformBehavior(ob);
   }
   
   
   public BranchGroup createSceneGraph(){
     
     
       
           BranchGroup RootBg = new BranchGroup();
      TransformGroup CastleTG = new TransformGroup();
      Transform3D CastleT3DX = new Transform3D();
      Transform3D CastleT3DY = new Transform3D();
     
     
      CastleT3DX.rotX((float)Math.toRadians(-90));
      CastleT3DY.rotZ((float)Math.toRadians(90));
      CastleT3DX.mul(CastleT3DY);
      CastleT3DX.setTranslation(new Vector3f(0.0f,0.0f,-6.0f));
     
      CastleTG.setTransform(CastleT3DX);
     
     
      try
       {
         s = f.load("Geist3.obj");
       }
       catch (Exception e)
       {
         System.out.println("File loading failed:" + e);
       }
   // Here comes the important code fragment i think
     
               
            TransformGroup tgground = new TransformGroup();
      Appearance abc = new Appearance();
      Texture txGround = new TextureLoader("gelb.jpg",frame).getTexture();  // maybe "frame" is wr0ng??
      abc.setTexture(txGround);
     
                Box w = new Box(10000,10000,10000,Box.GENERATE_NORMALS,abc);
      w.setAppearance(abc);
      tgground.addChild(w);
                RootBg.addChild(tgground);                 // here it ends

     

                 BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),Double.MAX_VALUE);
     
      TextureLoader textureLoad = new TextureLoader("full.png",null);
     
      Background bgImage = new Background(textureLoad.getImage());
         
      bgImage.setApplicationBounds(bounds);
      RootBg.addChild(bgImage);
      RootBg.addChild(m.playMusic());
     
      CastleTG.addChild(s.getSceneGroup());
       RootBg.addChild(CastleTG);
       RootBg.compile();
       
     
       
       return RootBg;
   }}
   


So whats wrong here ? is something missing ? did i add something wrong ? i dont get any errors !

please  help me =(

thanks !!!
Offline DonDon

Senior Newbie


Exp: 10-12 months



« Reply #1 - Posted 2014-11-21 16:31:28 »

my bad, post removed
Offline davidave

Senior Newbie





« Reply #2 - Posted 2014-11-21 17:46:52 »

thank you very much but im not allowed to use other libraries Sad so has no one a solution for my little problem?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Stranger
« Reply #3 - Posted 2014-11-21 19:30:29 »

Try to add flag Box.GENERATE_TEXTURE_COORDS to Bpx ctor call.

Anton
Offline Gibbo3771

JGO Kernel


Medals: 128
Projects: 5
Exp: 1 year


Currently inactive on forums :(


« Reply #4 - Posted 2014-11-21 21:12:28 »

When in doubt read a book, seriously don't watch videos. They teach you what only what you see, not what you can do.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Offline gouessej
« Reply #5 - Posted 2014-11-22 11:31:55 »

Hi

If you really want to obtain some help about Java3D, ensure that you use the very latest version (currently 1.6.0 pre 11) and post your question on its official forum. Stranger is problably right; if you don't set any texture coordinates, you have to ask Java 3D to generate them. You can't display a texture without texture coordinates.

DonDon's answer is offtopic as the original poster is asking for help, not to switch to another library.

Julien Gouesse | Personal blog | Website | Jogamp
Offline DonDon

Senior Newbie


Exp: 10-12 months



« Reply #6 - Posted 2014-11-23 17:24:02 »

Hi

If you really want to obtain some help about Java3D, ensure that you use the very latest version (currently 1.6.0 pre 11) and post your question on its official forum. Stranger is problably right; if you don't set any texture coordinates, you have to ask Java 3D to generate them. You can't display a texture without texture coordinates.

DonDon's answer is offtopic as the original poster is asking for help, not to switch to another library.

Sorry my post wasn't helpful, I'm just a newbie too  Lips Sealed  I've deleted the post
Pages: [1]
  ignore  |  Print  
 
 

 
mercenarius (14 views)
2020-06-04 19:26:01

mercenarius (24 views)
2020-06-04 19:13:43

Riven (866 views)
2019-09-04 15:33:17

hadezbladez (5848 views)
2018-11-16 13:46:03

hadezbladez (2657 views)
2018-11-16 13:41:33

hadezbladez (6273 views)
2018-11-16 13:35:35

hadezbladez (1518 views)
2018-11-16 13:32:03

EgonOlsen (4749 views)
2018-06-10 19:43:48

EgonOlsen (5804 views)
2018-06-10 19:43:44

EgonOlsen (3298 views)
2018-06-10 19:43:20
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!