Guest Posted September 8, 2017 Posted September 8, 2017 In my mod I am using OBJ models for the guns which means that I have to use a Forge Blockstate file to apply transformations to the model. To find the best values I used the ItemTransformHelper mod. When I put the display section it generated into the Blockstate file, the model does load but it is not translated, scaled or rotated in any way. Do I need to create a custom implementation of the OBJModel class to be able to do this or is there a dumb mistake in the Blockstate file? This is the important part of my Blockstate file: { "forge_marker": 1, "defaults": { }, "variants": { "gun": { ..., "mp7": { "model": "rssmc:gun/item_gun_mp7.obj", "display": { "thirdperson_righthand": { "rotation": [ 0, 180, 0 ], "translation": [ -1.25, -1.50, -3.25 ], "scale": [ 0.20, 0.20, 0.20 ] }, "thirdperson_lefthand": { "rotation": [ 0, 0, 0 ], "translation": [ 0.00, 0.00, 0.00 ], "scale": [ 1.00, 1.00, 1.00 ] }, "firstperson_righthand": { "rotation": [ 0, 180, 0 ], "translation": [ -3.75, -0.75, -6.75 ], "scale": [ 0.30, 0.30, 0.30 ] }, "firstperson_lefthand": { "rotation": [ 0, 0, 0 ], "translation": [ 0.00, 0.00, 0.00 ], "scale": [ 1.00, 1.00, 1.00 ] }, "gui": { "rotation": [ 26, 218, 0 ], "translation": [ -4.50, -0.25, 0.00 ], "scale": [ 0.20, 0.20, 0.20 ] }, "head": { "rotation": [ 0, 0, 0 ], "translation": [ 0.00, 0.00, 0.00 ], "scale": [ 1.00, 1.00, 1.00 ] }, "fixed": { "rotation": [ 0, 90, 0 ], "translation": [ 4.75, -1.00, -0.75 ], "scale": [ 0.15, 0.15, 0.15 ] }, "ground": { "rotation": [ 0, 0, 0 ], "translation": [ 1.75, 2.50, 5.00 ], "scale": [ 0.20, 0.20, 0.20 ] } } }, ... } } } Quote
Choonster Posted September 8, 2017 Posted September 8, 2017 Forge's blockstates file doesn't use that format for display transformations, only Vanilla item models do. I briefly explain display transformations in Forge's blockstates format here: On 15/08/2017 at 0:02 PM, Choonster said: I think you can specify a base TRSRTransformation for a model using Forge's blockstates format. Set the "transform" key of a variant to an object with either a single "matrix" key or some combination of "translation", "rotation", "scale" and/or "post-rotation" keys. You can see a simple example here in RFTools and a slightly more complex example here in a Forge test mod. Look at ForgeBlockStateV1.TRSRDeserializer to see how Forge deserialises TRSRTransformations. In addition to specifying a base TRSRTransformation in the "transform" object, you can specify a TRSRTransformation for each ItemCameraTransforms.TransformType ("thirdperson_righthand", "firstperson_lefthand", "gui", etc.). The complex example I linked in the quoted post uses this to specify a TRSRTransformation for "thirdperson" (which Forge treats as an alias of "thirdperson_righthand") and "gui". Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Guest Posted September 9, 2017 Posted September 9, 2017 Great, thanks for the explanation, I will try that out tomorrow. Quote
Guest Posted September 9, 2017 Posted September 9, 2017 I tried it and the transforms seem really off. When I use the data I would have used inside the model if it was a json model, the scaling, translation and rotation are completely off. Does the Forge Blockstate transform the item differently or am I making a dumb mistake again? This is the new Blockstate file: { "forge_marker": 1, "defaults": { }, "variants": { "gun": { ..., "mp7": { "model": "rssmc:gun/item_gun_mp7.obj", "transform": { "thirdperson_righthand": { "rotation": [ {"x": 0}, {"y": 180}, {"z": 0} ], "translation": [ -1.25, -1.50, -3.25 ], "scale": 0.20 }, "firstperson_righthand": { "rotation": [ {"x": 0}, {"y": 180}, {"z": 0} ], "translation": [ -3.75, -0.75, -6.75 ], "scale": 0.30 }, "gui": { "rotation": [ {"x": 26}, {"y": 218}, {"z": 0} ], "translation": [ -4.50, -0.25, 0.00 ], "scale": 0.20 }, "fixed": { "rotation": [ {"x": 0}, {"y": 90}, {"z": 0} ], "translation": [ 4.75, -1.00, -0.75 ], "scale": 0.15 }, "ground": { "rotation": [ {"x": 0}, {"y": 0}, {"z": 0} ], "translation": [ 1.75, 2.50, 5.00 ], "scale": 0.20 } } }, ... } } } This is what I expect it to look like: This is what it looks like: Quote
Choonster Posted September 9, 2017 Posted September 9, 2017 (edited) Yes, Forge's TRSRTransformation (used in Forge's blockstates format) is different to Vanilla's ItemTransformVec3f (used in Vanilla item models). I don't fully understand the model system, but I think you can use the TRSRTransformation(ItemTransformVec3f) constructor to convert an ItemTransformVec3f to a TRSRTransformation. You can then use TRSRTransformation#getTranslation, TRSRTransformation#getLeftRot, TRSRTransformation#getScale and TRSRTransformation#getRightRot to get the values for the "translation", "rotation", "scale" and "post-rotation" keys in the blockstates file. Forge has a method to convert an entire ItemCameraTransforms object into a Map<ItemCameraTransforms.TransformType, TRSRTransformation> (PerspectiveMapWrapper.getTransforms(ItemCameraTransforms)), but I don't think you want to use this because it converts each TRSRTransformation from centre-block to corner-block and Forge's blockstates loader applies the same conversion when loading the TRSRTransformations from the blockstates file (so you'd apply the conversion twice, probably resulting in incorrect values). Edited September 9, 2017 by Choonster Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Guest Posted September 9, 2017 Posted September 9, 2017 This makes no sense to me. I tried simply calculating the correct values the way you suggested by doing TRSRTransformation trsr = new TRSRTransformation(new ItemTransformVec3f(new Vector3f(0, 180, 0), new Vector3f(-1.25F, -1.5F, -3.25F), new Vector3f(.2F, .2F, .2F))); but that did not work whatsoever. The translation and scale values I get out of this are the same as those I put in and the rotation value I get out of this is a strange negative value with a high negative exponent. Those values don't get me anywhere so it looks like I have to get the correct values by changing them in the file and reloading it over and over again which is really annoying. Quote
Choonster Posted September 9, 2017 Posted September 9, 2017 I remember having similar issues converting the Vanilla transform format to the Forge format back in 1.8.9, I never fully figured out how to solve them. You could try calling TRSRTransformation.blockCenterToCorner or TRSRTransformation.blockCornerToCenter on the TRSRTransformation to see if that produces the correct values, but I'm not sure if it will. Maybe someone with more knowledge of the model system can help here. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.