Everything is transparent to loaded sprites
Blitz3D Forums/Blitz3D Programming/Everything is transparent to loaded sprites
| ||
the cube is rotating. for some reason, the cube is semi-transparent when it is on one side. when it rotates to the other side, it covers the sprite so you cant see it. the sprite should be on top of the cube(closer to the camera). it works fine when I do createsprite, but not with load sprite. what do I do? I tried setting the flags parameter, but the docs dont explain nearly enough. This is why I dont like programming in 3D. you dont have control of what is on the screen, and all these unexpected things happen Graphics3D 800,600,0,2 SetBuffer BackBuffer() light=CreateLight() camera=CreateCamera() TurnEntity camera,90,0,0 PositionEntity camera,0,20,0 s=LoadSprite("ship.bmp") SpriteViewMode s,2 TurnEntity s,90,0,0 PositionEntity s,1,15,0 EntityAlpha s,1 cube=CreateCube() ScaleEntity cube,20,1,10 PositionEntity cube,0,-50,0 EntityAlpha cube,1 Repeat If KeyHit(1) Then End TurnEntity cube,1,0,0 RenderWorld Flip Forever |
| ||
Deactivate the following lines: ;SpriteViewMode s,2 ;TurnEntity s,90,0,0 and test if the Sprite can be seen at all. Maybe you have to use an other Degree: turnentity 0,0,90 instead? |
| ||
What did you set the flag parameter to? it should work Ok if you set 2 or 4. Otherwise I think blend mode 3 is assigned. If you dont want to use 2 or 4 then try Entityblend s,1. There is a bit of a difference here between createsprite and loadsprite behaviour. I expect it goes something like this. Loadsprite knows what flags are being used and sets the blend mode accordingly. Createsprite has no such luxury and so the default blend mode is used. So, clever old Loadsprite eh? |
| ||
thanks, It works when I set the flag to 4, what does it mean by masked? doesnt work with 2. entityblend works but causes it to draw the black of the image also was I supposed to know that? |
| ||
Hmmm, yes sorry, you probably need an alpha channel for 2 to work properly (not possible with a bmp though, you need to use png or tga). Otherwise the alpha value at each pixel is derived from the total r+g+b color values which will be more or less effective depending on the colors used (black is transparent, white is opaque). Masked (flag 4) means the black parts of the texture are set to alpha 0 (transparent). See Createtexture in the docs for a description of the flags. If its not in the docs generally I just experiment and see what happens. Needless to say all this stuff has been discussed on these forums in the past, though granted finding it might be a problem! Studying some of the the code in the archives can be enlightening as well. |