Skip to content

Commit

Permalink
Modified item rendering. (#307)
Browse files Browse the repository at this point in the history
* Reverted design, tape measure, and bit bag rendering back to normal.

* Chisels, wrenches, and saws now render the same as item/handheld, except at the scale of normal items and with slight tweaking of position.

* Reduced code duplication by extracting matrix creation to a method.

* Matched perspective model rendering to block.json (translation values in json files specify pixels, but are scaled to meters in ItemTransformVec3f$Deserializer.deserialize).
  • Loading branch information
Phylogeny authored and AlgorithmX2 committed Sep 24, 2017
1 parent 2fcb485 commit 13c96ec
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 72 deletions.
Expand Up @@ -24,62 +24,29 @@ public abstract class BaseBakedPerspectiveModel implements IPerspectiveAwareMode

static
{
// for some reason these are not identical to vanilla's Block.json, I
// don't know why.. but its close.

{
final javax.vecmath.Vector3f translation = new javax.vecmath.Vector3f( 0, 0, 0 );
final javax.vecmath.Vector3f scale = new javax.vecmath.Vector3f( 0.625f, 0.625f, 0.625f );
final Quat4f rotation = TRSRTransformation.quatFromXYZDegrees( new javax.vecmath.Vector3f( 30, 225, 0 ) );

final TRSRTransformation transform = new TRSRTransformation( translation, rotation, scale, null );
gui = transform.getMatrix();
}

{
final javax.vecmath.Vector3f translation = new javax.vecmath.Vector3f( 0, 0, 0 );
final javax.vecmath.Vector3f scale = new javax.vecmath.Vector3f( 0.25f, 0.25f, 0.25f );
final Quat4f rotation = TRSRTransformation.quatFromXYZDegrees( new javax.vecmath.Vector3f( 0, 0, 0 ) );

final TRSRTransformation transform = new TRSRTransformation( translation, rotation, scale, null );
ground = transform.getMatrix();
}

{
final javax.vecmath.Vector3f translation = new javax.vecmath.Vector3f( 0, 0, 0 );
final javax.vecmath.Vector3f scale = new javax.vecmath.Vector3f( 0.5f, 0.5f, 0.5f );
final Quat4f rotation = TRSRTransformation.quatFromXYZDegrees( new javax.vecmath.Vector3f( 0, 0, 0 ) );

final TRSRTransformation transform = new TRSRTransformation( translation, rotation, scale, null );
fixed = transform.getMatrix();
}

{
final javax.vecmath.Vector3f translation = new javax.vecmath.Vector3f( 0, 0, 0 );
final javax.vecmath.Vector3f scale = new javax.vecmath.Vector3f( 0.375f, 0.375f, 0.375f );
final Quat4f rotation = TRSRTransformation.quatFromXYZDegrees( new javax.vecmath.Vector3f( 75, 45, 0 ) );

final TRSRTransformation transform = new TRSRTransformation( translation, rotation, scale, null );
thirdPerson_lefthand = thirdPerson_righthand = transform.getMatrix();
}

{
final javax.vecmath.Vector3f translation = new javax.vecmath.Vector3f( 0, 0, 0 );
final javax.vecmath.Vector3f scale = new javax.vecmath.Vector3f( 0.40f, 0.40f, 0.40f );
final Quat4f rotation = TRSRTransformation.quatFromXYZDegrees( new javax.vecmath.Vector3f( 0, 45, 0 ) );

final TRSRTransformation transform = new TRSRTransformation( translation, rotation, scale, null );
firstPerson_righthand = transform.getMatrix();
}
gui = getMatrix( 0, 0, 0, 30, 225, 0, 0.625f );
ground = getMatrix( 0, 3 / 16.0f, 0, 0, 0, 0, 0.25f );
fixed = getMatrix( 0, 0, 0, 0, 0, 0, 0.5f );
thirdPerson_lefthand = thirdPerson_righthand = getMatrix( 0, 2.5f / 16.0f, 0, 75, 45, 0, 0.375f );
firstPerson_righthand = getMatrix( 0, 0, 0, 0, 45, 0, 0.40f );
firstPerson_lefthand = getMatrix( 0, 0, 0, 0, 0, 225, 0.40f );
}

{
final javax.vecmath.Vector3f translation = new javax.vecmath.Vector3f( 0, 0, 0 );
final javax.vecmath.Vector3f scale = new javax.vecmath.Vector3f( 0.40f, 0.40f, 0.40f );
final Quat4f rotation = TRSRTransformation.quatFromXYZDegrees( new javax.vecmath.Vector3f( 0, 225, 0 ) );
private static Matrix4f getMatrix(
final float transX,
final float transY,
final float transZ,
final float rotX,
final float rotY,
final float rotZ,
final float scaleXYZ )
{
final javax.vecmath.Vector3f translation = new javax.vecmath.Vector3f( transX, transY, transZ );
final javax.vecmath.Vector3f scale = new javax.vecmath.Vector3f( scaleXYZ, scaleXYZ, scaleXYZ );
final Quat4f rotation = TRSRTransformation.quatFromXYZDegrees( new javax.vecmath.Vector3f( rotX, rotY, rotZ ) );

final TRSRTransformation transform = new TRSRTransformation( translation, rotation, scale, null );
firstPerson_lefthand = transform.getMatrix();
}
final TRSRTransformation transform = new TRSRTransformation( translation, rotation, scale, null );
return transform.getMatrix();
}

@Override
Expand Down
@@ -1,5 +1,5 @@
{
"parent":"item/handheld",
"parent":"item/generated",
"textures": {
"layer0":"chiselsandbits:items/bit_bag"
}
Expand Down
@@ -1,18 +1,18 @@
{
"parent": "item/generated",
"parent":"item/generated",
"textures": {
"layer0":"chiselsandbits:items/bitsaw_diamond"
},
"display": {
"thirdperson_righthand": {
"rotation": [ 0, 90, 55 ],
"translation": [ 0, 4.0, 0.5 ],
"scale": [ 0.85, 0.85, 0.85 ]
"translation": [ 0, 3.5, 0.75 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"thirdperson_lefthand": {
"rotation": [ 0, -90, -55 ],
"translation": [ 0, 4.0, 0.5 ],
"scale": [ 0.85, 0.85, 0.85 ]
"translation": [ 0, 3.5, 0.75 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"firstperson_righthand": {
"rotation": [ 0, 90, 25 ],
Expand Down
@@ -1,5 +1,5 @@
{
"parent":"item/handheld",
"parent":"chiselsandbits:item/tool",
"textures": {
"layer0":"chiselsandbits:items/chisel_diamond"
}
Expand Down
@@ -1,5 +1,5 @@
{
"parent":"item/handheld",
"parent":"chiselsandbits:item/tool",
"textures": {
"layer0":"chiselsandbits:items/chisel_gold"
}
Expand Down
@@ -1,5 +1,5 @@
{
"parent":"item/handheld",
"parent":"chiselsandbits:item/tool",
"textures": {
"layer0":"chiselsandbits:items/chisel_iron"
}
Expand Down
@@ -1,5 +1,5 @@
{
"parent":"item/handheld",
"parent":"chiselsandbits:item/tool",
"textures": {
"layer0":"chiselsandbits:items/chisel_stone"
}
Expand Down
@@ -1,5 +1,5 @@
{
"parent":"item/handheld",
"parent":"item/generated",
"textures": {
"layer0":"chiselsandbits:items/mirrorprint"
}
Expand Down
@@ -1,5 +1,5 @@
{
"parent":"item/handheld",
"parent":"item/generated",
"textures": {
"layer0":"chiselsandbits:items/mirrorprint_written"
}
Expand Down
@@ -1,5 +1,5 @@
{
"parent":"item/handheld",
"parent":"item/generated",
"textures": {
"layer0":"chiselsandbits:items/negativeprint"
}
Expand Down
@@ -1,5 +1,5 @@
{
"parent":"item/handheld",
"parent":"item/generated",
"textures": {
"layer0":"chiselsandbits:items/negativeprint_written"
}
Expand Down
@@ -1,5 +1,5 @@
{
"parent":"item/handheld",
"parent":"item/generated",
"textures": {
"layer0":"chiselsandbits:items/positiveprint"
}
Expand Down
@@ -1,5 +1,5 @@
{
"parent":"item/handheld",
"parent":"item/generated",
"textures": {
"layer0":"chiselsandbits:items/positiveprint_written"
}
Expand Down
@@ -1,5 +1,5 @@
{
"parent":"item/handheld",
"parent":"item/generated",
"textures": {
"layer0":"chiselsandbits:items/tape_measure"
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/resources/assets/chiselsandbits/models/item/tool.json
@@ -0,0 +1,15 @@
{
"parent": "item/handheld",
"display": {
"thirdperson_righthand": {
"rotation": [ 0, -90, 55 ],
"translation": [ 0, 3.5, 0.75 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"thirdperson_lefthand": {
"rotation": [ 0, 90, -55 ],
"translation": [ 0, 3.5, 0.75 ],
"scale": [ 0.55, 0.55, 0.55 ]
}
}
}
@@ -1,5 +1,5 @@
{
"parent":"item/handheld",
"parent":"chiselsandbits:item/tool",
"textures": {
"layer0":"chiselsandbits:items/wrench_wood"
}
Expand Down

0 comments on commit 13c96ec

Please sign in to comment.