Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

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

Link to post
Share on other sites

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.

Link to post
Share on other sites

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()

Link to post
Share on other sites
  • 1 month later...

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?

Link to post
Share on other sites

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

Link to post
Share on other sites

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

Link to post
Share on other sites

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

Link to post
Share on other sites

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?

Link to post
Share on other sites

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

Link to post
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
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...