Jump to content

Only Rendering The Visible Sides Of A Mob


ducsuus

Recommended Posts

Hello!

 

Due to my derp nature, I felt the need to make a door mob in-game (literally, a door which walks around and beets the shizz out of you). As many of you may know, you can only ever see up to three sides of a block when you look at it, this means if the block is transparent, you can't see textures from the other side of the block.

 

This is the case for doors as well. Doors have a window in the top part of the block, because of the above rule you can look through the window and never see the other side of the door.

 

Unfortunately, this rule doesn't apply to rendering mobs. Mobs appear to have all sides rendered, meaning if you have create a door and look through the window you will still see the back of the door.

 

An screenshot below I took illustrates this:

 

width=800 height=424DvTJrqK.png?1 [/img]

 

Could somebody please explain to me how I would create a mob with the same effect as the door has.

 

I haven't supplied code because I didn't feel it was needed, if code is needed please ask.

 

Thanks!

 

~Joe

Link to comment
Share on other sites

I had hoped there was some option to disable rendering invisible sides.

 

The problem is that the back side is NOT invisible.  I mean the transparency on the front side means that the graphics engine will try to render the back too -- I think even with culling it would decide that it should be rendered.  I'm not expert on this, just thinking that a good graphics engine would try to do that.

 

But this would make one side look like it has a massive hole in it, surely that's worse?

 

Well, it is good to be picky, but I'm not sure it would look that bad -- I'm suggesting to just remove the lattice between the panes in the window on the back side.  There would still be the lattice on the other side which people would see from the back (indeed that is your current problem from the front).

 

Anyway, someone that is good with the rendering may know a better way to do client-side disabling.  However, a block is different than an entity because blocks have a regular model and so the idea of sides is well-defined whereas generally entities have all sorts of moving pieces and so I don't think there is a general solution.

 

One other idea is to swap the texture depending on what side of the entity is facing the player running the client.  That would take a little bit of coding, but shouldn't be too hard.  So you could use a texture with the back transparent if the front is facing player, and use a texture with the front transparent if the back is facing the player.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

I had hoped there was some option to disable rendering invisible sides.

 

The problem is that the back side is NOT invisible.  I mean the transparency on the front side means that the graphics engine will try to render the back too -- I think even with culling it would decide that it should be rendered.  I'm not expert on this, just thinking that a good graphics engine would try to do that.

 

But this would make one side look like it has a massive hole in it, surely that's worse?

 

Well, it is good to be picky, but I'm not sure it would look that bad -- I'm suggesting to just remove the lattice between the panes in the window on the back side.  There would still be the lattice on the other side which people would see from the back (indeed that is your current problem from the front).

 

Anyway, someone that is good with the rendering may know a better way to do client-side disabling.  However, a block is different than an entity because blocks have a regular model and so the idea of sides is well-defined whereas generally entities have all sorts of moving pieces and so I don't think there is a general solution.

 

One other idea is to swap the texture depending on what side of the entity is facing the player running the client.  That would take a little bit of coding, but shouldn't be too hard.  So you could use a texture with the back transparent if the front is facing player, and use a texture with the front transparent if the back is facing the player.

 

In fact, I think it would be easier (possible more efficient?) to just create a model which is made of 6 cubes shaped like a door, that way the "inside" sides of the cubes could be textured to be transparent.

 

The only problem I could see, is Techne seems to have a bug when texturing objects - if I have two cubes in Techne, they will use the same coordinates on the texture map meaning I can't have individual textures :S Please not it is completely possible that this is not a bug and is me being a derp; I don't have to time to conduct proper research right now :P

 

I think that the reason blocks have this feature and entities do not is because entities are more subject to moving around and exposing the "invisible" sides. Blocks don't turn around, the only way the invisible sides can be rendered is for the player to move around the block.

 

Try comparing the yaws of your entity and the player and switching between two textures depending on what side of the door the player is facing. Each texture would have a different side of the door transparent!

 

This may be the way I have to go, but it seems a bit sloppy? I would need 6 textures, which seems a bit stupid :S

 

Why? The door has 6 sides, therefore there are 6 possible combinations of the 3 sides the player can see, for each one of those combinations there are 3 sides which should be invisible. I certainly don't like the sound of having to:

 

a) make 6 textures for each one of these blocks I am making (more blocks to be like this one)

 

