Skip to content

Instantly share code, notes, and snippets.

View michaliskambi's full-sized avatar

Michalis Kamburelis michaliskambi

View GitHub Profile
@michaliskambi
michaliskambi / sphere_fun.lpr
Last active September 16, 2016 23:59
Build at runtime X3D graph with a sphere, display it.
{ Build at runtime X3D graph with a sphere, translated, with some texture.
Then load this into a scene (TCastleScene), and open a window showing it.
The default camera (Examine) works, so you can drag and rotate it.
Be sure to place test_texture.png file in the same directory,
or update the line Texture.FdUrl.Items.Add(...) to point to a correct
texture filename / URL. You can use
Texture.FdUrl.Items.Add(ApplicationData('texture.png'));
### Keybase proof
I hereby claim:
* I am michaliskambi on github.
* I am michaliskambi (https://keybase.io/michaliskambi) on keybase.
* I have a public key whose fingerprint is C8BB 4494 F6E8 7767 34A2 4971 FF74 8D13 B240 711F
To claim this, I am signing this object:
@michaliskambi
michaliskambi / load_model_fix_crease_angle.lpr
Created September 21, 2016 19:46
Read a 3D model, change creaseAngle to some constant value (to force smoothing)
{ Based on view_3d_model_basic demo in Castle Game Engine examples.
Read a 3D model, change creaseAngle to some constant value
(4.0 in this example), and then load it to TCastleScene.
(Note that you can also change the VRML/X3D graph after loading
to TCastleScene, by using TCastleScene.RootNode property,
followed by TCastleScene.ChangedAll call.
But doing it before loading, if possible, is a little faster.) }
program load_model_fix_crease_angle;
@michaliskambi
michaliskambi / clip_plane_portable.x3dv
Last active September 21, 2016 21:20
ClipPlane in X3D test
#X3D V3.2 utf8
PROFILE Interchange
COMPONENT Rendering:5
# Demo of ClipPlane.
#
# Based on https://github.com/castle-engine/demo-models/blob/master/x3d/clip_plane.x3dv
# but with view3dscene-specific features
# (Teapot, Vec4Interpolator using CastleScript) removed,
# to work with any VRML/X3D browser.
@michaliskambi
michaliskambi / test_onfont.lpr
Created December 6, 2016 00:08
Demo of TFontStyle.OnFont usage in Castle Game Engine
uses SysUtils,
CastleWindow, CastleScene, X3DNodes, CastleTextureFontData;
type
TEventHandler = class
class procedure CustomizeFont(const FontStyle: TFontStyleNode;
var Font: TTextureFontData);
end;
var
@michaliskambi
michaliskambi / car_world.x3dv
Created February 22, 2017 03:44
X3D file showing a Viewpoint and a car moving together
#X3D V3.2 utf8
PROFILE Interchange
# Place this alongside the "car.x3d" file.
# Open in any engine example program or view3dscene.
# The 1st Viewpoint inside will be automatically bound,
# and it will move, along with the car.
DEF MovingCar Transform {
children [
@michaliskambi
michaliskambi / play_image_animation.lpr
Created March 16, 2017 18:10
Play animation from an image sequence (like a GIF animation) using Castle Game Engine
uses SysUtils,
CastleControls, CastleWindow, CastleTimeUtils, CastleUIControls,
CastleGLImages, CastleVideos;
type
TMap = class(TUIControlSizeable)
private
Video: TGLVideo2D;
AnimationTime: TFloatTime;
public
@michaliskambi
michaliskambi / test_keep_existing.lpr
Created March 17, 2017 23:30
Test KeepExisting on X3D node in Castle Game Engine
{ -*- compile-command: "castle-engine simple-compile --mode=debug test_keep_existing.lpr && ./test_keep_existing" -*- }
uses SysUtils, X3DNodes;
var
Texture: TImageTextureNode;
TextureProperties: TTexturePropertiesNode;
begin
TextureProperties := TTexturePropertiesNode.Create;
TextureProperties.AnisotropicDegree := 8;
TextureProperties.KeepExisting := 1;
@michaliskambi
michaliskambi / scene_position_vs_center.lpr
Last active March 25, 2017 02:33
Show 2D scene at the X,Y postion relative to center
// -*- compile-command: "castle-engine simple-compile scene_position_vs_center.lpr" -*-
uses SysUtils, CastleVectors, Castle3D,
CastleFilesUtils, CastleWindow, CastleSceneCore, CastleScene,
CastleUIControls, Castle2DSceneManager;
const
PositionX = 0;
PositionY = 0;
@michaliskambi
michaliskambi / sprites.x3dv
Created March 25, 2017 02:35
Trivial X3D quad centered around (0,0) with size (300,300)
#X3D V3.2 utf8
PROFILE Interchange
Shape {
appearance Appearance {
}
geometry QuadSet {
coord DEF coord Coordinate {
point [