Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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  
  box2dlight + libgdx -> cant get it to work (SOLVED)  (Read 638 times)
0 Members and 1 Guest are viewing this topic.
Offline Nesopharus

Senior Newbie





« Posted 2013-08-22 12:43:52 »

Hello peeps, I started to create a 2D topdown Tilebased Game and i wanted to add some lightning.

I found this tut:http://voodoobits.blogspot.de/2012/04/and-there-was-light.html
but i could not get it to work.

at this place:
1  
2  
3  
light_world = new com.badlogic.gdx.physics.box2d.World(new Vector2(), true);
RayHandler.useDiffuseLight(true);
rayHandler = new RayHandler(light_world); // <----- this one

i get an Exception and that was it then :/


here is what my eclipse says :

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.IllegalArgumentException: color attribute must have 4 components
   at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:113)
Caused by: java.lang.IllegalArgumentException: color attribute must have 4 components
   at com.badlogic.gdx.graphics.VertexAttributes.checkValidity(VertexAttributes.java:104)
   at com.badlogic.gdx.graphics.VertexAttributes.<init>(VertexAttributes.java:52)
   at com.badlogic.gdx.graphics.glutils.VertexArray.<init>(VertexArray.java:53)
   at com.badlogic.gdx.graphics.Mesh.<init>(Mesh.java:99)
   at box2dLight.RayHandler.<init>(RayHandler.java:120)
   at box2dLight.RayHandler.<init>(RayHandler.java:87)
   at de.vdb.tiledmapgametest.LightRenderer.<init>(LightRenderer.java:30)
   at de.vdb.tiledmapgametest.WorldRenderer.drawLight(WorldRenderer.java:93)
   at de.vdb.tiledmapgametest.WorldRenderer.render(WorldRenderer.java:86)
   at de.vdb.tiledmapgametest.Gamescreen.render(Gamescreen.java:97)
   at com.badlogic.gdx.Game.render(Game.java:46)
   at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:187)
   at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:110)


i am using the stable libgdx 0.9.8

maybe somebody around here may have an idea Cheesy

btw. the light_world is filled somewhere else after that piece of code but as far as i can see that is nothing i have to care about at this place right?  Roll Eyes

edit: got the line of code where it all goes to valhalla x.x  its in libgdx  :
com.badlogic.gdx.graphics.VertexAttributes  Line 104
1  
2  
3  
4  
5  
6  
if (attribute.usage == Usage.Color || attribute.usage == Usage.ColorPacked) {
            if (attribute.numComponents != 4) throw new IllegalArgumentException("color attribute must have 4 components"); // <--- this one :D

            if (cols) throw new IllegalArgumentException("two color attributes were specified");
            cols = true;
         }


while debugging i found out that i have got 2 attributes    vertex positions and color     color got 4 args  thats ok but here the color attribute got the usage code 4  and the positions 1   libgdx is asking for code 1 as color code and then it runs into 2 components  not 4  after that ->  crash x.x


edit 2 :

Okay now i can see that box2dlights uses the Usage class of libgdx  and takes Usage.Position for the position attributes and Usage.ColorPacked for the Color   so far its okay    but now at Runtime i got the code 1 for the pos attribute and it is recognized as a color, but for the position the code 0 is used in my libgdx o.O    seems like in my libgdx there are other codes used then in box2dlight  ill try to change from stable to nightly if that fixes my bug   ill report back soon Tongue

edit 3:

after a break and updating my libs to the nightly build its working now Cheesy

sorry for spamming your forum xD but i did not know that i can fix it on my own Tongue just started my apprenticeship this month as a programmer ^^

Hi! Cheesy
Offline namrog84

JGO Ninja


Medals: 46
Projects: 4


Keep programming!


« Reply #1 - Posted 2013-08-22 14:48:39 »

but i did not know that i can fix it on my own Tongue

I feel like I spend many hours on problems myself,  post to this forum and solve it on my own within a few minutes later. I usually have several edits of my progress too. (happens all of the time) Its totally fine  Grin  And it can be good too, because sometimes others might have similiar ideas/issues and can see this post while searching for solutions

The only thing I would suggest is editing your title to include (SOLVED) at the end of it.

"Experience is what you get when you did not get what you wanted"
Offline jeffberhow

Junior Newbie





« Reply #2 - Posted 2013-08-22 16:59:52 »

I agree. Documenting your mistakes and fixes can be hugely beneficial to other users, especially when they get snatched up by the Google indexer. They are also great to turn into blog posts if you are into that sort of thing!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Nesopharus

Senior Newbie





« Reply #3 - Posted 2013-08-23 09:00:26 »

i dont even know how a blog post would look like o.O
im not really into such things Tongue but ill try to document my problems and stuff like that

for now ill just try to complete my tasks so i can keep working on my game Cheesy

Hi! Cheesy
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.

xsi3rr4x (53 views)
2014-04-15 18:08:23

BurntPizza (51 views)
2014-04-15 03:46:01

UprightPath (65 views)
2014-04-14 17:39:50

UprightPath (48 views)
2014-04-14 17:35:47

Porlus (65 views)
2014-04-14 15:48:38

tom_mai78101 (89 views)
2014-04-10 04:04:31

BurntPizza (149 views)
2014-04-08 23:06:04

tom_mai78101 (245 views)
2014-04-05 13:34:39

trollwarrior1 (203 views)
2014-04-04 12:06:45

CJLetsGame (210 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!