Libgdx rendering floor for 3D game

In my first 3D game, I now want to make a floor, which is actually a plane (not libgdx Plane) on y = 0.

I want to add to it Texture, so I can have different floors at each level.

Now my question is: what is the best way to create and render this textured floor?

I thought about using the basic Block Modelsone done with help ModelBuilder, and then added Texture, but since I can only see 1 out of 6 faces, 2d Texturewill be enough, so I thought about Plane.

Can I add Texturein Plane, since this is an infinite face in a 3D room? The last thing I thought about was Decals.

Are Decalwhat I'm looking for? And how can I use them? Or you have another solution.

Any tutorial or other help would be great.

thank

+3
source share
1 answer

First, about labels, stickers are similar to sprites, but in the 3d coordinate, use them like this:

private sticker with the inscription; Private DecalBatch decalBatch;

in show () or create ()

decalBatch = new DecalBatch();
CameraGroupStrategy cameraGroupStrategy = new CameraGroupStrategy(camera);
decal = Decal.newDecal(textureRegion, true);
decal.setPosition(5, 8, 1);
decal.setScale(0.02f);
decalBatch.setGroupStrategy(cameraGroupStrategy);

in render ()

//Add all your decals then flush()
decalBatch.add(decal);
decalBatch.flush();

also have decalBatch.dispose ();

note that in the future the decal will become part of 3d, I personally do not recommend using Decals like me using a 3d plane, and I saw some problems with it, to use using a 3d plane like this, I insert some of my codes here

private Model createPlaneModel(final float width, final float height, final Material material, 
            final float u1, final float v1, final float u2, final float v2) {

modelBuilder.begin();
MeshPartBuilder bPartBuilder = modelBuilder.part("rect", 
GL10.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.TextureCoordinates, 
material);
//NOTE ON TEXTURE REGION, MAY FILL OTHER REGIONS, USE GET region.getU() and so on
bPartBuilder.setUVRange(u1, v1, u2, v2);
        bPartBuilder.rect(
                -(width*0.5f), -(height*0.5f), 0, 
                (width*0.5f), -(height*0.5f), 0, 
                (width*0.5f), (height*0.5f), 0, 
                -(width*0.5f), (height*0.5f), 0,
                0, 0, -1);


        return (modelBuilder.end());
    }

texture can be added as a material attribute

material.set(new TextureAttribute(TextureAttribute.Diffuse, texture)

, -

attributes.add( new BlendingAttribute(color.getFloat(3)));          
attributes.add( new FloatAttribute(FloatAttribute.AlphaTest, 0.5f));

material.set(attributes);

ModelInstance,

modelInstance = new ModelInstance(createPlaneModel(...))

render() ModelBatch

modelBatch.render(modelInstance );

. . http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=11884

http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=12493

+5

All Articles