Comments (5)
it looks like you didn't configure enough bones with your scene manager (default is 12 like libgdx classic). For instance, if you have up to 36 bones in your models, configure it like this :
new SceneManager(36);
Note that it has to be configured up front because scene manager don't know how many bones a scene would require.
from gdx-gltf.
note that you can get number of bones required by your scene : SceneAsset#maxBones
from gdx-gltf.
@waverider404 i think you make confusion between SceneAsset#maxBones and shader Config#numBones :
- SceneAsset#maxBones give you how many bones you have in your model file
- Config#numBones must be set to render these bones (default is 12)
Also, you may want to use PBRShaderProvider in order to enable other GLTF features (not mandatory but recommended), see example code. If you really want to use your own ModelBatch, you can create it like this : new ModelBatch(PBRShaderProvider.createDefault(maxBones))
If you have further questions, we can talk about it on discord ;-)
from gdx-gltf.
I guess i still have the same issue:
Model url: https://cdn.glitch.com/ca440387-5ef4-4401-a707-6a988d4e8bc5%2Fcynthia.glb?v=1585537867699
Here's my code:
`package com.mygdx.game;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.PerspectiveCamera;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
import com.badlogic.gdx.graphics.g3d.Environment;
import com.badlogic.gdx.graphics.g3d.Model;
import com.badlogic.gdx.graphics.g3d.ModelBatch;
import com.badlogic.gdx.graphics.g3d.ModelCache;
import com.badlogic.gdx.graphics.g3d.ModelInstance;
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute;
import com.badlogic.gdx.graphics.g3d.environment.DirectionalLight;
import com.badlogic.gdx.graphics.g3d.Material;
import com.badlogic.gdx.graphics.g3d.utils.AnimationController;
import com.badlogic.gdx.graphics.g3d.utils.CameraInputController;
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder;
import com.badlogic.gdx.physics.bullet.Bullet;
import com.badlogic.gdx.physics.bullet.collision.btCollisionObject;
import com.badlogic.gdx.utils.Array;
import net.mgsx.gltf.loaders.gltf.GLTFLoader;
import net.mgsx.gltf.loaders.glb.GLBLoader;
import net.mgsx.gltf.scene3d.attributes.PBRCubemapAttribute;
import net.mgsx.gltf.scene3d.attributes.PBRTextureAttribute;
import net.mgsx.gltf.scene3d.scene.Scene;
import net.mgsx.gltf.scene3d.scene.SceneAsset;
import net.mgsx.gltf.scene3d.scene.SceneManager;
import net.mgsx.gltf.scene3d.scene.SceneSkybox;
import net.mgsx.gltf.scene3d.utils.EnvironmentUtil;
public class MyGdxGame extends ApplicationAdapter {
public Environment environment;
public PerspectiveCamera cam;
public CameraInputController camController;
public ModelBatch modelBatch;
public Model model;
public ModelInstance instance;
public Array trees = new Array();
public ModelCache treeCache; //needed to reduce draw calls!
AnimationController controller;
ModelInstance player;
private SceneManager sceneManager;
private Scene scene;
private float time;
@OverRide
public void create() {
Bullet.init();
btCollisionObject groundObject = new btCollisionObject();
CharSequence str = groundObject.toString();
System.out.println(str);
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
modelBatch = new ModelBatch();
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(10f, 10f, 10f);
cam.lookAt(0,0,0);
cam.near = 1f;
cam.far = 300f;
cam.update();
SceneAsset model_asset = new GLBLoader().load(Gdx.files.internal("room.glb"));
this.instance = new ModelInstance(model_asset.scene.model);
this.instance.transform.scale(8.5f, 8.5f, 8.5f);
SceneAsset player_asset = new GLBLoader().load(Gdx.files.internal("cynthia.glb"));
player_asset.maxBones = 36;
player = new ModelInstance(player_asset.scene.model);
player.transform.scale(2.05f, 2.05f, 2.05f);
controller = new AnimationController(player);
controller.setAnimation("Armature|mixamo.com|Layer0", -1);
this.trees.add(this.instance);
// this.trees.add(player);
camController = new CameraInputController(cam);
Gdx.input.setInputProcessor(camController);
}
@Override
public void render() {
camController.update();
Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
controller.update(Gdx.graphics.getDeltaTime());
modelBatch.begin(cam);
modelBatch.render(player);
modelBatch.render(trees, environment);
modelBatch.end();
}
@Override
public void dispose() {
modelBatch.dispose();
trees.clear();
}
@Override
public void resize(int width, int height) {
}
@Override
public void pause() {
}
@Override
public void resume() {
}
}`
from gdx-gltf.
This helped me a lot. I wasn't using SceneManager at all (I only extract the model from SceneAsset), and am new to GDX, so was confused by the earlier advice. Instead, I needed to configure the numBones
value on my ShaderProvider
before passing it to my ModelBatch
:
(Kotlin but hope it's readable for Java folks)
fun createShaderProvider(): ShaderProvider {
val config = DefaultShader.Config()
config.numBones = 50
return DefaultShaderProvider(config)
}
// ...
val modelBatch = ModelBatch(createShaderProvider())
from gdx-gltf.
Related Issues (20)
- Model loading error: "Cannot read field "size" because "group" is null"
- Cascade Shadow Map shows shadow "clamping" when enabled HOT 1
- The GlbExporter is missing. HOT 5
- Ability to use custom DirectionalShadowLight into CascadeShadowMap
- Systematic OpenGL error when using unlit material in combination with CSM
- Cannot use pattern matching in instanceof due to "sourceCompatibility = 1.8" in gradle build HOT 1
- Native memory leak: pixmaps are never released HOT 4
- IBL: ability to create different sized maps for Skybox and radiance HOT 1
- Specular color texture is never passed to the PBR shader HOT 2
- Android error on reading gltf files when minify is enabled HOT 5
- the android module is disabled and app can not run success
- Model transparent sorting HOT 1
- RFE: Implement support for C_UINT, unsigned integer indices
- GLTF extensions: KHR_mesh_quantization
- How to render a transparent object which receive shadows? HOT 1
- [Feature Request] Add Spherical Harmonics to PBR light shader HOT 2
- MeshLoader. Add model file name to message [suggestion] HOT 1
- Add support for hiding mesh parts HOT 1
- Ability to pass a custom RenderableSorter to TransmissionSource batch
- Pixmaps: novel about unpredictable disposing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gdx-gltf.