Jump to content

Recommended Posts

Posted

I want to start updating my mod (http://minecraft.curseforge.com/projects/techguns) to 1.10, but the biggest problem is item Rendering.

 

There are many 3D gun models which all extend ModelBase (Techne models exported to java), They are alle rendered with IItemRender. So, what is the best way to even get 3D models for items in 1.10 and get the same features as in 1.7? It's really hard to find informations on that topic. I have read something about ItemOverrideList? but i can't find any proper documentation/tutorial on it? Also I would like to reuse the Models and not have to convert them to some other format, since this would be a lot of work.

 

The Features I need: Render Item as 3D, Transform differenty depending on RenderType (Inventory, 1st Person, 3rd Person, Entity) and only render specific sub-parts (so I can apply different transformations on them, or hide a part in some cases).

 

Just for Reference, this is the base gun renderer:

 

  Reveal hidden contents

 

 

PS: are there some good documentations about the new capability system? Especially in what cases to use it?

 

Edit: typos

 

Posted

The only way to render a

ModelBase

for an

Item

is with a

TESR

, but this is deprecated and will be removed as soon as possible. You will need to convert your models to JSON, OBJ or B3D or write your own model loader for some other format. This program converts Techne models to JSON.

 

You can apply transformations to and hide model parts using

AnimationProperty

and

IModelState

. Forge has an example of hiding model parts here.

 

You can apply transformations to the whole model depending on the transform type (

thirdperson_righthand

,

thirdperson_lefthand

,

firstperson_righthand

,

firstperson_lefthand

,

head

,

gui

,

ground

,

fixed

) using Forge's blockstates format. Forge has an example here, but it's slightly outdated because it doesn't account for the left-/right-hand transform types added in 1.9 (though Forge will use the

thirdperson

transformation as

thirdperson_righthand

, the same applies to

firstperson

and

firstperson_righthand

).

 

Forge's documentation has a section on capabilities here. The main use case is to implement an API (your own or someone else's) and allow other mods to interact with your things, e.g.

IItemHandler

to allow automated item storage access,

IFluidHandler

to allow automated fluid storage access. Another use case is to store data in an

ItemStack

(e.g. an

IItemHandler

inventory) without having to read from/write to NBT every time you interact with it.

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.

Posted

Thanks, that's definitely helpful, but this seems to be for Blocks only? I can't find an example what is needed to load an .obj for an item. How must the .json for the item look like? Do I need a blockstate definition for an model for a pure item (no ItemBlock, an item, that only has an item form)? This is quite confusing and all the examples are Blocks only?

Posted
  On 7/24/2016 at 6:38 AM, pWn3d said:

Thanks, that's definitely helpful, but this seems to be for Blocks only? I can't find an example what is needed to load an .obj for an item. How must the .json for the item look like? Do I need a blockstate definition for an model for a pure item (no ItemBlock, an item, that only has an item form)? This is quite confusing and all the examples are Blocks only?

Currently, yes, you need blockstate definitions for items too. It works well for items just like blocks, if you specify 'inventory' type correctly.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

I got the model loaded, but I can't get the Texture to work, how do I set the Texture for a .obj? Preferable I could change the texture from withing code (I had custom textures dependent on NBT tags).

 

Posted

I think I'm hitting the wall with 1.10. Is it even possible to rotate/translate the model around like in IItemRenderer, not during initialization but during rendering?

 

Example: Player fires gun. Client saves timestamp. In ItemRenderer the timestamp is used to calculate the recoilprogress, and then the model gets additionally rotated back a bit and then forward again. So, every Frame I need do calculate the rotations/translations the model has.

 

 

Posted
  On 7/24/2016 at 6:38 AM, pWn3d said:

Thanks, that's definitely helpful, but this seems to be for Blocks only? I can't find an example what is needed to load an .obj for an item. How must the .json for the item look like? Do I need a blockstate definition for an model for a pure item (no ItemBlock, an item, that only has an item form)? This is quite confusing and all the examples are Blocks only?

 

