Issue with point lights when on mobile - gluon

it seems to me that PointLight do not light the scene properly when running an app on Android. Event though this was coded using Gluon Mobile, it seems to me that this is a javafxport or JavaFX 3D issue.
Here's a demo View that demonstrate the issue:
import com.gluonhq.charm.glisten.application.MobileApplication;
import com.gluonhq.charm.glisten.control.AppBar;
import com.gluonhq.charm.glisten.mvc.View;
import com.gluonhq.charm.glisten.visual.MaterialDesignIcon;
import javafx.animation.Interpolator;
import javafx.animation.TranslateTransition;
import javafx.scene.PointLight;
import javafx.scene.SubScene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Sphere;
import javafx.util.Duration;
public final class LightView extends View {
public LightView() {
setOnShown(event -> build3DContent());
}
private void build3DContent() {
Sphere sphere = new Sphere();
sphere.setRadius(100);
sphere.setTranslateX(getWidth() / 2d);
sphere.setTranslateY(getHeight() / 2d);
final PointLight light = new PointLight(Color.WHITE);
light.getScope().add(sphere);
light.setTranslateZ(-300);
light.setTranslateY(getHeight() / 2d);
final Pane root = new Pane();
root.getChildren().addAll(sphere, light);
SubScene subScene = new SubScene(root, getWidth(), getHeight());
setCenter(subScene);
final TranslateTransition animation = new TranslateTransition(Duration.seconds(2));
animation.setNode(light);
animation.setToX(getWidth());
animation.setAutoReverse(true);
animation.setCycleCount(TranslateTransition.INDEFINITE);
animation.setInterpolator(Interpolator.EASE_BOTH);
animation.playFromStart();
}
#Override
protected void updateAppBar(AppBar appBar) {
appBar.getActionItems().add(MaterialDesignIcon.ARROW_BACK.button(event -> MobileApplication.getInstance().switchView(MobileApplication.HOME_VIEW)));
}
}
When running on desktop on Windows, the PointLight is centered on the Y axis and the animation makes it move left and right of the sphere. The sphere itself is also centered on the Y axis so the light runs though its equator. But when running on Android, the sphere is centered but the light only illuminates the top of the sphere. Coordinates of the PointLight appear correct though. This was not tested on ARM (Pi), iOS simulator or iOS device or any other desktop OS.
Desktop version Android version
Here's another more complex example with a planet illuminated by 3 point lights. Light1 is positioned center left and in front of the sphere, light2 is positioned center right and behind the sphere and light 3 is positioned freely in front of the sphere by moving the white dot with the mouse or by tap moving. All point lights coordinates appear correct but the illuminations are definitely not correct when running on Android. Everything looks fine when running on Windows.
Desktop version Android version
Additional info:
Windows 10 Version 10.0.16299.371
JDK 9.0.1
Android Samsung Galaxy 8 Plus Android 8.0.0 security patch April 2018
Intellij IDEA 2018.1.1
Gluon (from build.graddle)
JavaFXPorts 2.0.19
source compatibility 1.8
target compatibility 1.8
Gluon Charm 5.0.0-jdk9
Gluon Charm Down config 3.8.0
Note: I was suggested to post this issue to StackOverflow after I contacted Gluon's support directly.
EDIT - spelling

Related

How to fix Blue Screen appearing after GameObject is removed in Unity 2d Project

