I've drawn a 3D cube on an applet, it appeared fine, then I translated it to another coordinates and painted in again. So now I have both cubes on the applet.
But the second cube appeared distorted, How can I fix it???
I tried using a Buffered Image, it appeared fine, but in my project I'm not supposed to use it. Because at the end it's supposed to be animated all with translations and rotations. so using a Buffered Image would be useless here.
Any ideas?
for every frame, you have to draw the background, so the previously drawed gets deleted, and then draw the cube again.
However, If you wanna do more complicated 3d things, jME is a good, easy to understand 3d engine.
Related
For reference the effect I'm going for is this:
I'm working in Processing 3, NOT p5.js.
I've looked around processing forums, but i can't find anything that works in the current version or doesn't use PGraphics and a mask which from what I've read can be expensive to use.
My current ideas and implementations have resulted to drawing shapes around the player and filling the gaps in with a circles with no fill that has a large stroke weight.
Does anyone know of any methods to easily and inexpensively draw a black background over everything except a small circular area?
If this is the wrong place to ask this question just send me on my way I guess, but please be nice. Thank you:)
You could create an image (or PGraphics) that consists of mostly black, with a transparent circle in it. This is called image masking or alpha compositing. Doing a Google image search for "alpha composite" returns a bunch of the images I'm talking about.
Anyway, after you have the image, it's just a matter of drawing it on top of your scene wherever the player is. You might also use the PImage#mask() function. More info can be found in the reference.
I thought about the best way to draw a picture in OpenGL / JOGL.
I currently program a Game and it is my goal to save the information about a picture in a text file instead of saving the picture.
My idea was to program a method that saves every pixel information (RGB) at the position of X and Y.
Then I draw every pixel and it is finished.
What you think about that idea?
You should simply use TextureIO to make a texture from your picture and use this texture with 4 vertices that have some texture coordinates while drawing. glReadPixels() is very slow, reading each pixel of a picture would take a lot of time, saving its content as a text file would require a lot of memory (saving it as a compressed image in a loss-less format like PNG might be worth a try), drawing each pixel one by one would be a lot slower than drawing a texture. derhass is right. You could vectorize your picture (make a SVG from it) but you would have to rasterize it after or you would have to implement some rendering of vectorized contents and it would be probably slower than using a texture. I'm not sure you really need an offscreen buffer.
I had a similar problem when I began working on my first person shooter. I wasn't using JOGL at the very beginning, I reused the source code of someone else, it relied on software rendering in an image, it was very slow. Then, I used JOGL to draw each pixel one by one instead of using Java2D, it was about 4 times faster on my machine but still very slow for me. At the end, I had to redesign the whole rendering to use OpenGL for what it is for as derhass would say, I used triangles, quads and textures. The performance became acceptable and this is what you should do, use OpenGL to draw primitives and clarify what you're trying to achieve so that we can help you a bit better.
I have a 3D scene that runs on libGDX(Android). I want to use particle system. When I create one using the tutorials/examples found online (e.g. Particle System libGDX) I get a particle system which works fine. Except for one thing: it is fixed on screen.
When I move the camera around the particle system stays on the same place on screen (like a fixed HUD element or so). Maybe it's because of Sprite-nature of ParticleEffect.
The other issue related is that the ParticleEffect.setPosition() method takes values not in the World coordinates but in screen pixels. Is this correct? I can calculate new on-screen coordinates in pixels and update ParticleEffect position every frame. But that seems like a hack to me.
Is there a more "right" way to make my particle system behave like other objects in my 3D scene and not be fixed on screen?
The Particle System is just working in 2D System. It's not a 3D Particle System thats why you wont get it into your world. That's why it's inside of the g2d package (graphics 2D). Thats also the reason why it just take 2D cords and not 3D cords.
Also the Feature list says that it's inside of the 2D Highlevel API.
Featurelist
I'm making a 2D Java program with LWJGL and its OpenGL. It uses LWJGL's display.
I would like one image to show above the second image on screen, but it's blocked out, I assume by default. Does LWJGL have a setting so that the image has 'priority' over the background, so that it sends the image in front of it?
OpenGL has no concept of "priority" in the way you mean. If there is no depth testing (or other testing), then what you see is in the order you gave it to OpenGL. So if you want something to appear on top of something else, it is up to you to draw it after what it should appear on top of.
I'm developing 2D Side Scroll Android Game, using AndEngine.
I have problem with tiles quality.
If I will use DEFAULT texture option, for my texture congaing tiles, it doesn't look perfect, contours ARE NOT smooth, etc:
DEFAULT Texture options, uses such OPEN GL parameters:
new TextureOptions(GL10.GL_NEAREST, GL10.GL_NEAREST, GL10.GL_CLAMP_TO_EDGE, GL10.GL_CLAMP_TO_EDGE, GL10.GL_MODULATE, true);
But lately I realized, that if I will use such parameters (similar to BILINEAR parameters, except last one)
new TextureOptions(GL10.GL_LINEAR, GL10.GL_LINEAR, GL10.GL_CLAMP_TO_EDGE, GL10.GL_CLAMP_TO_EDGE, GL10.GL_MODULATE, true)
graphic looks smooth (i would say perfect, check image below)
Everything would be perfect, but while moving camera (Camera is chasing player) there are visible contours of those sprites, like for example on this screen:
I have been trying to use different OPEN GL parameters, but with no luck. I would be grateful for some help. With DEFAULT texture option, such problem doesn't exist, but quality is bad. Thanks.
Ps: I have been trying to cast integer on my setCenter method inside camera, but with no luck, some people were saying it should help, but it didn't.
This occurs because the function that is used for smoothing out the textures uses pixels that are outside of the pictures on the Texture Atlas. These are black by default so the pixels on the edges are poisoned by the black area outside.
I have temporarily fixed the issue by extending the picture an all sides by 1px and putting there a copy of the adjacent 1px line from the picture. Then I set my TextureRegion to contain only the middle of the picture with the padding being outside. The results are probably not perfect but the lines are no longer noticeable.
I have seen someone on the AndEngine forums say that in the newest version the problem is fixed, so you may try updating.