Jump to content

Cole Chapman

Members
  • Posts

    138
  • Joined

  • Last visited

Posts posted by Cole Chapman

  1. Was wondering if anyone on here has invested in Gold. I about 2 1/4 oz gold coins not too long ago and with the events currently playing out, prices are soaring. :(

  2. Sorry for the abundance of questions I have been asking.

     

    Problem: Identifier "FreeTexture" not found

     

    Variables:

    Framework MaxGUI.MaxGUI
    Import MaxGUI.Drivers
    Import BRL.EventQueue
    Import Leadwerks.Engine
    Import "../../Imports/Framework.BMX"
    RegisterAbstractPath("C:\Leadwerks Engine SDK")
    

     

    I want it to free everything (I found ResetFramework() and I am currently using that) however, I still would like to know what this issue is.

  3. When I have VSync on The program's CPU Usage stays around 4-6%. When I turn VSync off, the CPU Usage goes to about 50%. Is that big of a change normal?

     

    EDIT: On that same note, I think its sweet that the CPU performance is so low when VSync in on. I use "While PeekEvent" in BMax (without any Leadwerks code) and the CPU Usage is about 50% but when I use leadwerks and set VSync on, it stays low (4-6%) so thats sweet.

  4. Nvm, I got it

     

    Framework leadwerks.ENGINE
    Import "Framework.BMX"
    RegisterAbstractPath( "C:/Leadwerks Engine SDK" ) 
    'RegisterAbstractPath("zip::Package.pak")
    SetZipStreamPassword("PackagePass.pak", "12345")
    GCSetMode(2)
    AppTitle:String = "Game Client"
    
    
    Global FW:TFramework
    Local Mesh:TMesh
    Local Light:TLight
    Local Ground:TMesh
    Local Material:TMaterial
    
    
    Graphics(800,600)
    
    
    FW:TFramework = CreateFramework()
    If Not FW RuntimeError "Failed to create world."
    
    Global Terrain:TTerrain
    Local TerrainText:TTexture
    Global Move:Float
    Global Strafe:Float
    Global CamRotation:TVec3 = Vec3(0)
    Global mx:Float
    Global my:Float
    Global MouseXInt:Int
    Global MouseYInt:Int
    
    Terrain = CreateTerrain(2048)
    LoadTerrainHeightmap(Terrain, "zip::PackagePass.pak//Terrain.raw")
    TerrainText = LoadTexture("zip::PackagePass.pak//TerrainGrass.dds")
    SetTerrainTexture(Terrain, TerrainText, 0, 0)
    PositionEntity(FW.Main.Camera, Vec3(0.0, 280.0, 0.0))
    Light:TLight = CreateDirectionalLight()
    PositionEntity(Light, Vec3(0.0, 350.0, 0.0))
    RotateEntity(Light, Vec3(45,45,0))
    
    CameraRange(FW.Main.Camera, 0.1, 750.0)
    
    'DOF
    SetSkyBox(LoadMaterial("abstract::FullskiesBlueClear0016_2_L.mat"))
    SetBackGroundColor(Vec4(1,1,1,1))
    
    
    SetStats(1)
    Repeat	
    If KeyHit(KEY_ESCAPE) Exit
    If AppTerminate() Exit
    
    CameraUpdate()
    
    FW.Update()
    FW.Render()
    
    
    Flip(0)
    Forever
    
    GCCollect()
    End
    
    
    Function CameraUpdate()
    If KeyDown(KEY_SPACE)
    	mx = MouseX() - GraphicsWidth()/2
    	my = MouseY() - GraphicsHeight()/2
    	MoveMouse(GraphicsWidth()/2, GraphicsHeight()/2)
    	CamRotation.X = CamRotation.X + my
    	CamRotation.Y = CamRotation.Y - mx
    	RotateEntity(FW.Main.Camera, CamRotation)
    
    	move = (KeyDown(KEY_W) - KeyDown(KEY_S)) * 10
    	strafe = (KeyDown(KEY_D) - KeyDown(KEY_A)) * 10
    	MoveEntity(fw.Main.camera, Vec3(strafe / 10.0, 0, move / 10.0))
    EndIf
    EndFunction

  5. I was wondering if there is a package system for BMAX that allows it to read .pak files like on Josh's blog and in examples people have given. If there is one for BMAX, can someone please post an example? :P Thank you

  6. Collisions only have three parameters, The first two are (I BELIEVE) Entity Groups in a way and the third is what happens if Entities from those groups collide. I have tried

    Collisions(1, 3, True)

    Collisions(1, 3, 1)

    Collisions(1, 3, 2)

    Collisions(1, 3, 3)

     

    And I have also assigned EntityType(Terrain, 1,2,3,etc with no such luck.

    Marleys code works though and I am hoping its not because of the LUA stuff

  7. I used Marleys Third Person Cam tutorial and made a Player Type but I cannot get collisions to work. The only differences as far as I can tell is I did not use (and do not want to) use LUA functions and I use MaxGUI(though I cannot see how that would make a difference)

     

    The Code:

     

    SuperStrict
    
    
    Framework Leadwerks.Engine
    Import "Framework.BMX"
    Import MaxGUI.MaxGUI
    Import MaxGUI.Drivers
    Import BRL.EventQueue
    RegisterAbstractPath("C:\Leadwerks Engine SDK")
    GCSetMode(2)
    
    
    Global FW:TFramework
    Local GEWindow:TGadget
    Local GEWindowX:Int 'Null (WINDOW_CENTER)
    Local GEWindowY:Int 'Null (WINDOW_CENTER)
    Local GEWindowW:Int = 800
    Local GEWindowH:Int = 600
    Local GEWindowStyle:Int = WINDOW_TITLEBAR|WINDOW_RESIZABLE|WINDOW_MENU|WINDOW_STATUS|WINDOW_CENTER
    Local Canvas1:TGadget
    
    Global Terrain:TTerrain
    Global TerrainText:TTexture
    Global Light:TLight
    
    DebugPhysics(1)
    
    Type TPlayer
    Global Current:TPlayer
    Field Controller:TController
    Field Move:Float
    Field Strafe:Float
    Field CamRotation:TVec3
    Field MX:Float
    Field MY:Float
    Field Jump:Float
    Field Position:TVec3
    Field Body:TEntity
    Field CamY:Float
    Field CamZ:Float
    
    Function Create:TPlayer()
    	Local Player:TPlayer = New TPlayer
    
    	Player.Move:Float = 0.0
    	Player.Strafe:Float = 0.0
    	Player.CamRotation:TVec3 = Vec3(0)
    	Player.MX:Float = 0.0
    	Player.MY:Float = 0.0
    	Player.Jump:Float = 0.0
    	Player.CamY:Float = 0.0
    	Player.CamZ:Float = 0.0
    
    	Player.Controller = CreateController(2.0)
    
    	PositionEntity(Player.Controller, EntityPosition(FW.Main.Camera))
    	EntityType(Player.Controller, 3)
    	SetBodyMass(Player.Controller, 10.0)
    	SetBodyBuoyancyMode(Player.Controller, 0)
    	Collisions(1, 3, 3)
    
    	Player.Body:TEntity = CreateCube(Player.Controller)
    	ScaleEntity(Player.Body, Vec3(0.5, 1.8, 0.5))
    	Return Player
    EndFunction
    
    Method Update()
    	Self.MX = Curve(MouseX() - GraphicsWidth() / 2, Self.MX, 6)
    	Self.MY = Curve(MouseY() - GraphicsHeight() / 2, Self.MY, 6)
    	MoveMouse(GraphicsWidth()/2, GraphicsHeight()/2)
    	Self.CamRotation.X = Self.CamRotation.X + Self.MX / 10.0
    	Self.CamRotation.Y = Self.CamRotation.Y - Self.MX / 10.0
    
    	RotateEntity(FW.Main.Camera, Self.CamRotation)
    
    	If Self.CamRotation.X > 90.0 Then Self.CamRotation.X = 90.0
    	If Self.CamRotation.X < -20.0 Then Self.CamRotation.X = -20.0
    
    	Self.Move = KeyDown(KEY_W) - KeyDown(KEY_S)
    	Self.Strafe = KeyDown(KEY_D) - KeyDown(KEY_A)
    	Self.Jump:Float = 0.0
    
    	If KeyHit(KEY_SPACE) And Not ControllerAirborne(Self.Controller) Then
    		Self.Jump = 4.0
    	EndIf
    	If KeyDown(KEY_LSHIFT) Or KeyDown(KEY_RSHIFT) Then
    		Self.Move = Self.Move * 3.0
    		Self.Strafe = Self.Strafe * 3.0
    	EndIf
    
    	PositionEntity(FW.Main.Camera, Vec3(Self.Controller.Position.X, Self.Controller.Position.Y + 0.8, Self.Controller.Position.Z))
    	Self.CamY = 0.5
    	If MouseZ() > 0 Then FlushMouse()
    	If MouseZ() < 0 Then Self.CamY = 0.0
    	Self.CamZ = Curve(MouseZ(), Self.CamZ, 10)
    	MoveEntity(FW.Main.Camera, Vec3(0, Self.CamY, Self.CamZ))
    
    	UpdateController(Self.Controller, Self.CamRotation.Y, Self.Move * 3, Self.Strafe * 3, Self.Jump, 0.5)
    EndMethod
    EndType
    
    
    GEWindow:TGadget = CreateWindow("GE", GEWindowX, GEWindowY, GEWindowW, GEWindowH, Null, GEWindowStyle)
    Canvas1:TGadget = CreateCanvas(0, 0, ClientWidth(GEWindow), ClientHeight(GEWindow), GEWindow)
    
    SetGadgetLayout(Canvas1, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED)
    SetGraphics(CanvasGraphics(Canvas1))
    ActivateGadget(Canvas1)
    EnablePolledInput()
    
    
    FW:TFramework = CreateFramework()
    If Not FW RuntimeError "Failed to Initialize Engine"
    
    
    
    Terrain = CreateTerrain(2048)
    LoadTerrainHeightmap(Terrain, "Terrain.raw")
    TerrainText = LoadTexture("TerrainGrass.dds")
    SetTerrainTexture(Terrain, TerrainText, 0, 0)
    
    
    PositionEntity(FW.Main.Camera, Vec3(0.0, 1000.0, 0.0))
    Light:TLight = CreateDirectionalLight()
    PositionEntity(Light, Vec3(0.0, 350.0, 0.0))
    RotateEntity(Light, Vec3(45,45,0))
    CameraRange(FW.Main.Camera, 0.1, 750.0)
    
    SetSkyBox(LoadMaterial("abstract::FullskiesBlueClear0016_2_L.mat"))
    SetBackGroundColor(Vec4(1,1,1,1))
    SetFarDOF(1)
    SetFarDOFStrength(1)
    SetFarDOFRange(600.0, 750.0)
    
    
    Global MainPlayer:TPlayer
    MainPlayer:TPlayer = TPlayer.Create()
    If Not MainPlayer RuntimeError "Failed to Create Player."
    
    Repeat
    
    While PeekEvent()
    	WaitEvent()
    	Select EventID()
    		Case EVENT_WINDOWCLOSE
    			End
    		Case EVENT_WINDOWSIZE
    			SetGraphics CanvasGraphics(Canvas1)
    	EndSelect
    Wend
    
    MainPlayer.Update()
    
    If KeyDown(KEY_ESCAPE) Then End
    
    FW.Update()
    FW.Render()
    
    SetBlend(1)
    DrawText(MouseX(), 0, 10)	
    SetBlend(0)	
    
    Flip(0)
    Forever
    
    GCCollect()
    End
    
    

  8. I do believe they are your models bud. (I am no expert) When I put them in the editor, the largest number that jumped out was the 3000 batches (I'm not sure what exactly they are though) so I started messing with them. In the image below, I deleted those two small models (Both of the Crates models) from the scene and the batch size went down by roughly 820. The FPS difference after this was about 17 Before to 25 after. I could be very wrong, but thats just what I picked up on.

     

    unledgxj.png

     

    Since the Arctic scene has WAY more polys than your mall scene and WAY less batches, I think we can say that that is the first issue you should try and tackle.

     

    (Like I said though, could be wrong)

  9. Oh wow, I forgot all about build options. I thought that the exe that BMax built just said .debug and it was the final executable :P Thank you for helping, the FPS cleared right up when I unchecked Debug. and I had no idea the editor was made in Bmax, thats pretty sweet :( Thanks again!

  10. The Problem: When the window is 800,600 using the Scene I want to load, I get about 13 Ave FPS (Not suprised, the Day and Night Settings are way up) What surprises me though is when I maximize the parent window to my full resolution (1920x1080), the FPS stays the same. When I scale it even lower than 800x600, the FPS still does not break 13. I always thought the more space a program/game had to render, the slower the performance (made sense logically)

     

    On another note, when I open the scene up in the Leadwerks Editor, I get a solid 30 FPS. Is this due to problems in my code, or does BlitzMax generally operate that slow (assuming Leadwerks Editor was written in C++ or something)

     

    Heres the code:

     

    SuperStrict
    
    
    Framework Leadwerks.Engine
    Import "Framework.BMX"
    Import MaxGUI.MaxGUI
    Import MaxGUI.Drivers
    Import BRL.EventQueue
    Include "lua-gluefunctions.bmx"
    RegisterAbstractPath("C:\Leadwerks Engine SDK")
    GCSetMode(2)
    
    
    Global FW:TFramework
    Local GEWindow:TGadget
    Local GEWindowX:Int 'Null (WINDOW_CENTER)
    Local GEWindowY:Int 'Null (WINDOW_CENTER)
    Local GEWindowW:Int = 800
    Local GEWindowH:Int = 600
    Local GEWindowStyle:Int = WINDOW_TITLEBAR|WINDOW_RESIZABLE|WINDOW_MENU|WINDOW_STATUS|WINDOW_CENTER
    Local Canvas1:TGadget
    
    Global Scene:TEntity
    Global Move:Float
    Global Strafe:Float
    Global CamRotation:TVec3 = Vec3(0)
    Global mx:Float
    Global my:Float
    Global MouseXInt:Int
    Global MouseYInt:Int
    
    
    GEWindow:TGadget = CreateWindow("GE", GEWindowX, GEWindowY, GEWindowW, GEWindowH, Null, GEWindowStyle)
    Canvas1:TGadget = CreateCanvas(0, 0, ClientWidth(GEWindow), ClientHeight(GEWindow), GEWindow)
    
    SetGadgetLayout(Canvas1, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED)
    SetGraphics(CanvasGraphics(Canvas1))
    ActivateGadget(Canvas1)
    EnablePolledInput()
    
    
    FW:TFramework = CreateFramework()
    If Not FW RuntimeError "Failed to Initialize Engine"
    SetScriptObject("fw", fw)
    Scene:TEntity = LoadScene("abstract::DayNightCycle.sbx")
    PositionEntity(fw.Main.camera, StringToVec3(GetEntityKey(scene, "cameraposition")))
    
    
    Repeat
    
    While PeekEvent()
    	WaitEvent()
    	Select EventID()
    		Case EVENT_WINDOWCLOSE
    			End
    		Case EVENT_WINDOWSIZE
    			SetGraphics CanvasGraphics(Canvas1)
    	EndSelect
    Wend
    
    CameraUpdate()
    
    If KeyDown(KEY_ESCAPE) Then End
    
    FW.Update()
    FW.Render()
    
    SetBlend(1)
    DrawText(MouseX(), 0, 10)	
    SetBlend(0)	
    
    Flip(0)
    Forever
    
    GCCollect()
    End
    
    
    Function CameraUpdate()
    If KeyDown(KEY_SPACE)
    	mx = MouseX() - GraphicsWidth()/2
    	my = MouseY() - GraphicsHeight()/2
    	MoveMouse(GraphicsWidth()/2, GraphicsHeight()/2)
    	CamRotation.X = CamRotation.X + my
    	CamRotation.Y = CamRotation.Y - mx
    	RotateEntity(FW.Main.Camera, CamRotation)
    
    	move = KeyDown(KEY_W) - KeyDown(KEY_S)
    	strafe = KeyDown(KEY_D) - KeyDown(KEY_A)
    	MoveEntity(fw.Main.camera, Vec3(strafe / 10.0, 0, move / 10.0))
    EndIf
    EndFunction
    
    
    
    Function StringToVec3:TVec3(text:String, scale:Float = 1.0)
    Local t:TVec3 = Vec3(1)
    Local sarr:String[]
    sarr = text.split(",")
    If sarr
    	If sarr.length > 0 t.x = Float(sarr[0]) * scale
    	If sarr.length > 1 t.y = Float(sarr[1]) * scale
    	If sarr.length > 2 t.z = Float(sarr[2]) * scale
    EndIf
    Return t
    EndFunction
    
    'These functions allow you to pass framework to the lua state'
    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
    
    
    
    

  11. I was looking at the animation tutorial and I wanted to know if the latest Leadwerks contains the Crawler model. If not can someone point me in the direction of where I can get it?

     

    Thanks!

  12. Well anything with memory is generally important (just a logical rule of thumb) but if I dont have it, does that mean that (and this is an uneducated guess) more memory will be allocated for my program as I load and delete more and more things?

  13. Ah, yes GCCollect() makes more sense than calling GCSetMode() again.

     

    I did both GCCollect AND removing all Garbage Collection codes and they both run on par with each other (I saw higher spikes with removing but it was only a few frames

    So I need to know if not having GCCollect is okay and I guess what does it exactly do?

  14. Bringin this ol' thread back up. I had an example program stripped down and running and I noticed the cube rotating got slow so I threw in a DrawText UPS() to see how the FPS was doing and I noticed it was getting slow. I recalled that this issue happened a while back to me (This thread) so I revisited and put in the correction. However, even when I through in GCSetMod(2) in the loop, the UPS dropped progressively from over 1000 to just below 200 before I terminated it. Im going to paste my code and hopefully someone can shed some light :)

     

    SuperStrict
    
    Framework leadwerks.ENGINE
    
    Local world:TWorld
    Local gbuffer:TBuffer
    Local camera:TCamera
    
    GCSetMode(2)
    
    RegisterAbstractPath( "C:/Leadwerks Engine SDK" ) 
    
    Graphics(800,600)
    
    world=CreateWorld()
    If Not world RuntimeError "Failed to create world."
    gbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),BUFFER_DEPTH|BUFFER_COLOR0|BUFFER_COLOR1|BUFFER_COLOR2)
    
    camera=CreateCamera()
    PositionEntity camera,[0.0,0.0,-2.0]
    
    Repeat
    GCSetMode(2)
    
    If KeyHit(KEY_ESCAPE) Exit
    If AppTerminate() Exit
    UpdateAppTime()
    UpdateWorld(AppSpeed())
    SetBuffer(gbuffer)
    RenderWorld()
    SetBuffer(BackBuffer())
    RenderLights(gbuffer)
    
    DrawText (UPS(), 0, 0)
    DrawRect MouseX(), MouseY(), 250, 250
    
    Flip(0)
    
    Forever
    
    gbuffer=Null
    GCCollect()
    End
    
    

  15. Haha well thank you very much for the response! I figured out that I could declare a variable saying MouseFromX and MouseFromY is already declared and that could work. But I know from looking at it right now, that I would completely have to rewrite (If MouseDown on THIS GUI Object) because currently if I added lets say a button, it would think I am clicking on the button as well as the window.

     

    I will sit down right now and think about all of this. Thanks again!

     

    ah, was posting this while you edited, yeah boolean is what ill have to do ^^, thanks man

  16. Couple questions.

    1. Am I correct in saying that it would be faster for my program to render 2d GUI instead of 3D? (3D Being making a cube or a plane and adding textures to those)

    2. Will it work just as fast programming GUI in BlitzMax(What I am using) than it would be to program it in LUA and run scripts?

    3. As far as code, I am still working on it and I may get this done before anyone posts, but if not... What is the code for having a window (in this case a rectangle) move with the mouse if the mouse is clicked?

     

    So far I have:

    		Method DrawWindow()
    	DrawRect x,y,w,h
    	If MouseDown(1) Then
    		If (MouseX() > x And MouseX() < x+w) And (MouseY() > y And MouseY() < y+h) Then
    			Local MouseFromX:Int = MouseX() - x
    			Local MouseFromY:Int = MouseY() - y
    			Repeat
    				Local XPos:Int = MouseX() - MouseFromX
    				Local YPos:Int = MouseY() - MouseFromY
    				x=XPos
    				y=YPos
    			Until MouseDown(1) = False
    		EndIf
    	EndIf		
    End Method

     

    With that code, I used the repeat so it wouldnt declare MouseFromX and MouseFromY again, however, being stuck in that loop stops the rendering so that wont be able to work. Is there a way to declare those once and not have it declared again until a new MouseClick occurs?

×
×
  • Create New...