The

ModelResourceLocation

you set for an

Item

using

ModelLoader.setCustomModelResourceLocation

/

setCustomMeshDefinition

can point to a model in any supported format or a variant of a blockstates file. I explain the model loading process and how

ModelResourceLocation

s are mapped to models here.

 

To use an OBJ model, you must call

OBJLoader#addDomain

with your resource domain (lowercase mod ID) in preInit and then specify the OBJ model the same way you'd specify a JSON model, but include the .obj extension in the path.

 

OBJ textures are specified in the material library (.mtl) file with the same name as the model. You can see some examples from Forge here.

 

To hide item model parts dynamically, you'll probably need to create your own

IModel

,

ICustomModelLoader

and

ItemOverrideList

. There's not much documentation, but again there are examples in Forge (though not of this specific thing) like

ModelDynBucket

.

 

Forge now has an animation system for baked models, which you'll probably want to use for the recoil. You can see an example from Forge here: code, assets. This page explains the grammar of the Animation State Machine files.

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.

Posted

I got the model including texture working by manually writing the mtl definitions in the .obj file. At the beginning:

 

mtllib <name_of_ml>.mtl

usemtl <name_of_material_defined_in.mtl>

 

I also had to resize the texture to quadratic and mirror it vertically.

 

I was very close to saying "Fuck it, I'm staying on 1.7.10". I can understand anybody who has not updated yet.

 

Let's see how the Transformations work out, I have a bad feeling about this...

Posted

I give up, that's just hopeless. Staying with 1.7.10 it is then. Maybe there will be a solution at a later point.

 

 

Edit: Is there really no way to get ModelBase rendered for items in 1.10?

Posted
  On 7/24/2016 at 12:33 PM, pWn3d said:

I give up, that's just hopeless. Staying with 1.7.10 it is then. Maybe there will be a solution at a later point.

 

 

Edit: Is there really no way to get ModelBase rendered for items in 1.10?

 

As I said in my first post, you can use a

TESR

; though this is deprecated and marked for removal. You can register this

TESR

with

ForgeHooksClient.registerTESRItemStack

.

 

There is no other way, the baked model and animation systems are the replacement for direct OpenGL rendering.

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.

Posted
  On 7/24/2016 at 2:01 PM, Choonster said:

  Quote

I give up, that's just hopeless. Staying with 1.7.10 it is then. Maybe there will be a solution at a later point.

 

 

Edit: Is there really no way to get ModelBase rendered for items in 1.10?

 

As I said in my first post, you can use a

TESR

; though this is deprecated and marked for removal. You can register this

TESR

with

ForgeHooksClient.registerTESRItemStack

.

 

There is no other way, the baked model and animation systems are the replacement for direct OpenGL rendering.

 

A solution that will be removed soon is not really something I want, the moment this is gone I have an new problem :-/.

 

The biggest problem with the new system is that there is very little documentation. I could not find a single example where a custom item with an .obj model is rendered. I got it to render the item as obj, but I have no Idea how all that animation stuff works. I have read everything you linked and looked at the forge interfaces, but the documentation is so minimal and the methods are all totally confusing.

 

It can't be nobody uses 3d models for items.

 

Edit:

Ok, I can handle transformations in json, so I need to see how the animation system works.

 

At least I can hold a m4 in my hand now:

Posted

I tried now to create an animation with the animation system, but that's pretty much not understandable. The whole example from forge has no comments and doesn't really explain much. Is there any proper explanation on how the animation system is used? What it can do, and what not? How to I "play" an animation on an item?

 

I want IItemRenderer back  :'(

Posted

Unfortunately I can't really help you with the animation system myself.

 

Looking at the example I linked, it seems you use

IAnimationStateMachine#transition

to transition to a new state and play the corresponding clip.

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.