Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (120)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Game Play & Game Design / Re: Mountain outline formula on: 2014-04-24 14:55:41
Thanks I will use this.
2  Game Development / Game Play & Game Design / Re: Mountain outline formula on: 2014-04-24 13:33:08
Sorry.I want to create 2d polygon mountain.
3  Game Development / Game Play & Game Design / Mountain outline formula on: 2014-04-24 13:28:07
Is there a good formula for generating random mountain outline?
4  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Mesh won`t render. on: 2014-04-17 07:20:49
I sorry for the lack of info but I am new to opengl .Now I have a big black triangle on the screen.
5  Java Game APIs & Engines / Engines, Libraries and Tools / Mesh won`t render. on: 2014-04-17 06:57:47
Can render the mesh.I have used the tutorial.
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  
public class ShapeTerrain {
   private Mesh mesh;
   private Texture texture;
   private ShaderProgram shader ;
   PolygonShape poly;
   PolygonRegion po;
   TextureRegion texreg;
   static String vertexShader = "attribute vec4 a_position;    \n" +
            "attribute vec4 a_color;\n" +
            "attribute vec2 a_texCoord0;\n" +
            "uniform mat4 u_worldView;\n" +
            "varying vec4 v_color;" +
            "varying vec2 v_texCoords;" +
            "void main()                  \n" +
            "{                            \n" +
            "   v_color = vec4(1, 1, 1, 1); \n" +
            "   v_texCoords = a_texCoord0; \n" +
            "   gl_Position =  u_worldView * a_position;  \n"      +
            "}                            \n" ;
static String fragmentShader = "#ifdef GL_ES\n" +
              "precision mediump float;\n" +
              "#endif\n" +
              "varying vec4 v_color;\n" +
              "varying vec2 v_texCoords;\n" +
              "uniform sampler2D u_texture;\n" +
              "void main()                                  \n" +
              "{                                            \n" +
              "  gl_FragColor = v_color * texture2D(u_texture, v_texCoords);\n" +
              "}";
   protected static ShaderProgram createMeshShader() {
       ShaderProgram.pedantic = false;
       ShaderProgram shader = new ShaderProgram(vertexShader, fragmentShader);
       return shader;
   }

   public ShapeTerrain()
   {
        mesh = new Mesh(true, 3, 3,
                   new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE),
                   new VertexAttribute(Usage.Color, 4, ShaderProgram.COLOR_ATTRIBUTE),
                   new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE));

          mesh.setVertices(new float[] { -5f, -5f, 0, 0.2f, 0.3f, 0.4f, 1f, 0, 1,
                                          5f, -5f, 0, 0.1f, 0.2f, 0.1f, 1f, 1, 1,
                                          0, 5f, 0, 0, 0.4f, 0.5f, 0.5f, 1f, 0 });

           mesh.setIndices(new short[] { 0, 1, 2 });

           texture = new Texture(Gdx.files.internal("data/badlogic.png"));

           shader =   ImmediateModeRenderer20.createDefaultShader(true,true,0);
   }
   public void render(SpriteBatch batch,PolygonSpriteBatch poly)
   {
      texture.bind();
      shader.begin();
       mesh.render(shader, GL20.GL_TRIANGLES);
       shader.end();
   }
6  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [Libgdx] Problem with ImmediateModeRenderer20 on: 2014-04-15 16:51:49
Well the texture is 100 by 100 and the device is 1280x756 but I think that I place the vertices too close.
7  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [Libgdx] Problem with ImmediateModeRenderer20 on: 2014-04-15 16:01:43
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  
public class LevelBackground {
   private ImmediateModeRenderer20 renderer;
   private Texture backgroundText;
   private Matrix4 projMatrix;
   private Body terrainBody;
   private ChainShape line;
   private BodyDef lineBodyDef;
   private ArrayList<Vector2> terrainVectors;
   private double dots[];
   private int speed;
   private Camera camera;

   

