Turn child brush transparant
Blitz3D Forums/Blitz3D Beginners Area/Turn child brush transparant
| ||
Another question from me! :) I have this map loading code:Function LoadWorld(file$) map=LoadAnimMesh(file) If Not map Return world=CreatePivot() meshes=CreatePivot(world) renderbrushes=CreateMesh(world) collisionbrushes=CreatePivot(world) pointentities=CreatePivot(world) solidentities=CreatePivot(world) EntityType collisionbrushes,COLLISIONTYPE_BRUSH For c=1 To CountChildren(map) node=GetChild(map,c) classname$=Lower(KeyValue(node,"classname")) DebugLog "Loading "+Chr(34)+classname+Chr(34)+"..." Select classname ; world Case "mesh" EntityParent node,meshes EntityType node,COLLISIONTYPE_MESH c=c-1 Case "terrain" EntityParent node,collisionbrushes EntityType node,COLLISIONTYPE_BRUSH, True c=c-1 Case "brush" AddMesh node,renderbrushes EntityType node,COLLISIONTYPE_BRUSH EntityAlpha node,0 EntityParent node,collisionbrushes c=c-1 Case "func_wall" AddMesh node,renderbrushes EntityType node,COLLISIONTYPE_BRUSH EntityParent node,collisionbrushes EntityAlpha node,0.5 c=c-1 ; info_dev_cam Case "info_devcam" angles$=keyvalue(node,"angles","0 0 0") pitch#=piece(angles,1," ") yaw#=piece(angles,2," ") roll#=piece(angles,3," ") If cam PositionEntity cam,EntityX(node),EntityY(node),EntityZ(node) RotateEntity cam,pitch,yaw,roll EndIf ; item_test Case "item_test" angles$=keyvalue(node,"angles","0 0 0") pitch#=piece(angles,1," ") yaw#=piece(angles,2," ") roll#=piece(angles,3," ") ; Laad de models item_test_model = LoadAnimMesh("content\models\item_score\item_score.b3d") PositionEntity item_test_model,EntityX(node),EntityY(node),EntityZ(node) RotateEntity item_test_model,pitch,yaw,roll ; create the entity create_item_test(item_test) End Select Next FreeEntity map Return world End Function When you look at the case "info_wall" you see that I am trying to make it partially transparent. It's basically a brush structure turned into a child in 3D world studio. Obviously, it does not work. I figured I need to get his surface first somehow and turn that alpha to 0.5. I tried to find more info, but could not find any. Can anyone help me with this? Thanks! |
| ||
AddMesh node,renderbrushes EntityType node,COLLISIONTYPE_BRUSH EntityParent node,collisionbrushes EntityAlpha node,0.5 c=c-1 That is not the way to use AddMesh. AddMesh copies the mesh and adds it to another mesh. Changing it afterwards has no effect on the added copy. I'm not working on a PC now, but maybe you can try to first apply alpha: 'EntityType node,COLLISIONTYPE_BRUSH 'EntityParent node,collisionbrushes EntityAlpha node,0.5 AddMesh node,renderbrushes FreeMesh node 'since node is not added to renderbrushes c=c-1 In order to get the brush, you'll need to get the meshes surfaces. Each surface has a brush assigned to it. A mesh could contain hierarchy, then the mesh has child entities. If memory serves me well, and say, the mesh has no childs, you should be able to do something like this: For i = 1 To CountSurfaces(mesh) surf = GetSurface(mesh, i) brush = GetSurfaceBrush(surf) BrushAlpha brush, 0.5 PaintSurface surf, brush '<--not sure if you need to do this FreeBrush brush '<---and this Next |
| ||
Thanks Warner! I've tried applying alpha first. It does not work. I do need it with this setup, cause the alpha thing is just a test. I would like to use brushes (child/limb) for many things so I would like to have it working in my current code. Anymore ideas? |
| ||
Maybe this?For i = 1 To CountSurfaces(mesh) surf = GetSurface(mesh, i) brush = CreateBrush(0, 127, 0) BrushAlpha brush, 0.5 PaintSurface surf, brush Next |
| ||
Forgive my ignorance but I've tried to incorporate that code into my own, but I must be doing something wrong.Case "func_wall" AddMesh node,renderbrushes For i = 1 To CountSurfaces(node) surf = GetSurface(node, i) brush = CreateBrush(0, 127, 0) BrushAlpha brush, 0.5 PaintSurface surf, brush Next This is part of the code posted in the first post. |
| ||
Well, what does AddMesh do there? AddMesh makes a copy of a mesh, and attaches/merges it with another mesh. After using AddMesh, you should free the original mesh. So maybe remove that line there for now. It could be a good idea to try it in a separate program. I can't do that right now (working on my Mac), but it would be a good approach. Just create a sphere or a cube, and try making it transparent with the above method. If that works, try using a loaded mesh instead of the cube/sphere. If that works, incorporate it in your original program. |
| ||
Thanks Warner, I will give it a shot. I will first take a look at how it will look without the add mesh. If that fail, I try the experiment. |