1. Home
  2. /
  3. Urho3d
  4. /
  5. Physics Cube Example

Physics Cube Example - Urho3d Typing CST Test

Loading…

Physics Cube Example — Urho3d Code

Applies physics to a cube object.

#include <Urho3D/Engine/Application.h>
#include <Urho3D/Physics/PhysicsWorld.h>
#include <Urho3D/Scene/Scene.h>
#include <Urho3D/Graphics/StaticModel.h>
#include <Urho3D/Graphics/Model.h>

using namespace Urho3D;

class PhysicsApp : public Application {
public:
	PhysicsApp(Context* context) : Application(context) {}

	void Setup() override {}
	void Start() override {
		scene_ = new Scene(context_);
		Node* cube = scene_->CreateChild("Cube");
		cube->CreateComponent<StaticModel>()->SetModel(GetSubsystem<ResourceCache>()->GetModel("Models/Box.mdl"));
		cube->CreateComponent<RigidBody>();
		cube->CreateComponent<CollisionShape>()->SetBox(Vector3::ONE);
	}

private:
	SharedPtr<Scene> scene_;
};

URHO3D_DEFINE_APPLICATION_MAIN(PhysicsApp)

Urho3d Language Guide

Urho3D is an open-source, cross-platform 2D and 3D game engine written in C++ with optional AngelScript and Lua scripting. It provides a lightweight, flexible environment for building games and real-time simulations.

Primary Use Cases

  • ▸2D and 3D PC games
  • ▸Mobile games (Android/iOS)
  • ▸Educational simulations
  • ▸Real-time visualizations
  • ▸Interactive prototypes

Notable Features

  • ▸C++ core with scripting via AngelScript/Lua
  • ▸Cross-platform (Windows, macOS, Linux, iOS, Android)
  • ▸Scene graph and node-based architecture
  • ▸Integrated physics (Bullet Physics) and networking
  • ▸Flexible rendering pipeline (shaders, lights, shadows)

Origin & Creator

Urho3D was created in 2007 by the Finnish developer Jukka Jylänki, later developed and maintained by a community of contributors.

Industrial Note

Urho3D is valued by developers seeking a lightweight, open-source engine with full access to C++ code, cross-platform deployment, and integrated physics and rendering systems.

Quick Explain

  • ▸Urho3D is C++-based with scripting support via AngelScript and Lua for rapid prototyping.
  • ▸It supports both 2D and 3D graphics, physics, networking, audio, and scene management.
  • ▸Used by indie developers, hobbyists, and educators for games, simulations, and interactive applications.

Core Features

  • ▸Node and component system
  • ▸3D and 2D model support (OBJ, FBX, glTF)
  • ▸Camera and lighting system
  • ▸Physics and collision detection
  • ▸Audio, input, GUI, and particle systems

Learning Path

  • ▸Learn C++ fundamentals
  • ▸Understand scene graph and node/component system
  • ▸Practice physics integration
  • ▸Implement custom shaders
  • ▸Deploy to multiple platforms

Practical Examples

  • ▸2D platformer
  • ▸3D racing game
  • ▸Physics-based puzzle
  • ▸VR prototype
  • ▸Interactive 3D visualization

Comparisons

  • ▸Urho3D vs Unity: lightweight C++ engine vs full-featured editor-based engine
  • ▸Urho3D vs jMonkeyEngine: C++/AngelScript vs Java, more 2D support
  • ▸Urho3D vs Godot: flexible C++ core vs GUI-rich editor
  • ▸Urho3D vs Unreal: lightweight open-source vs AAA engine
  • ▸Urho3D vs LibGDX: C++/3D+2D vs Java/2D+3D hybrid

Strengths

  • ▸Lightweight and fast
  • ▸Open-source and fully C++ accessible
  • ▸Good 2D and 3D support
  • ▸Cross-platform deployment
  • ▸Active community and example projects

Limitations

  • ▸No official visual editor (third-party editors exist)
  • ▸Smaller community compared to Unity/Unreal
  • ▸Documentation less extensive than major engines
  • ▸Networking is basic; advanced multiplayer requires custom work
  • ▸Less beginner-friendly without C++ experience

When NOT to Use

  • ▸Non-programmer drag-and-drop prototyping
  • ▸AAA visual fidelity projects
  • ▸Projects requiring large asset marketplaces
  • ▸Extensive multiplayer frameworks
  • ▸Teams unfamiliar with C++ or scripting

Cheat Sheet

  • ▸Scene = root container
  • ▸Node = object container
  • ▸Component = adds behavior
  • ▸ResourceCache = manages assets
  • ▸Event system = messaging/signals

FAQ

  • ▸Is Urho3D free?
  • ▸Yes - fully open-source under MIT license.
  • ▸Does it support 2D?
  • ▸Yes - both 2D and 3D are supported.
  • ▸Which platforms are supported?
  • ▸Windows, macOS, Linux, Android, iOS.
  • ▸Is it beginner-friendly?
  • ▸Moderate; requires C++ or scripting knowledge.
  • ▸Does it have a visual editor?
  • ▸Limited; third-party editors exist but not core engine.

30-Day Skill Plan

  • ▸Week 1: C++ basics and Hello Urho3D
  • ▸Week 2: Scene graph and nodes
  • ▸Week 3: Physics and collision handling
  • ▸Week 4: Shaders, lighting, and post-processing
  • ▸Week 5: Cross-platform builds and optimization

Final Summary

  • ▸Urho3D is a lightweight, C++-based 2D/3D engine with scripting support.
  • ▸It supports cross-platform deployment and flexible scene graph architecture.
  • ▸Best suited for C++ developers and hobbyists creating games, simulations, or prototypes.
  • ▸Offers open-source flexibility with integrated physics and rendering systems.
  • ▸Less suitable for rapid drag-and-drop development or AAA projects.

Project Structure

  • ▸Main.cpp - entry point
  • ▸Scenes/ - scene files
  • ▸Resources/ - models, textures, audio
  • ▸Scripts/ - AngelScript/Lua files
  • ▸Components/ - custom C++ or scripts

Monetization

  • ▸Paid PC/mobile games
  • ▸In-app purchases on mobile
  • ▸Educational licensing
  • ▸Ad integration via SDK
  • ▸VR/AR commercial projects

Productivity Tips

  • ▸Use example projects for faster setup
  • ▸Reuse Components
  • ▸Profile performance early
  • ▸Use LOD for large models
  • ▸Batch static geometries

Basic Concepts

  • ▸Scene graph: hierarchical node structure
  • ▸Node: basic object container
  • ▸Component: adds functionality to nodes
  • ▸Resource cache: manages models, textures, audio
  • ▸Event system: signal-slot messaging

Official Docs

  • ▸https://urho3d.github.io/documentation/
  • ▸https://github.com/urho3d/Urho3D
  • ▸https://urho3d.github.io/community/

More Urho3d Typing Exercises

Urho3D Simple Counter ExampleUrho3D Move Cube ExampleUrho3D Rotate Object ExampleUrho3D Keyboard Input ExampleUrho3D UI Button ExampleUrho3D Light ExampleUrho3D Camera Follow ExampleUrho3D Particle ExampleUrho3D Animated Model Example

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher