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.
this is a function missing in the doc
let _LDalphaBitmap _channel _checkpack "tests/transparent.png" -> abmp in
let _GETalphaBitmaps abmp -> [b24bits b8bits] in
oh yes, i'll fix it soon.
Offline
Iri you missed _GETalphaBitmaps...I'm so ignorant ( ) that I didn't even know that the function exists.
So the vm starts, and I get the text written on a white window....I assume then that the default color of the window is white and the .png file, being transparent, does nothing to change the background color, correct?
Here is the client code...I think I am ready to take this to 3d. thx for your help Iri.
typeof window = ObjWin;;
typeof abmp = AlphaBitmap;;
typeof bmp = ObjBitmap;;
fun CBpaint (win, user_parameter)=
_BLTbitmap window bmp 0 0;
0;;
fun CBend (win, user_parameter)=
_DSbitmap bmp; // we destroy the bitmap object
_DSalphaBitmap abmp; // destroy the AlphaBitmap loaded object
_closemachine;; // we exit the program
fun main ()=
_showconsole;
// load an alpha bitmap
//set abmp=_LDalphaBitmap _channel _checkpack "tests/transparent.png";
let _GETalphaBitmaps _LDalphaBitmap _channel _checkpack "tests/transparent.png" -> [b24bits b8bits] in
let _CRfont _channel 24 nil FF_WEIGHT "Arial" -> font in
(
set bmp = b24bits;
_DRAWtext bmp font 150 50 TD_CENTER|TD_TOP 0xDddDdd "Hello wolrd !";
0;
);
// create a window
set window = _CRwindow _channel nil 0 0 512 512 WN_MENU "Bitmap Window";
_CBwinDestroy window @CBend 0;
//paint bitmap into window
_CBwinPaint window @CBpaint 0;
_PAINTwindow window;
0;;
Offline
Remark : in this case, the global variable abmp is useless and you should remove it.
agreed, I will clean it up.
Offline
So the vm starts, and I get the text written on a white window....I assume then that the default color of the window is white and the .png file, being transparent, does nothing to change the background color, correct?
When you get the ObjBitmap object in the AlphaBitmap, you lost the transparency.
You can have a transparency with an AlphaBitmap object. You can not have a transparency with an ObjBitmap.
If I recall correctly, the default background color in an ObjBitmap is black. But the OS set the white by default (the ObjWin is managed by the OS).
With 3d, you can set the transparency with b8bits and _CRalphaBitmap (see doc) :
/* the string has been drawn in the ObjBitmap */
let _CRalphaBitmap _channel b24bits b8bits ....
(or maybe perform a mutate) and apply this AlphaBitmap on a 3d material (see a previous post : SO3TextureBlitAlpha)
Other thing, about your code : always test the return of all functions (if this return has a sense).
Indeed, you can manage an error.
By example :
let _LDalphaBitmap _channel _checkpack "tests/transparent.png" -> abmp in
if abmp == nil then // an error is occured, as a file not found or other reasons
/* manage this error here */
else
let _GETalphaBitmaps abmp -> [b24bits b8bits] in
if b24bits == nil then /* error ! */
/* manage this error here */
else
let _CRfont _channel 24 nil FF_WEIGHT "Arial" -> font in
....
For example, to prevent a file not found, you can use the Scol logo fiile by default ("logo.bmp"), etc.
To know the error value for each function, you must read the doc. Generally, it is nil or 1 but not always.
Offline
oh, now I'm confused again.:|
since I can create an alphabitmap object without errors, I will start playing with this in os3d.:cool:
Last edited by hebdemnobad (15-Jan-2014 21:06:37)
Offline
thx for the advice on error handling Iri, when I clean up the code I will add that.
Offline
ok, I went through redmine and added code to get references to the material I want to put the alpha map on, and the material's texture....
so what would I do to paint "Iri and Arkeon are the most helpful guys in the world!" on the entity in question, where the bitmap is a .png with a completely transparent alpha channel?
Perhaps that would get me to my goal better than trying to understand the creation of alphabitmaps and object bitmaps, 24bits, and 8 bits, and tuples thereof...respond at your convenience.
this function is a prerender callback. I can add an if then else block to prevent scol from resetting the texture every frame if this is something that does not have to be done (i.e. that the code painting the text onto an alphabitmap onto a texture in a material does not have to be done every single frame).
thx!
-h
fun moveplane (inst, viewstr, elpased_time, object_to_move)=
_ADDcompText ongoing_chat_textfield strcatn "prerender elapsed time is ":: (itoa elpased_time)::"\n":: nil hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
//_PAINTcontainer hacker_window_object_container;
let SO3SceneGetNode (V3DgetSession c3dXsession) "12.plane"-> plane_node in
let SO3SceneGetMaterial (V3DgetSession c3dXsession) "Man_group_resources" "planematerial"-> plane_material in
let SO3SceneGetTexture (V3DgetSession c3dXsession) "Man_group_resources" "planematerial" -> planetexture in
let V3DgetObjectByName c3dXsession "Current camera shell" -> camshell in
let [1 0 1]-> axistorotate in
let [0.0 0.0 0.0]-> naturalfacing in
let SO3SceneGetObject (V3DgetSession c3dXsession) "plane.mesh"->plane_entity in
let SO3ObjectGetNodeFacingOrientation plane_node camshell naturalfacing axistorotate -> facingrotate in
(
SO3ObjectSetOrientation plane_node facingrotate;
let facingrotate-> [qx qy qz mf] in
(
_ADDcompText ongoing_chat_textfield strcatn "\n":: "postrender xrot: ":: (ftoa qx)::"yrot: ":: (ftoa qy)::"zrot: ":: (ftoa qz):: "mysteriousfloat: ":: (ftoa mf):: "\n":: nil hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer hacker_window_object_container;
0;
);
0;
);
0;;
Last edited by hebdemnobad (16-Jan-2014 17:40:38)
Offline
here a part code get from 3D gallery plugIT
this create a plane object without mesh file and create material associated and also blit an alpha bitmap
don't forget to destroy all this resources when the user logoff
to add the text create the alpha bitmap and write the text on both RGB bitmap and bitmap 8 to see the text (you need to set the text on alpha channel if you don't want your text transparent)
let SO3MaterialCreate (V3DgetSession c3dXsession) (strcat name ".material") gallerystr.GALL_sGroupName -> mat in
let SO3TextureCreate (V3DgetSession c3dXsession) (strcat name ".texture") nil gallerystr.GALL_sGroupName bw bh -> tex in
let SO3PlaneCreate (V3DgetSession c3dXsession) gallerystr.GALL_sGroupName name psize nil nil -> plane in
(
set elemstr.GELEM_plane = plane;
set elemstr.GELEM_material = mat;
set elemstr.GELEM_texture = tex;
SO3MaterialSetTexture mat tex 0 0 0;
SO3TextureBlitAlpha tex abmp;
SO3EntitySetMaterial plane mat 0;
SO3MaterialIsLighting mat 0;
SO3ObjectLink plane gallerystr.GALL_shellPos;
SO3ObjectSetPosition plane elemstr.GELEM_vPosition;
//turn 90° on X
SO3ObjectSetOrientation plane SO3MathsEulerXYZToQuat [(SO3MathsDegreeToRadian (-.180.0)) (SO3MathsDegreeToRadian 90.0) 0.0];
set gallerystr.GALL_lSearchElem = [plane elemstr]::gallerystr.GALL_lSearchElem;
//TODO verify the visible status for the current page
let (gallerystr.GALL_iCurrentPages * gallerystr.GALL_iNbPerPage)-> pos in
let if (!gallerystr.GALL_bShowOnlyCurrent && gallerystr.GALL_bShow) then 1 else if (!gallerystr.GALL_bShow) || (elemstr.GELEM_iPos < pos || elemstr.GELEM_iPos >= pos + gallerystr.GALL_iNbPerPage) then 0 else 1 -> visible in
SO3ObjectSetVisible elemstr.GELEM_plane visible 1;
);
_DSalphaBitmap abmp;
set elemstr.GELEM_bLoaded = 1;
);
Offline
thx arkeon, all that remains is figuring out:
to add the text create the alpha bitmap and write the text on both RGB bitmap and bitmap 8 to see the text (you need to set the text on alpha channel if you don't want your text transparent)
you can give me psuedo code and I can take it from there
thx!
-h
Offline
something like that
let "my text" -> text in
let [256 64] -> [texWidth texHeight] in
let G2DgetStringSize font text -> [_ th] in //text height
let _FILLbitmap (_CRbitmap _channel texWidth texHeight) 0xffffff -> bmpRgb in
let _FILLbitmap8 (_CRbitmap8 _channel texWidth texHeight) 0x00 -> bmp8 in
let _CRalphaBitmap _channel bmpRgb bmp8 0 0 -> abmp in
(
_DRAWtext bmpRgb font (texWidth / 2) (texHeight / 2) - (th / 2) TD_CENTER 0x000000 text;
_DRAWtext8 bmp8 font (texWidth / 2) (texHeight / 2) - (th / 2) TD_CENTER 0xff text;
SO3TextureBlitAlpha materialTexture abmp;
// free resources
_DSbitmap bmpRgb;
_DSbitmap8 bmp8;
_DSalphaBitmap abmp;
);
Offline
wow that's great, I'll get it into my code when I have time, I think I have all the components I need
-h
Offline
A simple remark : G2DgetStringSize is not a Scol function, so, if you try to use it outside of Openspace3d, you'll an error.
Another remark : the 2d resources should be always destroyed if no longer needed.
If you prefer (i think it is more readable for a non-expert !, only my mind)
let _FILLbitmap
_CRbitmap _channel texWidth texHeight
0xffffff
-> bmpRgb in
let _FILLbitmap8
_CRbitmap8 _channel texWidth texHeight
0x00
-> bmp8 in
Offline
thx guys....my day job is getting busier so it may be a few days before I get to this.
-h
Offline
something like that
let "my text" -> text in let [256 64] -> [texWidth texHeight] in let G2DgetStringSize font text -> [_ th] in //text height let _FILLbitmap (_CRbitmap _channel texWidth texHeight) 0xffffff -> bmpRgb in let _FILLbitmap8 (_CRbitmap8 _channel texWidth texHeight) 0x00 -> bmp8 in let _CRalphaBitmap _channel bmpRgb bmp8 0 0 -> abmp in ( _DRAWtext bmpRgb font (texWidth / 2) (texHeight / 2) - (th / 2) TD_CENTER 0x000000 text; _DRAWtext8 bmp8 font (texWidth / 2) (texHeight / 2) - (th / 2) TD_CENTER 0xff text; SO3TextureBlitAlpha materialTexture abmp; // free resources _DSbitmap bmpRgb; _DSbitmap8 bmp8; _DSalphaBitmap abmp; );
this is crashing the voyager vm...I will try without the G2 api when I have time.
Offline
in fact this is SO3SceneGetTexture who crash...
be sure to create the resource group before calling it, you should also destroy the resources and resources groups when no more used.
the resource must also be added before trying to load it.
I've corrected the code to prevent the crash in the 3D engine.
Offline
Thx arkeon....the material is on a plane I added in the editor....how would I change the way I add the plane in the Editor?......regardless do I have to wait for an update in the vm to do this.
Offline
the resource group name you provide is not the scene resource group where the texture is present.
by the way you should create the plane, and materials by code like I show you some posts ago.
in your case you won't be able to display a different name on textures since all the mesh and the material are the same.
Offline
the resource group name you provide is not the scene resource group where the texture is present.
by the way you should create the plane, and materials by code like I show you some posts ago.
in your case you won't be able to display a different name on textures since all the mesh and the material are the same.
Will creating the resource group, loading the .mesh and .material and giving the material a different name prevent the crash?
Last edited by hebdemnobad (19-Jan-2014 18:46:44)
Offline
yes providing correct resources will prevent the crash
but here you should create on plane and one material and one texture per user to set the name on the texture
Offline
yes providing correct resources will prevent the crash
but here you should create on plane and one material and one texture per user to set the name on the texture
That is my intent, create a new plane entity and node for each remote user, which will be a child of the node containing the animated mesh.
Offline
I changed my code so that instead of adding a .mesh in the builder, I load it with code.
Here is the code that loads all the resources for the remote_bots and plane.mesh:
//create avatar mesh resources and resource group
fun load3dResources() =
SO3GroupCreate (V3DgetSession c3dXsession) "Man_group_resources";
//load fallback baked normal and diffuse map
V3DaddResource c3dXsession "shaderavatar/danfallbackcolorbump.png" "Man_group_resources" SO3_RESOURCE_TEXTURE;
//load diffuse map
V3DaddResource c3dXsession "shaderavatar/bodycolor.png" "Man_group_resources" SO3_RESOURCE_TEXTURE;
//load normal map
V3DaddResource c3dXsession "shaderavatar/dannormalmap.png" "Man_group_resources" SO3_RESOURCE_TEXTURE;
//load specular map
V3DaddResource c3dXsession "shaderavatar/danspecular2.png" "Man_group_resources" SO3_RESOURCE_TEXTURE;
//load alpha map
V3DaddResource c3dXsession "shaderavatar/torsosalpha.png" "Man_group_resources" SO3_RESOURCE_TEXTURE;
//load the two shader files
V3DaddResource c3dXsession "shaderavatar/Example_Basic.hlsl" "Man_group_resources" SO3_RESOURCE_HIGHLEVELGPUPROGRAM;
V3DaddResource c3dXsession "shaderavatar/animatedNormalSpecular.hlsl" "Man_group_resources" SO3_RESOURCE_HIGHLEVELGPUPROGRAM;
//load the mesh and skeleton and material
V3DaddResource c3dXsession "shaderavatar/onematerialdanavatar.material" "Man_group_resources" SO3_RESOURCE_MATERIAL;
V3DaddResource c3dXsession "shaderavatar/man.skeleton" "Man_group_resources" SO3_RESOURCE_SKELETON;
V3DaddResource c3dXsession "shaderavatar/man.mesh" "Man_group_resources" SO3_RESOURCE_MESH;
V3DaddResource c3dXsession "plane/plane.material" "Man_group_resources" SO3_RESOURCE_MATERIAL;
V3DaddResource c3dXsession "plane/transparent.png" "Man_group_resources" SO3_RESOURCE_TEXTURE;
//add plane resources
V3DaddResource c3dXsession "plane/plane.mesh" "Man_group_resources" SO3_RESOURCE_MESH;
V3DaddResource c3dXsession "plane/plane.material" "Man_group_resources" SO3_RESOURCE_MATERIAL;
V3DaddResource c3dXsession "plane/transparent.png" "Man_group_resources" SO3_RESOURCE_TEXTURE;
0;;
here is the code that may be causing the crash:
fun moveplane (inst, viewstr, elpased_time, object_to_move)=
_ADDcompText ongoing_chat_textfield strcatn "prerender elapsed time is ":: (itoa elpased_time)::"\n":: nil hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
//_PAINTcontainer hacker_window_object_container;
//add plane node manually, if plane node exists we don't have to add it
if plane_node == nil then
(
set plane_node = V3DaddShell c3dXsession "plane" nil nil [0.0 (-.1.3677) 2.8053] [0.0 0.0 0.0 1.0];
)
else
(
nil;
);
//add plane entity manually, if plane node exists we don't have to add it
if plane_entity == nil then
(
set plane_entity = V3DaddMesh c3dXsession "plane/plane.mesh" "plane mesh" nil "Man_group_resources" plane_node;
)
else
(
nil;
);
//let SO3SceneGetNode (V3DgetSession c3dXsession) "12.plane"-> plane_node in
let SO3SceneGetMaterial (V3DgetSession c3dXsession) "Man_group_resources" "planematerial"-> plane_material in
let SO3SceneGetTexture (V3DgetSession c3dXsession) "Man_group_resources" "planematerial" -> planetexture in
let V3DgetObjectByName c3dXsession "Current camera shell" -> camshell in
let [1 0 1]-> axistorotate in
let [0.0 0.0 0.0]-> naturalfacing in
let SO3ObjectGetNodeFacingOrientation plane_node camshell naturalfacing axistorotate -> facingrotate in
let "my text" -> text in
let [256 64] -> [texWidth texHeight] in
let G2DgetStringSize hacker_font text -> [_ th] in //text height
let _FILLbitmap (_CRbitmap _channel texWidth texHeight) 0xffffff -> bmpRgb in
let _FILLbitmap8 (_CRbitmap8 _channel texWidth texHeight) 0x00 -> bmp8 in
let _CRalphaBitmap _channel bmpRgb bmp8 0 0 -> abmp in
(
_DRAWtext bmpRgb hacker_font (texWidth / 2) (texHeight / 2) - (th / 2) TD_CENTER 0x000000 text;
_DRAWtext8 bmp8 hacker_font (texWidth / 2) (texHeight / 2) - (th / 2) TD_CENTER 0xff text;
SO3TextureBlitAlpha planetexture abmp;
SO3ObjectSetOrientation plane_node facingrotate;
let facingrotate-> [qx qy qz mf] in
(
_ADDcompText ongoing_chat_textfield strcatn "\n":: "postrender xrot: ":: (ftoa qx)::"yrot: ":: (ftoa qy)::"zrot: ":: (ftoa qz):: "mysteriousfloat: ":: (ftoa mf):: "\n":: nil hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer hacker_window_object_container;
0;
);
0;
);
0;;
here is the whole thing:
struct Interpoloation_node = [
OINT_inst : PInstance,
OINT_obj : SO3_OBJECT,
OINT_srcpos : [[F F F] [F F F F]],
OINT_dstpos : [[F F F] [F F F F]],
OINT_fCoef : F
] mkInterpoloation_node;;
struct PlugChat = [
CHAT_instance : PInstance,
CHAT_netcomm : NetComm
]mkPlugChat;;
struct Remote_bot = [
Remote_bot_name : S,
Remote_bot_user : NetUser,
Remote_bot_shell : SO3_OBJECT,
Remote_bot_Mesh : SO3_OBJECT,
Remote_bot_target_position : [F F F],
Remote_bot_target_rotation : [F F F F],
Remote_bot_source_position : [F F F],
Remote_bot_source_rotation : [F F F F],
Remote_bot_float_coefficient : F,
Remote_bot_time_to_travel_inseconds : F,
Remote_bot_movement_flag : I
]mkRemote_bot;;
// Create type of Remote_bot_List. Each element of the list will be a tuple of an Interger extracted from a remote netuser object using the NetComm.netUserGetId function. so I can use the remove_idx_from_list function.
typeof Remote_bot_List = [[I Remote_bot] r1];;
//alhpamap stuff
typeof window = ObjWin;;
typeof abmp = AlphaBitmap;;
typeof bmp = ObjBitmap;;
//position interpoloation function
fun vecLerp (v1, v2, coef)=
let multiplyVectorF v2[coef coef coef] -> v1t in
let multiplyVectorF v1[(1.0 -. coef) (1.0 -. coef) (1.0 -. coef)] -> v2t in
addVectorF v1t v2t;;
fun CBpaint (win, user_parameter)=
_BLTbitmap window bmp 0 0;
0;;
fun CBend (win, user_parameter)=
_DSbitmap bmp; // we destroy the bitmap object
_DSalphaBitmap abmp; // destroy the AlphaBitmap loaded object
// _closemachine;; // we exit the program
0;;
//set varible to hold camera sheel possiitnoa nd orientation
typeof avLastPos = [[F F F] [F F F F]];;
//initialize plane objects
typeof plane_node = SO3_OBJECT;;
typeof plane_entity = SO3_OBJECT;;
typeof plane_material = SO3_MATERIAL;;
//initialize man node objects
typeof man_node = SO3_OBJECT;;
typeof man_entity = SO3_OBJECT;;
typeof man_material = SO3_MATERIAL;;
//tracerdialogbox
typeof dialogboxtracer = MessageBox;;
typeof man_physics_body =SO3_PHYSICBODY;;
//man node code ends here for declarations
//variable to hold window with position/orientation values of avatars
typeof remote_avatar_transform_window = ObjWin;;
//text field to hold strings of remote avatars position and rotation
typeof remote_avatar_transform_field = ObjText;;
typeof audio = ObjAudio;;
//string variable to hold viewport name
typeof viewport_string_variable = S;;
//window variable to parent container
typeof fatherwindow= ObjWin;;
//container that will be in the main window
typeof parent_chat_window = ObjWin;;
//create hacker font object
typeof hacker_font= ObjFont;;
//container that will be in the main window
typeof hacker_window_object_container=ObjContainer;;
//CompText object that will hold ongoing chat
typeof ongoing_chat_textfield = CompText;;
//CompText object that will hold chat entry
typeof chat_entry_textfield = CompText;;
//function to calculate distance between source position and target position
fun time_to_travel_distance_in_seconds(remote_bot, sourcelocation, detinationlocation)=
let sourcelocation -> [cx cy cz] in
let detinationlocation -> [ox oy oz] in
let sqrt ((sqr(cx -. ox)) +. (sqr(cy -. oy)) +. (sqr(cz -. oz))) -> dist in
let dist/. 2.0-> timetotravel in
timetotravel;;
//function to display amount of clients in an environment in ongoing chat text field
fun bot_list_size(list_to_iterate,counter)=
// let netThisUser plugchatvariable.CHAT_netcomm -> userstr in
let list_to_iterate ->[first_element rest_of_elements] in
//open in brace
(
if (first_element ==nil) then
//open then brace
(
set counter=counter+1;
_ADDcompText ongoing_chat_textfield strcatn "there are "::(itoa counter)::" users in the environment now."::"\n"::nil hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer hacker_window_object_container;
//close then brace
0;
)
else
//open else brace
(
set list_to_iterate = rest_of_elements;
set counter=counter+1;
bot_list_size rest_of_elements counter;
//close else brace
//0;
);
//close let brace
);
0;;
//function to get a Remote_bot object from the [[I Remote_bot]r1]Remote_bot_list
fun get_Remote_bot (list, index_to_search)=
switch list index_to_search;;
//dummy function for now
fun intialize_Remote_bot_list()=
_ADDcompText ongoing_chat_textfield "intialilzed remot bots" hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer hacker_window_object_container;
0;;
fun deleteOb(inst, constr)=
_DScontainer hacker_window_object_container;
//SO3GroupDelete (V3DgetSession c3dXsession) "Man_group_resources";
0;;
//type a global variable with the new PlugChat type
typeof plugchatvariable= PlugChat;;
typeof global_chat_instance_variable = PInstance;;
//create avatar mesh resources and resource group
fun load3dResources() =
SO3GroupCreate (V3DgetSession c3dXsession) "Man_group_resources";
//load fallback baked normal and diffuse map
V3DaddResource c3dXsession "shaderavatar/danfallbackcolorbump.png" "Man_group_resources" SO3_RESOURCE_TEXTURE;
//load diffuse map
V3DaddResource c3dXsession "shaderavatar/bodycolor.png" "Man_group_resources" SO3_RESOURCE_TEXTURE;
//load normal map
V3DaddResource c3dXsession "shaderavatar/dannormalmap.png" "Man_group_resources" SO3_RESOURCE_TEXTURE;
//load specular map
V3DaddResource c3dXsession "shaderavatar/danspecular2.png" "Man_group_resources" SO3_RESOURCE_TEXTURE;
//load alpha map
V3DaddResource c3dXsession "shaderavatar/torsosalpha.png" "Man_group_resources" SO3_RESOURCE_TEXTURE;
//load the two shader files
V3DaddResource c3dXsession "shaderavatar/Example_Basic.hlsl" "Man_group_resources" SO3_RESOURCE_HIGHLEVELGPUPROGRAM;
V3DaddResource c3dXsession "shaderavatar/animatedNormalSpecular.hlsl" "Man_group_resources" SO3_RESOURCE_HIGHLEVELGPUPROGRAM;
//load the mesh and skeleton and material
V3DaddResource c3dXsession "shaderavatar/onematerialdanavatar.material" "Man_group_resources" SO3_RESOURCE_MATERIAL;
V3DaddResource c3dXsession "shaderavatar/man.skeleton" "Man_group_resources" SO3_RESOURCE_SKELETON;
V3DaddResource c3dXsession "shaderavatar/man.mesh" "Man_group_resources" SO3_RESOURCE_MESH;
V3DaddResource c3dXsession "plane/plane.material" "Man_group_resources" SO3_RESOURCE_MATERIAL;
V3DaddResource c3dXsession "plane/transparent.png" "Man_group_resources" SO3_RESOURCE_TEXTURE;
//add plane resources
V3DaddResource c3dXsession "plane/plane.mesh" "Man_group_resources" SO3_RESOURCE_MESH;
V3DaddResource c3dXsession "plane/plane.material" "Man_group_resources" SO3_RESOURCE_MATERIAL;
V3DaddResource c3dXsession "plane/transparent.png" "Man_group_resources" SO3_RESOURCE_TEXTURE;
0;;
fun loadman()=
load3dResources;
0;;
//key is the Scol keyboard key value
//key code is the virtual corresponding scancode
fun containerkeydown (calling_container, userparam, key, keycode)=
if (keycode==65360) then
(
_SETcompTextFirstLine ongoing_chat_textfield 1;
)
else if (keycode==65367) then
(
let _GETcompTextLineCount ongoing_chat_textfield-> line_count in
_SETcompTextFirstLine ongoing_chat_textfield line_count;
)
else nil;
0;;
fun localuser_enter_text (textobject, user_parameter,type,value)=
// get the NetUser structure for this client
let netThisUser plugchatvariable.CHAT_netcomm -> userstr in
// get the login of the client
let netUserGetLogin userstr -> login in
netSendBroadMessage plugchatvariable.CHAT_netcomm strtoweb (getPluginInstanceName global_chat_instance_variable) strcatn login ::" > " ::value::nil 1;
//erase contents of chat_entry_textfield
_DELcompTextLine chat_entry_textfield 1 CT_BEGIN;
_SETcompText textobject "" hacker_font [0x00FFFF 0 0 0xFFFF00] CT_BEGIN;
_PAINTcontainer hacker_window_object_container;
0;;
// scan through remote_bot list and update positions as they are updated in messsages received from server, we will change code to do interpolation in the postrender callback as the next step.
fun scan_through_bot_list_and_set_values( list_to_iterate, remote_bot_id, new_remote_bot_position, new_remote_bot_rotation) =
if (list_to_iterate == nil) then
(
//do nothing
0;
)
else
(
let hd list_to_iterate -> [id remote_bot] in // hd gets the first element
(
//find the remote_bot we want to evaluate
if (id== remote_bot_id) then
(
//update position and rotation values for the remote bot we are loooking for
set remote_bot.Remote_bot_target_position = new_remote_bot_position;
set remote_bot.Remote_bot_target_rotation = new_remote_bot_rotation;
// get the remote bot's present position and reotation and set them as new source positions and rotations
set remote_bot.Remote_bot_source_position = SO3ObjectGetPosition remote_bot.Remote_bot_shell;
set remote_bot.Remote_bot_source_rotation = SO3ObjectGetOrientation remote_bot.Remote_bot_shell;
set remote_bot.Remote_bot_time_to_travel_inseconds = time_to_travel_distance_in_seconds remote_bot remote_bot.Remote_bot_source_position remote_bot.Remote_bot_target_position;
//zero out remote_bot's polation coefficient to start interpolation to new target position
//set remote_bot.Remote_bot_float_coefficient = 0.0;
//SO3ObjectSetPosition remote_bot.Remote_bot_shell new_remote_bot_position;
//SO3ObjectSetOrientation remote_bot.Remote_bot_shell new_remote_bot_rotation;
//return 0 and close let in brace
0;
)
else
(
//shrink list_to_iterate since we haven't found the correct remote bot yet
set list_to_iterate = tl list_to_iterate;
scan_through_bot_list_and_set_values list_to_iterate remote_bot_id new_remote_bot_position new_remote_bot_rotation;
//return 0 and close if then else brace
0;
);
//return 0 and close let in brace
0;
);
//return 0 and close if then else brace
0;
);
0;;
fun sliceupmessage(netstr, userstr, message_string)=
if (userstr == (netThisUser netstr)) then nil else
(
//treat the message as a list. all of the words are contained in the first element of the list, gotten through the hd function
let hd strextr message_string -> list in
//in the send_client_avatar_position_and_rotation_to_room function, this first word is derived from the userid of the remote client, which is used to create the name of the remote client's remote_bot scne node
let nth_list list 0-> remote_bot_index in
let remote_bot_index -> remote_bot_shell_name in
let V3DgetObjectByName c3dXsession remote_bot_shell_name -> remote_bot_shell in
let nth_list list 1-> symbol_to_ignore in
let nth_list list 2-> flag in
let nth_list list 3-> posx in
let nth_list list 4-> posy in
let ((atof posy)+.0.2)->posy in
let nth_list list 5-> posz in
let nth_list list 6-> angx in
let nth_list list 7-> angy in
let atof angy-> angy in
//let angy -> angby in
let nth_list list 8-> angz in
let nth_list list 9-> mysterious_float in
let [(atof posx) posy (atof posz)]-> new_remote_avatar_position in
let [(atof angx) (angy) (atof angz) (atof mysterious_float)]-> new_remote_avatar_rotation in
//get the remote bot from the Remote_bot_list that we want to operate on
let get_Remote_bot Remote_bot_List (atoi remote_bot_index) -> remote_bot_to_alter in
(
// set movement flag to indicate remote_bot is moving. this will be used to determine whether remote clients trigger idel or walk animations
set remote_bot_to_alter.Remote_bot_movement_flag = 1;
//load new values of rotation and position into the remote_bot object in the remote_bot_list
scan_through_bot_list_and_set_values Remote_bot_List (atoi remote_bot_index) new_remote_avatar_position new_remote_avatar_rotation;
//return 0 and close let brace
0;
);
//return 0 and close if then else brace
0;
);
0;;
fun initial_positionload() =
// get the NetUser structure for this client
let netThisUser plugchatvariable.CHAT_netcomm -> userstr in
let netUserGetId userstr -> userid in
// get the login of the client
let V3DgetDefaultCamera c3dXsession -> camera in
let SO3ObjectGetParent camera -> currentCamShell in
let SO3ObjectGetPosition currentCamShell -> [posx posy posz] in
let SO3ObjectGetOrientation currentCamShell-> [qx qy qz qw] in
//open let braces
(
netSendBroadMessage plugchatvariable.CHAT_netcomm strtoweb (getPluginInstanceName global_chat_instance_variable) strcatn (itoa userid) ::" > " :: "A4_234x "::" "::(ftoa posx)::" ":: (ftoa posy)::" "::(ftoa posz)::" "::(ftoa qx)::" "::(ftoa qy)::" "::(ftoa qz)::" "::(ftoa qw)::nil 0; 0;
//close let braces
);
0;;
fun trigger_walk(entity)=
let SO3ObjectGetAnimation entity "Walk" -> walk_animation in
let SO3ObjectGetAnimation entity "Idle" -> idle_animation in
//open let brace
(
SO3AnimationSetEnable idle_animation 0;
SO3AnimationSetEnable walk_animation 1;
SO3AnimationSetPause walk_animation 0
//close let brace
);
0;;
fun trigger_idle(entity)=
let SO3ObjectGetAnimation entity "Walk" -> walk_animation in
let SO3ObjectGetAnimation entity "Idle" -> idle_animation in
//open let brace
(
SO3AnimationSetEnable walk_animation 0;
SO3AnimationSetEnable idle_animation 1;
SO3AnimationSetPause idle_animation 0
//close let brace
);
0;;
fun cbReceivedMessage (inst, netstr, userstr, cmd, message, arg, constr)=
if ((strfindi "A4_234x" message 0) != nil) then
//code here for sending setting transform of remote avatar
(
sliceupmessage netstr userstr message;
0;
)
//code for triggering Idle animation
else if ((strfindi "idlex_5_24cv" message 0) != nil) then
(
0;
)
//code for triggering Idle animation
else if ((strfindi "walk_*7&&" message 0) != nil) then
(
0;
)
else
(
//load incoming message into ongoing chat stream
set message = strcat message "\n";
_ADDcompText ongoing_chat_textfield strcatn message:: "":: "\n"::nil hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
//update contents of chat interface
_PAINTcontainer hacker_window_object_container;
//make a sound for incoming message
set audio = _CRAudio _channel "beep" (_checkpack "tests/incomingsound.ogg") 0;
_AudioPlay audio 0;
);
0;;
fun cbAddUser(inst, netstr, userstr, constr)=
//this happens when client logs in to display message that client has logged in...this usually is overwrriten by the cbshow function //
//which is something I am dealing with in that function
//_showconsole;
set audio = _CRAudio _channel "beep" (_checkpack "tests/incomingsound.ogg") 0;
_AudioPlay audio 0;
if (userstr == (netThisUser netstr)) then
(
let netUserGetId userstr -> userid in
(
_ADDcompText ongoing_chat_textfield strcatn "your user id name is"::(itoa userid)::" and you are now connected."::"\n"::nil hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer hacker_window_object_container;
initial_positionload;
0;
);
)
//this happens when a remote client logs in to a sphere
else
//open else brace
(
//put message in chat stream telling you that anoother client has logged in
let netUserGetLogin userstr -> login in
//create a new Remote_bot object, including scene node and mesh, initializaing the fields with temporarary variables
let netUserGetId userstr-> remote_bot_index_and_scene_name in
//create a temp variable to hold new netuser object for Remote_bot object
let userstr-> remote_bot_user_object in
//create a name for the remote_bot node that includes the name of this client's chat plugin
let strcatn (itoa remote_bot_index_and_scene_name) :: nil-> bot_shell_name in
//create a new scene node for new remote bot object
let V3DaddShell c3dXsession bot_shell_name nil nil [0.0 (-.2.8967) 2.8053] [0.0 0.0 0.0 1.0] -> new_remote_bot_node in
//create new entity that has the name of the remote user's user interger id turned into a string
let V3DaddMesh c3dXsession "shaderavatar/man.mesh" (itoa remote_bot_index_and_scene_name) nil "Man_group_resources"
new_remote_bot_node -> new_remote_bot_entity in
//set remote bot new postion to nil
let [0.0 (-.2.8967) 2.8053] -> bot_new_position in
let [nil nil nil nil] -> bot_new_rotation in
let [0.0 (-.2.8967) 2.8053] -> bot_old_position in
let [nil nil nil nil] -> bot_old_rotation in
let 1.1 -> botcoefficient in
//create a new Remote_bot object 0 movement flag means robot is not moving
let mkRemote_bot [(itoa remote_bot_index_and_scene_name) remote_bot_user_object new_remote_bot_node new_remote_bot_entity bot_new_position bot_new_rotation bot_old_position bot_old_rotation botcoefficient 0.0 0] -> new_remote_bot in
//open let brace
(
_ADDcompText ongoing_chat_textfield strcatn "\n"::">> "::(itoa remote_bot_index_and_scene_name) :: "is the name of the scene node now connected, drawn from the remote users userID.":: "the name derived from the just created scene node is":: (SO3ObjectGetName new_remote_bot.Remote_bot_shell) ::"remote bot's name is" :: new_remote_bot.Remote_bot_name:: "\n"::nil hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_ADDcompText ongoing_chat_textfield strcatn "\n"::">> "::login::" connected."::"\n"::nil hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer hacker_window_object_container;
//attach skeleton to new_remote_bot_entity
SO3EntityAttachSkeleton new_remote_bot_entity _checkpack "shaderavatar/man.skeleton";
SO3ObjectSetPosition new_remote_bot.Remote_bot_shell bot_new_position;
//the index of each tuple in the Remote_bot_list is an integer crated from the remote users userID and the new remote bot object to allow
//for getting, setting, adding, and removing remote bot objects in the Remote_bot_list
//add the new Remote_bot into the Remote_bot_List global variable
set Remote_bot_List= [remote_bot_index_and_scene_name new_remote_bot]::Remote_bot_List;
//display amount of users in environment
bot_list_size Remote_bot_List 0;
//_fooSList Remote_bot_List;
//set scale, position and yaw rotation for new_remote_bot_node
SO3ObjectSetScale new_remote_bot_node [0.02 0.02 0.02];
SO3ObjectRotateYaw new_remote_bot_node 1.0 0;
//SO3ObjectSetPosition new_remote_bot_node [3.0(-.1.7) 0.0];
//close let brace
);
//return 0 and close if then else brace
0;
);
0;;
fun cbDelUser(inst, netstr, userstr, constr)=
let netUserGetId userstr-> remote_bot_index_and_scene_name in
let SO3SceneGetNode (V3DgetSession c3dXsession) (itoa remote_bot_index_and_scene_name) -> scenenode_to_destroy in
let get_Remote_bot Remote_bot_List remote_bot_index_and_scene_name-> bot_to_destroy in
(
_ADDcompText ongoing_chat_textfield strcatn ">> ":: "Remote bot with userID by the name of" :: (itoa remote_bot_index_and_scene_name):: "has left the environment. and the scenenode name of the scene node to be destroyed is" ::(SO3ObjectGetName bot_to_destroy.Remote_bot_shell) ::"\n"::nil hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer hacker_window_object_container;
SO3ObjectDestroy scenenode_to_destroy;
set Remote_bot_List= remove_idx_from_list Remote_bot_List remote_bot_index_and_scene_name;
//show amount of Remote_bots that remain after removal from list
bot_list_size Remote_bot_List 0;
//_fooSList Remote_bot_List;
0;
);
0;;
fun send_client_avatar_position_and_rotation_to_room(trm, param)=
// get the NetUser structure for this client
let netThisUser plugchatvariable.CHAT_netcomm -> userstr in
// get the unique userID of the client, this will be used as part of the transform string list and will be used as the name of the remote bot scene node created on other clients
let netUserGetId userstr -> userid in
let V3DgetObjectByName c3dXsession "Current camera shell" -> camshell in
//let V3DgetDefaultCamera c3dXsession -> camera in
let SO3ObjectGetParent camshell -> currentCamShell in
let SO3ObjectGetPosition camshell -> [posx posy posz] in
let SO3ObjectGetOrientation camshell-> [qx qy qz qw] in
// get the last sent values
let avLastPos -> [[pposx pposy pposz] [pqx pqy pqz pqw]] in
//open let braces
(
//open if then else braces
if (((absf (pposx-. posx)) >. 0.21)|| ((absf (pposy-. posy)) >. 0.21) || ((absf (pposz-. posz)) >. 0.21) || (qx != pqx) || ((absf (qy-. pqy)) >. 0.21) || (qz != pqz) || (qw != pqw) ) then
//open if brace
(
// save the sent values for next test
set avLastPos = [[posx posy posz] [qx qy qz qw]];
netSendBroadMessage plugchatvariable.CHAT_netcomm strtoweb (getPluginInstanceName global_chat_instance_variable) strcatn (itoa userid) ::" > " :: "A4_234x "::" "::(ftoa posx)::" ":: (ftoa posy)::" "::(ftoa posz)::" "::(ftoa qx)::" "::(ftoa qy)::" "::(ftoa qz)::" "::(ftoa qw)::nil 0;
set avLastPos = [[posx posy posz] [qx qy qz qw]];
//return 0 and close if brace
0;
)
else
(
//camera not moving don't do anything
0;
);
//close let braces
);
0;;
fun cbShow(inst, from, action, param, reply, constr)=
//alphabitmapstuff
let _GETalphaBitmaps _LDalphaBitmap _channel _checkpack "tests/transparent.png" -> [b24bits b8bits] in
let _CRfont _channel 24 nil FF_WEIGHT "Arial" -> font in
(
set bmp = b24bits;
_DRAWtext bmp font 150 50 TD_CENTER|TD_TOP 0xDddDdd "Hello wolrd !";
0;
);
// create a window
set window = _CRwindow _channel nil 0 0 512 512 WN_MENU "Bitmap Window";
_CBwinDestroy window @CBend 0;
//paint bitmap into window
_CBwinPaint window @CBpaint 0;
_PAINTwindow window;
let (V3DgetSessionView c3dXsession) -> viewstr in
let viewstr.V3D_win -> fatherwin in
// fatherwin the ObjWin used to create the 3d buffer
set parent_chat_window = _CRwindow _channel fatherwin 0 450 800 150 WN_NOBORDER|WN_CHILDINSIDE "A window";
set hacker_window_object_container= _CRcontainerFromObjWin _channel parent_chat_window 0 0 800 150 CO_CHILDINSIDE 0x000000 "hackerwindow";
set hacker_font = _CRfont _channel 12 0 0 "Lucida Console";
set ongoing_chat_textfield = _CRcompText _channel hacker_window_object_container nil [0 0] OBJ_ENABLE|OBJ_VISIBLE|CT_LEFT|CT_LABEL|CT_WORDWRAP|CT_LABEL|CT_SELECT OBJ_CONTAINER_KEYDOWN 800 100 strcat "hacker window chat text field" "\n" hacker_font [0x00FFFF 0 0 0xFFFF00] [0xFFFFFF 50] nil nil;
set chat_entry_textfield = _CRcompText _channel hacker_window_object_container nil [0 101] OBJ_ENABLE|OBJ_VISIBLE|CT_LEFT|CT_WORDWRAP|CT_EDITLINE 0 800 50 "hacker entry field" hacker_font [0x00FFFF 0 0 0xFFFF00] [0xFFFFFF 50] nil nil;
_PAINTcontainer hacker_window_object_container;
//callback for when user hits the enter key after entering chat string
_CBcompTextValidation chat_entry_textfield @localuser_enter_text nil CT_VALIDENTER;
_CBcontainerKeyDown hacker_window_object_container @containerkeydown nil;
//section to create window to hold ongoing stream of transform information for remote avatars
//set remote_avatar_transform_window =_CRwindow _channel nil 500 100 400 300 WN_MENU|WN_MINBOX "Avatar Transform Data";
set remote_avatar_transform_field = _CRtext _channel remote_avatar_transform_window 0 0 400 250 ET_AVSCROLL|ET_ALIGN_LEFT|ET_VSCROLL|ET_TABFOCUS|ET_DOWN "";
//timer to send positionn and orientation of walkthrough scenenode to server
_rfltimer _starttimer _channel 2500 @send_client_avatar_position_and_rotation_to_room "myparam";
loadman;
intialize_Remote_bot_list;
if ((netThisUser plugchatvariable.CHAT_netcomm) !=nil)
then
//open then brace
(
let netThisId plugchatvariable.CHAT_netcomm-> userid in
let "8.danremappedlowpoly25" -> nodename in
let SO3SceneGetNode (V3DgetSession c3dXsession) "8.danremappedlowpoly25"-> nodetoget in
let V3DgetSession c3dXsession-> scene_structure in
let SO3ObjectGetName nodetoget-> nodename1 in
//
(
initial_positionload;
bot_list_size Remote_bot_List 0;
0;
);
0;
)
else
(
0;
);
0;;
fun cbHide(inst, from, action, param, reply, constr)=
//do nothing
0;;
fun interpolate_bots (botlist, elapsted_time)=
if (botlist==nil) then
(
0;
)
else
(
let hd botlist-> [id thisremote_bot] in
(
//force last frame and set coefficient to 1.0
let thisremote_bot.Remote_bot_float_coefficient -> botcoefficient in
//open let brace
(
if (thisremote_bot.Remote_bot_movement_flag == 0 ) then
(
//set coefficient to zero so it does not start gooing up
set thisremote_bot.Remote_bot_float_coefficient = 0.0;
//put in flag to check whether bot has received a new message or not
0;
)
else if (( botcoefficient >. 1.0)&& (thisremote_bot.Remote_bot_movement_flag == 1)) then
(
//set thisremote_bot.Remote_bot_float_coefficient = 1.0;
SO3ObjectSetPosition thisremote_bot.Remote_bot_shell thisremote_bot.Remote_bot_target_position;
SO3ObjectSetOrientation thisremote_bot.Remote_bot_shell thisremote_bot.Remote_bot_target_rotation;
//todo: put in a flag to show that bot has not receved any new messages, the flag will be set to 1 (true) when a new message for a position/rotation change comes from server
//we are done moving, set movement flag back to zero
set thisremote_bot.Remote_bot_movement_flag = 0;
trigger_idle thisremote_bot.Remote_bot_Mesh;
0;
)
else if (( botcoefficient <. 1.0 )&& (thisremote_bot.Remote_bot_movement_flag == 1)) then
(
trigger_walk thisremote_bot.Remote_bot_Mesh;
//increase botcoefficient, interpolate, and set position and orientation
set thisremote_bot.Remote_bot_float_coefficient = thisremote_bot.Remote_bot_float_coefficient +. (elapsted_time/. thisremote_bot.Remote_bot_time_to_travel_inseconds);
let vecLerp thisremote_bot.Remote_bot_source_position thisremote_bot.Remote_bot_target_position thisremote_bot.Remote_bot_float_coefficient -> newposition in
let SO3MathsQuatInterpolate thisremote_bot.Remote_bot_source_rotation thisremote_bot.Remote_bot_target_rotation thisremote_bot.Remote_bot_float_coefficient 1 -> newrotation in
//open let brace
(
SO3ObjectSetPosition thisremote_bot.Remote_bot_shell newposition;
SO3ObjectSetOrientation thisremote_bot.Remote_bot_shell newrotation;
//close let brace
0;
);
//close else if brace
0;
)
else
(
//close if then else brace
0;
);
//close let brace
0;
);
//close let brace
0;
);
//shrink list and perform the function again
set botlist = tl botlist;
interpolate_bots botlist elapsted_time;
//close if then else
0;
);
0;;
fun moveplane (inst, viewstr, elpased_time, object_to_move)=
_ADDcompText ongoing_chat_textfield strcatn "prerender elapsed time is ":: (itoa elpased_time)::"\n":: nil hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
//_PAINTcontainer hacker_window_object_container;
//add plane node manually, if plane node exists we don't have to add it
if plane_node == nil then
(
set plane_node = V3DaddShell c3dXsession "plane" nil nil [0.0 (-.1.3677) 2.8053] [0.0 0.0 0.0 1.0];
)
else
(
nil;
);
//add plane entity manually, if plane node exists we don't have to add it
if plane_entity == nil then
(
set plane_entity = V3DaddMesh c3dXsession "plane/plane.mesh" "plane mesh" nil "Man_group_resources" plane_node;
)
else
(
nil;
);
//let SO3SceneGetNode (V3DgetSession c3dXsession) "12.plane"-> plane_node in
let SO3SceneGetMaterial (V3DgetSession c3dXsession) "Man_group_resources" "planematerial"-> plane_material in
let SO3SceneGetTexture (V3DgetSession c3dXsession) "Man_group_resources" "planematerial" -> planetexture in
let V3DgetObjectByName c3dXsession "Current camera shell" -> camshell in
let [1 0 1]-> axistorotate in
let [0.0 0.0 0.0]-> naturalfacing in
let SO3ObjectGetNodeFacingOrientation plane_node camshell naturalfacing axistorotate -> facingrotate in
let "my text" -> text in
let [256 64] -> [texWidth texHeight] in
let G2DgetStringSize hacker_font text -> [_ th] in //text height
let _FILLbitmap (_CRbitmap _channel texWidth texHeight) 0xffffff -> bmpRgb in
let _FILLbitmap8 (_CRbitmap8 _channel texWidth texHeight) 0x00 -> bmp8 in
let _CRalphaBitmap _channel bmpRgb bmp8 0 0 -> abmp in
(
_DRAWtext bmpRgb hacker_font (texWidth / 2) (texHeight / 2) - (th / 2) TD_CENTER 0x000000 text;
_DRAWtext8 bmp8 hacker_font (texWidth / 2) (texHeight / 2) - (th / 2) TD_CENTER 0xff text;
SO3TextureBlitAlpha planetexture abmp;
SO3ObjectSetOrientation plane_node facingrotate;
let facingrotate-> [qx qy qz mf] in
(
_ADDcompText ongoing_chat_textfield strcatn "\n":: "postrender xrot: ":: (ftoa qx)::"yrot: ":: (ftoa qy)::"zrot: ":: (ftoa qz):: "mysteriousfloat: ":: (ftoa mf):: "\n":: nil hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer hacker_window_object_container;
0;
);
0;
);
0;;
fun cbMoveObj (inst, viewstr, elpased_time, object_to_move)=
let (itof elpased_time) /. 1000.0 -> fsec in //time since last frame in second
(
interpolate_bots Remote_bot_List fsec;
_ADDcompText ongoing_chat_textfield strcatn "elapsed time is ":: (ftoa fsec)::"\n":: nil hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
//_PAINTcontainer hacker_window_object_container;
0;
);
0;;
fun newOb(inst)=
let mkPlugChat [inst netcomOS3D] -> constr in
(
set global_chat_instance_variable=inst;
set plugchatvariable = constr;
setPluginInstanceCbDel inst mkfun2 @deleteOb plugchatvariable;
PluginRegisterAction inst "Show" mkfun6 @cbShow plugchatvariable;
setPluginInstanceCbNetUserMessage inst mkfun7 @cbReceivedMessage plugchatvariable;
setPluginInstanceCbNetNewUser inst mkfun4 @cbAddUser plugchatvariable;
setPluginInstanceCbNetDelUser inst mkfun4 @cbDelUser plugchatvariable;
//register the prerender callback, the callback will be called before rendering each frame
//setPluginInstanceCbScenePreRender inst mkfun4 @cbVnavPreRender plugchatvariable;
//get the node created in the os3d editor
setPluginInstanceCbScenePostRender inst mkfun4 @cbMoveObj nil;
setPluginInstanceCbScenePostRender inst mkfun4 @moveplane nil;
//close let brace
);
0;;
fun IniPlug(file)=
PlugRegister @newOb nil;
setPluginEditor @dynamicedit;
0;;
-h
Offline
let SO3SceneGetTexture (V3DgetSession c3dXsession) "Man_group_resources" "planematerial" -> planetexture in
the second name should be the texture name, not the material name (error in the documentation)
but once again you should create the plane mesh and mateiral by code, you don't need external resource files for this and it will not work for multiple user names.
let SO3MaterialCreate (V3DgetSession c3dXsession) (strcat name ".material") gallerystr.GALL_sGroupName -> mat in
let SO3TextureCreate (V3DgetSession c3dXsession) (strcat name ".texture") nil gallerystr.GALL_sGroupName bw bh -> tex in
let SO3PlaneCreate (V3DgetSession c3dXsession) gallerystr.GALL_sGroupName name psize nil nil -> plane in
Offline
let SO3SceneGetTexture (V3DgetSession c3dXsession) "Man_group_resources" "planematerial" -> planetexture in
the second name should be the texture name, not the material name (error in the documentation)but once again you should create the plane mesh and mateiral by code, you don't need external resource files for this and it will not work for multiple user names.
let SO3MaterialCreate (V3DgetSession c3dXsession) (strcat name ".material") gallerystr.GALL_sGroupName -> mat in let SO3TextureCreate (V3DgetSession c3dXsession) (strcat name ".texture") nil gallerystr.GALL_sGroupName bw bh -> tex in let SO3PlaneCreate (V3DgetSession c3dXsession) gallerystr.GALL_sGroupName name psize nil nil -> plane in
My code loads a man.mesh and dependencies for multiple users...why can't it do the same for another .mesh, in this case plane. mesh?
Offline