generated from Over-Run/project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
272 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...eeworld.client/src/main/java/freeworld/client/render/world/entity/CubeEntityRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* freeworld - 3D sandbox game | ||
* Copyright (C) 2024 XenFork Union | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; | ||
* only version 2.1 of the License. | ||
*/ | ||
|
||
package freeworld.client.render.world.entity; | ||
|
||
import freeworld.client.Freeworld; | ||
import freeworld.client.render.RenderSystem; | ||
import freeworld.client.render.Tessellator; | ||
import freeworld.client.render.gl.GLDrawMode; | ||
import freeworld.client.render.gl.GLStateMgr; | ||
import freeworld.math.Matrix4f; | ||
import freeworld.world.entity.CubeEntity; | ||
|
||
/** | ||
* @author squid233 | ||
* @since 0.1.0 | ||
*/ | ||
public class CubeEntityRenderer extends EntityRenderer<CubeEntity> { | ||
public CubeEntityRenderer(Freeworld client) { | ||
super(client); | ||
} | ||
|
||
@Override | ||
public void render(GLStateMgr gl, double partialTick, Matrix4f positionMatrix, CubeEntity entity) { | ||
RenderSystem.useProgram(client.gameRenderer().positionColorProgram()); | ||
Tessellator t = Tessellator.getInstance(); | ||
t.begin(GLDrawMode.TRIANGLES); | ||
|
||
// +z | ||
t.indices(0, 1, 2, 2, 3, 0); | ||
t.position(positionMatrix, 0.0f, 1.0f, 1.0f).color(0, 148, 255).texCoord(0, 0).emit(); | ||
t.position(positionMatrix, 0.0f, 0.0f, 1.0f).color(0, 148, 255).texCoord(0, 0).emit(); | ||
t.position(positionMatrix, 1.0f, 0.0f, 1.0f).color(0, 148, 255).texCoord(0, 0).emit(); | ||
t.position(positionMatrix, 1.0f, 1.0f, 1.0f).color(0, 148, 255).texCoord(0, 0).emit(); | ||
|
||
t.end(gl); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...s/freeworld.client/src/main/java/freeworld/client/render/world/entity/EntityRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* freeworld - 3D sandbox game | ||
* Copyright (C) 2024 XenFork Union | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; | ||
* only version 2.1 of the License. | ||
*/ | ||
|
||
package freeworld.client.render.world.entity; | ||
|
||
import freeworld.client.Freeworld; | ||
import freeworld.client.render.gl.GLStateMgr; | ||
import freeworld.math.Matrix4f; | ||
import freeworld.world.entity.Entity; | ||
|
||
/** | ||
* @author squid233 | ||
* @since 0.1.0 | ||
*/ | ||
public abstract class EntityRenderer<T extends Entity> { | ||
protected final Freeworld client; | ||
|
||
protected EntityRenderer(Freeworld client) { | ||
this.client = client; | ||
} | ||
|
||
public interface Factory<T extends Entity> { | ||
EntityRenderer<T> create(Freeworld client); | ||
} | ||
|
||
public abstract void render(GLStateMgr gl, double partialTick, Matrix4f positionMatrix, T entity); | ||
} |
42 changes: 42 additions & 0 deletions
42
.../freeworld.client/src/main/java/freeworld/client/render/world/entity/EntityRenderers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* freeworld - 3D sandbox game | ||
* Copyright (C) 2024 XenFork Union | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; | ||
* only version 2.1 of the License. | ||
*/ | ||
|
||
package freeworld.client.render.world.entity; | ||
|
||
import freeworld.registry.MappedRegistry; | ||
import freeworld.registry.Registries; | ||
import freeworld.registry.Registry; | ||
import freeworld.util.Identifier; | ||
import freeworld.world.entity.Entity; | ||
import freeworld.world.entity.EntityType; | ||
import freeworld.world.entity.EntityTypes; | ||
|
||
/** | ||
* @author squid233 | ||
* @since 0.1.0 | ||
*/ | ||
public final class EntityRenderers { | ||
private static final MappedRegistry<EntityRenderer.Factory<Entity>> REGISTRY = new MappedRegistry<>(Identifier.ofBuiltin("entity_renderer")); | ||
|
||
private EntityRenderers() { | ||
} | ||
|
||
public static void bootstrap() { | ||
register(EntityTypes.CUBE, CubeEntityRenderer::new); | ||
} | ||
|
||
public static <T extends Entity> void register(EntityType<T> entityType, EntityRenderer.Factory<T> renderer) { | ||
Registry.register(REGISTRY, Registries.ENTITY_TYPE.getId(entityType), (EntityRenderer.Factory<Entity>) renderer); | ||
} | ||
|
||
public static Registry<EntityRenderer.Factory<Entity>> registry() { | ||
return REGISTRY; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.