Jump to content

[1.5.2] Obj rendering - doesn't render


VitezKolya

Recommended Posts

I've been trying to figure out how to render obj files into minecraft. I've gotten it to render as an item but it just won't render as a tileEntity. Here is a github link to my testing mod. Any idea why it's not rendering?

 

https://github.com/VitezKolya/TestMod

 

https://github.com/VitezKolya/TestMod/blob/master/common/testmod/blocks/BlockTileTest.java

 

https://github.com/VitezKolya/TestMod/blob/master/common/testmod/client/render/model/ModelTest.java

 

https://github.com/VitezKolya/TestMod/blob/master/common/testmod/client/render/tileentity/TileTestRenderer.java

 

https://github.com/VitezKolya/TestMod/blob/master/common/testmod/core/proxy/ClientProxy.java

 

https://github.com/VitezKolya/TestMod/blob/master/common/testmod/TestMod.java

 

Also note that I've registered the item renderer and tileEntity renderer in the ClientProxy.java.

Link to comment
Share on other sites

	int scale = 1;

GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);

// Scale, Translate, Rotate
GL11.glScalef(scale, scale, scale);
GL11.glTranslatef((float) x, (float) y, (float) z);
GL11.glRotatef(-90F, 0F, 0F, 0F);

FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_BUSWAY);

model.renderPart("test");

 

use glTranslated instead of glTranslatef

model.render(), instead of renderPart(String), the part "test" might not exists

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

Oh I know that the part "test" is there, it's listed in the obj file. Also I'm using renderPart in the item renderer too and it's working.

 

Here is the obj file for reference:

 

 

# Blender v2.67 (sub 0) OBJ File: 'test.blend'
# www.blender.org
g test
v 1.000000 0.000000 0.500000
v 1.000000 1.000000 0.500000
v 0.853553 0.000000 0.853553
v 0.853553 1.000000 0.853553
v 0.500000 0.000000 1.000000
v 0.500000 1.000000 1.000000
v 0.146447 0.000000 0.853553
v 0.146447 1.000000 0.853553
v 0.000000 0.000000 0.500000
v 0.000000 1.000000 0.500000
v 0.146447 0.000000 0.146447
v 0.146447 1.000000 0.146447
v 0.500000 0.000000 0.000000
v 0.500000 1.000000 0.000000
v 0.853553 0.000000 0.146447
v 0.853553 1.000000 0.146447
vt 0.500000 0.627194
vt 0.499999 0.303674
vt 0.623805 0.303673
vt 0.623806 0.627193
vt 0.747611 0.303673
vt 0.747612 0.627193
vt 0.871418 0.303672
vt 0.871417 0.627193
vt 0.995224 0.303673
vt 0.995223 0.627194
vt 0.004778 0.627196
vt 0.004776 0.303676
vt 0.128582 0.303675
vt 0.128584 0.627196
vt 0.252388 0.303675
vt 0.252390 0.627195
vt 0.376194 0.303674
vt 0.376195 0.627194
vt 0.660066 0.092321
vt 0.958962 0.092321
vt 0.958962 0.216128
vt 0.660066 0.216128
vt 0.747611 0.004776
vt 0.871418 0.004776
vt 0.958961 0.714737
vt 0.660068 0.714737
vt 0.958961 0.838543
vt 0.660068 0.838543
vt 0.871417 0.926087
vt 0.747611 0.926086
vn 0.923880 0.000000 0.382683
vn 0.382683 0.000000 0.923880
vn -0.382683 0.000000 0.923880
vn -0.923880 0.000000 0.382683
vn -0.923879 0.000000 -0.382684
vn -0.382683 0.000000 -0.923880
vn 0.382683 0.000000 -0.923880
vn 0.923879 0.000000 -0.382684
vn -0.000000 1.000000 0.000000
vn 0.000000 -1.000000 0.000000
s off
f 1/1/1 2/2/1 4/3/1 3/4/1
f 3/4/2 4/3/2 6/5/2 5/6/2
f 5/6/3 6/5/3 8/7/3 7/8/3
f 7/8/4 8/7/4 10/9/4 9/10/4
f 9/11/5 10/12/5 12/13/5 11/14/5
f 11/14/6 12/13/6 14/15/6 13/16/6
f 13/16/7 14/15/7 16/17/7 15/18/7
f 15/18/8 16/17/8 2/2/8 1/1/8
f 2/19/9 12/20/9 10/21/9 4/22/9
f 12/20/9 2/19/9 16/23/9 14/24/9
f 4/22/9 10/21/9 8/7/9 6/5/9
f 5/6/10 7/8/10 9/25/10 3/26/10
f 3/26/10 9/25/10 11/27/10 1/28/10
f 13/29/10 15/30/10 1/28/10 11/27/10

 

 

Link to comment
Share on other sites

I just figured it out. I changed this:

GL11.glRotatef(-90F, 0F, 0F, 0F);

to this:

GL11.glRotatef(0F, 0F, 0F, 0F);

This is what was causing the problem. The -90degree rotation made the model invisible or unrenderable. And it also seems that I pre-rotated the model in the export options in blender so it wasn't needed in the first place.

 

Anyway thanks for responding.

Link to comment
Share on other sites

