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.
lost code to my chat plugit, but a working version is on my server. can I unpack the .zp file of the .pkg I want to use? what program would I use
thx!
Offline
uhh, the pkg is not on the server ...
the code which is on the forum is too far ?
I posted a scene to the server. It contains an archive of the plugit I wrote, in the .zp file extension. I have downloaded the file. Is there a utility I can use to extract the text in the .zp file?
Offline
I figured out how to get the code to do what I wanted it to do, here it is safe and sound for scolring (and me)
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_movement_flag : I,
Remote_bot_travel_time : F
]mkRemote_bot;;
//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;;
// 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];;
//set varible to hold camera sheel possiitnoa nd orientation
typeof avLastPos = [[F F F] [F F F F]];;
//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;;
//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 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;
0;;
fun loadman()=
load3dResources;
0;;
//key is the Scol keyboard key value
//keycode 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;;
//calculate time it takes for bot to get from source position to 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;;
// 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;
let time_to_travel_distance_in_seconds remote_bot remote_bot.Remote_bot_source_position remote_bot.Remote_bot_target_position->time_to_travel in
(
set remote_bot.Remote_bot_travel_time = time_to_travel;
_ADDcompText ongoing_chat_textfield strcatn "time to travel is"::(ftoa time_to_travel)::"\n"::nil hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer hacker_window_object_container;
);
//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;
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;
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 [nil nil nil] -> bot_new_position in
let [nil nil nil nil] -> bot_new_rotation in
let [nil nil nil] -> bot_old_position in
let [nil nil nil nil] -> bot_old_rotation in
let 0.0 -> 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 nil] -> 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";
//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
// 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;
//_ADDcompText ongoing_chat_textfield strcatn "my camera shell position is":: (ftoa posx):: (ftoa posz):: "\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;
set avLastPos = [[posx posy posz] [qx qy qz qw]];
//close let braces
);
0;;
fun cbShow(inst, from, action, param, reply, constr)=
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)=
//_ADDcompText ongoing_chat_textfield strcatn "elapsted time since last frame is "::(ftoa elapsted_time)::"\n"::nil hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
//_PAINTcontainer hacker_window_object_container;
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 (to do this we must divide elapsed time by the time it takes to travel from source to target
let elapsted_time/. (thisremote_bot.Remote_bot_travel_time/. 1000.0) -> coefficient_increase_number in
(
set thisremote_bot.Remote_bot_float_coefficient = thisremote_bot.Remote_bot_float_coefficient +. (coefficient_increase_number/. 1000.0);
0;
);
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 cbMoveObj (inst, viewstr, elpased_time, object_to_move)=
let (itof elpased_time)/. 1000.0 -> timepassed in
(
interpolate_bots Remote_bot_List timepassed;
//_ADDcompText ongoing_chat_textfield strcatn "time passed since last frame is "::(ftoa timepassed)::"\n"::nil hacker_font [0x00FFFF 0 0 0xFFFF00] CT_END;
//_PAINTcontainer hacker_window_object_container;
);
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;
//close let brace
);
0;;
fun IniPlug(file)=
PlugRegister @newOb nil;
setPluginEditor @dynamicedit;
0;;
Offline
thx arkeon...I got it.
Last edited by hebdemnobad (29-Jan-2014 18:28:21)
Offline