I have been successfully building and running a Unity 2D game, but started receiving a Blue Screen during one of my operations. Specifically, when I close a popup and remove all of its child Game Objects, the entire Game Screen turns dark blue (the default background color of the main camera). The music for the game still plays and clicks are still registered if you click in the right area (I can still press the back button, just can't see it).
If I remove 1 gameobject, this problem doesn't come up. But once I have to remove 2 game objects, the entire screen turns blue.
This is my function for removing my game object in case it helps, which works perfectly when it comes to actually removing the gameObjects correctly (game objects to be removed are created from prefabs). I think the problem may be with the camera for some reason, but I have no clue as to why it happens on this function.
public void Remove(int index)
{
float toggleWidth = toggle.GetComponent<RectTransform>().sizeDelta.x;
DestroyImmediate(scrollSnap.pagination.transform.GetChild(scrollSnap.NumberOfPanels - 1).gameObject);
scrollSnap.Remove(index);
scrollSnap.pagination.transform.position += new Vector3(toggleWidth / 2f, 0, 0);
}
I don't receive any errors or warnings in the console. Just a blue screen once more than one GameObject is removed
EDIT:
Turns out my main Canvas's planeDistance was being changed from 100 to 3200. I still have no clue as to why this change occurred...but for anyone else having a similar issue with a dark blue screen appearing in the middle or start of their game, then please check the values your canvas and camera in the Inspector. Simply controlling the planeDistance did the trick for me!
Made a new scene next to the sample scene when i started my sprite learning game. Forgot all about that.
When I had to publish it, In the Build Settings, I had the wrong scene selected. So It published an empty scene instead of my game.
I solved it by putting game in 3d mode and realized that the camera is positioned very far from the sprites, just change the z-axis and again go to 2d mode.
Just Move your camera in Z-axis position, it could be too far from object or it is behind the object, you can also check it by 3D mode the check the object position and change it in positive and negative values.

Unity short Black Screen after loading first scene

Scenes:
1.Splash,
one image with the IEnumerator Start() code as described below.
2.Menu,
Canvas UI with a few buttons and a some gameobjects in the scene as background. Camera has a tonemapping and depth of field script.
Stats: Batches 96, tris 20.4k, 41.5k
3.Main
Main scene of the game.
Bug, happend on android device and on pc in the editor:
1.Splash scene loads the menu scene using:
IEnumerator Start()
{
AsyncOperation async = SceneManager.LoadSceneAsync("Menu");
while (!async.isDone)
{
yield return null;
}
}
2.The canvas UI of the Menu scene appears with a black background, the gameobjects in the scene are not visible, for a few seconds.
3.The canvas UI + the scene is visible.
Same bug happens when the Menu scene is loaded from the Main scene.
Unity version = 2017.3.0f3
Using vuforia in the main scene.
EDIT:
I disabled all the objects and camera effects in the Menu scene except for a plane and the canvas, the canvas still appears a few seconds before the plane.
To describe the bug better, the camera seems to active a second after the canvas UI is shown.
EDIT2:
I created a new camera in the menu scene and the problem still persists.
I found my fix by adding an AR camera to the scene and disabling the the VuforiaBehavior component which was making the black screen when the scene was loading.
In my case, I just had checked Split Application Binary in Publishing settings to be able to upload my game to Play Store. (Play Store does not accept apk files to be bigger than 100mb, so you split your big apk into a smaller apk & a obb file)
However, if you do that, you need to put both your .apk and .obb files to specific folders in your phone, when you are manually testing the game.
.obb needs to be in a specifically named folder, with a specific name, as explained here: http://graphicdna.blogspot.com/2017/06/manually-copying-unitys-apk-and-obb.html
Shortly, name should be in the format:
main.[FIRST_PART_OF_VERSION_NUMBER].[PACKAGE_NAME].obb
Where [FIRST_PART_OF_VERSION_NUMBER] is the highest digit of the version number you can find in the Player Settings. For instance, if your version is 1.0.0, [FIRST_PART_OF_VERSION_NUMBER] is 1.
And [PACKAGE_NAME] is the package name specified in the same screen, right above the version number.
The game will expect to find that OBB file in a location like:
[INSTALL_LOCATION]\Android\obb\[PACKAGE_NAME]
Where [PACKAGE_NAME] is the same value described above, and INSTALL_LOCATION refers to whether the game is installed in the internal memory or the external SD-Card (this depends on your own settings).

Car rig in blender and importing to Unity

I am new to unity and my question is: I am trying to import the rigged car model from blender 2.6 to unity 3.5. but when i import to unity the car physics and it's rig unable to act the same way how it's been created in blender. Please let me know do i need to setup all of the physics and rig in unity once again?
Are you using mesh collider ? Mesh collider only works right if you have a static object.
My recomendation is to use a box collider on car and the whell collider on whells, you can import the animation, and call them using Animation.Play("animation"), and put this on the if (Input.GetKeyDown (Keyboard.A)) for example. Or you can do the animation on unity, pressing CTRL+6
You can take a look on this Unity tutorial for Car games.

how to play two animations in the same time in unity 3D

I'm trying to rotate the Earth around the Sun in Unity 3D..
my question: How to rotates the earth around itself and in the same time it rotates around the sun. I can't do more than one animation for one object in Unity3D?
please,help me.. :)
I will do something like this :
public float speed = 1;
void Update() {
// Slowly rotate the object around its X axis at 1 degree/second.
transform.Rotate(speed * Time.deltaTime, 0, 0);
// ... at the same time as spinning it relative to the Sun
transform.RotateAroud(sun.transform, Vector3.up, speed * Time.deltaTime)
}
from http://unity3d.com/support/documentation/ScriptReference/Transform.RotateAround.html
There are several options in Unity3D to do this like blending, layering, adding and fading. Have a look at Unity - Character Animation and Unity - Animation Scripting
You can play two animations at the same time by creating multiple layers directly inside the unity animator system.Here a useful step by step guide:
http://gamedevelopertips.com/unity-run-2-animations/

