I want to set material on node in libgdx.
My cube is completely filled with one texture and I want one texture to be on one face, and another texture on another face like that.
I set it with model.materials.get(0).set(TextureAttribute.createDiffuse(new Texture("one.png")));
Also i tried set material model.getNode("plane1").parts.get(0).material.set(TextureAttribute.createDiffuse(new Texture("one.png")));, but in this case the game crashes on startup with NullPointerException
Tell me please how you can solve this problem.
Full project https://github.com/D0niL19/Project2
File with a problem
https://github.com/D0niL19/Project2/blob/main/core/src/com/mygdx/game/Screens/PlayScreen.java
Related
I've got a customised instance of GraphEditor in a view in an ASP.NET MVC app and I've got it set to use a database for diagram persistence. When opening, I've programmed it to create a new model to initialise the graph using the model data stored in the database. This works, except that vertexes and edges that were black and white when saved become blue when loaded. I'm guessing there's some default mxGraph style variable that's responsible for this, but I'm not sure. Anyone have any ideas? Thanks!
So, in case it's useful to anyone else, I actually found the solution. The default colours are defined in mxClient as hexadecimals and can be replaced with whatever you want to use.
I am making a simple game using libgdx. I have a TextureAtlas that has I ninepatch I am trying to use:
The image is saved as menu.9.png
I am using the following code:
Image bg = new Image(Room.iAtlas.findRegion("GUI/menu"));
bg.setBounds(guix-border,guiy-border,(border+radius)*2,(border+radius)*2);
batch.begin();
bg.draw(s,1);
batch.end();
The output is like this:
I really just have no idea what I am doing wrong, but it should be more like this(Except it would have the shapes on top of it, but I didn't add those):
(I created that by hand, i've never actually had 9patch working, and it doesn't have the ships because I didn't bother to edit those in)
It looks like your "nine patch" isn't being treated as a real nine path, and is being treated as a "degenerate" nine patch (I had a very similar problem earlier: Loading nine-patch image as a Libgdx Scene2d Button background looks awful, though I wasn't using a TextureAtlas which is supposed to be the solution.)
Basically, when Libgdx reads the nine-patch out of your atlas, its supposed to read all the meta-data that describes how to chop the image up into 9 tiles (see https://code.google.com/p/libgdx/wiki/TexturePacker#NinePatches). I see a couple places this could go wrong:
Your texture isn't a valid nine-patch, and the meta-data is being ignored. (Check with the Android draw9patch tool.)
Your texture packer isn't processing the .9.png file correctly. Check the contents of the .txt file for your atlas, and see if it has "split" entries associated with the "menu.9.png" entry.
The texture lookup is just returning a regular TextureRegion wrapper for the nine-patch region, and isn't wrapping it in a NinePatch object. Try using TextureRegion.createNinePatch to make that more explicit. (I'm under the impression that this isn't necessary, but maybe it is ...)
Im am working in Direct3d11 with Windows 8 Store apps.
I have been searching google and missing a few points, that i would be happy if someone could point out for me.
So far i have managed to created buffers, shaders and getting a texture sampled with D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST and i can ofcause change it to a LINELIST and get a line of my points.
What am I to look for when i want to draw the texture and also draw some lines or a trianglelist as lines ontop of the texture. I want to show the texture and a mesh ontop of it.
What are my next step.
A simple approach would be to fist render the object setting the render state to D3D11_FILL_SOLID. Then render the same object again but setting the render state to D3D11_FILL_WIREFRAME.
The "wireframe pass" shader can be very simple based on your needs, just remember to change the shading from the regular pass or else you wont be able to see the wireframe.
I have coded two programs using flash cs5.5. Both of them use addFrameScript to organize the code on each frame.
The first one I exported on Air For Android and had no problem with it.
The second one I exported on Air 2.6 and a problem occurred.
If I go from frame to frame in order (using gotoAndStop()) then frame script loads perfectly.
But when I use the same method (gotoAndStop()) to go back to a previous frame, all of the stage instances on my lower layers are not loaded properly so I get ERROR 1009: Cannot access a property or method of a null object reference
Funny thing, when I move them up to the first two layers, things start working again.
But I still want to keep them in their own layers. Some help please?
Thanks in advance
EDIT 1:
I just found out that if move them up to a new layer then the older elements in that layer will not be loaded properly. It's like only the first few children of the display list are loaded.
EDIT 2:
If I change it to Air For Android, the problem disappears !! my mind is blowing right now
I've built a photo booth app for an installation and I need to take a screen shot of the bitmap data with it's frame... I foolishly nested my objects all wrong way too early in the game so taking a picture of just the display object is moot at this juncture, and I dont have time to re-organize everything.
I know the encoder can output stills of the stage, but can that be a defined set of coords? I have an 800x600 region that needs to output, ignoring the rest of the stage.
I am playing with other options as well, but if there is anything that seems obvious, i would greatly appreaciate it!
You can get the whole stage as a bitmap data and then use the copypixels method to copy the region you need.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html#copyPixels%28%29
Or you can use the draw method of BitmapData class to draw a display object into that bitmap data.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html#draw%28%29