I need to align the emission cone to the emission vector.
What's the best way?
Use Arrows to modify emission pitch/yaw
+ - to modify emission cone
What's the best way?
Use Arrows to modify emission pitch/yaw
+ - to modify emission cone
Graphics3D 800,600,32,2 Global frameTimer = CreateTimer(60) Global camera=CreateCamera() CameraZoom camera,1 CameraRange camera, 0.1, 1000 MoveEntity camera,0,0,-3 Color 255,255,0 light=CreateLight(1) Type part Field sprite Field vx# Field vy# Field vz# Field deathtime End Type Global pAlive Global emDirX# Global emDirY# Global emDirZ# Global emDirYaw# Global emDirPitch#=90 Global emissionCone#=2 Global partSpeed#=.1 Global sphere=CreateSphere(2) ScaleEntity sphere,.08,.08,.08 HideEntity sphere Global arrow=CreateCone() ScaleEntity arrow,.08,.08,.08 RotateMesh arrow,90,0,0 EntityColor arrow,255,255,0 Global pole=CreateCube() ScaleEntity pole,.03,.03,.45 EntityColor pole,255,255,0 Function emissionTest() a.part=New part pAlive=pAlive+1 a\sprite=CopyEntity (sphere) EntityAlpha a\sprite,.3 a\deathtime=MilliSecs()+2000 rndEmCone#=Rnd(-emissionCone,emissionCone) p#=emDirPitch#+rndEmCone y#=emDirYaw#-rndEmCone sx#=Sin(p)*Cos(y#) sy#=Sin(p)*Sin(y#) sy#=Cos(p) a\vx#=sx*partSpeed# a\vy#=sy*partSpeed# a\vz#=sz*partSpeed# moveParticles() End Function Function moveParticles() For a.part=Each part MoveEntity a\sprite,a\vx*partSpeed,a\vy*partSpeed,a\vz*partSpeed If MilliSecs()>=a\deathtime Then FreeEntity a\sprite Delete a pAlive=pAlive-1 EndIf Next End Function Function drawEmDir() emDirX#=Sin(emDirPitch)*Cos(emDirYaw) emDirY#=Sin(emDirPitch)*Sin(emDirYaw) emDirZ#=Cos(emDirPitch) AlignToVector arrow,emDirX,emDirY,emDirZ,3 PositionEntity arrow,emDirX#*1.02,emDirY#*1.02,emDirZ#*1.02 AlignToVector pole,emDirX,emDirY,emDirZ,3 PositionEntity pole,emDirX#*.5,emDirY#*.5,emDirZ#*.5 End Function ;---------------------------------------------------------------------------------------------------- ; MAIN LOOP ----------------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------------- While Not KeyHit(1) WaitTimer(frameTimer) ;rispetta il limite di fps If KeyDown(205) Then emDirYaw=emDirYaw+2 If KeyDown(203) Then emDirYaw=emDirYaw-2 If KeyDown(200) Then emDirPitch=emDirPitch+2 If KeyDown(208) Then emDirPitch=emDirPitch-2 If KeyDown(78) And emissionCone<360 Then emissionCone=emissionCone+1 If KeyDown(74) And emissionCone>0 Then emissionCone=emissionCone-1 emissionTest() UpdateWorld() RenderWorld() drawEmDir() tc=0 tc=tc+1 Text (26-FontWidth()),FontHeight()*tc,"emDirPitch : "+emDirPitch tc=tc+1 Text (26-FontWidth()),FontHeight()*tc,"emDirYaw : "+emDirYaw tc=tc+1 Text (26-FontWidth()),FontHeight()*tc,"emDirX : "+emDirX tc=tc+1 Text (26-FontWidth()),FontHeight()*tc,"emDirY : "+emDirY tc=tc+1 Text (26-FontWidth()),FontHeight()*tc,"emDirZ : "+emDirZ tc=tc+1 Text (26-FontWidth()),FontHeight()*tc,"emissionCone : "+emissionCone tc=tc+1 Text (26-FontWidth()),FontHeight()*tc,"Parts Alive : "+pAlive Flip() Wend End