ShiVa3D
ShivaSDK: Cannot interact with engine from c++ [SOLVED]
Windows DX9/OpenGL 2 Standalone AppsShivaSDK: Cannot interact with engine from c++
by Barnski » 22 Apr 2010, 15:17
Hello,
I am trying to get communication between my c++ code and the shiva engine working.
The TEST_SDK demo works nicely, but when I try my own hooks and send message commands,
it does not work for me. I believe I am doing something wrong in the Shiva Editor.
Unfortunately, the TEST_SDK demo is not available as a sample to look at in the Shiva Editor, or am I wrong? Where could I find it?
Also: how can I use log.message in a running program? shouldnt it output to stdout? I am not seeing anything.
My shiva game setup:
Game: GamePanorama
AIModels: AIMain, AICameraCenter
Handlers in AICameraCenter: onSetRotation(yaw, pitch)
I am using the commands in c++ as follows (note that I do some calculation for the camera values, I just removed it for this snippet).
But it seems as the script handler is never called! I debugged the c code, the c code is being executed, but I dont know if the shiva handler is actually ever executed, because I dont know if log.message would print to stdout...?
What might I be missing? What other information might I have to share?
thanks!
Barnski
I am trying to get communication between my c++ code and the shiva engine working.
The TEST_SDK demo works nicely, but when I try my own hooks and send message commands,
it does not work for me. I believe I am doing something wrong in the Shiva Editor.
Unfortunately, the TEST_SDK demo is not available as a sample to look at in the Shiva Editor, or am I wrong? Where could I find it?
Also: how can I use log.message in a running program? shouldnt it output to stdout? I am not seeing anything.
My shiva game setup:
Game: GamePanorama
AIModels: AIMain, AICameraCenter
Handlers in AICameraCenter: onSetRotation(yaw, pitch)
- Code: Select all
function AICameraCenter.onSetRotation ( yaw, pitch )
--------------------------------------------------------------------------------
object.setRotationYPR(this.getObject(), yaw, pitch, 0, object.kGlobalSpace)
log.message ( "onSetRotation!" )
--------------------------------------------------------------------------------
end
I am using the commands in c++ as follows (note that I do some calculation for the camera values, I just removed it for this snippet).
- Code: Select all
S3DX::AIVariable aArguments[2] ;
float cameraYaw = 0;
float cameraPitch = 0;
//calculate camera values here (code removed)
aArguments[0].SetNumberValue(cameraYaw) ;
aArguments[1].SetNumberValue(cameraPitch);
bool result = S3DClient_SendEventToCurrentUser("AICameraCenter", "onSetRotation", 2, (const void *)aArguments ) ;
But it seems as the script handler is never called! I debugged the c code, the c code is being executed, but I dont know if the shiva handler is actually ever executed, because I dont know if log.message would print to stdout...?
What might I be missing? What other information might I have to share?
thanks!
Barnski
- Barnski
- Senior Boarder

- Posts: 41
- Location: Zurich, Switzerland
Re:ShivaSDK: Cannot interact with engine from c++ [SOLVED]
by Yopia » 22 Apr 2010, 16:13
Hi,
S3DClient_SendEventToCurrentUser send event to the user so the AIModel MUST be a User AIModel.
It seems that AICameraCenter is a Object AIModel.
You have to make a User AIModel which will retrieve the object (through its tag for example) and will forward the event to it.
S3DClient_SendEventToCurrentUser send event to the user so the AIModel MUST be a User AIModel.
It seems that AICameraCenter is a Object AIModel.
You have to make a User AIModel which will retrieve the object (through its tag for example) and will forward the event to it.
-

Yopia - Platinum Boarder

- Posts: 625
Re:ShivaSDK: Cannot interact with engine from c++
by Barnski » 22 Apr 2010, 20:46
Ah thank you Yopia, that solved it! I used AIMain, which I had added to the Game's User Main AI models. So I assume to create a User AI Model I have to drag them to that listbox (Game->Main->User Main AIs).
I also figured out where these log.messages go: to a log file called S3DLog.txt in the working directory.
To get the camera object I used this trick in onInit of the AIMain, in case someone is interested:
And then later, when the event is being called by the c++ code, I forward it to the AICameraCenter object model using this code:
Thanks for the help! I am new to Shiva, so bear with me...
will have surely more questions soon ;)
Regards,
Barnski
I also figured out where these log.messages go: to a log file called S3DLog.txt in the working directory.
To get the camera object I used this trick in onInit of the AIMain, in case someone is interested:
- Code: Select all
function AIMain.onInit ( )
--------------------------------------------------------------------------------
application.setCurrentUserScene ( "ScenePanorama" )
local s = application.getCurrentUserScene()
--local cam = scene.getTaggedObject (s, "CameraCenter" )
local cam = application.getCurrentUserActiveCamera ( )
this.hCameraCenter (cam)
--------------------------------------------------------------------------------
end
And then later, when the event is being called by the c++ code, I forward it to the AICameraCenter object model using this code:
- Code: Select all
function AIMain.onSetCameraRotation ( yaw, pitch )
--------------------------------------------------------------------------------
object.sendEvent(this.hCameraCenter ( ), "AICameraCenter", "onSetRotation", yaw, pitch)
--------------------------------------------------------------------------------
end
Thanks for the help! I am new to Shiva, so bear with me...
will have surely more questions soon ;)
Regards,
Barnski
- Barnski
- Senior Boarder

- Posts: 41
- Location: Zurich, Switzerland
3 posts
• Page 1 of 1