Jump to content
Arska134

Bullethole decals

Recommended Posts

So i am trying to make some bulletholes. I made it just like in Leadwerks documents, but i got "Compile error Unable to convert from 'TEntity' to 'TMesh'.

am.bullethole:TMesh = CreateDecal(spick.surface, TFormPoint(Vec3(spick.X, spick.Y, spick.Z), Null, spick.entity), 20.0/16.0, 32)
EntityParent(am.bullethole , spick.entity, 0)
PaintEntity(am.bullethole , LoadMaterial("abstract::fire.mat"))
addMesh(am.bullethole, spick.entity)
updatemesh(am.bullethole)

 

Error is pointing me to AddMesh line and i understand error, but without addmesh there is no bulletholes.

 

I followed this document:

http://www.leadwerks...tle=CreateDecal

Share this post


Link to post

Like this?

addMesh(am.bullethole, TMesh(spick.entity))

(No bulletholes, but no errors when compiling)

 

And another question is how do i check if picked entity is suitable for decals to it's surface? Because now it's crashing when "shooting" to ground.

Share this post


Link to post

When I first saw the name of the thread I thought it said "butthole decals"...

Thats what got your attention? :D

Share this post


Link to post

Okay... So i got bulletholes working with 'planes'. Only problem is that bullethole materials behave strangely. From far bulletholes is blue, little bit closer, bullethole texture is stretched oddly. Near bullethole material is right, but no masking.

Is it even possible to make round bulletholes with planes?

 

Here is my bullethole solution:

am.bullethole = Createplane()
Scaleentity(am.bullethole, Vec3(.0625,.0625,.0625))
PaintEntity(am.bullethole, LoadMaterial("abstract::bullethole.mat"), 1)
entityParent(am.bullethole, spick.entity)
Positionentity(am.bullethole, spick.position, 1)
AlignToVector(am.bullethole, spick.normal,2,1)
EntityViewRange( am.bullethole, VIEWRANGE_NEAR)
am.timer = MilliSecs()

Share this post


Link to post

Okay... Bumping this topic up...

 

Looks like planes are not good for this, so i am still struggling with this thing. I tried it again with decals with this code:

am.bullethole = CreateDecal(spick.surface, TFormPoint(Vec3(spick.X, spick.Y, spick.Z), Null, spick.entity), 20.0/16.0, 32);
EntityParent(am.bullethole , spick.entity, 0);
PaintEntity(am.bullethole , LoadMaterial("abstract::bullethole.mat"),1)
AddMesh(am.bullethole, TMesh(spick.entity))

 

And what happens is this:

lolmo.png

 

 

So... It paints the surface black. Not what i am trying to do. Ideas?

Share this post


Link to post

Try loading the material to a variable. That way the programm doesn´t have to search the material everytime you create a bullethole.

TMaterial bulletMaterial = LoadMaterial("abstract::bullethole.mat");

Share this post


Link to post

Still not working that way.

 

When i look painted wall closely i see this:

bulletholes.png

 

Looks like it's painting entire surface with bulletholes. Closely there is bulletholes, little bit further wall is blue. And far, wall is black.

Help is appreciated.

Share this post


Link to post

Still not working. Now bulletholes can't be seen even in close range. Now it's grey when close to "bullethole".

 

Edit:

I made little bit changes to .mat file and now i got this.

bullethole.png

 

When i shot to wall it makes bullethole where i hit, but paints entire surface. (black from far, blue from near) When second bullet hits wall. It makes the same, but i think it paints over the earlier bullethole.

 

mat file looks like this:

texture0="abstract::bullethole.dds"
zsort=1
overlay=1
clamp0=1,1,0
clamp1=1,1,0

Share this post


Link to post

Can you attach to the topic your material, textures and little lua-script representing that issue? So it will be much easier to investigate the case.

Share this post


Link to post

I am not programming with LUA, but here is BMax code:

am.bullethole = CreateDecal(spick.surface, TFormPoint(Vec3(spick.X, spick.Y, spick.Z), Null, spick.entity), 20.0/16.0, 32);
EntityParent(am.bullethole , spick.entity, 0)
PaintEntity(am.bullethole , bulletholeMat)
AddMesh(am.bullethole, TMesh(spick.entity))

 

And here is .dds and .mat files:

http://www.mediafire...6qpqibdxq68qqx6

Share this post


Link to post

Here is working example.

 

Material file:

texture0="abstract::bullethole.dds"
shader="abstract::mesh_diffuse_bumpmap.vert","abstract::mesh_diffuse_bumpmap.frag"
overlay=1
blend=alpha
zsort=1
clamp0=1,1,0
clamp1=1,1,0

 

LUA-code:


bulletholeMat = LoadMaterial("abstract::bullethole.mat")

 

picked = CameraPick(camera, Vec3(GraphicsWidth() / 2, GraphicsHeight() / 2, 100), 0);

bullethole = CreateDecal(picked.surface, TFormPoint(picked.position, nil, picked.entity), 1.0/16.0, 32);

 

EntityParent(bullethole, mesh, 0)

PaintEntity(bullethole, bulletholeMat)

AddMesh(bullethole, picked.entity)

FreeEntity(bullethole)

 

And video:

 

LUA-script and files in attachment.

Bullethole 2012-10-06.rar

Share this post


Link to post

Thanks Daimour, but here is still problem.

 

erroru.png

 

It is pointed to this line:

 

AddMesh(am.bullethole, spick.entity)

 

If i change it to this:

 

addMesh(am.bullethole, TMesh(spick.entity))

 

 

No error, but no bulletholes either. :/

Is this Blitzmax bug or what?

Share this post


Link to post

1. Check type of your picked entity. It can be animated model with LODs or terrain or vegetation or something else. You need to drill down to real mesh.

 

2. Try to not add decal to mesh for awhile. Leave it as separate entity.

Share this post


Link to post

Decals work in blitzmax... well, at least as well as any other language using LE decals that drag down the FPS whenever multiple ones are used...

 

Two issues that I could see that might be causing an issue for you:

1) Make sure you use the decal texture Daimour returned in his example as it was a power of 2 and the original one you provided was not.

2) In the material file Daimour provided he is using a bumpmap shader, but yet there is no bumpmap assigned. This can cause issues as sometimes the last bumpmap will be used from another model. My suggestion is to either remove the bumpmap reference in the shader assignment or create a bumpmap and assign it in the material file.

 

Other than that, I can only assume its your code. Rather than wasting your time just posting snippets, make a small example and post it. It removes the problem with people having to guess whether there is another problem in your code that is causing the problem and it allows people to quickly test it without having to resort to building their own example.

 

bulletholeBMX.zip

Share this post


Link to post

I was writing message while you posted it. Now it's kind of working

holes.png

 

 

What are those black lines coming top of the hole?

 

And how can i get those holes working on picked entity?

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...