block model work
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
9dc6235e4a
commit
f875f4a80f
@ -1,3 +1,3 @@
|
||||
#maven.buildNumber.plugin properties file
|
||||
#Tue Dec 24 16:29:47 EST 2024
|
||||
buildNumber=603
|
||||
#Sat Jan 25 16:45:57 EST 2025
|
||||
buildNumber=605
|
||||
|
||||
@ -1309,6 +1309,9 @@ Procedural block item types
|
||||
|
||||
(01/25/2025)
|
||||
Update flush method in tests to account for faster loading
|
||||
Allow pre-setting queued asset path
|
||||
Fix asset manager texture queueing (was not pushing queued textures into loaded texture map)
|
||||
Model for single block (hooked up to item as well)
|
||||
|
||||
|
||||
|
||||
|
||||
@ -623,6 +623,17 @@ public class Globals {
|
||||
"Textures/color/transparent_yellow.png",
|
||||
"Textures/bloodsplat1.png",
|
||||
};
|
||||
|
||||
/**
|
||||
* The set of models who should correspond to no pose model
|
||||
*/
|
||||
private static String[] defaultModelsWithNoPose = new String[]{
|
||||
AssetDataStrings.POSE_EMPTY,
|
||||
AssetDataStrings.UNITSPHERE,
|
||||
AssetDataStrings.UNITCYLINDER,
|
||||
AssetDataStrings.UNITCUBE,
|
||||
AssetDataStrings.MODEL_BLOCK_SINGLE,
|
||||
};
|
||||
|
||||
/**
|
||||
* Inits default graphical resources
|
||||
@ -659,6 +670,7 @@ public class Globals {
|
||||
assetManager.registerModelWithPath(RenderUtils.createUnitsphere(), AssetDataStrings.UNITSPHERE);
|
||||
assetManager.registerModelWithPath(RenderUtils.createUnitCylinder(), AssetDataStrings.UNITCYLINDER);
|
||||
assetManager.registerModelWithPath(RenderUtils.createUnitCube(), AssetDataStrings.UNITCUBE);
|
||||
assetManager.registerModelWithPath(RenderUtils.createBlockSingleModel(), AssetDataStrings.MODEL_BLOCK_SINGLE);
|
||||
assetManager.addModelPathToQueue("Models/basic/geometry/SmallCube.fbx");
|
||||
assetManager.addModelPathToQueue("Models/basic/geometry/unitcapsule.glb");
|
||||
assetManager.addModelPathToQueue("Models/basic/geometry/unitplane.fbx");
|
||||
@ -669,10 +681,9 @@ public class Globals {
|
||||
|
||||
//init pose models for basic shapes
|
||||
PoseModel emptyPoseModel = PoseModel.createEmpty();
|
||||
assetManager.registerPoseModelWithPath(emptyPoseModel, AssetDataStrings.POSE_EMPTY);
|
||||
assetManager.registerPoseModelWithPath(emptyPoseModel, AssetDataStrings.UNITSPHERE);
|
||||
assetManager.registerPoseModelWithPath(emptyPoseModel, AssetDataStrings.UNITCYLINDER);
|
||||
assetManager.registerPoseModelWithPath(emptyPoseModel, AssetDataStrings.UNITCUBE);
|
||||
for(String modelPath : defaultModelsWithNoPose){
|
||||
assetManager.registerPoseModelWithPath(emptyPoseModel, modelPath);
|
||||
}
|
||||
|
||||
//image panel
|
||||
ImagePanel.imagePanelModelPath = assetManager.registerModel(RenderUtils.createPlaneModel("Shaders/core/imagepanel/imagepanel.vs", "Shaders/core/imagepanel/imagepanel.fs"));
|
||||
|
||||
@ -24,6 +24,17 @@ public class AssetDataStrings {
|
||||
public static final String MODEL_PARTICLE = "particleModel";
|
||||
public static final String TEXTURE_PARTICLE = "particleTexture";
|
||||
public static final String POSE_EMPTY = "poseEmpty";
|
||||
public static final String MODEL_BLOCK_SINGLE = "modelBlockSingle";
|
||||
|
||||
/**
|
||||
* Fundamental textures of the engine
|
||||
*/
|
||||
public static final String TEXTURE_TEAL_TRANSPARENT = "Textures/color/transparent_teal.png";
|
||||
|
||||
/**
|
||||
* Atlas texture paths
|
||||
*/
|
||||
public static final String TEXTURE_BLOCK_ATLAS = "textureBlockAtlas";
|
||||
|
||||
/**
|
||||
* UI textures
|
||||
|
||||
@ -164,7 +164,7 @@ public class AssetManager {
|
||||
queuedAsset.load();
|
||||
if(queuedAsset.get() instanceof Model){
|
||||
this.modelsLoadedIntoMemory.put(queuedAsset.getPromisedPath(),(Model)queuedAsset.get());
|
||||
} else if(queuedAsset.get() instanceof Model){
|
||||
} else if(queuedAsset.get() instanceof Texture){
|
||||
this.texturesLoadedIntoMemory.put(queuedAsset.getPromisedPath(),(Texture)queuedAsset.get());
|
||||
}
|
||||
}
|
||||
@ -622,9 +622,21 @@ public class AssetManager {
|
||||
this.queuedAssets.add(asset);
|
||||
|
||||
//promise a specific string for this asset
|
||||
UUID newUUID = UUID.randomUUID();
|
||||
String promisedPath = newUUID.toString();
|
||||
asset.setPromisedPath(promisedPath);
|
||||
String promisedPath;
|
||||
if(asset.suppliedPath()){
|
||||
promisedPath = asset.getPromisedPath();
|
||||
if(promisedPath == null || promisedPath == ""){
|
||||
String message = "Queued an asset with an empty promised path!" +
|
||||
" " + promisedPath +
|
||||
" " + asset
|
||||
;
|
||||
throw new Error(message);
|
||||
}
|
||||
} else {
|
||||
UUID newUUID = UUID.randomUUID();
|
||||
promisedPath = newUUID.toString();
|
||||
asset.setPromisedPath(promisedPath);
|
||||
}
|
||||
|
||||
queuedAssetLock.unlock();
|
||||
|
||||
|
||||
@ -34,4 +34,10 @@ public interface QueuedAsset<T> {
|
||||
*/
|
||||
public void setPromisedPath(String promisedPath);
|
||||
|
||||
/**
|
||||
* True if the path to register this asset was supplied while it was being queued, false if the promised path should be generated when it is placed in queue
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean suppliedPath();
|
||||
|
||||
}
|
||||
|
||||
@ -79,4 +79,9 @@ public class QueuedModel implements QueuedAsset<Model> {
|
||||
return model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean suppliedPath() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -67,6 +67,11 @@ public class QueuedTexture implements QueuedAsset<Texture> {
|
||||
*/
|
||||
String promisedPath;
|
||||
|
||||
/**
|
||||
* true if the path to register this asset was supplied while it was being queued, false if the promised path should be generated when it is placed in queue
|
||||
*/
|
||||
boolean suppliedPath = false;
|
||||
|
||||
/**
|
||||
* Creates the queued texture object
|
||||
* @param buffer The data to buffer
|
||||
@ -142,6 +147,18 @@ public class QueuedTexture implements QueuedAsset<Texture> {
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the queued texture object
|
||||
* @param path The path to register this texture to
|
||||
* @param image the image to load to gpu
|
||||
*/
|
||||
public static QueuedTexture createFromImage(String path, BufferedImage bufferedImage){
|
||||
QueuedTexture rVal = QueuedTexture.createFromImage(bufferedImage);
|
||||
rVal.promisedPath = path;
|
||||
rVal.suppliedPath = true;
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
switch(this.type){
|
||||
@ -208,4 +225,9 @@ public class QueuedTexture implements QueuedAsset<Texture> {
|
||||
return texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean suppliedPath() {
|
||||
return suppliedPath;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ public class InitialAssetLoading {
|
||||
Globals.profiler.endCpuSample();
|
||||
|
||||
//queue to asset manager
|
||||
atlasQueuedTexture = QueuedTexture.createFromImage(image);
|
||||
atlasQueuedTexture = QueuedTexture.createFromImage(AssetDataStrings.TEXTURE_BLOCK_ATLAS, image);
|
||||
Globals.assetManager.queuedAsset(atlasQueuedTexture);
|
||||
|
||||
|
||||
|
||||
@ -122,7 +122,7 @@ public class Item extends CommonEntityType {
|
||||
|
||||
|
||||
NonproceduralModel modelData = new NonproceduralModel();
|
||||
modelData.setPath(AssetDataStrings.UNITCUBE);
|
||||
modelData.setPath(AssetDataStrings.MODEL_BLOCK_SINGLE);
|
||||
GraphicsTemplate blockItemGraphicsTemplate = new GraphicsTemplate();
|
||||
blockItemGraphicsTemplate.setModel(modelData);
|
||||
rVal.setGraphicsTemplate(blockItemGraphicsTemplate);
|
||||
|
||||
@ -384,7 +384,7 @@ public class RenderUtils {
|
||||
|
||||
//setup extra structures
|
||||
Material mat = new Material();
|
||||
mat.set_diffuse("Textures/color/transparent_teal.png");
|
||||
mat.set_diffuse(AssetDataStrings.TEXTURE_TEAL_TRANSPARENT);
|
||||
sphereMesh.setMaterial(mat);
|
||||
sphereMesh.setShader(VisualShader.smartAssembleShader(false, true));
|
||||
GL40.glBindVertexArray(0);
|
||||
@ -439,7 +439,7 @@ public class RenderUtils {
|
||||
|
||||
//setup extra structures
|
||||
Material mat = new Material();
|
||||
mat.set_diffuse("Textures/color/transparent_teal.png");
|
||||
mat.set_diffuse(AssetDataStrings.TEXTURE_TEAL_TRANSPARENT);
|
||||
sphereMesh.setMaterial(mat);
|
||||
sphereMesh.setShader(VisualShader.smartAssembleShader(false, true));
|
||||
GL40.glBindVertexArray(0);
|
||||
@ -526,7 +526,7 @@ public class RenderUtils {
|
||||
|
||||
//setup extra structures
|
||||
Material mat = new Material();
|
||||
mat.set_diffuse("Textures/color/transparent_teal.png");
|
||||
mat.set_diffuse(AssetDataStrings.TEXTURE_TEAL_TRANSPARENT);
|
||||
sphereMesh.setMaterial(mat);
|
||||
sphereMesh.setShader(VisualShader.smartAssembleShader(false, true));
|
||||
GL40.glBindVertexArray(0);
|
||||
@ -536,6 +536,93 @@ public class RenderUtils {
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a unit cylinder model
|
||||
* @return The model
|
||||
*/
|
||||
public static Model createBlockSingleModel(){
|
||||
Model model = new Model();
|
||||
Mesh cubeMesh = new Mesh("cube");
|
||||
cubeMesh.generateVAO();
|
||||
|
||||
//buffer coords
|
||||
int numTriangles = 12;
|
||||
|
||||
//verts
|
||||
BufferUtils.createFloatBuffer(3 * 8);
|
||||
FloatBuffer verts = BufferUtils.createFloatBuffer(3 * 8);
|
||||
verts.put(new float[]{
|
||||
-0.1f,-0.1f,-0.1f,
|
||||
0.1f,-0.1f,-0.1f,
|
||||
-0.1f, 0.1f,-0.1f,
|
||||
0.1f, 0.1f,-0.1f,
|
||||
|
||||
-0.1f,-0.1f, 0.1f,
|
||||
0.1f,-0.1f, 0.1f,
|
||||
-0.1f, 0.1f, 0.1f,
|
||||
0.1f, 0.1f, 0.1f,
|
||||
});
|
||||
verts.flip();
|
||||
cubeMesh.bufferVertices(verts, 3);
|
||||
|
||||
//indices
|
||||
IntBuffer indices = BufferUtils.createIntBuffer(3*12);
|
||||
indices.put(new int[]{
|
||||
//Top
|
||||
2, 6, 7,
|
||||
2, 3, 7,
|
||||
|
||||
//Bottom
|
||||
0, 4, 5,
|
||||
0, 1, 5,
|
||||
|
||||
//Left
|
||||
0, 2, 6,
|
||||
0, 4, 6,
|
||||
|
||||
//Right
|
||||
1, 3, 7,
|
||||
1, 5, 7,
|
||||
|
||||
//Front
|
||||
0, 2, 3,
|
||||
0, 1, 3,
|
||||
|
||||
//Back
|
||||
4, 6, 7,
|
||||
4, 5, 7
|
||||
});
|
||||
indices.flip();
|
||||
cubeMesh.bufferFaces(indices, numTriangles * 3);
|
||||
|
||||
//texture coords
|
||||
FloatBuffer texCoords = BufferUtils.createFloatBuffer(2*8);
|
||||
texCoords.put(new float[]{
|
||||
0,0,
|
||||
1,0,
|
||||
0,1,
|
||||
1,1,
|
||||
|
||||
0,0,
|
||||
0,1,
|
||||
1,0,
|
||||
1,1,
|
||||
});
|
||||
texCoords.flip();
|
||||
cubeMesh.bufferTextureCoords(texCoords, 2);
|
||||
|
||||
//setup extra structures
|
||||
Material mat = new Material();
|
||||
mat.set_diffuse(AssetDataStrings.TEXTURE_BLOCK_ATLAS);
|
||||
cubeMesh.setMaterial(mat);
|
||||
cubeMesh.setShader(VisualShader.smartAssembleShader(false, true));
|
||||
GL40.glBindVertexArray(0);
|
||||
cubeMesh.setParent(model);
|
||||
model.getMeshes().add(cubeMesh);
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public static Model createBitmapDisplay(){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user