Half-viewed sprite

Blitz3D Forums/Blitz3D Programming/Half-viewed sprite

wizzlefish(Posted 2004) [#1]
I want to make a bullethole sprite appear on the level mesh, and it does, but half of it is inside the mesh, so you can't see it. I've tried "EntityOrder," but this just makes it so it appears on top of everything, which I don't want to happen. I only want it to appear on top of the level. Any ideas?


jfk EO-11110(Posted 2004) [#2]
move it a little away from the wall. Since you used AlignToVector (I assume) to position it on the wall, all you need to do now is to

MoveEntity hole,0,0,0.05

or maybe it's -0.05, or 0.01 - check it out.


wizzlefish(Posted 2004) [#3]
I didn't use align to vector.

It's a sprite positioned with "CameraPick."

But I'll try the MoveEntity anyway.


wizzlefish(Posted 2004) [#4]
Didn't work.

Any other suggestions?

Or how could I switch everything to AlignToVector?


_PJ_(Posted 2004) [#5]
Sorry, do you mean the Sprite isnt rotated correctly to align to the wall, or is it just too close to the wall that it is clipped?

I would suggest using AlignToVector so that the Sprite's rotation matches the wall exactly, remembering to select the correct SpriteViewMode.


Ross C(Posted 2004) [#6]
Using your camerapick, AlignToVector using the collision NX NY and NZ. Can't remember the order they are used, so you might have to fiddle about with it.


wizzlefish(Posted 2004) [#7]
I know I'm using the correct "SpriteViewMode," but I'll see about this "AlignToVector" stuff - that command has never worked in the past.


wizzlefish(Posted 2004) [#8]
I think I do

AlignToVector(bullet_h, PickedX(), PickedY(), PickedZ()-0.05, 3, 1)


That would align the bullet to the wall, but 0.05 ahead, I think.


wizzlefish(Posted 2004) [#9]
nope - didn't work.


GfK(Posted 2004) [#10]
No. Use PickedNX, PickedNY and PickedNZ. You need a normal vector for AlignToVector to work. PickedX/Y/Z simply return world coordinates.


John Blackledge(Posted 2004) [#11]
Sorry to be picky, Gfk, but I need to know this too.
Could you give a slightly more 'fleshed out' example, just say half a dozen lines?


GfK(Posted 2004) [#12]
Quick and dirty example. This aligns the bottom of the cone to the nearest polygon of the sphere. (The sphere is rotated to emphasise the fact that the AlignToVector stuff is actually doing something).

Graphics3D 800,600
camera = CreateCamera()
light = CreateLight(2)
MoveEntity light,-10,10,-10
sphere = CreateSphere()
EntityPickMode sphere,2
cone = CreateCone()
MoveEntity cone,5,0,0
MoveEntity camera,0,0,-10
While Not KeyDown(1)
	TurnEntity sphere,0,1,0
	LinePick EntityX(cone),EntityY(cone),EntityZ(cone),-10,0,0
	NX# = PickedNX()
	NY# = PickedNY()
	NZ# = PickedNZ()
	AlignToVector cone,nx,ny,nz,2,0.1
	UpdateWorld()
	RenderWorld()
	Flip
Wend



wizzlefish(Posted 2004) [#13]
So I could use this:
If MouseHit(1)
    ammo = ammo - 1
    picked = CameraPick(camera, 400, 300)
    nx# = PickedNX()
    ny# = PickedNY()
    nz# = PickedNZ()
    AlignToVector bullet_sprite, nx, ny, nz, 2, 0.1
EndIf


Or should I substitute CameraPick for LinePick?


GfK(Posted 2004) [#14]
You could use that. Personally I'd use LinePick as it isn't reliant on the camera being in any specific position etc.


wizzlefish(Posted 2004) [#15]
Yeah - I'll try that.


wizzlefish(Posted 2004) [#16]
This is what I ended up doing - although the sprite isn't even visible when I do this:
	;Shoot
	;-----
	If gun=1
	If ammo >= 1
	If MouseHit(1)
		PlaySound shoot
		ammo = ammo - 1
		picked=LinePick(400, 300, EntityZ(camera), 1, 1, 100)
		p.hole = New hole
		p\entityhandle = CopyEntity(bullethole)
		p\alpha = 0.9
		p\typething = "pistol"
		MoveEntity p\entityhandle, 0, 0, -1
		AlignToVector p\entityhandle, PickedNX(), PickedNY(), PickedNZ()-1, 3
		CreateSomeParticles(PickedX(), PickedY(), PickedZ(), 100, 100, 100, 6)
	EndIf
	EndIf
	EndIf



Ross C(Posted 2004) [#17]
AlignToVector p\entityhandle, PickedNX(), PickedNY(), PickedNZ()-1, 3


Your subtracting one from the vector. why? :o) Don't do that, and it should be fine.


wizzlefish(Posted 2004) [#18]
ok - I took away that:
	;Shoot
	;-----
	If gun=1
	If ammo >= 1
	If MouseHit(1)
		PlaySound shoot
		ammo = ammo - 1
		picked=LinePick(400, 300, EntityZ(camera), 0, 0, 100)
		p.hole = New hole
		p\entityhandle = CopyEntity(bullethole)
		p\alpha = 0.9
		p\typething = "pistol"
		nx# = PickedNX()
    	        ny# = PickedNY()
    	        nz# = PickedNZ()
		PositionEntity p\entityhandle, PickedX(), PickedY(), PickedZ()
		AlignToVector p\entityhandle, nx#, ny#, nz#, 2, 1
		MoveEntity p\entityhandle, 0, 0, -0.05
		CreateSomeParticles(PickedX(), PickedY(), PickedZ(), 100, 100, 100, 6)
	EndIf
	EndIf
	EndIf


and tried that - to no effect :(


big10p(Posted 2004) [#19]
try:

	;Shoot
	;-----
	If gun=1
	If ammo >= 1
	If MouseHit(1)
		PlaySound shoot
		ammo = ammo - 1
		picked = CameraPick(camera, 400, 300)
		p.hole = New hole
		p\entityhandle = CopyEntity(bullethole)
		p\alpha = 0.9
		p\typething = "pistol"
		nx# = PickedNX()
    	        ny# = PickedNY()
    	        nz# = PickedNZ()
		PositionEntity p\entityhandle, PickedX(), PickedY(), PickedZ()
		AlignToVector p\entityhandle, -nx#, -ny#, -nz#, 3, 1
		MoveEntity p\entityhandle, 0, 0, 0.05
		CreateSomeParticles(PickedX(), PickedY(), PickedZ(), 100, 100, 100, 6)
	EndIf
	EndIf
	EndIf




GfK(Posted 2004) [#20]
Um, is it a Blitz Sprite you're using? If so, try disabling backface culling using EntityFx Sprite,16. Its probably just facing the wrong way. You could also rotate it 180 degrees on the X or Y axis after AlignToVector as an alternative to disabling backface culling.


Ross C(Posted 2004) [#21]
Remember and make sure the spriteviewmode is set correctly.


DJWoodgate(Posted 2004) [#22]
Here is another example. Big10p and the others have probably fixed you up, but hey, I was bored.

Edit. Posted it to the the online docs.
http://www.blitzbasic.co.nz/b3ddocs/command.php?name=AlignToVector&ref=3d_cat#comments


wizzlefish(Posted 2004) [#23]
Thanks everyone!

This is what I ended up using - and it works! Thanks to all of you that helped! I'm really glad to have finally made this work.
	;Shoot
	;-----
	If gun=1 
	If ammo >= 1 
	If MouseHit(1) 
		PlaySound shoot 
		ammo = ammo - 1 
	 	picked = CameraPick(camera, 400, 300)
	 	p.hole = New hole
	 	p\entityhandle = CopyEntity(bullethole)
	 	p\alpha = 0.9
	 	p\typething = "pistol"
	 	nx# = PickedNX()
     	        ny# = PickedNY()
     	        nz# = PickedNZ()
	 	PositionEntity p\entityhandle, PickedX(), PickedY(), PickedZ()
	 	AlignToVector p\entityhandle, -nx#, -ny#, -nz#, 3, 1
	 	MoveEntity p\entityhandle, 0, 0, -0.05
	 	CreateSomeParticles(PickedX(), PickedY(), PickedZ(), 100, 100, 100, 6)
	EndIf
	EndIf
	EndIf



big10p(Posted 2004) [#24]
Ah, I almost got it right. In my drunken state I forgot to MoveEntity the sprite in the right direction. :P