Jump to content

[1.11.2] Can you use an obj for an entity model?


Kriptikz

Recommended Posts

I can find tutorials for using obj models for items and blocks, but not for entities. Can you use obj models for entities?

I'm pretty much stuck at creating the Render class for the entity.

Here is what I have so far:

Spoiler

public class RenderSpellProjectile extends Render<EntitySpellProjectile>
{
	private ResourceLocation texture = new ResourceLocation(Reference.MODID, "textures/entity/spell_projectile.png");
	private ResourceLocation obj = new ResourceLocation(Reference.MODID, "models/obj/sphere/sphere.obj");
		
	//private ModelBase model1;
	private IModel model2;
	
	public static final RenderFactory FACTORY = new RenderFactory();
	
	public RenderSpellProjectile(RenderManager renderManager)
	{
		super(renderManager);
		
		//model1 = new ModelSpellProjectile();
		
		try
		{
			model2 = OBJLoader.INSTANCE.loadModel(obj);
		} catch (Exception e)
		{
			System.out.println("Unable to load sphere.obj");
		}
	}

	@Override
	protected ResourceLocation getEntityTexture(EntitySpellProjectile entity)
	{
		return texture;
	}
	
	@Override
	public void doRender(EntitySpellProjectile entity, double x, double y, double z, float entityYaw, float partialTicks)
	{
		// Render for model1
		/*
		GL11.glPushMatrix();
		bindTexture(texture);
		GL11.glTranslated(x, y - 1.25D, z);
		model1.render(entity, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);
		GL11.glPopMatrix();
		*/

		// Render for model2
		
	}

	public boolean shouldRender(EntitySpellProjectile livingEntity, ICamera camera, double camX, double camY, double camZ)
	{
		return true;
	}

	public static class RenderFactory implements IRenderFactory<EntitySpellProjectile>
	{

		@Override
		public Render<? super EntitySpellProjectile> createRenderFor(RenderManager manager)
		{
			return new RenderSpellProjectile(manager);
		}

	}
}

 

That should load the model, right? If so, how do I render it in doRender()?

Link to comment
Share on other sites

AnimationModelBase is a ModelBase that renders an animated baked model. If the model isn't animated, you can create your own Render/ModelBase and cache the IBakedModel instead of re-baking it each frame.

  • Like 1

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.

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.



×
×
  • Create New...

Important Information

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