Jump to content

Emitters + Framework


Quan
 Share

Recommended Posts

I have been playing around with loading scenes and working out how to use the framework when I ran into a problem with Emitters which I haven't been able to nut out.

 

While loading a scene, I thought ' hey this would be cool with snow ' So I wipped up a emitter in a basic program then moved it into the scene loader.

 

When I compile and run I first get a dialog box with just 0 in it. Then I get Unhanded Exception:Attempt to access field or method of null object. The debugger then points to fw.render()

 

Any ideas as to what I am doing wrong with the Emitters ?

 

Thanks

 

Here is the code for the scene loader:

 

Strict
Framework leadwerks.engine 

Import "C:\Program Files\Leadwerks Engine SDK\BMX\Framework\framework.bmx"
Include "lua-gluefunctions.bmx"

AppTitle:String = "Test World"

RegisterAbstractPath("C:\Program Files\Leadwerks Engine SDK\")

Graphics 1024,768,0

AFilter(1)
TFilter(1)

Global fw:TFramework = TFramework.Create()
If Not fw RuntimeError "Failed to initialize engine."

       SetScriptObject("fw", fw)'Setup the global script objects.
       SetPostFX()'Setup the post processing FX

Local cam:TCamera = fw.Main.Camera
MoveEntity cam, Vec3(0, 20, - 3)
TurnEntity cam, Vec3(5, 0, 0)

local scene:TEntity = LoadScene("abstract::basic.sbx")

local snowemitter:TEmitter=CreateEmitter(100,1000)
PaintEntity snowemitter,LoadMaterial("Abstract::dust.mat")
SetEmitterRadius snowemitter,0,0.1
SetEmitterArea snowemitter,vec3(100)
SetEmitterVelocity snowemitter,vec3(0),vec3(1)
SetEmitterAcceleration snowemitter,vec3(0,-0.5,0)
SetEmitterWaver snowemitter,2.0

'Local music:TSound = LoadSound("C:\BlitzMax\My Projects\LeadWerks Test\Sound\snowing.ogg")
'Global bgmusic:TSource = CreateSource(music,SOURCE_LOOP)
'PlaySource(bgmusic)

Local camrotation:TVec3=Vec3(0) 
Local mx:Float 
Local my:Float 

Local move:Float
Local strafe:Float

HideMouse 
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2

While Not ( KeyHit (KEY_ESCAPE) )

	mx=Curve(MouseX()-GraphicsWidth()/2,mx,6)
	my=Curve(MouseY()-GraphicsHeight()/2,my,6) 
	MoveMouse GraphicsWidth()/2,GraphicsHeight()/2

	camrotation.x=camrotation.x+my/10 
	camrotation.y=camrotation.y-mx/10 
	RotateEntity cam,camrotation

	move =Curve(KeyDown(KEY_W)-KeyDown(KEY_S),move,20) 
	strafe =Curve(KeyDown(KEY_D)-KeyDown(KEY_A),strafe,20) 
	MoveEntity cam,Vec3(strafe/10,0,move/10)

	fw.Update()
	fw.render()
	Flip
Wend

'Functions from Marleys Ghost simple scene loader http://leadwerks.com/werkspace/index.php?/topic/670-a-simple-scene-loader-in-blitzmax/ 

Function SetPostFX()'0 = off : 1 = on.
       fw.renderer.SetAntialias(1)
       fw.renderer.SetBloom(1) 
       fw.renderer.SetGodRays(1)
       fw.renderer.SetHDR(1)
       fw.renderer.SetSSAO(0)
       fw.renderer.SetWireFrame(0)     
End Function

Function SetScriptObject(name:String, o:Object)
       Local size:Int=GetStackSize()
       lua_pushbmaxobject(luastate.L,o)
       lua_setglobal(luastate.L,name)
       SetStackSize(size)
EndFunction

Function GetStackSize:Int()
       Return lua_gettop(luastate.L)
EndFunction

Function SetStackSize(size:Int)
       Local currentsize:Int=GetStackSize()
       If size<currentsize
       lua_pop(luastate.L,currentsize-size)
       EndIf
EndFunction

BMax 1.38 * Leadwerks 2.4 * Unity 3.0 Pro * Intel Core 2 Duo 6600 - Win7 64bit - ATI 4870

Link to comment
Share on other sites

you are not alone... even a simple emitter entity placed into an Editor scene and then loaded into a bmax program causes a crash now. I assume it has to do with this statement from Josh's blog:

In addition, particle emitters will now store the particle velocity in the first texture coordinate array of the surface

whatever that means ;)

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

I added an emitter to the test scene I use with the basic scene loader in Bmax and got the same error .. however I did not get the error when using the same scene with the basic scene loader in C++, and an emitter was placed and working.

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

You have to have the scripts folder in the appdir so removal is not good lol, but intersting you then get an emitter to work after doing so...

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

You have to have the scripts folder in the appdir so removal is not good lol, but intersting you then get an emitter to work after doing so...

 

well i assume that shows there's an issue between lua's framework and bmax framework then? something that would affect emitters? ;)

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Not sure yet, just trying a few things.

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

well this is interesting... wh1sper had reported the same bug for c++ on the 6th inside the tracker. but you said it works now for you in c++? did this just get fixed on the c++ side?

 

 

Just checking on that.. I simply ran the app as was .. need to check the C++ app with the latest scripts and DLL's ..

 

still far too early for problem solving lol

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

ok updated the scripts, DLL's and shader.pak for the C++ app and it still runs fine. Hey god rays has a nice effect on the snow lol ..

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

Extra things tried so far.

 

Regenerated lua-gluefunctions.bmx

Sync'd again (just in case)

Updated the scripts in the appdir

updated DLL's in appdir

 

