Animate an existing model with Java? - java

Imagine I have a model that I want to use in a LibGDX game project (as described here). Let's say, it's the model of a human. Now I want to do several animations with this human: I want him to raise his left/right arm, his left/right leg, to raise a single finger, and also all possible combinations of those animations.
My question is: Do I need to create a single animation for all of those movements outside of my Java code (which would mean I need a file for every single animation and would make my project extremly large), or is it somehow possible to create a model (e.g. by using Blender's Armature or something like that) that can be transformed inside my Java code?

Assuming you're asking if you can include one or more animations with the g3db/g3dj file format. Yes you can. Just create your model, including the skeleton and animations. Export it to FBX (with animation enabled). Next, convert to g3db or g3dj (fbx-conv -f file.fbx). Load your model as described in the tutorial you referenced. Now you can animate your model using an AnimationController. If you want to combine multiple animations at the same time, you can use multiple AnimationControllers, as long as they don't affect the same bones.

Related

Advices to improve performance in javafx

I'm working on an app where I need to draw a lot of data. There are different functions that can be used to work with the data. The main functions share two views, that right now I draw every time I start the functions. They differ in the middle part where the data is displayed different. Right now my main goal is to improve the performance of the app. When I switch from view A to B runs smoother than the other way around. My idea is to store all the parts (from all views) in a list so when I jump back to the view I can reuse them instead of building them again. Is this a good idea? Are there some general performance advices when building an app with javafx?
In GUI desktop development, there is a technique named "double buffering", which is useful to make fast screen flips:
It consists on having two separated and different panels that occupy the whole application viewport and that must be permanently updated, but just one of them must be visible at the same time. Changing from one to another is as fast as to hide one of them and to show the other one.

Why LibGDX doesn't have update and render separated?

I am working currently with LibGDX and Java.
Im wonder me, why LibGDX give you only a render Mehtod for game logic and rendering.
Why LibGDX do this, why LibGDX does not inherited another mehtod like update ?
And should I handle game Logic and rendering in the render method(Of course I split it in an render and update method)
Both render and update methods would be called consecutively if they existed. So there is not much point in separating them and complicating the API.
Of course, if you like, you can create two different methods and call them in provided render method (if you want to separate stuff). You can also conditionally call them if you sometimes want to call only update or only render.
The point here is that it serves simple purposes to have them combined and if you want advanced stuff you can always extend the functionality.

Concept of User Controls in LibGDX

I have a screen in my LibGDX game that will be essentially two columns, the first being 75% of the real estate and containing labels/buttons, and the next being 25% that will contain text and images. It is pretty complicated to include all of the code directly in the screen itself for this.
What I would like to do is to have one object contain the logic for the left side of the screen, and one for the right. This would be similar to ASP.NET, where I have a page, with one user control for the left content, and one for the right.
How can this be setup in a LibGDX screen?
I recommend you use scene2D and create new class for each element.
For example, you can create one class that extends Group for each side. Then you can add a ClickListener to group or to each Actor of the group with your logic.
Actually there are alot of ways you could do this. You can handle the events yourself by checking the if something is touched and if so, you do handle it yourself by the position.
On the other side you can use the scene2D system by creating Actors inside of a Stage and set the inputprocessor to the stage. In that case every event is given to the actors and if its inside of his bounds he does handle it depending on the implemented way (Take a look at this: ActionListenes).
So in your case you could create 2 Actors which are invisible
and everyone of it has its side.
You could also use the Button
from libgdx and use this without a background/foreground or such. Simply set the right sizes and make it invisible by the alpha or no background.
or you do check in every cycle of the gameloop if something is touched and if so you do handle the event as you whish. Take a look at this: input polling and creating an input processor

What is the best way to manage application screens in SWT?

I'm creating a standalone SWT desktop application that has around 10 different screens (few wizards, help, forms, etc). Some elements on screen don't change at all (like header, background, etc) and there is a working area that changes depending on what is clicked, etc.
What is the best way to manage application screens? Do I need to create all screen at startup and then show/hide them depending on what is clicked? Or do I need to create those screens dynamically?
Also, I couldn't find any way to show/hide a Composite, do I need to dispose it and then create again?
What is the best practice? I'm new to SWT developing outside of Eclipse so any help would be beneficial.
Deciding whether to create screens up front or creating them the first time they need to be displayed is a decision that needs to be made on a per application basis. If there is a good chance that all the screens are going to need to be used on a particular application run and the number of screens is low (10 screens is relatively low) then you may want to create them at application startup so the UI is snappier once the application loads.
If you use bindings then you may need to come up with a dispose strategy (even if you only dispose the bindings) so you don't have too many events flying around.
Control has a setVisible(boolean) method (and Composite inherits from Control) which you can use to show and hide a component. Note this will only prevent the composite from being shown on the screen, the layout manager will still allocate a blank space for it. Many SWT layouts have a way to exclude a control from the layout which will get rid of the blank space. For example if you are using GridLayout then you would set the exclude variable on you GridData object to true when you hide that control.
Another option is to use StackLayout. This lets you stack a bunch of Composites on top of each other and then choose which on is on top. This might be a good fit for you if you have static areas plus a working area like you described. I would put the header, footer, and an empty composite with a StackLayout in a class file. I would then put each screen that will be displayed in the working area in their own classes. You can either have these screen classes extend Composite and then set up themselves in the constructor or you can use a factory method to setup the screen. Either one is a common and acceptable practice and comes down to a matter of taste.

How to make an Advanced user interface in Android?

i wonder how you can make an advanced Android User interface where you can add for example a drag drop and more graphics options? is that by using OpenGl ?!
this is example of UI in iPhone Apps.
example 1
example 2
Thanks
Your examples just seem to be composed of a lot of nice images. Your first example looks pretty static and could probably be made from buttons with custom images and setting lots of backgrounds on your layout items. The second looks like you would need to make a custom Gallery and do a little more manipulation and composition of images so it might be worth your time to go a little lower level for performance.
Basically, you're looking at using a lot of images. You can make them work with existing widgets and components and get the functionality more easily, or you can use OpenGL ect. To get some more flexibility and performance at the cost of having to code all the functionality in yourself.
If you're looking at drag and drop this post points to the source for a ListView with some rudimentary drag and drop functionality.

Categories