How to only render part of a mesh

Blitz3D Forums/Blitz3D Programming/How to only render part of a mesh

Rad Gravity(Posted 2006) [#1]
Hi everyone, just wondering if anyone knows of a way to render part of a mesh? The reason being I need an entity to appear through a semi-transparent surface without being visible behind the surface, ala stargate etc.

Thanks.


GfK(Posted 2006) [#2]
You could do a multi-pass render and switch off z-buffer clearing with CameraClsMode. I've never done it and don't use Blitz3D any more so can't really offer an example I'm afraid, but I'm pretty sure it could be done in this way.


big10p(Posted 2006) [#3]
Alternatively, you could clip the mesh, using this code:
http://www.blitzbasic.com/codearcs/codearcs.php?code=1143

However, this does not work with animated meshes!


Rad Gravity(Posted 2006) [#4]
Don't fancy doing any multipass renders as framerate tends to suffer too much.

That code is exactly what I need, thanks big10p, it's a static mesh too so no probs there. Guess I should have checked the archives first..


GfK(Posted 2006) [#5]
Don't fancy doing any multipass renders as framerate tends to suffer too much.
Shouldn't do - you're rendering the same amount of stuff, only you're doing it in two parts.


Rad Gravity(Posted 2006) [#6]
Surely you have to do at least two renderworld() calls? or am I barking up the wrong tree?


Damien Sturdy(Posted 2006) [#7]
Big10P i'm surprised you never linked to the z-clip code, it was you who created it originally wasn't it? :)

'Fraid I don't have the link here.


big10p(Posted 2006) [#8]
Big10P i'm surprised you never linked to the z-clip code, it was you who created it originally wasn't it? :)
Er, I did! :) Or, are you talking about some other clipping code?


Barliesque(Posted 2006) [#9]
I thought this new command would do something like that...

Added MeshCullBox for manual mesh culling. This allows you to correct some situations where an
animated mesh extends beyond the guesstimated bounding box.


...maybe it wasn't intended for this purpose exactly, but could be used for the same result?


Damien Sturdy(Posted 2006) [#10]
@Barliesque: Nope, not at all...

Big10p,I was talking about the DirectX Clip Plane code :)


big10p(Posted 2006) [#11]
Big10p,I was talking about the DirectX Clip Plane code :)
Ah, right. I didn't do that - I think it might have been Tom. Not sure. :)


Damien Sturdy(Posted 2006) [#12]
The include I have has your name on it... :S will source it out later. Maybe I'm getting confused :)


Rad Gravity(Posted 2006) [#13]
What's this about DX clip plane code?? sounds interesting.


big10p(Posted 2006) [#14]
Not sure what's happened there - I know nowt about DirectX and haven't written a dll in my life. :)


Damien Sturdy(Posted 2006) [#15]
Rad, I will post a demo later. I beleive the main function behind it was written by Tom (That's a known fact as it uses DX7) however i was pretty certain the demo code I based my system off was by big10p lol. Apparently not :)


Sledge(Posted 2006) [#16]
Yeah, Tom wrote the clip-plane DX stuff, didn't he? I use it. It's very good.

The thread author wants a far-side clip, though, and you can do that in B3D without resorting to a dll: Use a black* plane** to clip the object in question; copy the scene to a masked buffer; re-render with the object in question hidden; composite the masked buffer back over the scene; flip.

EDIT:
Like-a-this...



*or whatever mask colour you prefer.

**entityFX 1, mind.


Rad Gravity(Posted 2006) [#17]
Don't worry big10, your code archive does the job nicely anyway! I do like the idea of accessing dx more directly where it's appropriate though.

Cygnus, I'd be interested to see that demo.

Sledge, good to know there's more than one way to skin the cat as it were.


Damien Sturdy(Posted 2006) [#18]
my little tech demo here demonstrates how to use Tom's DX7 code to split a mesh at rendertime.

There's an include in there that you can use, at the moment it's got a credit to Big10p as his name was in the original one I modified lol... not sure how all that happened :)

http://damientsturdy.pwp.blueyonder.co.uk/Craft.zip

note: Copy the decls file to the blitz Decls folder for it to work. Also, It may have problems with Tom's latest DX7 dll.


Wings(Posted 2006) [#19]
You can modify the mesh too. if not removing vertex one can just adjust em.. dont ask me how i never done it.


Rad Gravity(Posted 2006) [#20]
Thanks for the demo cygnus, I may have to use this technique as, unfortunately, big10's algo works really well but is a little too resource intensive for my game (85fps drops to 40fps when using it).


Damien Sturdy(Posted 2006) [#21]
No prob. Thanks Tom and <unanimous> for the above :) (Will <Unanimous> come forward i wonder? :)