3d Game Programming with Java and libGDX — Hints and Tricks

TL;DR

Always think of performance

Table of contents

  1. Code Related
  2. libGDX related
  3. Model related
  4. Other considerations

Code Related

Pre-compute everything

Don’t create new objects

Watch out for floating point mathematics

Adding 0.0 + 1.392 = 1.392
Adding 1.392 + 1.392 = 2.784
Adding 2.784 + 1.392 = 4.1759996
Adding 4.1759996 + 1.392 = 5.568
Adding 5.568 + 1.392 = 6.96
Adding 6.96 + 1.392 = 8.352
Adding 8.352 + 1.392 = 9.744
Adding 9.744 + 1.392 = 11.136001
Adding 11.136001 + 1.392 = 12.528001
Adding 12.528001 + 1.392 = 13.920001
Adding OFFSET 10 times in a loop = 13.920001
Multiplying OFFSET by 10 = 13.92
  • Choose multiply or add and use it always — multiply is faster, but beware of loops and resetting counters.
  • Round your floats to a number of decimal places (i.e. remove the least significant digits)

Throw some of the core Object Orientated tenets out the window

libGDX related

Model related

Watch for scaling and the models

Invert the textures when you fbx-conv

fbx-conv -v -f -o G3DB medium-rhombic.fbx medium-rhombic.g3db

Multiple models/image textures

// create a new material with an image texturethis.originalMaterial = 
new Material(
TextureAttribute.createDiffuse(
new Texture("textures/texture.png")));

// you will need this line if you have any alpha
(i.e. transparency) in the image
this.originalMaterial.set(
new BlendingAttribute(
GL20.GL_SRC_ALPHA,
GL20.GL_ONE_MINUS_SRC_ALPHA));

// clear the material which was loaded with the model
this.materials.get(0).clear();
// set the material on the model
this.materials.get(0).set(originalMaterial);

Other considerations

Load time is better than wait time

Screen planning

All sorts of interests

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Does the Oracle Explain Plan command really show the execution plan that will be used?

How to secure your Nginx website with SSL using Let’s Encrypt on Ubuntu 18.04

Understanding Discord — Scheduled Events

V20 Lydia is live

Thanks You To The A&Q Community For Participating In Ask Me Anything ( AMA ) With IoTeX On October…

A Jumping Jacks Exercise Trainer

What are Dedicated SQL Pools in Azure Synapse Analytics

Google Training: Day 4

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
synapticloop

synapticloop

All sorts of interests

More from Medium

Types of Update operations in MongoDB using Spring Boot

Spring boot

Local variables with “var” since Java 10

Implementing Google ReCaptcha in Angular and Java Spring boot