no actually its because you rotated with a weird quaternion, resulting the messing up the model completelly

 

GL11.glRotatef(-90F, 0F, 0F, 0F);

 

this is useless and will probably f up your model

 

GL11.glRotatef(-90F, 0F, 1F, 0F);

^ this will rotate the model

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

I see now. The first variable sets the rotation angle and the other vars are for telling what axis to rotate on.

 

Anway I got the Testing renderer working on the test mod, but the main mod isn't rendering what I want to.

 

 

Renderer:

package altenergy.client.render.tileentity;

import java.util.Random;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;

import org.lwjgl.opengl.GL11;

import altenergy.client.model.ModelEnergyBusway;
import altenergy.content.conductors.TileEnergyBusway;
import altenergy.lib.Textures;
import cpw.mods.fml.client.FMLClientHandler;

public class TileEntityEnergyBuswayRenderer extends TileEntitySpecialRenderer {

private ModelEnergyBusway model = new ModelEnergyBusway();

private int random(int maxNum) {

	Random randNum = new Random();
	return randNum.nextInt(maxNum);
}

public void renderModelAt(TileEnergyBusway tileEntity, double x, double y, double z, float tick) {

	float scale = 1;

	GL11.glPushMatrix();
	GL11.glDisable(GL11.GL_LIGHTING);

	// Scale, Translate, Rotate
	GL11.glScalef(scale, scale, scale);
	GL11.glTranslatef((float) x, (float) y, (float) z);
	// angle, xaxis, yaxis, zaxis
	GL11.glRotatef(0F, 0F, 0F, 0F);

	// Bind Texture
	// bindTextureByName(Textures.MODEL_BUSWAY);
	FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_BUSWAY);

	boolean[] connectedSides = tileEntity.visuallyConnected;

	if (connectedSides[0]) {
		model.renderPart("BuswayConnectionF");
	}

	if (connectedSides[1]) {
		model.renderPart("BuswayConnectionE");
	}

	if (connectedSides[2]) {
		model.renderPart("BuswayConnectionA");
	}

	if (connectedSides[3]) {
		model.renderPart("BuswayConnectionB");
	}

	if (connectedSides[4]) {
		model.renderPart("BuswayConnectionC");
	}

	if (connectedSides[5]) {
		model.renderPart("BuswayConnectionD");
	}

	model.renderPart("BuswayNone");

	GL11.glEnable(GL11.GL_LIGHTING);
	GL11.glPopMatrix();
}

@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) {

	renderModelAt((TileEnergyBusway) tileEntity, x, y, z, tick);
}
}

 

TileEntity:

package altenergy.content.conductors;

import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.block.IConnector;
import universalelectricity.core.block.INetworkProvider;
import universalelectricity.prefab.tile.TileEntityConductor;
import altenergy.lib.Reference;

public class TileEnergyBusway extends TileEntityConductor {

public TileEnergyBusway() {

	channel = Reference.CHANNEL_NAME;
}

@Override
public double getResistance() {

	return 0;
}

@Override
public double getCurrentCapcity() {

	return 5000000;
}

public int getNumCon(boolean[] connections) {

	int count = 0;

	for(int side = 0; side < connections.length; side++) {
		if(connections[0]) {
			count++;
		}
	}


	return count;
}

public void printConnections() {
	System.out.println("Bottom: " + this.visuallyConnected[0]);
	System.out.println("Top: " + this.visuallyConnected[1]);
	System.out.println("Front: " + this.visuallyConnected[2]);
	System.out.println("Back: " + this.visuallyConnected[3]);
	System.out.println("Left: " + this.visuallyConnected[4]);
	System.out.println("Right: " + this.visuallyConnected[5]);
}

@Override
public void updateConnection(TileEntity tileEntity, ForgeDirection side) {

	if (!worldObj.isRemote) {
		if(tileEntity instanceof TileEnergyBusway) {
			if (tileEntity instanceof IConnector) {
				if (((IConnector) tileEntity).canConnect(side.getOpposite())) {
					connectedBlocks[side.ordinal()] = tileEntity;
					visuallyConnected[side.ordinal()] = true;

					if (tileEntity.getClass() == this.getClass() && tileEntity instanceof INetworkProvider) {
						getNetwork().mergeConnection(((INetworkProvider) tileEntity).getNetwork());
					}
					//System.out.println("Connection Complete");
					//printConnections();
					return;
				}
			}

			if (connectedBlocks[side.ordinal()] != null) {
				getNetwork().stopProducing(connectedBlocks[side.ordinal()]);
				getNetwork().stopRequesting(connectedBlocks[side.ordinal()]);
			}
			connectedBlocks[side.ordinal()] = null;
			visuallyConnected[side.ordinal()] = false;
		}
	}
}
}

For some reason the connectedSides array when the tileEntity is place down doesn't seem to see or connect to the tile entity's visuallyConnected array. So that when I have placed two blocks next to each other the renderer is suppose to render one of the BuswayConnection's but isn't. I've tested all the parts and they all work just fine. It's just the instance of tileEnergyBusway isn't sending the visuallyConnected boolean array. At lest that's what it seems like.

 

I'm using the Universal Electricity api for the electric network.

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.