still getting Unhandled Exception:Attempt to access field or method of null object @ fw.render()

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

in the standard Bmax IDE it halts and highlights fw.render() ..

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

Been doing a bit more testing. It only gets upset if I load a scene with a directional light in it. As soon as I delete that light its happy but I guess that light is what creates the godrays.

 

As a test I added a directional light to my test code with no scene and I got the same issue. Removed Emitters and the program compiles ( and I now have godrays :) ).

BMax 1.38 * Leadwerks 2.4 * Unity 3.0 Pro * Intel Core 2 Duo 6600 - Win7 64bit - ATI 4870

Link to comment
Share on other sites

yeah you need the D-Light for G-Rays ... the same scene I am using that gets the issue in Bmax works fine in C++ the scene only has the one light, a D-Light ..

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

Sitting down last night I dragged out the C++ compiler and did a bit more testing.

 

What I found is I get the same sort of crash when I run this C++ code. If you change from a Directional Light to a point light it is fine.

 

//	====================================================================
//	This file was generated by Leadwerks C++/LEO/BlitzMax Project Wizard
//	Written by Rimfrost Software
//	http://www.rimfrost.com 
//	====================================================================

#include "engine.h"

int WINAPI WinMain( HINSTANCE hInstance,
				HINSTANCE hPrevInstance,
				LPSTR lpCmdLine,
				int nShowCmd ) 
{
Initialize() ;
RegisterAbstractPath("C:/Program Files/Leadwerks Engine SDK");
SetAppTitle( "LWVS2008test" ) ;
Graphics( 1024, 768 ) ;
AFilter() ;
TFilter() ;

TWorld	world;
TBuffer gbuffer;

world = CreateWorld() ;
if (!world) {
	MessageBoxA(0,"Error","Failed to create world.",0);
	return Terminate();
}

gbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL);

TEntity cam;
cam=CreateCamera(0);
MoveEntity(cam,Vec3(0,0,-5));

TMesh cube;
cube=CreateCube(0);
MoveEntity(cube,Vec3(1,0,0));

TMesh ground;
ground=CreateCube(0);
ScaleEntity(ground,Vec3(50,.1,50));
MoveEntity(ground,Vec3(0,-20,0));

TLight light=CreateDirectionalLight(); // causes crash.
// TLight light=CreatePointLight(); // works fine.
PositionEntity(light,Vec3(2,2,-2));
RotateEntity(light,Vec3(45,45,0));
SetShadowmapSize(light,512);

TEmitter snowemitter = CreateEmitter(500,10000);
PaintEntity (snowemitter,LoadMaterial("Abstract::dust.mat"));
SetEmitterRadius (snowemitter,0,0.2);
SetEmitterArea (snowemitter,Vec3(100));
SetEmitterVelocity (snowemitter,Vec3(0),Vec3(1));
SetEmitterAcceleration (snowemitter,Vec3(0,-0.5,0));
SetEmitterWaver (snowemitter,2.0);

EntityParent(snowemitter,cam);


// Game loop
while( !KeyHit() && !AppTerminate() )
{
		TurnEntity(cube,Vec3(1,1,0));
		UpdateWorld(1);
		SetBuffer(gbuffer);
		RenderWorld(RENDER_ALL);
		SetBuffer(BackBuffer());
		RenderLights(gbuffer);
		Flip(1) ;

}

// Done
return Terminate() ;
}

BMax 1.38 * Leadwerks 2.4 * Unity 3.0 Pro * Intel Core 2 Duo 6600 - Win7 64bit - ATI 4870

Link to comment
Share on other sites

I think theres more to this than just the emitters :)

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

yeah, this looks like there are some files that didn't get updated for this update...

 

so far:

  • Emitters (whether created by bmax or loaded from a sbx) will crash the bmax program with blide pointing at an issue at Emitters.bmx (maxide points to the fw.Render())
  • Any pointlight in a scene with water loaded into a bmax program will crash the program with blide pointing to world.bmx (maxide points to the fw.Render())

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Yep.

 

Now that I can see the snow I have noticed that its falling behind the water. I think this is because its on the wrong layer but I am not sure how to tell the emitter to be in the transparency layer.

 

When it comes to using the framework I do get a bit lost :)

BMax 1.38 * Leadwerks 2.4 * Unity 3.0 Pro * Intel Core 2 Duo 6600 - Win7 64bit - ATI 4870

Link to comment
Share on other sites

SetWorld(fw.transparency.world)
then create the emitter
and set its properties
...
SetWorld(fw.main.world)

 

But there is a bigger issue happening here. Any emitter created and saved in an Editor scene will crash a bmax program. Same thing happens with pointlights and waterplanes. Both emitters and pointlights were worked on during this update. So I am hoping Josh just forgot to upload some new files...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Certainly something is broken thats for sure ..

 

As mack said about the Waterplane and pointlight .. a simple scene with only a water plane and a PLight will cause the error .. other scenes when a P light is rendered and its light would fall "onto" a WPlane .. the error happens. I have checked the same scenes in C++ and no error. The same for emitters .. any scene with an emitter causes the crash, not so in C++ as far as I can tell.

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

Yep seems something is broken in 2.31 :)

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

actually it seems it happens if the P-Light is rendered in the same view as the WPlane it does not have to actually render on it :)

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

:blink:

 

The Emitter Problem:

 

Basic scene, 1 x Directional light : 1 x Skybox : 1 x Terrain : 1 x Emitter (all generic to the SDK)

 

LE_TEST.zip

 

Using the Basic Scene Loader code it will crash the app with:

 

"Unhandled Exception:Attempt to access field or method of null object."

 

The debugger then points to fw.render()

 

Remove the Emitter and alls well in the world. Except of course no emitter :)

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...