Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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  
  Why when i move the object it disappears after some distance?[SOLVED]  (Read 1416 times)
0 Members and 1 Guest are viewing this topic.
Offline hhfjkehfe

Senior Newbie





« Posted 2012-07-14 14:18:46 »

Why when i move the object it disappears after some distance?
Offline Sickan

Senior Duke


Medals: 9



« Reply #1 - Posted 2012-07-14 14:20:16 »

Why when i move the object it disappears after some distance?
This is a typical example of a poor question. You provide no code examples, so we have nothing to work from at all. Your question could really be anything. Try posting some code, and if it's not a logic error from your part then touch up your knowledge of the language.
Offline _Al3x

Senior Duke


Medals: 7


Indie Games FTW!


« Reply #2 - Posted 2012-07-14 14:24:04 »

This is not a poor question. Obviously he has a blind spot in his eye, go to the doctor ASAP.

Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Sickan

Senior Duke


Medals: 9



« Reply #3 - Posted 2012-07-14 14:26:21 »

This is not a poor question. Obviously he has a blind spot in his eye, go to the doctor ASAP.

Smiley
No, I'm pretty sure that then his a part of his screen would disappear, too.

I could try a few guesses as to why, but I'd be throwing chips in the water, hoping a fish would pop up so I could hug it to death with my bear arms.
Offline hhfjkehfe

Senior Newbie





« Reply #4 - Posted 2012-07-14 14:34:10 »

Ok here is the code:
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  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212  
213  
214  
215  
216  
217  
218  
219  
220  
221  
222  
223  
224  
225  
226  
227  
228  
229  
230  
231  
232  
233  
package com.daltonfilho.tutorials.java3d;
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.GraphicsConfiguration;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.FileNotFoundException;
import java.util.Enumeration;

import javax.media.j3d.AmbientLight;
import javax.media.j3d.Appearance;
import javax.media.j3d.Background;
import javax.media.j3d.Behavior;
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.Canvas3D;
import javax.media.j3d.ColoringAttributes;
import javax.media.j3d.DirectionalLight;
import javax.media.j3d.Shape3D;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.WakeupCriterion;
import javax.media.j3d.WakeupOnElapsedTime;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;
import javax.vecmath.Vector3f;

import com.sun.j3d.loaders.Scene;
import com.sun.j3d.loaders.objectfile.ObjectFile;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.behaviors.mouse.MouseRotate;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.SimpleUniverse;

class sss
{
   public void aa()
   {}
   }
public class themain extends Applet implements KeyListener {
   public static void main(String[] args)
   {
      themain aa=  new themain();
      new MainFrame(aa,400,400);
      aa.addKeyListener(aa);
     
   }
   class main extends Behavior
   {
      WakeupCriterion yawn ;
      public main(){
         System.out.println("bbb");
         yawn  = new WakeupOnElapsedTime(30);
      }
      public void initialize() {
          wakeupOn(yawn);
      }
      public  void processStimulus(Enumeration arg0) {
         
      themain.this.update();
         wakeupOn(yawn);
      }
      }
   

   float posokaz = 0.0f;
   float posokay=0.0f;
   float posokax=5.0f;
   float posoka2z = 10.0f;
   float posoka2y=0.0f;
   float posoka2x=0.0f;
    Transform3D transform;
    Vector3f mqsto;
    Transform3D transform2;
    Transform3D transform3;
    Vector3f mqstomishena;
    TransformGroup view;
    TransformGroup tg;
    TransformGroup tg2;
     DirectionalLight light1;
     Shape3D korab;
     Background background =null;
     Shape3D mishena;
     Transform3D lookat ;
      SimpleUniverse universe ;
      ObjectFile f;
      Scene s = null;
      BranchGroup b ;
public themain ()
{
   
   
   setLayout(new BorderLayout());
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
      Canvas3D canvas = new Canvas3D(config);
  universe = new SimpleUniverse(canvas);
  tg = new TransformGroup();
  tg2 =new TransformGroup();
 

  tg2.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
  tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
  transform = new Transform3D();
  transform2 = new Transform3D();
  transform3 = new Transform3D();
  lookat= new Transform3D();
   mqsto =new Vector3f(posokax,posokay,posokaz);
   mqstomishena =new Vector3f(0,0,0);
  // mqstomishena =new Vector3f(20,0,0);
   add( canvas);
   canvas.addKeyListener(this);
   transform.setTranslation(mqsto);
   background=new Background();
   background.setColor(1.0f, 0.0f, 0.0f);
   background.setCapability(Background.ALLOW_APPLICATION_BOUNDS_WRITE);
 
   lookat.lookAt(new Point3d(0,0,0), new Point3d(mqsto.getX(),mqsto.getY(),mqsto.getZ()), new Vector3d() );
   lookat.setTranslation(mqsto);
   transform2.setTranslation(mqstomishena);
   tg.setTransform(transform);

   tg2.setTransform(transform);
   String s1 = "samolet.obj";
   String s2 = "mishena.obj";
   BranchGroup group = new BranchGroup();
   korab=loader(s1);
   b.removeChild(0);
   mishena = loader(s2);
   b.removeChild(0);
   Color3f light1Color = new Color3f(1.8f, 0.1f, 0.1f);
   BoundingSphere bounds = new BoundingSphere();
   Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f);
    light1 = new DirectionalLight(light1Color, light1Direction);
   light1.setInfluencingBounds(bounds);
   background.setApplicationBounds(bounds);
   
