Crystal Space
Welcome,
Guest
. Please
login
or
register
.
May 24, 2013, 07:43:40 pm
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
9224
Posts in
2230
Topics by
5389
Members
Latest Member:
Sandradhernandez
Crystal Space
Crystal Space Development
Support
TraceBeam question
« previous
next »
Pages:
[
1
]
Author
Topic: TraceBeam question (Read 3479 times)
SkyFox
Newbie
Posts: 47
TraceBeam question
«
on:
November 02, 2007, 08:43:29 am »
Hello, I have a question about one of the functions mentioned in API.
csColliderHelper :: TraceBeam
looks like a handy function to me, but it seems to register meshes and not colliders. So what if I add a collider with
iCollideSystem :: CreateCollider (iPolygonMesh*)
? Will the tracebeam function still register the polygonmesh intersection position and give the mesh pointer a value of zero, or will it completely ignore the polygonmesh?
Logged
jorrit
Administrator
Hero Member
Posts: 1703
Re: TraceBeam question
«
Reply #1 on:
November 02, 2007, 08:44:23 am »
It will ignore it. TraceBeam works only on meshes.
Greetings,
Logged
SkyFox
Newbie
Posts: 47
Re: TraceBeam question
«
Reply #2 on:
November 02, 2007, 10:49:21 am »
I see, well I was planning to use tracebeam for positioning a 3rd person camera which I don't want to go through walls. In my case it's handier to let tracebeam check bounding boxes rather than the visible meshes themselves. But it seems now that I have to add addiontional meshes to represent these bounding boxes. Is there a way to make sure a mesh isn't drawn on the screen? Like invisible?
Logged
jorrit
Administrator
Hero Member
Posts: 1703
Re: TraceBeam question
«
Reply #3 on:
November 02, 2007, 10:54:35 am »
You can also add a new collider mesh to the walls themselves. i.e. by default the collider will be taken from the actual mesh but if you add a construction like this to your meshobj or meshfact:
Code:
<trimesh>
<mesh>
<v x= y= z= />
<v x= y= z= />
...
<t v1= v2= v3= />
...
</mesh>
<id>colldet</id>
</trimesh>
You can then get another polygonmesh for that mesh. In that case you don't have to add invisible meshes as your real meshes will be used. Just with other geometry for the collision detection. There is an example in data/flarge/world where this syntax is used to add a collider to a fountain particle system (which usually doesn't have a collider).
Greetings,
Logged
SkyFox
Newbie
Posts: 47
Re: TraceBeam question
«
Reply #4 on:
November 02, 2007, 11:36:20 am »
So ... a meshfactory contains multiple polygonmeshes, that are each used for different puposes. If I understood it correctly.
Well that is handy.
Logged
jorrit
Administrator
Hero Member
Posts: 1703
Re: TraceBeam question
«
Reply #5 on:
November 02, 2007, 11:45:29 am »
Quote from: SkyFox on November 02, 2007, 11:36:20 am
So ... a meshfactory contains multiple polygonmeshes, that are each used for different puposes. If I understood it correctly.
Well that is handy.
Not multiple. Just one that you can replace. But that's enough.
Greetings,
Logged
SkyFox
Newbie
Posts: 47
Re: TraceBeam question
«
Reply #6 on:
November 02, 2007, 01:19:55 pm »
But if I use a construction like that, will the involved trimesh automaticly be used for collision detection?
Logged
jorrit
Administrator
Hero Member
Posts: 1703
Re: TraceBeam question
«
Reply #7 on:
November 02, 2007, 01:21:12 pm »
yes
Logged
SkyFox
Newbie
Posts: 47
Re: TraceBeam question
«
Reply #8 on:
November 02, 2007, 11:19:16 pm »
It seems the method is for genmeshes, but do thingmeshes also have a similar structure?
Logged
jorrit
Administrator
Hero Member
Posts: 1703
Re: TraceBeam question
«
Reply #9 on:
November 03, 2007, 05:50:01 am »
Quote from: SkyFox on November 02, 2007, 11:19:16 pm
It seems the method is for genmeshes, but do thingmeshes also have a similar structure?
It is for all meshes. Not only for genmesh.
Greetings,
Logged
SkyFox
Newbie
Posts: 47
Re: TraceBeam question
«
Reply #10 on:
November 03, 2007, 09:58:30 am »
Oh yeah my fault, the difference I saw was the thingmesh having a polymesh and the genmesh having trimesh structure. The two meshes were generated by the blender2crystal exporter.
Logged
SkyFox
Newbie
Posts: 47
Re: TraceBeam question
«
Reply #11 on:
November 06, 2007, 06:21:51 pm »
I believe the feature has a bug. I have used it on a ceiling, composed of two triangles of which the four vectors all have the same y-value. The actual collision geometry is represented by a copy of those triangles(
stated on the map file within the meshobject
). The only difference is that the vectors have a little lower y-value.
Now i use
tracebeam_result.sqdistance >= 0
to test if there was a hit. The thing is that this test only returns true when the triangles of the mesh factory intersect with the beam. When that happens however, the
tracebeam_result.closest_isect
returns the value of intersection with the triangles which represent collision geometry.
It's not a big problem to me, I can get around it. Just letting you know.
«
Last Edit: November 06, 2007, 06:30:31 pm by SkyFox
»
Logged
jorrit
Administrator
Hero Member
Posts: 1703
Re: TraceBeam question
«
Reply #12 on:
November 07, 2007, 08:22:06 am »
I would be surprised if there was a bug here. Can you show me the code that demonstrates this bug?
Greetings,
Logged
SkyFox
Newbie
Posts: 47
Re: TraceBeam question
«
Reply #13 on:
November 07, 2007, 03:43:50 pm »
OK the factory of the ceiling mesh contains this code:
<meshfact name='thingCeiling'>
<plugin>thingfact</plugin>
<zuse/>
<params>
<material>Material.005parket.jpg</material>
<v x='11.7083' y='0.0664438' z='10.6122'/>
<v x='11.7083' y='0.0664438' z='-9.78781'/>
<v x='-12.3097' y='0.0664438' z='-9.78781'/>
<v x='-12.3097' y='0.0664438' z='10.6122'/>
<p name="0">
<v>3</v>
<v>2</v>
<v>1</v>
<v>0</v>
<material>Material.005parket.jpg</material>
<texmap>
<uv idx="2" u="-2" v="3"/> <uv idx='1' u='3' v='3'/> <uv idx='0' u='3' v='-2'/> </texmap>
</p>
</params>
</meshfact>
And the world file, that is loaded contains this:
<meshobj name='ceiling'>
<plugin>thing</plugin>
<params>
<factory>thingCeiling</factory>
</params>
<zuse/>
<trimesh>
<mesh>
<v x="12.7448" y="-0.442003" z="12.7448"/>
<v x="12.7448" y="-0.442003" z="-12.7448"/>
<v x="-12.7448" y="-0.442003" z="-12.7448"/>
<v x="-12.7448" y="-0.442003" z="12.7448"/>
<t v1="3" v2="2" v3="1"/>
<t v1="3" v2="1" v3="0"/>
</mesh>
<id>colldet</id>
</trimesh>
<move>
<v y='4.29926' x='1.10138' z='-2.69455'/>
</move>
</meshobj>
Now the camera, that I put in the game world after loading the map always chooses to have a position relative to the player. Tracebeam is used to adjust that position for collisions. The NUM_8 and NUM_2 keys move the camera up and down. Here is a piece of code that is called every frame:
static float desiredDistance = 2.0f;
if(kbd->GetKeyState(CSKEY_PAD2) && desiredDistance < 5.0f) desiredDistance += 10.0f*delta;
else if(kbd->GetKeyState(CSKEY_PAD8) && desiredDistance > 2.0f) desiredDistance -= 10.0f*delta;
csVector3 startpos, tarpos, endpos;
startpos = player->GetPosition(); tarpos = startpos; tarpos.y += desiredDistance; endpos = tarpos;
csTraceBeamResult cd_result = csColliderHelper::TraceBeam(cdsys,sector,startpos,tarpos,true);
if( cd_result.sqdistance >= 0 )
{
endpos = cd_result.closest_isect;
}
camera->GetTransform().SetOrigin(endpos);
So tracebeam should check whether the ceiling is hit and the camera shouldn't move up any further. I have made a little graph to illustrate what happens when I start pressing down the num_2 key at t=0:
graph.jpg
(35.24 KB, 600x300 - viewed 227 times.)
«
Last Edit: November 08, 2007, 12:10:31 pm by SkyFox
»
Logged
Pages:
[
1
]
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Crystal Space Development
-----------------------------
=> General Crystal Space Discussion
=> Support
-----------------------------
Crystal Space Project Development
-----------------------------
=> Feature Requests
=> Plugins
=> Bug Reports
-----------------------------
Crystal Space Development
-----------------------------
=> Game Content Creation
-----------------------------
Miscellaneous
-----------------------------
=> Article/Tutorial Requests
=> Article/Tutorial Discussion
-----------------------------
Crystal Space Project Development
-----------------------------
=> Development Discussion
-----------------------------
Crystal Space Projects
-----------------------------
=> Project Discussion
=> WIP Projects
=> Finished Projects
-----------------------------
Associate Projects
-----------------------------
=> CEL Discussion
=> Crystal Core Discussion
=> CrystalBlend Discussion
-----------------------------
Crystal Space Project Development
-----------------------------
=> Google Summer of Code
-----------------------------
Associate Projects
-----------------------------
=> Apricot (Open Game)
=> Ares Project
Loading...