May 22, 2012, 06:03:47 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Please report any bugs or issues that you might be encountering with the Beta in the Support System so that we can better keep track of any oustanding issues that may come up.

GameCore Support System
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Engine Function question: Can we draw polygons along a raycasted line?  (Read 1053 times)
zknack
Full Member
***
Posts: 207


View Profile
« on: December 10, 2008, 01:59:10 PM »

Gekido (Or others):

Can we draw a line of polygons that would be determined by a raycasted line between the emitter (on the player) and a collision? Especially one that could grow or shrink based on player to collision point distance?

This would be for continuous lazer weapons (where it emits from a trap, turret, or player weapon),
or things such as grappling hooks. (Or heck, it'd be great for things like creating a guide-by-wire
missle weapon as well)

The main reason is that for some time, I have been trying to convert old quake 1/2 code for the grappling hook (the non swinging version), but this is one of the functions that I cannot figure out how to recreate.

Any help, or examples would be great as we had nothing of the sort in the old forum, nor do we have
any reference point to do such now.
« Last Edit: December 10, 2008, 02:01:32 PM by zknack » Logged
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #1 on: December 10, 2008, 03:47:48 PM »

If you can read the length/startposition/direction of the ray, you can orient a cylinder and set a scale value. Assuming scale works in the game. That, or you can use addobject to create an array of cylinders based on the same info. If you go further, you can calculate the positions of joints between them.

We talked about this before. I have a solid theory, but yet to quite grasp the raycasting. I looked into it and it appears to be a bit proprietary and the values are already determined. You get output of the things you'd need to orient I guess about anything...except maybe to the normal angle of the target polygon (which we need badly).

I'll look into it more during my menu phase. I need it for aligning an object to the camera.
Logged
gekido
Guest
« Reply #2 on: December 11, 2008, 05:31:18 PM »

There is a DrawDebugLine function in the new version (at least, not sure if it's in RC1) that does exactly what you are asking for ;}

http://www.gamecore.ca/docs/scripting-reference/global-functions/DrawDebugLine

That page isn't fleshed out with details about the function quite yet, but we're getting there ;}
Logged
zknack
Full Member
***
Posts: 207


View Profile
« Reply #3 on: December 11, 2008, 05:44:27 PM »

Gekido,
You are a horrible, horrible tease... I love your guys' products, and can't wait for the next release... I'm hoping it's soonishk ;-)
Logged
Spaz
Full Member
***
Posts: 109


View Profile
« Reply #4 on: December 11, 2008, 07:35:49 PM »

I second that!  Any chance we'll see the next version before Christmas? Cheesy
Logged
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #5 on: December 15, 2008, 06:21:52 PM »

The page appears to be fleshed out with more details.

Quote
void DrawDebugLine( const Vector& point1, const Vector& point2, int r, int g, int b)Draws a debug line on screen with the specified points and colour.

Parameters

point1 - the start point

point2 - the end point

r - red colour component

g - green colour component

b - blue colour component

So if we wanted this from the player's gun, to a point that it's looking at, it's not something we can just discount as point1 and point2 because we need the player's raycast.

So am I correct that we'd merely need to do something like I'm guessing here?
(don't wanna try in RC1)

Quote

Object@ hitObject = GetGameManager().GetWorld().RayCast( shotPosition, shotDirection, distance, intersect, normal, false);

void DrawDebugLine( shotPosition, intersect, 1, 0, 0)

That would effectively draw it from our face to an object and technically not be visible as anything more than a single pixel, correct? It would be a dot at most.

So what about if I wanted to alter it so "shotDirection" was to be from the gun model at all times (following the animation) and raycast directly out of the front of it, and not from my viewport?

Would it be something close to this?
Quote

Matrix mtx = GUNbase.GetMatrix();
Vector rayPos = mtx.T;

object.GetWorld().RayCast( rayPos, Vector( 0, 0, 1), distance, intersect, normal, false);

void DrawDebugLine( rayPos, intersect, 1, 0, 0)
Logged
gekido
Guest
« Reply #6 on: December 22, 2008, 01:33:15 AM »

we'll have some good news for everyone early this week.  Gonna leave it at that for now ;}

(ducks for cover)
Logged
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #7 on: December 22, 2008, 02:00:58 PM »

Oh you shouldn't of said that

(Stockpiles)  Kiss
Logged
zknack
Full Member
***
Posts: 207


View Profile
« Reply #8 on: August 19, 2009, 04:16:05 PM »

yay! More info in my quest for grappling hooks has been revealed :-)

http://www.gamecore3d.com/docs/scripting-reference/classes-structures/math-functions/ClosestPointOnLine

Still not sure how to create a spline-style or textured polygon line set to go to the point though...
Logged
gekido
Guest
« Reply #9 on: September 01, 2009, 04:12:52 PM »

You should NOT be using the DrawDebugLine for anything game-related - it's a debug function for a reason - doing line drawing like this is very slow.

What you would want to use for a grappling hook or anything similar would be the Beam FX.  We added the ability to modify the target of the beam from script.

We're using this in MetaJets for laser weapons as an example.

The functions that you are looking for are in the FXObject class (which let's you manipulate FX once they are spawned).

http://www.gamecore3d.com/docs/scripting-reference/classes/FXObject/SetObject
http://www.gamecore3d.com/docs/scripting-reference/classes/FXObject/SetTargetObject

Both CreateFX and CreateFXAtPosition return handles to the FXObject that was just spawned.

Something like this:
Quote
Object@ startObject = world.GetObject("BeamStart");
Object@ endObject = world.GetObject("BeamEnd");

FXObject@ myEffect = GetFXManager().CreateFX("MyEffect.fxt", position);

myEffect.SetObject( startObject);
myEffect.SetTargetObject( endObject);

Hope this helps,
Logged
Pages: [1]
  Print  
 
Jump to:  

 
Powered by MySQL Powered by PHP bluBlur Skin © 2006, hbSkins
Powered by SMF 1.1.14 | SMF © 2006-2011, Simple Machines LLC
Valid XHTML 1.0! Valid CSS!