Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
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  
  3D sphere texturing and manipulation. -Using LWJGL and Slick Util  (Read 1284 times)
0 Members and 1 Guest are viewing this topic.
Offline EmanP

Junior Member


Projects: 2
Exp: 3 years


Satisfaction never guaranteed.


« Posted 2013-10-01 00:14:34 »

Hello JGO!
I thought I wouldn't be asking another newb question for a while, but I got SFX greedy.

For my intro of my game, I want the earth and sun spinning around, and, I could draw an undynamic animation or array of .png files, or I could draw a sphere to do it for me, and considering it's going to be the only 3D in my game (planned so far), it shouldn't be too bad to implement.

A few problems with the code below:
* It uses the slick Texture to bind to the glu.sphere, but it only shows the average colour- there is only 1 colour.
* I cannot understand how to map the texture if I got it working
* Only the leftmost and rightmost pixels are processed from the .png to the sphere
* Transparency only whitens the sphere.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
private static Texture image;
private void renderSphere(float x, float y, float z)
   {
      image.bind();
      glPushMatrix();
      glTranslatef(x, y, z);
      Sphere s = new Sphere();
      s.draw(0.4f, 16, 16);
      glPopMatrix();
   }


So any ideas? I cannot understand how it does work.

Signed- EmanP
Offline davedes
« Reply #1 - Posted 2013-10-01 02:21:30 »

What do you mean "average color" ? If it renders as a solid color, its probably a sign that
GL_TEXTURE_2D
is not enabled. Further, SlickUtil is kind of buggy depending on the version you have.

I would just bind the texture directly:
1  
2  
3  
4  
5  
6  
7  
8  
9  
//enable transparency
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

//enable and bind the texture
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID());

..render sphere...


Even with all of that, it might not work. I'm not familiar with LWJGL's GLU emulation and I'm not sure how it handles texture coordinates. GLU is really old and for the most part only used for simple debugging.

Rendering a sphere in OpenGL isn't too difficult, and actually is a good way to introduce yourself to modern OpenGL. It basically comes down to spherical coordinates:
http://stackoverflow.com/questions/969798/plotting-a-point-on-the-edge-of-a-sphere/969880#969880
http://en.wikipedia.org/wiki/Spherical_coordinates

If you can't get it working and can't be bothered to learn the OpenGL way, I would suggest just using LibGDX, jME, jPCT, or another library to help you with the 3D aspects.

Offline relminator
« Reply #2 - Posted 2013-10-01 04:05:43 »

Yes, spherical coords.  You could approximate texture coords from 0 to 2PI in both the azimuth and horizon.

www.rel.phatcode.net/junk.php?id=61
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline EmanP

Junior Member


Projects: 2
Exp: 3 years


Satisfaction never guaranteed.


« Reply #3 - Posted 2013-10-01 19:45:48 »

Yes, spherical coords.  You could approximate texture coords from 0 to 2PI in both the azimuth and horizon.
www.rel.phatcode.net/junk.php?id=61
Oh.. god. I've never seen such a trippy thing in my life.. Now I just need to figure out what this .bas file says.. and how to use it's equations hidden within the syntax.

What do you mean "average color" ? If it renders as a solid color, its probably a sign that
GL_TEXTURE_2D
is not enabled. Further, SlickUtil is kind of buggy depending on the version you have.
Even with all of that, it might not work. I'm not familiar with LWJGL's GLU emulation and I'm not sure how it handles texture coordinates. GLU is really old and for the most part only used for simple debugging.
If you can't get it working and can't be bothered to learn the OpenGL way, I would suggest just using LibGDX, jME, jPCT, or another library to help you with the 3D aspects.
Thanks for the links! About glu.Sphere, I am new to it, so I figured out that a texture to wrap it around should have many colours, as to see which pixel to attach where, but it seems It just blurs it into the texture's average colour and then implements it. Also, GL_TEXTURE_2D was enabled, as I was using other textures at the time as well.

Signed- EmanP
Offline relminator
« Reply #4 - Posted 2013-10-02 01:51:52 »

It's a supershape morpher I made from the equations developed by Paul Bourke.

www.paulbourke.net/geometry/


Basically, I already had a working tesselator for quadric shapes so I only have to enter the equations, do some interpolation to its parameters.

Bas files are BASIC code(freebasic.net). One of the languages I code for fun. Smiley

I'd be happy to walk you through the code if you want. Smiley
Offline EmanP

Junior Member


Projects: 2
Exp: 3 years


Satisfaction never guaranteed.


« Reply #5 - Posted 2013-10-02 18:11:02 »

It's a supershape morpher I made from the equations developed by Paul Bourke.

www.paulbourke.net/geometry/


Basically, I already had a working tesselator for quadric shapes so I only have to enter the equations, do some interpolation to its parameters.

Bas files are BASIC code(freebasic.net). One of the languages I code for fun. Smiley

I'd be happy to walk you through the code if you want. Smiley
Erf.. I would like a walk-through for this please.

Signed- EmanP
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.

pw (17 views)
2014-07-24 01:59:36

Riven (17 views)
2014-07-23 21:16:32

Riven (14 views)
2014-07-23 21:07:15

Riven (17 views)
2014-07-23 20:56:16

ctomni231 (45 views)
2014-07-18 06:55:21

Zero Volt (40 views)
2014-07-17 23:47:54

danieldean (32 views)
2014-07-17 23:41:23

MustardPeter (36 views)
2014-07-16 23:30:00

Cero (51 views)
2014-07-16 00:42:17

Riven (50 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!