Jump to content

[SOLVED] [1.8] How Do I Use IPerspectiveAwareModel? It Destroys Models


EverythingGames

Recommended Posts

Hi, I've used this interface in the past - it only destroys my model's appearance (screws up the transforms for first person, third person, gui, etc.). The question is very simple - how do I use this interface properly? The method found in it called "handlePerspective" is what I specifically need help on. I understand that I won't get much support because - it's a question that's been asked for a while by myself and not many people have any experience with these new rendering classes. Anyway, this is really the last part of my mod that's been in development for a very long time. If anyone could help me out, I'd be so very grateful!

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Link to comment
Share on other sites

The whole point of IPerspectiveAwareModel is to let you define exactly which transforms you want to apply in each perspective, and it would be much more difficult to do that if it applied all of the vanilla transformations for you first.

 

If your model needs to have different transformations in one or more perspectives but you still want to use the vanilla transformations as a base, you can easily do so:

switch (cameraTransformType) {
case GUI:
  RenderItem.applyVanillaTransform(parent.getItemCameraTransforms().gui);
  break;
// etc. for other cases

Link to comment
Share on other sites

The whole point of IPerspectiveAwareModel is to let you define exactly which transforms you want to apply in each perspective, and it would be much more difficult to do that if it applied all of the vanilla transformations for you first.

 

If your model needs to have different transformations in one or more perspectives but you still want to use the vanilla transformations as a base, you can easily do so:

switch (cameraTransformType) {
case GUI:
  RenderItem.applyVanillaTransform(parent.getItemCameraTransforms().gui);
  break;
// etc. for other cases

 

Thanks so much for the reply, @coolAlias, it makes total sense to me. I don't need to add any transforms, I just wanna use the same transforms provided in the .JSON model itself - I am using IPerspectiveAwareModel to return different collections of BakedQuads(using the transformType parameter). I tried to use the suggestion that you provided along with returning the Pair, but no luck - the model is messed up even more. Here is my code:

 

@Override
public Pair<IBakedModel, Matrix4f> handlePerspective(TransformType transformType)
{

	final Matrix4f firstperson = ForgeHooksClient.getMatrix(this.getItemCameraTransforms().firstPerson);
	final Matrix4f thirdperson = ForgeHooksClient.getMatrix(this.getItemCameraTransforms().thirdPerson);
	final Matrix4f gui = ForgeHooksClient.getMatrix(this.getItemCameraTransforms().gui);
	final Matrix4f head = ForgeHooksClient.getMatrix(this.getItemCameraTransforms().head);

	switch(transformType)
	{

	case FIRST_PERSON : { RenderItem.applyVanillaTransform(this.getItemCameraTransforms().firstPerson); return Pair.of(this, firstperson); }	

	case THIRD_PERSON : { RenderItem.applyVanillaTransform(this.getItemCameraTransforms().thirdPerson); return Pair.of(this, thirdperson); }

	case GUI : { RenderItem.applyVanillaTransform(this.getItemCameraTransforms().gui); return Pair.of(this, gui); }

	case HEAD : { RenderItem.applyVanillaTransform(this.getItemCameraTransforms().head); return Pair.of(this, head); } 

	default : return null; 

	}

}

 

Hopefully, you can point out what I did wrong there. As for using ForgeHooksClient to get the matrix from the transform vector, it seems to be working better than using TRSRTransformation to get the matrix. Anyway, this is a large part of the last part of my mod, I'd really appreciate it if you could help me further to get this thing going!

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Link to comment
Share on other sites

Thanks again for the reply, @coolAlias. Here is a run-down of what I need to do and why I need to do it, while also explaining my problem further:

 

Problem:

At first, my item has a 3D .JSON model, just like any normal item would - nothing special. This model has various rotations, translations, and scale added to it just like you would do in any .JSON model to get it to look correct in-game - still nothing special. I then want to wrap the model using IPerspectiveAwareModel, using the code provided above - no crashes, everything runs fine. When I look at the item in-game, the model looks nothing like it did before I wrapped it with IPerspectiveAwareModel - it has new, crazy rotations and translations added to it. The problem lies within IPerspectiveAwareModel - somehow it is messing up the item transforms / rotations.

 

What I Need To Possibly Do:

Remember, I am not using IPerspectiveAwareModel to add more translations / rotations. I want to be able to use it while still having my model look EXACTLY the same as it was before I used IPerspectiveAwareModel. Have you used this interface for your models (I am basing my question off of earlier topics by you)? If so, how did you work this problem out?

 

I really appreciate your help and anyone's help on this problem!

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Link to comment
Share on other sites

Literally a few minutes after posting that I realized just what to do! I got it working right (your earlier suggestion played a major role) - I appreciate your time @coolAlias! Here's the code for anyone needing it:

 

@Override
public Pair<IBakedModel, Matrix4f> handlePerspective(TransformType transformType)
{

	switch(transformType)
	{

	case FIRST_PERSON : { RenderItem.applyVanillaTransform(this.getItemCameraTransforms().firstPerson); break; }	

	case THIRD_PERSON : { RenderItem.applyVanillaTransform(this.getItemCameraTransforms().thirdPerson); break; }

	case GUI : { RenderItem.applyVanillaTransform(this.getItemCameraTransforms().gui); break; }

	case HEAD : { RenderItem.applyVanillaTransform(this.getItemCameraTransforms().head); break; } 

	default : break;

	}

	 return Pair.of(this, null); 

}

 

I realized that the matrix can be null and that returning new added matricies for every transform was a really bad idea! Anyway, that a step closer. Again, thanks!

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Link to comment
Share on other sites

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.