   public LevelBackground(String name,double dots[], World world,
         Camera camera,int speed) {
      this.camera = camera;
      this.speed = speed;
      this.dots = dots;
      projMatrix = new Matrix4();
      renderer = new ImmediateModeRenderer20( true, true, 1);
      backgroundText = new Texture(
            (Gdx.files.internal(name)),false);
      backgroundText.setFilter(TextureFilter.Linear, TextureFilter.Linear);
      line = new ChainShape();
      lineBodyDef = new BodyDef();
      terrainVectors = new ArrayList<Vector2>();
      lineBodyDef.position.set(0, 0);
      lineBodyDef.type = BodyType.StaticBody;
      // terrainBody = world.createBody(lineBodyDef);
      // for (int i = 0; i < floats.length; i++) {
      // terrainVectors.add(screenToPhysics(camera, new Vector2(
      // i * 100f - 50f, (float) ((floats[i]) / 2f) + 220f)));
      // }
      // line.createChain(terrainVectors.toArray(new Vector2[terrainVectors
      // .size()]));
      // for (int i = 0; i < terrainBody.getFixtureList().size; i++) {
      // terrainBody.getFixtureList().get(i).setFriction(1f);
      // }
      // terrainBody.createFixture(line, 1f);
   }

   public void render(float offset) {
      backgroundText.bind(GL20.GL_TEXTURE_2D);
      renderer.begin(projMatrix, GL20.GL_TRIANGLE_STRIP);
      Gdx.app.log("size", "" + dots.length);
      for (float i = 0; i < dots.length; i++) {
         renderer.texCoord((i%2),1f);
         renderer.color(1f, 1f, 1f, 1f);
         renderer.vertex(i / (float) (dots.length) * 2 - 1.5f - offset
               / (float)speed, (float) ((dots[(int) (i)]) / 900f) - 0.8f, 1f);
         renderer.texCoord(0f, 0f);

         renderer.color(1f, 1f, 1f, 1f);
         renderer.vertex(i / (float) (dots.length) *2 - 1.5f - offset
               / (float)speed, -1f, 1f);

      }
      renderer.end();
   }

   private Vector2 screenToPhysics(Camera camera, Vector2 screenPos) {
      Vector3 worldPos = new Vector3(screenPos.x, screenPos.y, 0);
      camera.unproject(worldPos);

      return new Vector2(worldPos.x, worldPos.y).scl(1f / 32f);
   }
}

