How do game programmers define what 3D objects are?

452 viewsOtherTechnology

For the sake of the question, imagine that I’m making a game engine from scratch by one of the popular programming languages and I would like to put an interactable crate in my game. How does the game know what a crate is? I’m thinking like they create a crate in one of the rendering software, but how do they translate that to a game? Do they do something like

`define “crate” crate.stl`

then refer to it only as “crate” to give it animation, physics and lighting properties by extra code, or does it work completely differently?

A follow up question, I want to give velocity to my crate when it’s propelled by the player. Let’s say I tell it moves on x axis by “5” when “interact” happens, how is x axis or velocity defined?

In: Technology

9 Answers

Anonymous 0 Comments

It would be an instance of a structure/class/object. In a voxel based it would have inherent position, otherwise it would have xyz position. Whatever other bits it has depends on the game. Probably xyz of momentum, hp and hp Max, pointer to a model and a while bunch of other things. 

There would be a loop that goes through all active objects and moves them. They would be added to that list if interacted with.

vec3 velocity;  // or float vx,vy,vz;

//X axis is just inherently 3d when you write physics and vertex shaders

You are viewing 1 out of 9 answers, click here to view all answers.