b) use this method - I hate hard coding stuff like this :( (it's not the nature of programming...).

 

Thanks for both of your replies, I suspect when I get home later today I will have bigger and deeper look at this (hopefully finding some kind of holy grail).

 

~Joe

Link to comment
Share on other sites

Hi

 

There is an easy way to do this, it is called back face culling.  If you turn culling off, the game will render both sides of each face.  If you turn back face culling on, you will only see one of them.

 

        GL11.glCullFace(GL11.GL_BACK);

        GL11.glEnable(GL11.GL_CULL_FACE);

or

        GL11.glDisable(GL11.GL_CULL_FACE);

 

 

This guide to openGL is pretty good and has more details.

http://www.glprogramming.com/red/

 

This link talks a bit about the tessellator and the "sides" of faces if you turn back face culling on.

 

http://greyminecraftcoder.blogspot.com.au/2013/08/the-tessellator.html

 

-TGG

Link to comment
Share on other sites

Hmm, I was thinking that backface culling wouldn't work if the front polygon is transparent -- normally in backface culling you use it for polygons that are fully not visible, but I guess you are right -- it will probably cull the back face anyway since that is usually determined simply by the direction considered the outside of the surface.  Basically in this particular case he wants an artifact that is usually undesirable.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello! My friends and I were attempting to add a few extra mods to the Create Chronicles modpack, and all was well until people started crashing when they opened their inventories. Any help finding the culprit would be MUCH appreciated, I've been scratching my head for the past few days on what went wrong. https://paste.ee/p/8pajP
    • >>>KLIK LOGIN DISINI SAYANG<<< >>>KLIK DAFTAR DISINI SAYANG<<< Pendahuluan Dalam dunia perjudian online, slot menjadi salah satu permainan yang paling diminati. Dengan munculnya berbagai platform, Togel2Win hadir sebagai salah satu pilihan menarik, terutama dengan fitur anti rungkad yang dijanjikan. Artikel ini akan membahas tentang Togel2Win, keunggulan slot terbaru, dan bagaimana server Thailand berperan dalam meningkatkan pengalaman bermain. Apa Itu Togel2Win? Togel2Win adalah platform permainan yang menawarkan berbagai jenis permainan, termasuk slot dan togel. Dengan antarmuka yang ramah pengguna dan beragam pilihan permainan, situs ini bertujuan untuk memberikan pengalaman bermain yang menyenangkan dan menguntungkan bagi para pemain. Keunggulan Slot Togel2Win Fitur Anti Rungkad: Salah satu keunggulan utama dari Togel2Win adalah fitur anti rungkad yang dirancang untuk mengurangi kemungkinan gangguan saat bermain. Ini memastikan bahwa pemain dapat menikmati permainan tanpa gangguan teknis, meningkatkan kenyamanan dan fokus. Beragam Pilihan Slot: Togel2Win menawarkan berbagai jenis slot, dari yang klasik hingga yang modern dengan grafis menawan dan tema yang menarik. Ini memberikan variasi yang cukup bagi pemain untuk menemukan permainan yang sesuai dengan preferensi mereka. Server Thailand yang Stabil: Server yang berlokasi di Thailand memberikan koneksi yang cepat dan stabil. Ini sangat penting untuk pengalaman bermain yang lancar, terutama saat bermain slot yang memerlukan respons cepat. Bonus dan Promosi Menarik: Togel2Win sering menawarkan bonus dan promosi yang menarik untuk menarik pemain baru dan mempertahankan loyalitas pemain yang sudah ada. Ini bisa berupa bonus deposit, putaran gratis, atau program loyalitas. Tips untuk Pemain Slot di Togel2Win Pilih Slot dengan RTP Tinggi: Sebelum memulai permainan, pastikan untuk memilih slot dengan tingkat pengembalian pemain (RTP) yang tinggi untuk meningkatkan peluang menang. Kelola Anggaran: Tentukan batasan anggaran sebelum bermain dan patuhi itu. Ini membantu mencegah kerugian besar dan menjaga pengalaman bermain tetap menyenangkan. Manfaatkan Bonus: Jangan ragu untuk memanfaatkan bonus dan promosi yang ditawarkan. Ini bisa memberikan tambahan modal untuk bermain lebih lama. Kesimpulan Togel2Win merupakan pilihan menarik bagi para penggemar slot, terutama dengan fitur anti rungkad dan server yang stabil. Dengan berbagai pilihan permainan dan bonus yang menggiurkan, Togel2Win siap memberikan pengalaman bermain yang tak terlupakan. Jika Anda mencari platform slot yang andal dan menyenangkan, Togel2Win bisa menjadi solusi yang tepat.
    • I'm trying to make my own modpack, but sometimes, in certain areas of the world, the game just says "server closed". Minecraft doesn't close, it just returns to the menu. When I tried to figure it out on my own and understand the logs, I didn't understand anything (English is not my native language, so it's difficult for me). I've been trying to solve the problem for the third month. So I ask if anyone is good at this and it's not difficult for you, to help me with this. If you need details, ask. I'll describe everything. What it looks like Logs
  • Topics

×
×
  • Create New...

Important Information

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