Jump to content

Bullethole decals


Arska134
 Share

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

Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax

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

Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax

Link to comment
Share on other sites

Is there example for me to take a look?

 

 

Have you tried .... searching the forum for "CreateDecal" or even just "Decal"?

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
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()

Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax

Link to comment
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?

Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax

Link to comment
Share on other sites

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.

Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax

Link to comment
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

Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax

Link to comment
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

Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax

Link to comment
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

  • Upvote 5
Link to comment
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?

Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax

Link to comment
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

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

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?

Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax

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

 Share

×
×
  • Create New...