Sign in to follow this  
vexe

In-game trigger boxes?

Recommended Posts

vexe    241

Greetings,

we're making a 90s style game with prerendered backgrounds and static camera angles using a custom software-based engine (Sample WIP video)

I was wondering what's the best way to go about setting up camera triggers. In the video I was manually switching cameras. I was thinking just OBBs (or AABBs), every camera would be associated with a bounding box, if you're in box A then camera A renders.

- Is this a good approach or is there a better more simpler/automated way of doing it? How did old games like Resident Evil or Final Fantasy do it?

- Doing it this way I'd have to use some sort of editor to setup the boxes. We're using Blender so I guess I could use that, although I'd prefer a more specialized editor. Is there any good 3rd party editor that's more suitable to doing this stuff? (The same editor would be used for door triggers, item/enemy spawns, text triggers etc). I thought about writing my own editor but that's a bit luxurious at the moment, I'm still setting the core things up.

Any ideas/help is greatly appreciated
Thanks
-vexe

Edited by vexe

Share this post


Link to post
Share on other sites
Zipster    2365

Bounding boxes seem reasonable to me. I wouldn't try and automate the process though, since this style of game relies pretty heavily on deliberate placement and selection of the camera at any given time. Since it's just a box, I don't see any reason not to just use Blender to place them. I'm not familiar with that tool in particular, so I can't comment on how you'd tag the boxes with additional information so the engine knows they're camera triggers (so they shouldn't be rendered). But I assume something like that is possible...

One thing you want to watch out for however are the effects of hysteresis. In this case, that would occur if the player is right on the border of two adjacent camera boundaries and moves slightly back and forth across the boundary, causing the camera to jump back and forth in a jarring and jittery fashion. To get around this, you would make your bounding boxes overlap by a certain amount, and only change the camera when the player leaves a bounding box, as opposed to just when they enter a bounding box. This creates a spatial buffer where the current camera "sticks" a little longer.

Share this post


Link to post
Share on other sites
vexe    241

Thanks for the reply @Zipster. Blender does seem the most reasonable approach. So I went ahead last night and just did it. Here's a clip for cameras, and here's text triggers. I haven't ran into the issue you mentioned yet, I will keep an eye on it, thanks for the headsup! For now I'm just doing a simple Point in AABB test to see which box I'm in and render the camera that's associated with that. I guess I'll try and make hysteresis happen. Never knew this thing has an actual term, cool.

To answer your question, the way the boxes are associated with their cameras is just by naming. In Blender, I name my cameras Camera_1, Camera_2 etc. So the boxes would be Box_C_1, Box_C_2 etc. As you see in the video there could be an instance where you need multiple boxes to cover a shot, and for that you get Box_C_3_0 and Box_C_3_1, it's pretty lame that Blender doesn't let you name two objects the same so I had to use another postfix.

The way I import things is via Assimp. I save .blend directly, preprocess it to an internal engine format and use that. I will write a file watcher of some sort to keep an eye out on the input files, as soon as it detects a change it will invoke the preprocessor and reload the .blend on the fly making edits more practical cause you could just Ctrl+S from Blender and see the change take affect.

Share this post


Link to post
Share on other sites
Scouting Ninja    3972
23 hours ago, vexe said:

We're using Blender so I guess I could use that, although I'd prefer a more specialized editor.

Thanks for this, I needed it.:D

You are overthinking this, like wanting to know if there is special paper made for drawing squares on.

Bounding boxes is 3D cubes, you could pay for expensive 3D software and get the exact same cube Blender will give you.

Blender is even better that most software for this kind of thing, because it has python. If you need tags or any special data to attach to boxes you can build your own exporter that does this for you.

A bounding box is just 4 points, 3D tools gives you a visual aid in moving them around.

 

It's also not worth building your own in-depth collision editor for these, instead make one where you can move colliders around for compound collisions. Use your 3D tool with a custom prefix to check if it's a collider or not.

1 hour ago, vexe said:

