Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Problem with if object visible command

Author
Message
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 8th Sep 2008 00:27
Hello all, I have been working on my game, and to save fps I finally decided to try and get culling working, but it doesn't seem like the command works, or maybe it's just me. Here is my code, any help is appreciated.


BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 8th Sep 2008 10:08
perhaps I am missing the point here, but couldn't you just use the set camera range command to clip things at a distance?

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Robert The Robot
18
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 8th Sep 2008 12:20 Edited at: 8th Sep 2008 12:26
I could be mistaken, but I believe culling is enabled by default so unless you've turned it off using Set Object, you can't gain anything with your frame rate.

You might want to try something like this to up your frame rate:


If the "Object Visible" command isn't working, could you just check that your variable ZombObj is actually greater than 3000? This is probably a dumb question, but if the answer's no then your for-loop won't be executing at all so you'll never get to the "If Object Visible" command.

[Edit] Blast! Hit the wrong key and posted before I'd finished typing.

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 9th Sep 2008 02:44
Yes I know Dbc culls objects automatically, but if you look at my source, you will see I'm not trying to cull the objects, but rather cut their calculations when their out of screen.

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 9th Sep 2008 04:10
@Satchmo
Much like your other post about simple AI, the same still applies. You need a method ahead of time like Robert The Robot proposes - then you can do the is visible check in your source. Here's a combination of your source and RTR's . I eliminated what I thought were superfluous intersectObjectDBC() functions and combined the inscreen and visibility into the same loop:



Enjoy your day.
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 9th Sep 2008 22:55 Edited at: 9th Sep 2008 23:47
Thanks I will try it out, and you were right, they were useless calls, just for checking how fast it would run.

Edit : Works perfectly, thanks!

Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 10th Sep 2008 03:38
Also, I heard you mention in the other thread about combining multiple objects into a single object(eg. the scene) to save frames. I am using a editor I made so I can't do this in a 3d modeling app. Are there any commands in DBC that do this?

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 10th Sep 2008 04:16
@Satchmo
Before I get into that, here's a modification to your source that should help speed things up a bit. You have a loop after your is visible routine:



You can eliminate this loop by combining it into the is visible routine. With an ELSE condition, you can move a zombie if it is visible or not without haveing to iterate through all of the zombies a second time:



Quote: "you mention in the other thread about combining multiple objects into a single object(eg. the scene) to save frames. I am using a editor I made so I can't do this in a 3d modeling app. Are there any commands in DBC that do this?"


Can your modeling app export a Scene as a single object? If so, you may be able to add your houses and trees and stuff to a scene and export it all at once.

In DBC, you would have to add each object as a limb to a single object. And after all of the limbs are added, you make a single mesh from the object and all the limbs, and then make an object from the mesh. The problem is if each object has it's own textures (it's own picture, jpg, bmp, etc), your final object won't be able to utilize them. However, if you didn't combine the limbed object into a single mesh, the individual limbs could be textured with their own images. The problem is, I don't think a limbed object would improve performance.

Anyway, here's an example that uses multiple limbs attached to one object (the green pillars). The subroutine that does this is called _environment_objects: . When you run this, the fps is displayed in the upper left hand corner. Use the mouse to turn and up arrow/down arrow to move:



Uncomment:



and run it again. These lines combine the limbs into one object. The FPS should improve.

Your best bet to improve performance would be to find a way to make your scene as one object in your modeling program or combine groups of your individual objects as one object to reduce the number of individual objects you load into DBC.

If you have to load a bunch of individual objects, you can hide them when they are not in screen just like the zombies.

Enjoy your day.
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 10th Sep 2008 04:44
My level editor is actually written in dbc, and just exports positions as well as properties and rotations.

What about... combining each type of object into a single object? Would I be able to use a texture then?

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 10th Sep 2008 04:54
It should if the type uses the same texture. Say you had 20 trees that used the same texture, then it would work. Once the final object is created, just texture it with the image and the UV data should carry over.

For a pretty simple (and free) 3d editor that will export multiple objects as one, try anim8or and save the scene as 3DS. Or try deled 3d.

Enjoy your day.
Satchmo
20
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 10th Sep 2008 05:38
Would 3ds be a better format for objects without animation? I currently use .x.

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 10th Sep 2008 07:56
No, not really. Anim8or just exports nicely to 3ds which DBC can use. That's why I mentioned it. Deled 3d can export to X or 3ds.

Enjoy your day.
Robert The Robot
18
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 10th Sep 2008 13:22
Actually, it might just be me but I found I had a little trouble with Anim8or's 3ds export routine. All the edges in my mesh were exported as "crease" instead of "smooth". That meant every polygon had a hard edge - equivalent to double-clicking the mesh and saying "Set Object Smoothing = 0".

It might be the effect you want, but personally I go down the slightly more complicated route of exporting from Anim8or as .Lwo (Lightwave), loading the object in LithUnwrap and then saving it again (having UV mapped it) as a .3ds.

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."

Login to post a reply

Server time is: 2025-06-07 06:49:22
Your offset time is: 2025-06-07 06:49:22