The problem whith the noise is that the texture don`t move smooth through the screen but at fixed intervals .I use a very detailed texture and this step movement create the effect of noise.
8  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [Libgdx] Problem with ImmediateModeRenderer20 on: 2014-04-15 09:43:37
Well I want to render the background which is 20MB and I want to use vertices.[20MB per level]
9  Java Game APIs & Engines / Engines, Libraries and Tools / [Libgdx] Problem with ImmediateModeRenderer20 on: 2014-04-15 06:38:50
When I draw a polygon with ImmediateModeRenderer20  and on the next frame I draw it with an offset  the polygon becomes noisy.How I can fix this?
10  Game Development / Newbie & Debugging Questions / Re: Libgdx and ImmediateModeRenderer20 on: 2014-02-28 10:53:46
I already use
Gdx.gl.glEnable(GL20.GL_BLEND);
      Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
but still no effect.
Btw here is how I draw the shape.
         renderer.texCoord(((float)i)*sizeConst, 0f);
         renderer.color(1, 1, 1, 1f);
         renderer.vertex(((2f / ((float) w)) * points.get(i).x - 1f),
               -1f*(((2f / ((float) h)) * points.get(i).y - 1f)
                     - (2f / ((float) h))*20f),1f);
         renderer.texCoord(((float)i)*sizeConst , 1f);
         renderer.color(1, 1, 1,1f);
         renderer.vertex(((2f / ((float) w)) * points.get(i).x - 1f) ,
               -1f*(((2f / ((float) h)) * points.get(i).y - 1f)), 1f);
11  Game Development / Newbie & Debugging Questions / Libgdx and ImmediateModeRenderer20 on: 2014-02-28 10:01:47
Why when I try to place a transparent  color I get black instead.
12  Game Development / Newbie & Debugging Questions / Collision problem. on: 2012-07-17 17:15:20
Why there is collision when the objects are 10000 meters one from another?
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  
234  
235  
236  
237  
238  
239  
240  
241  
242  
243  
244  
245  
246  
247  
248  
249  
250  
251  
252  
253  
254  
255  
256  
257  
258  
259  
260  
261  
262  
263  
264  
265  
266  
267  
268  
269  
270  
271  
272  
273  
274  
275  
276  
277  
278  
279  
280  
281  
282  
283  
284  
285  
286  
287  
288  
289  
290  
291  
292  
293  
294  
295  
296  
297  
298  
299  
300  
301  
302  
303  
304  
305  
306  
307  
308  
309  
310  
311  
312  
313  
314  
315  
316  
317  
318  
319  
320  
321  
322  
323  
324  
325  
326  
327  
328  
329  
330  
331  
332  
333  
334  
335  
336  
337  
338  
339  
340  
341  
342  
343  
344  
345  
346  
347  
348  
349  
350  
351  
352  
353  
354  
355  
356  
357  
358  
359  
360  
361  
362  
363  
364  
365  
366  
367  
368  
369  
370  
371  
372  
373  
374  
375  
376  
377  
378  
379  
380  
381  
382  
383  
384  
385  
386  
387  
388  
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.Bounds;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.Canvas3D;
import javax.media.j3d.DirectionalLight;
import javax.media.j3d.ImageComponent2D;
import javax.media.j3d.Shape3D;
import javax.media.j3d.Texture;
import javax.media.j3d.Texture2D;
import javax.media.j3d.TextureAttributes;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.View;
import javax.media.j3d.WakeupCriterion;
import javax.media.j3d.WakeupOnCollisionEntry;
import javax.media.j3d.WakeupOnCollisionExit;
import javax.media.j3d.WakeupOnCollisionMovement;
import javax.media.j3d.WakeupOnElapsedTime;
import javax.media.j3d.WakeupOr;
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.Primitive;
import com.sun.j3d.utils.geometry.Sphere;
import com.sun.j3d.utils.image.TextureLoader;
import com.sun.j3d.utils.universe.ConfiguredUniverse;
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 colision extends Behavior
   {
     
      WakeupCriterion yawn ;
      WakeupCriterion[]
      kolizia =new WakeupCriterion[3];
       protected WakeupOr oredCriteria;
       Shape3D shape;
      public colision(Shape3D shape,Bounds granici){
      this.shape=shape;
         System.out.println("bbbaaa");
         setSchedulingBounds(granici);
      }
      public void initialize() {
          kolizia[0]=new WakeupOnCollisionEntry(shape);
           kolizia[1] = new WakeupOnCollisionExit(shape);
           kolizia[2] = new WakeupOnCollisionMovement(shape);
           oredCriteria = new WakeupOr(kolizia);
           wakeupOn(oredCriteria);
     
      }
      public  void processStimulus(Enumeration criteria) {
           WakeupCriterion theCriterion = (WakeupCriterion) criteria.nextElement();
             if (theCriterion instanceof WakeupOnCollisionEntry) {
               themain.this.update(true);
               System.out.println("Collided with ");
             } else if (theCriterion instanceof WakeupOnCollisionExit) {
                  themain.this.update(true);
               System.out.println("Stopped colliding with  "
                 );
             } else {
                  themain.this.update(true);
               System.out.println("Moved whilst colliding with "
             );
             }
             wakeupOn(oredCriteria);

         
      }
      }
   
   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 criteria) {
   
      themain.this.update(false);
         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;
    double zawurtane = 0;
    Transform3D transform;
    Vector3f mqsto;
    Transform3D transform2;
    Transform3D transform3;
    Vector3f mqstomishena;
    View gledka;
    TransformGroup view;
    TransformGroup tg;
    TransformGroup tg2;
     DirectionalLight light1;
     Shape3D korab;
     Background background =null;
     //Shape3D mishena;
     Shape3D truba;
     Transform3D lookat ;
     ConfiguredUniverse ss;
     ConfiguredUniverse universe ;
      ObjectFile f;
      Scene s = null;
      BranchGroup b ;
public themain ()
{
   //javax.media.j3d.View.setFrontClipDistance(22);
   

   setLayout(new BorderLayout());
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
   
    Canvas3D canvas = new Canvas3D(config);
   // canvas.setBounds(10000, 10000, 10000, 10000);
    universe = new ConfiguredUniverse(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();
  View view = canvas.getView();
  view.setBackClipDistance(3000f);
   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();
   TextureAttributes texAttr = new TextureAttributes();
   texAttr.setTextureMode(TextureAttributes.MODULATE);
   //background.setColor(1.0f, 0.0f, 0.0f);
   background.setCapability(Background.ALLOW_APPLICATION_BOUNDS_WRITE);
   gledka=new View();
   lookat.lookAt(new Point3d(0,0,0), new Point3d(mqsto.getX(),mqsto.getY(),mqsto.getZ()), new Vector3d() );
   lookat.setTranslation(mqsto);
   transform2.setTranslation(mqstomishena);
   transform3.setTranslation(new Vector3f(0,0,0));
   tg.setTransform(transform);
   gledka.setBackClipDistance(3);
   gledka.setFrontClipDistance(30000);
//   gledka.addCanvas3D(canvas);
   tg2.setTransform(transform);
   String s1 = "mishena.obj";
   String s2 = "mishena.obj";
   String s3 = "truba.obj";

TextureLoader loader = new TextureLoader("rujda.jpg",this);
ImageComponent2D brick2 = loader.getImage();

Texture2D brick= new Texture2D(Texture2D.BASE_LEVEL, Texture2D.RGB, brick2.getWidth(), brick2.getHeight());
brick.setEnable(true);
brick.setImage(0, brick2);
TextureAttributes ta = new TextureAttributes();      

   BranchGroup group = new BranchGroup();
   korab=loader(s1);
   b.removeChild(0);
  // mishena = loader(s2);
 ////  b.removeChild(0);
   truba=loader(s3);
   b.removeChild(0);
   Color3f light1Color = new Color3f(0f, 255f, 1f);
   BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0,
            0.0), 100.0);
   bounds.setRadius(Float.MAX_VALUE);
   Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f);
    light1 = new DirectionalLight(light1Color, light1Direction);
   light1.setInfluencingBounds(bounds);
   background.setApplicationBounds(bounds);
   background.setName("rujda.jpg");
   
   AmbientLight ambientLightNode = new AmbientLight (light1Color);
   ambientLightNode.setInfluencingBounds (bounds);
   Appearance ap = new Appearance();
    Color3f col = new Color3f(0.0f, 0.0f, 22.0f);
   ap.setTextureAttributes(texAttr);
   ap.setTexture(brick);
 //  mishena.setAppearance(ap);
   truba.setAppearance(ap);
 
   korab.setAppearance(ap);
//  tg.addChild(mishena);
   tg.addChild(truba);
   tg2.addChild(korab);
   Sphere mySphere = new Sphere(0.7f,Primitive.GENERATE_TEXTURE_COORDS,ap);
tg2.addChild(mySphere);
   //tg.addChild(view);
   tg.addChild(ambientLightNode);
   MouseRotate myMouseRotate = new MouseRotate();
   myMouseRotate.setTransformGroup(tg);
   myMouseRotate.setSchedulingBounds(new BoundingSphere());
    group.addChild(tg);
   group.addChild(background);
    group.addChild(tg2);
 
    group.addChild(light1);
    main loop = new main();
    colision colisions = new colision(korab,bounds);
    colision colisions2 = new colision(truba,bounds);
    loop.setSchedulingBounds(bounds);
    colisions.setSchedulingBounds(bounds);
    group.addChild(loop);
    group.addChild(colisions);
    group.addChild(colisions2);
 
   
  universe.getViewingPlatform().setNominalViewingTransform();
 universe.getViewingPlatform().getViewPlatformTransform().setTransform(transform);
   universe.addBranchGraph(group);
   this.setVisible(true);
}
public static Texture getTexture(String path)
{
       TextureLoader texLoader = new TextureLoader(path, null);
       Texture texture =  texLoader.getTexture();
       if (texture == null)
         System.out.println("Cannot load texture from " + path);
       else {
         System.out.println("Loaded texture from " + path);
       //  texture.setEnable(true);
       }
       return texture;
}
public void keyPressed(KeyEvent e){
   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_A)
   {
      System.out.println("aa");
   
zawurtane=zawurtane+0.01;
transform2.rotZ(zawurtane);
tg2.setTransform(transform2);
   }
   if(e.getKeyCode()==KeyEvent.VK_D)
   {

zawurtane=zawurtane-0.01;
transform2.rotZ(zawurtane);
tg2.setTransform(transform2);
   }
   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_NUMPAD8)
   {
      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);
zawurtane=zawurtane+0.05;
transform.rotZ(zawurtane);
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);
zawurtane=zawurtane-0.05;
transform.rotZ(zawurtane);
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(boolean kol)
{
   if (kol==true)
   {
      transform.setTranslation(new Vector3f(0,0,0));
      tg.setTransform(transform);
      posokaz=0f;
      System.out.println("bbbbb");
   }
   else{
   posokaz=posokaz+10f;
   
transform.rotY(0);
transform.setTranslation(new Vector3f(posokay,posokax,posokaz));
tg.setTransform(transform);
   }
transform2.setTranslation(new Vector3f(posoka2y,posoka2x,10000));
tg2.setTransform(transform2);
transform3.setTranslation(new Vector3f(posoka2y,posoka2x+200,10500));
//lookat.lookAt(new Point3d(0,0,0), new Point3d(mqsto.getX(),mqsto.getY(),mqsto.getZ()), new Vector3d() );
universe.getViewingPlatform().getViewPlatformTransform().setTransform(transform3);

}

   }
13  Game Development / Newbie & Debugging Questions / Re: A problem with the textures. on: 2012-07-16 11:18:10
lwjgl is very low-level. And I know for this error.When I try with Texture2D the effect is the same.
14  Game Development / Newbie & Debugging Questions / A problem with the textures. on: 2012-07-16 07:32:23
How i can load the textures in java 3d.I tried several times but so far I have only colored the objects in some randomcolor.
1  
2  
3  
4  
5  
6  
TextureLoader loader = new TextureLoader("rujda.bmp",this);
Texture3D brick = (Texture3D)loader.getTexture();
TextureAttributes ta = new TextureAttributes();      
Appearance ap = new Appearance();
   ap.setTextureAttributes(ta);
   ap.setTexture(brick);
15  Game Development / Newbie & Debugging Questions / Re: Why when i move the object it disappears after some distance?[SOLVED] on: 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);
16  Game Development / Newbie & Debugging Questions / Re: Why when i move the object it disappears after some distance? on: 2012-07-15 13:24:00
how to increase the rendering distance
17  Game Development / Newbie & Debugging Questions / Re: Why when i move the object it disappears after some distance? on: 2012-07-15 11:52:35
So where is the problem?  Huh
18  Game Development / Newbie & Debugging Questions / Re: Why when i move the object it disappears after some distance? on: 2012-07-14 17:24:06
And i got an error: Sharing canvas with multiple views.From where to remove the cavans.
19  Game Development / Newbie & Debugging Questions / Re: Why when i move the object it disappears after some distance? on: 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);

}

   }
20  Game Development / Newbie & Debugging Questions / Why when i move the object it disappears after some distance?[SOLVED] on: 2012-07-14 14:18:46
Why when i move the object it disappears after some distance?
21  Game Development / Newbie & Debugging Questions / Re: 3d object on: 2012-07-02 09:29:59
But I want it for java.
22  Game Development / Newbie & Debugging Questions / Re: 3d object on: 2012-07-02 07:57:30
Ok.Now how to make a 3d object and how to move it ?
23  Game Development / Newbie & Debugging Questions / Re: 3d object on: 2012-07-01 12:29:35
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
   at java.lang.ClassLoader.loadLibrary(Unknown Source)
   at java.lang.Runtime.loadLibrary0(Unknown Source)
   at java.lang.System.loadLibrary(Unknown Source)
   at org.lwjgl.Sys$1.run(Sys.java:73)
   at java.security.AccessController.doPrivileged(Native Method)
   at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
   at org.lwjgl.Sys.loadLibrary(Sys.java:95)
   at org.lwjgl.Sys.<clinit>(Sys.java:112)
   at org.lwjgl.opengl.Display.<clinit>(Display.java:132)
   at InputExample.start(InputExample.java:11)
   at InputExample.main(InputExample.java:71)

Where is the problem?
24  Game Development / Newbie & Debugging Questions / Re: 3d object on: 2012-06-23 19:15:42
help?
25  Game Development / Newbie & Debugging Questions / Re: 3d object on: 2012-06-20 12:22:35
And now i got error on line 8
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  
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;

 class DisplayExample {
   public void start() {
      try {
         Display.setDisplayMode(new DisplayMode(800,600));
         Display.create();
      } catch (LWJGLException e) {
         e.printStackTrace();
         System.exit(0);
      }
     
      // init OpenGL here
     
      while (!Display.isCloseRequested()) {
         
         // render OpenGL here
         
         Display.update();
      }
     
      Display.destroy();
   }
   
   public static void main(String[] argv) {
      DisplayExample displayExample = new DisplayExample();
      displayExample.start();
   }
}
26  Game Development / Newbie & Debugging Questions / Re: 3d object on: 2012-06-20 11:40:32
Ok.On testing i got this ndowCreationTest
The following keys are available:
ESCAPE:         Exit test
ARROW Keys:     Move window when in non-fullscreen mode
L:              List selectable display modes
0-8:            Selection of display modes
F:              Toggle fullscreen
SHIFT-F:        Toggle fullscreen with Display.destroy()/create() cycle
Found 24 display modes
Problem retrieving mode with 640x480x24@-1
Problem retrieving mode with 800x600x24@-1
Problem retrieving mode with 1024x768x24@-1
27  Game Development / Newbie & Debugging Questions / Re: 3d object on: 2012-06-18 19:04:58
Help?
28  Game Development / Newbie & Debugging Questions / Re: 3d object on: 2012-06-17 18:12:28
Ok.I have an error
1  
2  
Description   Resource   Path   Location   Type
Access restriction: The type DisplayMode is not accessible due to restriction on required library C:\Program Files\Java\jre7\lib\rt.jar   main.java   /javax.media/src   line 3   Java Problem

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  
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;

public class DisplayExample {
   public void start() {
      try {
         Display.setDisplayMode(new DisplayMode(800,600));
         Display.create();
      } catch (LWJGLException e) {
         e.printStackTrace();
         System.exit(0);
      }
     
      // init OpenGL here
     
      while (!Display.isCloseRequested()) {
         
         // render OpenGL here
         
         Display.update();
      }
     
      Display.destroy();
   }
   
   public static void main(String[] argv) {
      DisplayExample displayExample = new DisplayExample();
      displayExample.start();
   }
}
29  Game Development / Newbie & Debugging Questions / 3d object on: 2012-06-17 17:15:25
Hi , I am new java game dev but I am not newbie in Java  Grin. Since one of the paradigm of Java is to keep it simple as possible I want to show me a tut just how to make a 3d object add move it.
Pages: [1]
 

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 (52 views)
2014-10-17 03:59:02

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

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

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

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

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

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

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

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

BurntPizza (86 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!