Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology
Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered
You are not logged in.
Pages: 1
Hi,
I am discovering the new SO3Engine too
This example is basic : a simple cylinder ...
This is a screenshot (under Wine, but it's the same under MS Windows) :
My code is correct ? Or not ? Why ? …
A better way or it is ok ?
var pathRsc = "tests/so3engine/1/rsc/";;
typeof win = ObjWin;;
/* 3D variables */
var scnUnit = 1.0;; /* 1 meter, SO3Engine takes the meter as the unit */
typeof scn = SO3_SCENE;; /* 3d scen */
typeof camera = SO3_OBJECT;; /* default camera */
typeof shellCamera = SO3_OBJECT;; /* shell for the camera */
typeof shell = SO3_OBJECT;;
typeof cylinder = SO3_OBJECT;; /* our poor object ! */
typeof viewport = SO3_VIEWPORT;;
/* Buffer */
typeof buffer = SO3_BUFFER;;
fun end ()=
SO3ViewportDestroy viewport;
SO3GroupDelete scn "GrpEx1resources";
SO3SceneDelete scn;
SO3DestroyBuffer buffer;
_closemachine;;
fun win_end (obj, user_data)=
end;;
/* Pre rendering
Perform a rotation ... */
fun cbPreRender (obj, user_data, elapsed_time) =
SO3ObjectRotate cylinder 0.1 [1.0 1.0 1.0] SO3_LOCAL_TS;
0;;
/* Post rendering
Here, nothing */
fun cbPostRender (obj, user_data, elapsed_time) =
0;;
/* Defines the 3d callbacks */
fun def3dCallbacks ()=
/* Sets the callback for our pre render event
The prototype of thecallback is : fun [SO3_SCENE u0 I] u1
the supplemental parameter is the elapsed time (in ms) since the last render */
SO3CbScenePreRender scn @cbPreRender 0;
/* Sets the callback for our post render event
The prototype of thecallback is : fun [SO3_SCENE u0 I] u1
the supplemental parameter is the elapsed time (in ms) since the last render */
SO3CbScenePostRender scn @cbPostRender 0;
0;;
fun load3dResources () =
/* create a group (see Ogre doc) to our 3d resources)
Several groups can be created */
SO3GroupCreate scn "GrpEx1resources";
/* Load any 3d resources in our scn. Some flags are availables :
SO3_RESOURCE_MESH SO3_RESOURCE_MATERIAL SO3_RESOURCE_TEXTURE SO3_RESOURCE_SKELETON
SO3_RESOURCE_GPUPROGRAM SO3_RESOURCE_HIGHLEVELGPUPROGRAM SO3_RESOURCE_PARTICLES
SO3_RESOURCE_PARTICLE_SYSTEM */
SO3SceneLoadResource scn "GrpEx1resources" _checkpack strcat pathRsc "scene.material" SO3_RESOURCE_MATERIAL;
SO3SceneLoadResource scn "GrpEx1resources" _checkpack strcat pathRsc "cylinder.mesh" SO3_RESOURCE_MESH;
/* Createan SO3 object from the mesh entity */
set cylinder = SO3SceneLoadEntity scn "GrpEx1resources" "Cylinder" _checkpack strcat pathRsc "cylinder.mesh";
/* Link our object to the shell */
SO3ObjectLink cylinder shell;
SO3ObjectSetPosition cylinder [0.0 0.0 0.0];
SO3ObjectSetScale cylinder [2.0 2.0 15.0];
0;;
fun init3d ()=
/* create our new scene */
set scn = SO3SceneCreate _channel "example 1";
/* Create and define our camera */
set camera = SO3CameraCreate scn "camera_0";
set shellCamera = SO3SceneNodeCreate scn "shell_camera";
SO3ObjectRotatePitch shellCamera (-.0.5) SO3_LOCAL_TS;
SO3ObjectLink camera shellCamera; /* first : the child, second, the father */
SO3ObjectSetPosition camera [0.0 0.0 (110.0 *. scnUnit)];
/* Set an ambient light of our scene */
SO3SceneSetAmbientLight scn 0x000000;
/* Create and define a viewport */
set viewport = SO3ViewportCreate _channel buffer camera 0.0 0.0 1.0 1.0 0;
SO3ViewportSetBackgroundColor viewport make_rgba 200 200 200 0;
/* create a shell (3d objects) */
set shell = SO3SceneNodeCreate scn "shell";
SO3ObjectSetPosition shell [0.0 0.0 0.0]; /* center of the world */
load3dResources;
def3dCallbacks;
0;;
fun initBuffer ()=
let _GETwindowPositionSize win -> [_ _ w h] in
set buffer = SO3BufferCreate _channel win 0 0 w h;
0;;
fun main ()=
_showconsole;
set win = _CRwindow _channel nil 50 50 500 400 WN_NORMAL "SO3Engine : example 1";
_CBwinDestroy win @win_end 0;
initBuffer;
init3d;
0;;
Thanks !
Offline
Ok, the code above is correct now.
So, 1.0 -> the width of the window; 0.5 -> the half ...
Hmmm
SO3ObjectRotatePitch shellCamera (-.0.5) SO3_LOCAL_TS;
Why ? What it does exactly ?
Offline
Yaw pitch roll are rotation on quaternions
see : http://en.wikipedia.org/wiki/Quaternion … l_rotation
Yaw for Y axis, Pitch for X axis and Roll for Z axis
the value is expressed in radian
Offline
Pages: 1