   AmbientLight ambientLightNode = new AmbientLight (light1Color);
   ambientLightNode.setInfluencingBounds (bounds);
   Appearance ap = new Appearance();
    Color3f col = new Color3f(0.0f, 0.0f, 22.0f);
   ColoringAttributes ca = new ColoringAttributes(col, ColoringAttributes.NICEST);
   ap.setColoringAttributes(ca);
   mishena.setAppearance(ap);
   tg.addChild(mishena);
   tg.addChild(new ColorCube(0.4));
   tg2.addChild(korab);
   tg.addChild(view);
   tg.addChild(ambientLightNode);
   MouseRotate myMouseRotate = new MouseRotate();
   myMouseRotate.setTransformGroup(tg);
   myMouseRotate.setSchedulingBounds(new BoundingSphere());
   ap.setColoringAttributes(ca);
    group.addChild(tg);
   group.addChild(background);
    group.addChild(tg2);
  // group.addChild(light1);
    main loop = new main();
    loop.setSchedulingBounds(bounds);
    group.addChild(loop);
   
  universe.getViewingPlatform().setNominalViewingTransform();
//  universe.getViewingPlatform().getViewPlatformTransform().setTransform(transform);
   universe.addBranchGraph(group);
}
public void keyPressed(KeyEvent e){
   if(e.getKeyCode()==KeyEvent.VK_NUMPAD8)
   {
      System.out.println("aa");
   
posokax=posokax+10.f;
mqsto.setX(posokax);
transform.setTranslation(mqsto);
tg.setTransform(transform);
   }
   if(e.getKeyCode()==KeyEvent.VK_NUMPAD2)
   {
      System.out.println("aa");
posokax=posokax-10.f;
mqsto.setX(posokax);
transform.setTranslation(mqsto);
tg.setTransform(transform);
   }
   if(e.getKeyCode()==KeyEvent.VK_NUMPAD4)
   {
      System.out.println("aa");
posokay=posokay+10.f;
mqsto.setY(posokay);
transform.setTranslation(mqsto);
tg.setTransform(transform);
   }
   if(e.getKeyCode()==KeyEvent.VK_NUMPAD6)
   {
      System.out.println("aa");
posokay=posokay-10.f;
mqsto.setY(posokay);
transform.setTranslation(mqsto);
tg.setTransform(transform);
   }

   }
public void keyReleased(KeyEvent e){

    }
public void keyTyped(KeyEvent e){

    }

public Shape3D loader(String s1)
{
     f = new ObjectFile ();
      try{
         s = f.load (s1);
         }
         catch(FileNotFoundException e)
         {
            System.out.println(e);
         }
       b = s.getSceneGroup();
      return (Shape3D) b.getChild(0);
}
public  void update()
{posokaz=posokaz-1f;
transform.setTranslation(new Vector3f(posokay,posokax,posokaz));
tg.setTransform(transform);
transform2.setTranslation(new Vector3f(posoka2y,posoka2x,posoka2z));
tg2.setTransform(transform2);
//lookat.lookAt(new Point3d(0,0,0), new Point3d(mqsto.getX(),mqsto.getY(),mqsto.getZ()), new Vector3d() );
//universe.getViewingPlatform().getViewPlatformTransform().setTransform(transform);

}

   }
Offline Sickan

Senior Duke


Medals: 9



« Reply #5 - Posted 2012-07-14 14:35:37 »

Oh God. That code. It's so poorly formatted. The OCD... it burns!

On topic though I've never used Java3D so I wouldn't be of any help, sorry.

Cheers Smiley
Offline gouessej
« Reply #6 - Posted 2012-07-14 15:55:30 »

Hi

Create a View object, use setBackClipDistance and setFrontClipDistance, then add your canvas to this view (view.addCanvas3D(canvas)). I hope you use the latest version of Java3D (1.6 pre based on JOGL 2.0).

Offline hhfjkehfe

Senior Newbie





« Reply #7 - Posted 2012-07-14 17:24:06 »

And i got an error: Sharing canvas with multiple views.From where to remove the cavans.
Offline hhfjkehfe

Senior Newbie





« Reply #8 - Posted 2012-07-15 11:52:35 »

So where is the problem?  Huh
Offline Roquen
« Reply #9 - Posted 2012-07-15 12:34:48 »

Your real problem is the distance to the far clipping plane.  Geometry is going past it and getting clipped (not rendered).  Your secondary problem is virtually nobody (here at least) uses JOGL, so there's a limited pool of people that can help you fix it.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline hhfjkehfe

Senior Newbie





« Reply #10 - Posted 2012-07-15 13:24:00 »

how to increase the rendering distance
Offline hhfjkehfe

Senior Newbie





« Reply #11 - Posted 2012-07-15 14:50:55 »

1  
2  
3  
4  
5  
6  
GraphicsConfiguration konfiguracii= SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas = new Canvas3D(konfiguracii);
SimpleUniverse universe = new SimpleUniverse(canvas);
universe.getViewingPlatform().setNominalViewingTransform();
View view = canvas.getView();
view.setBackClipDistance(1000f);
Offline gouessej
« Reply #12 - Posted 2012-07-15 15:58:49 »

Your secondary problem is virtually nobody (here at least) uses JOGL, so there's a limited pool of people that can help you fix it.
I use JOGL and I come here daily. Several JOGL users come here too but it is better to ask some help on the official JogAmp forum when it deals with APIs we actively maintain, including Java3D 1.6 pre.

1  
2  
View view = canvas.getView();
view.setBackClipDistance(1000f);

I'm glad to see that working Smiley

Offline StonePickaxes

JGO Coder


Medals: 4
Projects: 2


Nathan Kramber


« Reply #13 - Posted 2012-07-16 22:26:39 »

1  
2  
3  
4  
5  
class sss
{
   public void aa()
   {}
   }


What is the point of that class? Why don't you capitalize your class names, too?

 | Nathan

Check out my website!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (37 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (27 views)
2014-10-15 16:18:58

TehJavaDev (52 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (42 views)
2014-10-14 00:32:37

BurntPizza (63 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (77 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!