Box_C_3_0 and Box_C_3_1, it's pretty lame that Blender doesn't let you name two objects the same so I had to use another postfix.

This is done to keep things neat, it is maybe a pain with this one setup yet you will be thankful when it comes to rendering and composition.

Once you have imported the object you are free to remove tags so you can name a camera: Box_C_3_0 and Box_C_3_1 and tell your importer to delete the last two characters from the name.

With the names you have here you could end up regretting them. I advice giving each camera a name that tells you what it does. For example you can name one "CameraFacingFrontDoor" so that you know what each does.

23 hours ago, vexe said:

- Is this a good approach or is there a better more simpler/automated way of doing it? How did old games like Resident Evil or Final Fantasy do it?

Many games used a approach like you are doing now or even 2D colliders and screen space checks. Remember the tools you have now is a hundred times better than what they had to work with back then.

I wonder what Resident Evil would have looked like if they could have used Blender with cycles for rendering.

 

Share this post


Link to post
Share on other sites
vexe    241

@Scouting Ninja Glad I gave you something you needed :D

I just meant some sort of quad view editor like they had for Doom or Quake (example). I just love wireframe/ortho diagrams in quad views, nerdy stuff, it looks so retro. I was able to get quad views in Blender though.

For collision we're using a simplified level mesh for static collision geometry, and an ellipse for the player/enemies. For items/pickups etc, could just be a sphere or box. I'm thinking of using Blender for all of those too.

Custom exporter, yes eventually. Also a way to automate work for my artist having to go through each camera in the scene to spit out a color and depth map. I just never enjoyed working with Blender API in Python.

Good point on the names, I forgot I could just change them in the preprocessor. This is why you discuss things with people!

I don't think "CameraFacingFrontDoor" is a good idea in my case because, cameras don't do anything special, they're just a position/rotation in space with a FOV to render things from. And, "FacingFrontDoor" means you have to have some sort of predefined actions some where that those names could follow. Now you have to parse more stuff and compare it to your symbols to get a match. I'd much rather have a level meta file that has that extra information in it instead of baking it in the name. With the Camera_N convention, N is just an id that you could associate things to easily. Less parsing too, just a number. You read that id and index into some camera data structure that maybe has FacingFrontDoor=true, ShakeAndBakeIntensity=3.14 and etc=false

Share this post


Link to post
Share on other sites
Scouting Ninja    3972
46 minutes ago, vexe said:

Custom exporter, yes eventually. Also a way to automate work for my artist having to go through each camera in the scene to spit out a color and depth map.

Because blender is a rendering software there is many ways to do this without code.

The best way to do it would be with markers: https://blender.stackexchange.com/questions/3502/how-can-i-make-a-camera-the-active-one

Once you have that set you can use the composer to rip depth passes. Because depth will change based on range you can animated the offset value in your mapper.

Note: Blender needs the AnimAll addon enabled to animate values. It is installed with blender just go to addons and turn it on.

 

Attached is a Blend file I made for you, it will render the color to the temp folder and a depth folder will also be there.

Hope it helps.:)

 

The worst way to do it would be with drivers and code is in between the two.

 

Blender is 5-6th rated 3D software in the world and it's lower score is because of usability. There is noting it can't do, you just need to find how.

 

BlenderCameraHelp.blend

Edited by Scouting Ninja

Share this post


Link to post
Share on other sites
vexe    241
Quote

Attached is a Blend file I made for you, it will render the color to the temp folder and a depth folder will also be there.

