Noob needs help
Blitz3D Forums/Blitz3D Beginners Area/Noob needs help
| ||
hey all, am new here and to blitz3d/programming in general, I feel stupid for asking this but i just can't figure this out, Im trying to add a blur effect to my plane like in the jet trails sample, problem is i have my plane parented to a pivot ( camera is also parented to this ) and if i increase the speed of the pivot each loop so as to have the plane accelerate then the interval between the creation of each copy is equal to the speed of piv, meaning i end up with planes with huge gaps between them instead of a nice stream of blur behind my plane... ugh... that's the best i can really explain it... here's the code maybe you can figure out what i mean... Graphics3D 1024,768,32,1 Const FPS=30 Type blur Field entity Field alpha# End Type Type tower Field entity Field entityb End Type Collisions 2,1,2,2 Global sky,plane,skybox Global fighter,scraper,house Global wood_tex,redbrick,reflect_tex,building_tex,concrete_tex,sky_tex,tower_tex,ground Global piv,cam_piv,cam,camy,camz,pivspeed#,jumpspeed# Load_Textures() Create_Cameras() Load_Meshes() Setup_World() skybox=Make_Sky_Box("sky") EntityParent skybox,cam period=1000/FPS time=MilliSecs()-period WBuffer enable AntiAlias enable ;main loop While Not KeyHit(1) Cls Repeat elapsed=MilliSecs()-time Until elapsed ;how many 'frames' have elapsed ticks=elapsed/period ;fractional remainder tween#=Float(elapsed Mod period)/Float(period) For k=1 To ticks time=time+period If k=ticks Then CaptureWorld Update_Game() UpdateWorld Next RenderWorld tween RenderWorld tween Flip Wend End SetBuffer BackBuffer() Function Create_Cameras() piv=CreatePivot() EntityType piv,2 PositionEntity piv,EntityX(piv),EntityY(piv),EntityZ(piv) cam_piv=CreatePivot(piv) cam=CreateCamera(cam_piv) CameraRange cam,10,150000 CameraClsMode cam,True,True PositionEntity cam,0,80,-120 EntityPickMode(piv,1) End Function Function Make_Sky_Box( file$ ) m=CreateMesh() ;front face b=LoadBrush( file$+"_FR.bmp",49 ) s=CreateSurface( m,b ) AddVertex s,-1,+1,-1,0,0:AddVertex s,+1,+1,-1,1,0 AddVertex s,+1,-1,-1,1,1:AddVertex s,-1,-1,-1,0,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ;right face b=LoadBrush( file$+"_LF.bmp",49 ) s=CreateSurface( m,b ) AddVertex s,+1,+1,-1,0,0:AddVertex s,+1,+1,+1,1,0 AddVertex s,+1,-1,+1,1,1:AddVertex s,+1,-1,-1,0,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ;back face b=LoadBrush( file$+"_BK.bmp",49 ) s=CreateSurface( m,b ) AddVertex s,+1,+1,+1,0,0:AddVertex s,-1,+1,+1,1,0 AddVertex s,-1,-1,+1,1,1:AddVertex s,+1,-1,+1,0,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ;left face b=LoadBrush( file$+"_RT.bmp",49 ) s=CreateSurface( m,b ) AddVertex s,-1,+1,+1,0,0:AddVertex s,-1,+1,-1,1,0 AddVertex s,-1,-1,-1,1,1:AddVertex s,-1,-1,+1,0,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ;top face b=LoadBrush( file$+"_UP.bmp",49 ) s=CreateSurface( m,b ) AddVertex s,-1,+1,+1,0,1:AddVertex s,+1,+1,+1,0,0 AddVertex s,+1,+1,-1,1,0:AddVertex s,-1,+1,-1,1,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ScaleMesh m,1000,1000,1000 FlipMesh m EntityFX m,9 EntityOrder m,10 Return m End Function Function Load_Meshes() fighter=LoadMesh("newplane.b3d",piv) PositionEntity fighter,EntityX(fighter),EntityY(fighter)+40,EntityZ(fighter) RotateEntity fighter,0,180,0 EntityTexture fighter,reflect_tex scraper=LoadAnimMesh("buildingb.b3d") PositionEntity scraper,0,0.15,1000 RotateEntity scraper,0,180,0 ScaleEntity scraper,100,100,100 house=LoadMesh("house.b3d") ScaleEntity house,60,60,60 PositionEntity house,-6000,0.15,-6000 EntityType house,1 End Function Function Setup_World() plane=CreatePlane() EntityShininess plane,1 EntityTexture plane,ground light=CreateLight() For tempe=0 To 99 block.tower=New tower block\entity=CopyEntity(scraper) EntityType block\entity,1,True block\entityb=CreateCube() ScaleEntity block\entityb,2000,18200,2000 HideEntity block\entityb EntityTexture block\entityb,building_tex PositionEntity block\entity,4000+xpos,0.01,2000+zpos PositionEntity block\entityb,4000+xpos,0.01,2000+zpos zpos=zpos+15000 If zpos>=150000 zpos=zpos-150000 xpos=xpos+15000 EndIf Next FreeEntity scraper mode=1 count=0 End Function Function Load_Textures() ground=LoadTexture("ground.bmp") ScaleTexture ground,200,200 reflect_tex=LoadTexture("reflection.jpg",64) concrete_tex=LoadTexture("concrete.bmp") flame_tex=LoadTexture("flamesprite.bmp") building_tex=LoadTexture("building.bmp") ScaleTexture building_tex,1,0.05 sky_tex=LoadTexture("sky.bmp") tower_tex=CreateTexture(256,256) ScaleTexture tower_tex,1,0.2 redbrick=LoadTexture("redbrick.bmp") wood_tex=LoadTexture("wood.bmp") End Function Function Update_Player() RotateEntity piv,EntityPitch(piv),EntityYaw(piv),EntityRoll(piv) EntityRadius piv,140 If JoyDown(3)=True pivspeed#=pivspeed#+2 If pivspeed#>400 Then pivspeed#=400 If pivspeed#>0 And JoyDown(7)=True add_motion_blur(fighter) If EntityY(cam)<150 camy=camy+2 camz=camz-8 cap=cap-5 EndIf pivspeed#=pivspeed#*3 EndIf Else pivspeed#=pivspeed#-2 If EntityRoll(piv)>0 Then TurnEntity piv,0,0,-4 If EntityRoll(piv)<0 Then TurnEntity piv,0,0,4 If EntityPitch(piv)>0 Then TurnEntity piv,-4,0,0 If EntityPitch(piv)<0 Then TurnEntity piv,4,0,0 If pivspeed#<0 Then pivspeed#=0 EndIf MoveEntity piv,0,0,0+pivspeed# If JoyX()<-0.9 If EntityRoll(fighter)<180 TurnEntity fighter,0,0,-10 EndIf TurnEntity piv,0,4,0 EndIf If JoyX()>0.9 If EntityRoll(fighter)>-180 TurnEntity fighter,0,0,10 EndIf TurnEntity piv,0,-4,0 EndIf If EntityRoll(fighter)>0 TurnEntity fighter,0,0,-4 EndIf If EntityRoll(fighter)<0 TurnEntity fighter,0,0,4 EndIf If JoyY()<0.5 TurnEntity piv,4,0,0 EndIf If JoyY()>-0.5 TurnEntity piv,-4,0,0 EndIf End Function Function Update_Camera() If JoyRoll()>100 Then TurnEntity cam_piv,0,2,0 If JoyRoll()<-100 Then TurnEntity cam_piv,0,-2,0 If JoyZ()>0.9 Then TurnEntity cam_piv,2,0,0 If JoyZ()<-0.9 Then TurnEntity cam_piv,-2,0,0 If JoyHit(12) Then RotateEntity cam_piv,0,0,0 If EntityY(cam)>80 camy=camy-1 camz=camz+4 EndIf MoveEntity cam,0,camy,camz PositionEntity skybox,EntityX(cam),EntityY(cam),EntityZ(cam) RotateEntity skybox,0,0,0,True PositionEntity cam,EntityX(cam),EntityY(cam),EntityZ(cam) camy=0 camz=0 End Function Function Update_Game() Update_Camera() update_player() update_motion_blur(fighter) For block.tower=Each tower If EntityVisible (block\entity,cam) And EntityDistance(piv,block\entity)>30000 HideEntity block\entity ShowEntity block\entityb ElseIf EntityDistance(piv,block\entityb)<30000 HideEntity block\entityb ShowEntity block\entity EndIf Next End Function Function Add_Motion_Blur(ent) b.blur=New blur b\entity=CopyEntity(ent) PositionEntity b\entity,EntityX(ent,1),EntityY(ent,1),EntityZ(ent,1) RotateEntity b\entity,EntityPitch(ent,1),EntityYaw(ent,1),EntityRoll(ent,1) b\alpha#=0.5 EntityAlpha b\entity,b\alpha# ScaleEntity b\entity,0.95,0.95,0.95 End Function Function Update_Motion_Blur(ent) For b.blur=Each blur If b\alpha#>0 Then b\alpha#=b\alpha#-.02 EntityAlpha b\entity,b\alpha# Else FreeEntity b\entity Delete b End If Next End Function also have a question regarding the b3d format, i was wondering if the heirarchy is retained in b3d as in 3ds every time i use countchildren on a b3d mesh i only get 2 i think... it would be really useful for hiding an animated characters sword for example... |
| ||
There have been various methods for this: http://www.blitzbasic.com/codearcs/codearcs.php?code=1793 http://www.blitzbasic.com/codearcs/codearcs.php?code=1561 http://www.blitzbasic.com/codearcs/codearcs.php?code=1146 There are texture blur routines in the code archives too. |
| ||
thanks |
| ||
And yes, hierarchy is retained in .b3d format. If you look at the .b3d file spec here: http://www.blitzbasic.com/sdkspecs/sdkspecs/b3dfile_specs.txt There is an example down the bottom showing how it's structured. Obviously what you see with countchildren depends on how you created the model and what you exported it with / from. Typically you will have the scene root, then below that your mesh(es). |
| ||
Also, could you please make you post titles reflect in some way the information you are looking for. It makes it more likly that you will get help, and makes searching a lot easyer. Thanks |
| ||
cool thanks, will make my titles more informative in future, sry. |
| ||
Oh, just a tip, 786979... When you've got a lot of code you want to post, it makes your post a lot more readable if you put it in a codebox like this: That's the same code you entered in, but much more compact, visually speaking. If you want to know how to do that, click on the "Home" tab of this site, then click "FAQ," then click "forum codes." L8r! |
| ||
One more thing: to display an animated meshes hierarchy you should use one of the recursive sources from the archives. Additionally you can use EntityClass$(entity) to print out what it is, a pivot, mesh, etc. |
| ||
cool thnx a lot, and I'll use them codeboxes in future too :) sorry bout that, did say I'm a noob though huh :D |
| ||
ok, I've used jfk's recursive mesh hierarchy app from the code archives, problem is all my child entities are pivots, which is useful, but I really want to access the child meshes, so I can hide my characters sword for example, is this something to do with the modelling program I'm using? I'm using milkshape3d if I export to b3d format all I get are pivots and if I export to 3ds all I get are meshes, ideally I'd like to be able to access the pivots and meshes using .b3d, as I said above I'm a total Noob, so I apologise if this seems like a dumb question. |
| ||
The 3ds format probably doesn't support pivots, so things which Milkshape thinks are pivots are being exported as ( invisible? ) meshes. B3D format should have both meshes and pivots. However, it depends exactly what you're doing here. In order to be a separate mesh in the hierarchy, the objects need to be separate/detached in Milkshape, and/or they need a separate material. If you can, upload the model so that we can take a better look. |
| ||
no its exporting an animated mesh so I'm getting all my pivots/joints, just not my child meshes, doesn't matter I figured out a way to do it, I just use countsurfaces and then paint the sword with an alpha brush, same thing really, being able to access the mesh itself would be more useful. |
| ||
no its exporting an animated mesh so I'm getting all my pivots/joints, just not my child meshes, Assuming you mean skeletal animation then indeed all bets are off. Ultimate Unwrap will only export skeletal animation for a single object, so perhaps Milkshape is the same way except that it combines everything into one object automatically. Frankly, it would probably be better not to save the sword in the same file. Save it as a separate mesh, then find the right hand pivot and parent it to that pivot. Then not only do you have access to the mesh, you can actually swap it out for a different weapon, hide it, etc. |
| ||
Hey, 786979, don't sweat the codebox thing man; it doesn't matter all that much, it just makes you more likely to get a response. It's basic psychology: people are more liable to turn away from a post that opens with a large mass of text. I know it's the same amount with or without a codebox, it just looks better to people who decide "at-a-glance" whether to respond or not. BTW, while normally I like to help people with their problems, B3D is out of my league right now... Sorry T_T |
| ||
Hey, 786979, don't sweat the codebox thing man; it doesn't matter all that much, it just makes you more likely to get a response. It's basic psychology: people are more liable to turn away from a post that opens with a large mass of text. I know it's the same amount with or without a codebox, it just looks better to people who decide "at-a-glance" whether to respond or not. BTW, while normally I like to help people with their problems, B3D is out of my league right now... Sorry T_T |
| ||
Hey, 786979, don't sweat the codebox thing man; it doesn't matter all that much, it just makes you more likely to get a response. It's basic psychology: people are more liable to turn away from a post that opens with a large mass of text. I know it's the same amount with or without a codebox, it just looks better to people who decide "at-a-glance" whether to respond or not. BTW, while normally I like to help people with their problems, B3D is out of my league right now... Sorry T_T |