Tag Info

Hot answers tagged

6

How are you passing your normals to the vertex shader? It looks like those are the normals for each of the six faces of a cube, but the vertex shader operates on vertices, not faces. Unless you're doing something unusual, you need to specify a normal for each vertex. In addition, if you want a cube to look right, you will need 24 vertices rather than 8, so ...


5

I have good news and bad news for you: The Bad News: I don't know or remember any Java library that does what you want The Good News: It's really easy to implement this type of algorithm yourself! Here's a couple, you can mix them to optimize your collision detection depending on the type of shape. BB Collision Detection You can imagine a box around ...


3

Sure, this is quite simple really. I'll guide you through Paint.net. Open the application and go to New. In the dimensions, put 8 for width and 8 for height. A new 8x8 canvas will open, typically I zoom in all the way to 3200%. I'll also get rid of the white background layer, by making a new layer, then deleting the background one. Now you have the canvas ...


3

You don't need to call glVertexAttribPointer for the indexes; the indexes are found from the bound GL_ELEMENT_ARRAY_BUFFER during the drawElements call (which is saved in the VAO state IIRC). However indexes start from 0 so the contents of your index buffer are flawed they should be: {0,1,2,2,3,0}


3

In my experience with android, it is the garbage collection the kills the performance, not the allocation, although these two are tied hand and hand. As mentioned on the comments, pre-allocation is a way to deal with this issue. This is known as a memory pools. Another similar solution is object pool pattern. An object pool allocates as needed, but does ...


3

As already pointed out in the comments and answer: This can be arbitrarily complex. Particularly, depending on the exact use case and performance requirements, you can employ some rather sophisticated data structures in order to make these tests fast. The bounding box test is the simplest one that should be done in any case (and in fact, could already be ...


2

Try doing this:- try { Robot bot = new Robot(); bot.keyPress(KeyEvent.VK_F6); bot.delay(50); bot.keyRelease(KeyEvent.VK_F6); } catch (AWTException ex) { Logger.getLogger(main.class.getName()).log(Level.SEVERE, null, ex); }


2

It means desktop. You have two options to deploy your libGDX app to the desktop: Create a self-runnable JAR. This is easier (Eclipse can export it pretty easily). Create an EXE, via launch4j (or some other wrapper). This is possible too (especially with Gradle). I've used both approaches and they work equally well as far as I can tell. Both rely on ...


2

Convert them to the normalised space: float r1 = color1.r / 255.0f; float g1 = color1.g / 255.0f; float b1 = color1.b / 255.0f; float a1 = color1.a / 255.0f; float r2 = color2.r / 255.0f; float g2 = color2.g / 255.0f; float b2 = color2.b / 255.0f; float a2 = color2.a / 255.0f; and them multiply them: float r3 = r1 * r2; float g3 = g1 * g2; float b3 = b1 ...


2

You can explicitly get those numbers from id = glGetAttribLocation(program, name); after linking; the name is the string that appears in the vertex shader for the attribute. For example if you passed "vertexPosition" for name then you would get 0. If the layout information is not in the shader then openGL will create a default layout (usually in order as ...


1

What you need is double buffering I stole this from somewhere just to give you a quick answer: "Double buffering is conceptually pretty simple, instead of drawing your objects one by one, you draw them on an image and then tell the renderer to draw that entire image. This eliminates the flickering. Here's an example of how you might do this" class ...


1

I figured out the problem myself! After printing the coordinates of the mouse to the console I realized that where just something missing with my Input. Sure enough, I added GameContainer to the constructor of minigun and set input to equal GameContainer.getInput();. It works perfectly now :D public Minigun(GameContainer container){ try { ...


1

The positions and color (and all other vertex attributes) all use the same index buffer, there is no way to change that. So if you have an index X then that vertex will have the position at index X and the color at index X. The size parameter indicates how many values to take (1 to 4). Sometimes positions are stored in the homogenic format (essentially add ...


1

LET THIS BE A CAUTIONARY TALE ABOUT BOX2D! Haha! Here's the solution I came up with The problem I amrunning into is due to the fact that Box2D uses meters instead of pixels for the scale, in my game a screen that is 1920x1080 would be 1920 meters wide and if I am using sprites a small sprite will be only as many meters wide as it is in pixels. The reason ...


1

The distance moved does not take the delta time into account, so if you get updates coming at an irregular interval you'll get jerky motion. Scale your speed by the elapsed time, dt; public void update(float dt){ if(cont == true){ vec = makeVec(); x += vec.x * speed * dt; y += vec.y * speed * dt; } } This might mean you'll ...


1

Dialog is better suited for modal pop-up windows, and it includes a "button" and "content" table already in the window (as the docs say). You can grab these tables with getButtonTable() or getContentTable(). The dialog makes it easy to work with pop up windows. For example, here is a confirmation dialog: Dialog diag = new Dialog("Warning", skin, "dialog") ...


1

you say it's so complicated to implement a path-finding algorithm, but it isn't... and what's even better, once you have implemented one you can use that algorithm whenever needed again... i can provide you with an simple one (A* it is - and it is easy) and it's so open you can use it on hexfields, squared fields or even on cubes... private ...


1

Imagine the radius is one. That means every point around the circle is exactly one unit away from the center. Now what kind of vectors always have a length of one? Unit vectors of course. You can get a unit vector by normalizing a non-unit vector. Take the vector CA (center to A). Next, normalize CA to make it a unit vector, then scale it by the radius of ...


1

One obvious solution is to store the entityId inside each component structure or class. This way when you need to obtain components or do some entity-specific logic, you already have an easy way to obtain the entityId based on a given component. Another solution that may be a tad more complex but has some useful side affects is to assign each component a ...


1

yeah, all solutions have already been made... i'll just add some more code (i'm rather from stackoverflow ^^) assuming you're using bounding box assuming you use plain java (java.awt) . List<Shape> shapeList = ...; //you know where you get them Shape exampleShape = shapeList.get(0); Rectangle2D boundingBox = exampleShape.getBounds2D(); see ...


1

If you know the canvas is a rectangle then this simplifies to the case of checking if the bounding rectangle of the shape being drawn is contained within the canvas' rectangle. That's a fairly efficient check to run, and (generally) finding the bounding rectangle for your shape should be fairly easy (just finding the minimum and maximum x and y coordinates) ...


1

The setLinearVelocity method literally sets the Box2D body's x- and y-velocities to the given values. That means if the parameter for x is set, the character will begin moving horizontally. However, if the parameter for y is zero, the character will stop moving vertically. To fix this, you could either pass the character's current y-velocity in the ...



Only top voted, non community-wiki answers of a minimum length are eligible