Culling or just some simple python?

Yesterday I took a look at the shoot the bunny 1st person game on the blender gamekit CD. I was really inspirated in the way they load parts of the game. As example, they made a hall, and some cubes which are a littlebit in the hall. When you walk trough the hall, and go trough a cube, a compleet room will be loaded from a layer, so when you walk further and acces the door, the room is already loaded. When you go back into the hall again and the door close, and you arn’t in the cube anymore, the room will be deleted. So how did they do that? Can someone tell me how to do that? I really want to create such loading technic by myself. Or does someone have a simple source for it? I know that they used the add object actuator, but what kind of python did they use and how to set such things up? :frowning: :frowning: :frowning:

I don’t have the gamekit, but the best explanation would be that they used the ‘edit object’ actuator that replaces the mesh and a sector culling script that takes notice if the player is inside a sector or outside. Then there are one empty mesh and the mesh you see. If you are outside the sector and the door is closed (just a simple property set ‘open/closed’) then it just activates the actuator to replace the current mesh with the empy mesh. If the door is open or you’re in the other room (that is in another sector) it is just replaced with the room.
I don’t know if they did it this way, but it is one way to achieve this kind of behaviour.

Good night! Gotta get into my bed or I’ll have twice the hell at work.

older versions of blender had sectors (I think pre 2.1x)
look for level2.blend try it in a current release and 2.03 (wireframe view shows sectors more clearly)

see level2.blend in
http://ftp.stenstad.net/mirrors/ftp.blender.nl/demos/demo20.zip

and I found blender 2.03 on the blender 2.0 guide cd, I leave it as an exercise of the reader to find it (or similar) online

I would agree with the above, but they may have used touch sensors or messages (the door is open, player is through door, player is on first side of door) to determine how things should be done (both, second, or first respectively)

Ok, so there was a function in blender a while ago, to load sectors of game levels. But how can I do this in blender 2.25 with some python script and set up of logic bricks ? :frowning:

kEinStein
Have You ever tried the the replace Mesh Solution? I think, that will not work. If You do that, You will replace only the Meshdata, not the collision. That means: You will see the new Sector, but You will fall through the Ground. Correct me, if i’m wrong. I think GameKit Demo work with add/end Object Actuators.

Doc

No, I haven’t tried it. But I can’t see a reason why it shouldn’t work.

I think, that will not work. If You do that, You will replace only the Meshdata, not the collision.

That’s true. It does replace the mesh, not the collision. The collision detection uses the data when the object had been initialized (IIRC). That’s why using NMesh for realtime screws up the collision detection.

That means: You will see the new Sector, but You will fall through the Ground.

Well, if your object is initialized with no collision faces (means: if you start with an empty mesh) then this would happen. If your object is initialized with the correct mesh and then let the script decide if it shall replace the mesh with an empty/ lower poly mesh after initialization then collisions will be calculated as if the original mesh had always been there.
It also would be logic to do it this way and not with an empty mesh. Actually you want to see what you’re composing when editing a level for example.

Correct me, if i’m wrong. I think GameKit Demo work with add/end Object Actuators.

This would also be an alternative.

Nope. That wasn’t a ‘function’ to load sectors. The Enji engine simply used a kind of sector culling. You had to declare sectors and put your objects inside of the sectors if you wanted to display your stuff.

But how can I do this in blender 2.25 with some python script and set up of logic bricks ?

I’ll try to write an example script - but not today. I’ve got less than 5 hours left to sleep. :expressionless:

So I think, when you’ve got a empty with the add object actuator which adds a room when close to the empty and delete the room when your far away, you only have to write a script that recalls that action when the player walk to the empty again. I tried to add a room with add object actuator, and when it adds the room from a layer, you can walk over it without falling trough it. So it’s possible.

But I will see it when you’ve got more sparetime Keinstein, I look forward to the results. :stuck_out_tongue:

I use add object well in my bigworld system, which is a sort of culling, probably not too dissimilar from what is seen in the demo. The problem if you just use empties, is that it still has to calculate if you are near the empty etc, for ALL the emtpies of the world. In bigworld it has all the different areas mapped out and uses python to figure out which areas to add and where to add them. But for smaller scenes, simple add object style culling can work well - without python:)

it may sound stupid but…why use add object, replace mesh and not simply the visiblilty actuator? Sure collisions would still be detected, but I don’t think this would make such a difference in speed. just correct me if i’m wrong :wink:

I had the same thought when I started to make a sample file.
It also may be faster because it uses less memory than replace mesh which uses less memory than add object.
But replace mesh is more versatile - it gives you the possibilty to combine culling and LOD with the same script. I haven’t finished it but I will post it when all is done.

Well, in my game I can’t have it check collisions, that would be a major slowdown. The world is HUGE. Or at least going to be:) Add object works pretty well, although I wish I could add more than one object per actuator per frame.

But for most blender games, replace mesh or setVisibility(0) might be good enough, although I don’t know if setVisibility(0) will actually cull it if its not in view. In fact I think it wont. So replace mesh is probably the best option.

Lod and culling in one script is a great idea!

Well I used object.setVisible(0) and object.suspendDynamics(1) they were the most convenient to use and they give a good performance increase!!
I would have added LOD since the script already gives me what I need to get the distence between the player and the object but, I can’t replace the mesh of an object with bones and have it work properly. I will have to wait untill that problem is fixed.

You dudes are doing a great job, I think, but I’ve got a question about the culling if it was enabled in blender. In blender you can use a max of 10.000 vertices in one level. Now I’ve got this question, when there is culling, can I use 10.000 vertices in one screen (sight of camera), or still 10.000 vertices in one level, and when culling is added, should the vertices number ingreased or still the same?

I thought the max # of vertices in a level was 65k. If you mean using more than 10,000 vertices is too slow, yes culling will help you fit more vertices in a level, provided it is not all displayed at once. You do need to organize objects in the level to aid the culling however, and it can’t be all one object.

If you are referring to the max vertex count in blender scenes you might be able to overcome this if you use replacemesh or add object style culling. although I think even then you would run into a limit.

It would be solved if we could load in meshes from external files. One thing I really want to add to the source, but don’t quite know how to do.

Ach, hallo Keinstein, alter Pseudo-Rechtsanwalt!

You don’t need a fancy “culling script” to do that - a simple Near sensor that toggles objects is enough.

Or a series of near sensors that determine LOD.

verylongbeep

You don’t need a fancy “culling script” to do that - a simple Near sensor that toggles objects is enough.

You know that near sensors don’t work properly and that python is much faster and more versatile than logic bricks? Using near sensors chances are that you won’t improve the framerate - en contraire mon capitaine!

Logic bricks are faster than python. They use C++ operations. However Python is more versitile. It may appear faster because logic bricks poorly set up can be very power consuming.

Near sensors do work for the most part.

  1. for a small project, try not to use Culling. just hold back on dynamic lighting and as few faces working out collision as possible.

  2. Using lots of empties adding/ending objects doesn’t work. I tried it. the calculations of all the near sensors are and the ammounts of objects them selves slow it more than rendering the whole thing.

  3. For a big project, you need saluks big worldscript or a variation of.
    This script should work out where you are, and what level sections should be added. It achieves this by positioning an empty at the place you want to add the level section and then editting the object feild of the add object actuator to the desired piece of terrain.

  4. However i have used culling set ups to success before with levels that have about 6 sections. Loading using 6 near sensors.

-Luke

Where can I find the big world script of Saluk?? It should be very usefull :smiley:

Where can I find the big world script of Saluk?? It should be very usefull

In his game, he hasn’t released it.