folgender Code gibt einen Ungültigen Speicherzugriff, wenn der ParticleEmitter an das Entity "geheftet" werden soll:
Code: Alles auswählen
EnableExplicit
Define.i tempTexture, tempTexture2, tempMaterial, tempMaterial2, tempMesh, camera, light, emitter, entity
; init
InitEngine3D(#PB_Engine3D_DebugLog)
InitSprite()
InitKeyboard()
OpenWindow(0,0,0,1024,768,"Bug ParticleEmitter",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0), WindowHeight(0), 0, 0, 0, #PB_Screen_WaitSynchronization)
; create objects
tempTexture = CreateTexture(#PB_Any, 64, 64)
StartDrawing(TextureOutput(tempTexture))
Box(0, 0, 64, 64, RGB(128, 128, 128))
Box(0, 31, 64, 3, RGB(255, 255, 255))
Box(31, 0, 3, 64, RGB(255, 255, 255))
StopDrawing()
tempTexture2 = CreateTexture(#PB_Any, 5, 5)
StartDrawing(TextureOutput(tempTexture2))
DrawingMode(#PB_2DDrawing_AlphaBlend)
Box(0, 0, 5, 5, RGBA(0,0,0,0))
Circle(2, 2, 2, RGBA(0, 255, 255, 192))
StopDrawing()
tempMaterial = CreateMaterial(#PB_Any, TextureID(tempTexture))
tempMaterial2 = CreateMaterial(#PB_Any, TextureID(tempTexture2))
MaterialBlendingMode(tempMaterial2, #PB_Material_AlphaBlend)
MaterialDepthWrite(tempMaterial2, #False)
tempMesh = CreateCube(#PB_Any, 50)
entity = CreateEntity(#PB_Any, MeshID(tempMesh), MaterialID(tempMaterial), 0, 0, 0)
RotateEntity(entity, 0, 45, 0, #PB_Relative)
emitter = CreateParticleEmitter(#PB_Any, 5, 5, 10, #PB_Particle_Box)
ParticleMaterial(emitter, MaterialID(tempMaterial2))
ParticleEmitterDirection(emitter, 0, 1, 0)
ParticleSize(emitter, 5, 5)
ParticleTimeToLive(emitter, 10, 20)
ParticleEmissionRate(emitter, 30)
ParticleVelocity(emitter, 10, 20)
AttachEntityObject(entity, "", ParticleEmitterID(emitter))
; create light
light = CreateLight(#PB_Any, RGB(225, 225, 225), 0, 25, 250, #PB_Light_Directional)
LightLookAt(light, 0,0,0)
; create camera
camera = CreateCamera(#PB_Any, 0, 0, 100, 100)
MoveCamera(camera, 0, 25, 250, #PB_Absolute)
FreeMesh(tempMesh)
FreeMaterial(tempMaterial)
FreeMaterial(tempMaterial2)
FreeTexture(tempTexture)
FreeTexture(tempTexture2)
Repeat
While WindowEvent() : Wend
If ExamineKeyboard()
EndIf
RotateEntity(entity, 0, -0.1, 0, #PB_Relative)
RenderWorld()
FlipBuffers()
Until KeyboardReleased(#PB_Key_Escape)
End
Windows 7 64bit - DirectX9 und OpenGL subsystem - Purebasic 5.2 LTS (32bit & 64bit)
Laut Hilfe zu AttachEntityObject() soll man aber einen Emitter anheften können:
Code: Alles auswählen
ParticleEmitter: verwenden Sie ParticleEmitterID() als 'ObjektID'.