Half-viewed sprite
Blitz3D Forums/Blitz3D Programming/Half-viewed sprite
| ||
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? |
| ||
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. |
| ||
I didn't use align to vector. It's a sprite positioned with "CameraPick." But I'll try the MoveEntity anyway. |
| ||
Didn't work. Any other suggestions? Or how could I switch everything to AlignToVector? |
| ||
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. |
| ||
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. |
| ||
I know I'm using the correct "SpriteViewMode," but I'll see about this "AlignToVector" stuff - that command has never worked in the past. |
| ||
I think I doAlignToVector(bullet_h, PickedX(), PickedY(), PickedZ()-0.05, 3, 1) That would align the bullet to the wall, but 0.05 ahead, I think. |
| ||
nope - didn't work. |
| ||
No. Use PickedNX, PickedNY and PickedNZ. You need a normal vector for AlignToVector to work. PickedX/Y/Z simply return world coordinates. |
| ||
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? |
| ||
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 |
| ||
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? |
| ||
You could use that. Personally I'd use LinePick as it isn't reliant on the camera being in any specific position etc. |
| ||
Yeah - I'll try that. |
| ||
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 |
| ||
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. |
| ||
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 :( |
| ||
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 |
| ||
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. |
| ||
Remember and make sure the spriteviewmode is set correctly. |
| ||
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 |
| ||
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 |
| ||
Ah, I almost got it right. In my drunken state I forgot to MoveEntity the sprite in the right direction. :P |