Jump to content

How the hell do you friggin load .obj things or whatever


HatKidSoldTheirSoul

Recommended Posts

Hi

 

I just finished figuring this out myself; I loaded obj files as a block, for use by a TileEntityRenderer

Try this github branch

https://github.com/TheGreyGhost/MinecraftByExample/tree/1-15-2-working-latestMCP

 

The key files:

blockstates json:

{
  "forge_marker": 1,
  "variants": {
    "use_wavefront_obj_model=false": { "model": "block/hopper" },
    "use_wavefront_obj_model=true": { "model": "minecraftbyexample:block/mbe21_ter_wavefront_model" }
  }
}

in models/block:

{
  "loader": "forge:obj",
  "flip-v": true,
  "ambientToFullbright": false,
  "__comment": "flip-v may be required if your texture appears mirrored.  See OBJloader::read() for other flags.  currently the available options are",
  "__comment1": "detectCullableFaces (default true) = try to convert faces to Directional Quads (EAST, WEST, etc) instead of just general quads",
  "__comment2": "diffuseLighting (default false) = attempt to apply the direction-dependent lighting as per vanilla blocks.  Currently does nothing.",
  "__comment3": "flipV (default false) = mirror the texture sheet top-->bottom (if your textures appear upside-down)",
  "__comment4": "ambientToFullbright (default true) = always render at maximum world illumination (combinedLight) regardless of the actual skylight or blocklight present",
  "__comment5": "materialLibraryOverrideLocation (default null) = use this path/filename for the material library file .mtl",
  "model" : "minecraftbyexample:models/block/mbe21_ter_gem.obj"
}

obj file in same directory:

# Blender v2.80 (sub 75) OBJ File: 'mbe21_ter_gem.blend'
# www.blender.org
mtllib mbe21_ter_gem.mtl
o Gem
v 0.000000 1.000000 0.000000
v -0.500000 0.000000 -0.500000
v 0.500000 0.000000 -0.500000
v 0.500000 -0.000000 0.500000
v -0.500000 -0.000000 0.500000
v 0.000000 -1.000000 -0.000000
vt 0.125000 0.000000
vt 0.000000 0.500000
vt 0.250000 0.500000

vt 0.375000 0.000000
vt 0.250000 0.500000
vt 0.500000 0.500000

vt 0.625000 0.000000
vt 0.500000 0.500000
vt 0.750000 0.500000

vt 0.875000 0.000000
vt 0.750000 0.500000
vt 1.000000 0.500000

vt 0.125000 1.000000
vt 0.000000 0.500000
vt 0.250000 0.500000

vt 0.375000 1.000000
vt 0.250000 0.500000
vt 0.500000 0.500000

vt 0.625000 1.000000
vt 0.500000 0.500000
vt 0.750000 0.500000

vt 0.875000 1.000000
vt 0.750000 0.500000
vt 1.000000 0.500000
vn 0.0000 0.4472 -0.8944
vn 0.8944 0.4472 0.0000
vn 0.0000 0.4472 0.8944
vn -0.8944 0.4472 0.0000
vn 0.0000 -0.4472 -0.8944
vn 0.8944 -0.4472 -0.0000
vn 0.0000 -0.4472 0.8944
vn -0.8944 -0.4472 -0.0000
usemtl Material
s 1
f 1/1/1 3/2/1 2/3/1
f 1/4/2 4/5/2 3/6/2
f 1/7/3 5/8/3 4/9/3
f 1/10/4 2/11/4 5/12/4
f 6/13/5 2/14/5 3/15/5
f 6/16/6 3/17/6 4/18/6
f 6/19/7 4/20/7 5/21/7
f 6/22/8 5/23/8 2/24/8

mtl file in same directory:

# Blender MTL File: 'mbe21_ter_gem.blend'
# Material Count: 1

newmtl Material
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2
map_Kd minecraftbyexample:model/mbe21_ter_gem

texture file is in

textures/model

 

Cheers

  TGG

Link to comment
Share on other sites

On 3/15/2020 at 7:25 PM, TheGreyGhost said:

Hi

 

I just finished figuring this out myself; I loaded obj files as a block, for use by a TileEntityRenderer

Try this github branch

https://github.com/TheGreyGhost/MinecraftByExample/tree/1-15-2-working-latestMCP

 

The key files:

blockstates json:


{
  "forge_marker": 1,
  "variants": {
    "use_wavefront_obj_model=false": { "model": "block/hopper" },
    "use_wavefront_obj_model=true": { "model": "minecraftbyexample:block/mbe21_ter_wavefront_model" }
  }
}

in models/block:


{
  "loader": "forge:obj",
  "flip-v": true,
  "ambientToFullbright": false,
  "__comment": "flip-v may be required if your texture appears mirrored.  See OBJloader::read() for other flags.  currently the available options are",
  "__comment1": "detectCullableFaces (default true) = try to convert faces to Directional Quads (EAST, WEST, etc) instead of just general quads",
  "__comment2": "diffuseLighting (default false) = attempt to apply the direction-dependent lighting as per vanilla blocks.  Currently does nothing.",
  "__comment3": "flipV (default false) = mirror the texture sheet top-->bottom (if your textures appear upside-down)",
  "__comment4": "ambientToFullbright (default true) = always render at maximum world illumination (combinedLight) regardless of the actual skylight or blocklight present",
  "__comment5": "materialLibraryOverrideLocation (default null) = use this path/filename for the material library file .mtl",
  "model" : "minecraftbyexample:models/block/mbe21_ter_gem.obj"
}