Aww dude thanks greatly appreciated. That's neat! Will show it to my artist

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Similar Content

    • By noodleBowl
      I've gotten to part in my DirectX 11 project where I need to pass the MVP matrices to my vertex shader. And I'm a little lost when it comes to the use of the constant buffer with the vertex shader
      I understand I need to set up the constant buffer just like any other buffer:
      1. Create a buffer description with the D3D11_BIND_CONSTANT_BUFFER flag 2. Map my matrix data into the constant buffer 3. Use VSSetConstantBuffers to actually use the buffer But I get lost at the VertexShader part, how does my vertex shader know to use this constant buffer when we get to the shader side of things
      In the example I'm following I see they have this as their vertex shader, but I don't understand how the shader knows to use the MatrixBuffer cbuffer. They just use the members directly. What if there was multiple cbuffer declarations like the Microsoft documentation says you could have?
      //Inside vertex shader cbuffer MatrixBuffer { matrix worldMatrix; matrix viewMatrix; matrix projectionMatrix; }; struct VertexInputType { float4 position : POSITION; float4 color : COLOR; }; struct PixelInputType { float4 position : SV_POSITION; float4 color : COLOR; }; PixelInputType ColorVertexShader(VertexInputType input) { PixelInputType output; // Change the position vector to be 4 units for proper matrix calculations. input.position.w = 1.0f; // Calculate the position of the vertex against the world, view, and projection matrices. output.position = mul(input.position, worldMatrix); output.position = mul(output.position, viewMatrix); output.position = mul(output.position, projectionMatrix); // Store the input color for the pixel shader to use. output.color = input.color; return output; }  
    • By MarcusAseth
       
      I start by saying that I am aware that what I am trying to do can easily be achieved trough the <functional> part of the library or trough a Functor or a Lambda, but I wanted to see this in template form.(Code below)
      So the first function works, the find_if algorithm find the first value in a vector greater than the specified parameter, but there is no template argument deduction for that function call because the algorithm require a pointer to a function but at that time it is not know I will pass an int into it, and so I need to specify like this:
      LargerThan_NoDeduction<30,int> But this seems ugly because now I have to take care of match the two, like <31.2, double>, and the worst part is that if I now decide to pass something else, like a <'d',char> or a <-10,float> , the function expects a size_t as first template parameter, so this won't do.
      So what I wanted to achieve was to pass a predicate to an algorithm in the form of
      LargerThan(30) where the template part of it takes care both of storing the data value (in this case 30, but could be a 'c') and deducing the type we compare from out of it, so in this case int.
      So I have a function LargerThan(Type) that returns a function pointer and passes down the value to an helper function which takes both the value and the deduced type, so I don't have to type them myself.
      Problem is, this helper function still has an auto in the first template parameter, and the compiler doesn't like this
      How would you make this work trough template magics?
      #include <iostream> #include <vector> #include <algorithm> using namespace std; //// template<size_t TestCase,typename Type> bool LargerThan_NoDeduction(Type value) { return value > TestCase; } //// template<typename Type> auto LargerThan(Type TestCase)-> bool(*)(Type) { return LargerThan_helper<TestCase, Type>; } template<auto TestCase, typename Type> //auto here is not liked!!! bool LargerThan_helper(Type value) { return value > TestCase; } //// int main() { vector<int> vec{ 0,11,21,35,67,102 }; //Must specify size and type. auto p = find_if(vec.begin(), vec.end(), LargerThan_NoDeduction<30,int>);//WORKS if (p != vec.end()) { cout << *p << endl; }//WORKS //Deduces type from the value passed. p = find_if(vec.begin(), vec.end(), LargerThan(30));//ERROR if (p != vec.end()) { cout << *p << endl; }//ERROR return 0; }  
    • By markshaw001
      hi i am new to opengl can someone here tell me how to render this 2d shape i want to make curve or arc in 2d in between two lines its a rough sketch i made i tried the internet but could not find much help beacuse their were no specific tutorials of making arcs or curves

    • By GAFO
      Hello Community,
      I wanted to seperate drawings - different "IDirect3DDevice9Ex"  Devices for different purposes.
      The problem I have is that Device A is drawing the background and if I add Device B for drawing simple geometricts or even a simple line.. the background turns black but the line is drawn. So I dont really know how to configure device B that it only overwrite the pixels at e.g. destination of the line and not all pixels of device A.
      So what are the correct settings to archive the mentioned goal ?  (D3DPRESENT_PARAMETERS, Present/Clear)
      ,greetings
  • Popular Now