Java Swing - Translucent Components

I recently asked a question about translucent components causing odd artifacts from seemingly not updating properly. The answer I received caused the artifacts to go away, but at the cost of translucency.
The solution was to- for every translucent component- also call the setOpaque(false) function. This way, Swing knew that it needed to redraw the background behind those components.
However, this came at the cost of the translucency that I was trying to achieve. It caused the components to become transparent instead.
The premise is this: I am designing the GUI for a chat client, and a feature request was to have a background. I successfully got the background working by following a code snippet for extending the JPanel class, but then I wanted the components to allow the background to show. After setting their translucency, remnants of updated components were being displayed where they shouldn't have been. I came here and got my problem solved, but now I've got a new problem. So here we are.
So, here is what I've surmised:
-Calling the setOpaque(false) function for each desired component and NOT setting a translucent color does not achieve what I want.
-Setting a translucent color and NOT calling setOpaque(false) allows the translucent background to show, but causes artifacts, putting me back at square one.
So I need some middle ground between transparent with no artifacts, and translucent with artifacts. Namely, I want a translucent background (not completely transparent) that has no artifacts.
It seems like I'm going to need to override the JFrame to cause it to repaint all its components, regardless of the opacity. Unless there's something I'm missing.. which is why I'm here!
Thanks!
(Here's a link to the original question, with a picture for reference: Java Swing - Translucent Components causing Artifacts)
One option would be to override the components and draw the background yourself:
class TranslucentLabel extends JLabel {
public TranslucentLabel(String text) {
super(text);
setOpaque(false);
}
#Override
public void paintComponent(Graphics g) {
g.setColor(new Color(255, 0, 0, 64));
Insets insets = getInsets();
g.fillRect(insets.left, insets.top,
getWidth() - insets.left - insets.right,
getHeight() - insets.top - insets.bottom);
super.paintComponent(g);
}
}
EDIT: Alternatively you could draw the translucent background colour for the child components directly onto the panel, then you would not have to override components:
class YourPanel extends JPanel {
#Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D)g.create();
// Draw your background image here to g2d.
g2d.setColor(new Color(255, 0, 0, 64));
Area area = new Area();
for (Component component : getComponents()) {
area.add(new Area(component.getBounds()));
}
g2d.fill(area);
g2d.dispose();
}
}
There is a disadvantage to this approach. If there is a genuinely transparent part of a component (such as a rounded border), then its entire background will be coloured.

Resources