obj file in same directory:


# Blender v2.80 (sub 75) OBJ File: 'mbe21_ter_gem.blend'
# www.blender.org
mtllib mbe21_ter_gem.mtl
o Gem
v 0.000000 1.000000 0.000000
v -0.500000 0.000000 -0.500000
v 0.500000 0.000000 -0.500000
v 0.500000 -0.000000 0.500000
v -0.500000 -0.000000 0.500000
v 0.000000 -1.000000 -0.000000
vt 0.125000 0.000000
vt 0.000000 0.500000
vt 0.250000 0.500000

vt 0.375000 0.000000
vt 0.250000 0.500000
vt 0.500000 0.500000

vt 0.625000 0.000000
vt 0.500000 0.500000
vt 0.750000 0.500000

vt 0.875000 0.000000
vt 0.750000 0.500000
vt 1.000000 0.500000

vt 0.125000 1.000000
vt 0.000000 0.500000
vt 0.250000 0.500000

vt 0.375000 1.000000
vt 0.250000 0.500000
vt 0.500000 0.500000

vt 0.625000 1.000000
vt 0.500000 0.500000
vt 0.750000 0.500000

vt 0.875000 1.000000
vt 0.750000 0.500000
vt 1.000000 0.500000
vn 0.0000 0.4472 -0.8944
vn 0.8944 0.4472 0.0000
vn 0.0000 0.4472 0.8944
vn -0.8944 0.4472 0.0000
vn 0.0000 -0.4472 -0.8944
vn 0.8944 -0.4472 -0.0000
vn 0.0000 -0.4472 0.8944
vn -0.8944 -0.4472 -0.0000
usemtl Material
s 1
f 1/1/1 3/2/1 2/3/1
f 1/4/2 4/5/2 3/6/2
f 1/7/3 5/8/3 4/9/3
f 1/10/4 2/11/4 5/12/4
f 6/13/5 2/14/5 3/15/5
f 6/16/6 3/17/6 4/18/6
f 6/19/7 4/20/7 5/21/7
f 6/22/8 5/23/8 2/24/8

mtl file in same directory:


# Blender MTL File: 'mbe21_ter_gem.blend'
# Material Count: 1

newmtl Material
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2
map_Kd minecraftbyexample:model/mbe21_ter_gem

texture file is in

textures/model

 

Cheers

  TGG

 

So I feel bad asking here, but I can't find anything anywhere else so I'll just ask... So I've pretty much done what's in here. The game loads with no related errors or warnings. But when I place the block down, it's completely invisible. It has a hitbox, but there's nothing there. I saw one other person with this problem but they were using 1.9 and never got a good answer. Any idea what causes this?

Link to comment
Share on other sites

1 hour ago, TheGreyGhost said:

Hi

 

Short answer is: lots of things can cause this

 

If you post a link to a github I'll fork it and see if I can find any more clues.

 

-TGG

Hey! Thanks for the reply. Took me a while to figure out, and I'm not sure I did it right, but I think I finally managed to make a repository for it:
https://github.com/HappyHippo77/Witchery2

 

Please tell me if I did something wrong! I'm pretty new to github. I also may have changed some stuff in the files since I last replied.

 

(Also: I am recreating the Witchery mod, yes. Mostly for practice and personal use, though I may publicize it if it ever gets accurate enough to the original. The idea is not to claim the work as my own, but to bring back the work of another person.)

Edited by HappyHippo77
Link to comment
Share on other sites

Ah.  You're using 1.14.  Any reason you're not using 1.15?

 

I wrestled with it for a while but I couldn't get it to load properly.  It either sticks .json on the end of the .obj filename or it doesn't load at all.  I can't figure out how the object loader is supposed to be invoked.

 

Sorry dude, unless you update to 1.15 I'm out of ideas.

 

-TGG

 

Link to comment
Share on other sites

15 hours ago, TheGreyGhost said:

Ah.  You're using 1.14.  Any reason you're not using 1.15?

 

I wrestled with it for a while but I couldn't get it to load properly.  It either sticks .json on the end of the .obj filename or it doesn't load at all.  I can't figure out how the object loader is supposed to be invoked.

 

Sorry dude, unless you update to 1.15 I'm out of ideas.

 

-TGG

 

I might be able to figure it out in 1.15. I used 1.14 because the documentation sucks for 1.15, and there's no tutorials for it either. I'll see if I can update.

Link to comment
Share on other sites

In your material file you need to update the path for the .png file. It should be a path to a file in the textures directory. Which I see you have already copied the file there.

I.E update the line in the .mtl file to:

map_Kd witchery2:block/witchs_cauldron

 

Also the path in the .json model must be a full path, from the root of your mod. (this is probably the main problem for you)

So make the path:

"model" : "witchery2:models/block/witchs_cauldron.obj"

Adding the "models/" to the start.

 

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.