Crystal Space
Welcome, Guest. Please login or register.
December 22, 2014, 07:33:45 am

Login with username, password and session length
Search:     Advanced search
9032 Posts in 2046 Topics by 9300 Members
Latest Member: Almedamowery
* Home Help Search Login Register
+  Crystal Space
|-+  Associate Projects
| |-+  CEL Discussion
| | |-+  [solved] celstart xml beahviour layer: cannot move entity
« previous next »
Pages: [1] Print
Author Topic: [solved] celstart xml beahviour layer: cannot move entity  (Read 2941 times)
Neoberserker
Newbie
*
Posts: 7



View Profile WWW Email
« on: January 29, 2009, 11:13:27 am »

Hi there,
I have a problem that makes me crazy!! I just want to move a entity in my celstart app (written in xml) and don't get it to move! I use the physic layer (pcmechobject) for my entity. Its no problem to give duration on my model with the pcmechobject propertyclass, but setting the position to fix coords (i.e. 0,0,0) seems impossible.

Here a minimal example of my problem:
Code:
<addon plugin="cel.addons.celentity" entityname="camera">
<propclass name="pcmechsys">
            <action name="QuickStep" />
            <action name="SetStepTime">
        <par name="time" float="0.02" />
            </action>
        </propclass>

<propclass name="pccommandinput">
                     .
                     .
                     .
</propclass>

<propclass name="pcdefaultcamera">
    <action name="SetCamera">
    <par name="modename" string="freelook" />
    <par name="spring" vector="3.5,0.25,0.01" />
    <par name="distance" vector="2,8,16" />
    <par name="fpoffset" vector="0,1,0" />
    <par name="tpoffset" vector="0,1,3" />
    </action>
</propclass>

<propclass name="pcmesh">
    <action name="LoadMesh">
    <par name="factoryname" string="hamster" />
    </action>
           <action name="MoveMesh">
      <par name="sector" string="room" />
      <par name="position" vector="0,2,0" />
          </action>
</propclass>

<propclass name="pcmechobject">
<action name="SetColliderMesh">
<par name="factoryname" string="hamster" />
<par name="offset" vector="0.0,0.0,0.0" />
</action>
</propclass>

<behaviour name="shooter" />
<call event="init" />
</addon>
 
 
<addon plugin="cel.addons.xmlscripts">
<script name="shooter">
<event name="init">
                     <var name="pcmesh" value="pc(pcmesh)" />
                     <var name="pcmech" value="pc(pcmechobject)" />
</event>
                     .
                     .
                     .
<event name="shootEm">
<call event="calcShoot" />  <!-- Here x, y and z are calculated -->
<default propclass="?pcmech" />
<expr eval="AddForceDuration{force=[?x,?y,?z],relative=false,position=[-0.00000001,0,0.0000001],seconds=.2}" />
</event>
<event name="pccommandinput_restart1">
<default propclass="?pcmesh" />
<expr eval="MoveMesh{sector='room',position=[0,0,0]}" />
</event>
</script>
</addon>

Here is the runable celzip of my project (5,3MB):
http://knecht.homelinux.net/ftp/ftp2/knecht/hamsterRev.celzip
shoot the hamster with space, reset the scene with left CTRL (it does not change position back, that is my problem), and control the durationForce with cursorkeys (up,down = power, left/right=direction, w/s keys for the angle)


To run AddForceDuration on pcmechobject works, but there is no MoveMesh or SetPosition in that property class. I tried to work with pcmesh and MoveMesh (see my code), i tried to use pcmove.linear with SetPosition (there is no documentation, i tried to read the parameter names from cel api documentation) or MoveMesh, and tried a few other things, but my modell is not moving!! There are no errors on console, but also no effect in my game.

The game is to shoot a hamster out of a cage, and i want to reset the hamster to startposition, but i don't know how!
How can i just set the position of my model to an absolut position?

It seems that this post is about an similar problem:
http://www.crystalspace3d.org/forum/index.php/topic,906.msg4286.html#msg4286

I also ask in the irc chat (#crystalspace) and search for an solution. All they told me is: "use pcmechobject, use pcmesh, use pcmove.linear", but i can't figure it out. Has someone ever moved an entity from xml behaviour scripts? If yes, HOW? AddForceDuration is no problem and works, but to set the position i found no documentation and no examples.

Any suggestions ?

Thanks
Sebastian
« Last Edit: January 29, 2009, 12:28:11 pm by Neoberserker » Logged

---------------------------------------
Linux, CG and photographie
http://www.neoBerserker.de
Neoberserker
Newbie
*
Posts: 7



View Profile WWW Email
« Reply #1 on: January 29, 2009, 12:27:11 pm »

i have solved it! (thanks to jorrit)

I had to use
Code:
<default propclass="?pcmech" />
<action id="actid(SetPosition)">
    <par id="parid(position)" value="[0,0,0]" />
</action>
instead of:
Code:
<default propclass="?pcmech" />
<expr eval="SetPositon{position=[0,0,0]}" />
to move the mesh with mechanics

now it works
Logged

---------------------------------------
Linux, CG and photographie
http://www.neoBerserker.de
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 4.237 seconds with 15 queries.