Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Activate
Activate
2005-08-19, 8:54 PM #1
Is there any way to return a particular mesh of a 3do THING when it is activated? Am trying to get events to occur only when the console of a ship-3do is activated. I do not want them to be separate objects.

My 1 idea right would be test the distance from the center of the object to limit the activation to a smaller area of the 3do.
2005-08-19, 8:56 PM #2
put a ghost template over part of the console and attach the cog to that ghost object
</sarcasm>
<Anovis> mmmm I wanna lick your wet, Mentis.
__________
2005-08-19, 9:00 PM #3
I don't want them to be separate things
2005-08-19, 9:07 PM #4
I believe you're SOL then if the whole ship is a 3do. You can put a ghost template in and use attachthingtothing so that it's virtually the same thing as the ship 3do.
</sarcasm>
<Anovis> mmmm I wanna lick your wet, Mentis.
__________
2005-08-22, 1:13 PM #5
Couldn't he just use the center of the ship 3do, and its look vector as a reference point to determine the location of the player in relation to the ship? I would think the use of hasLOS() and maybe vectordot() you could probably set a point as activatable.

I don't know how reliable it would be. I'd probably just use the seperate thing if I could get away with it.
-El Scorcho

"Its dodgeball time!" -Stormy Waters
2005-08-22, 1:32 PM #6
I too think it would be possible to have the whole 3do send the activated message, then check the player's position in relation to the 3do's and only process any further if the position is close enough to the console.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2005-08-22, 1:43 PM #7
you can't return any particular 3do meshes in JK with cog

you could try VectorDist on the player's position and the console's position
it's a little complicated though, and only works if the console doesn't move around the 3do (with keyframe animations).

for symbols:
Code:
thing     ship
flex      consoleXcoord
flex      consoleYcoord
flex      consoleZcoord
flex      minDistance

flex      offsetX         local
flex      offsetY         local
flex      offsetZ         local
vector    consoleoffset   local
vector    consolepos      local

make ship, the ship thing
make consoleXcoord the console's X value from the center of the 3do.
make consoleYcoord the console's Y value from the center of the 3do.
make consoleZcoord the console's Z value from the center of the 3do.
make minDistance how close to the console's position the player needs to be in order to activate it.

for the activated message:
Code:
offsetX = VectorScale(GetThingRVec(ship), consoleXcoord);
offsetY = VectorScale(GetThingLVec(ship), consoleYcoord);
offsetZ = VectorScale(GetThingUVec(ship), consoleZcoord);
consoleoffset = VectorSet(offsetX, offsetY, offsetZ);
consolepos = VectorAdd(GetThingPos(ship), consoleoffset);

if(VectorDist(GetThingPos(ACTIVATOR), consolepos) <= minDistance)
{
   [ACTIVATION STUFF]
}


it should be able to work if the ship is moving, rotating, but not animated with keyframes.
visit my project

"I wonder to myself. Why? Simply why? Why why? Why do I ask why? Why do I need to find out why? Why do I have to ask why as a question? Why is why always used to find out why? Why is the answer to why always why? Why is there no final answer to why? Simply why not? Holy cow, this is pretty deep, meaningful **** I wrote. Glad I wrote it down. Oh man."
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ [slog], Echoman
2005-08-22, 6:52 PM #8
I got something to work yesterday.I'm only just starting to understand vectors

What I did was something like this...


Code:
Activate:

 Dot=VectorDot (VectorNorm(GetThingLvec(ship)) , VectorNorm(VectorSub
(GetThingpos(player), GetThingPos(ship))));

playerdistance=VectorLen(player);
shipdistance=VectorLen(ship);
shipZ=VectorZ(GetThingPos(ship));
playerZ=VectorZ(GetThingPos(player));


if ( (Dot >= -0.2)  &&  (Dot <= 0.2) && (playerdistance<shipdistance) &&
(playerZ>shipZ) )
{.....continue with activation instructions.....


All my "ships" are facing inward towards the origin so the consoles are all closer to the origin. So the VectorLen comparison makes sure the player is in the front and not the back because they both get the same total from VectorDot. The VEctorZ comparison makes sure the player is standing in the ship and not underneath it.

But the way ProdigyOddigy is saying to do it sounds much better. I just don't quite understand what VectorScale does to those look-vectors.
Maybe If I used one of those other Verbs like GetThingRvec instead I wouldn't need to test the vector length.

Also can I use ThingViewDot? I wasn't getting any effect when I tried it. What exactly defines a 'LookThing'?



Also, a basic cog fundamental question:
When I need something like GetThingPos(player) several times in cog is it better to assign it to a variable and use that or is it just as efficient to use the cog-verb over and over again?
2005-08-23, 12:31 AM #9
VectorScale() Multiplies the lenth/magitude of the vector.

GetThingLVec/GetThingRVec/GetThingLVec seem to always return unit vectors (1 JKU long).

GetThingLVec is the looking/forward vector, RVec is directly to the right, and UVec is up.

I don't know what a look thing is, but do you mean SetThingLook()? that changes a thing's orientation to face in the direction of a vector. keep in mind it doesn't preserve roll.

I don't know what really dot products can do exactly, I should probably find out.

BTW the code I posted is untested, but the idea should work (I hope).
visit my project

"I wonder to myself. Why? Simply why? Why why? Why do I ask why? Why do I need to find out why? Why do I have to ask why as a question? Why is why always used to find out why? Why is the answer to why always why? Why is there no final answer to why? Simply why not? Holy cow, this is pretty deep, meaningful **** I wrote. Glad I wrote it down. Oh man."
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ [slog], Echoman
2005-08-23, 6:57 PM #10
It does work, except for one minor change to it:

Code:
offsetX = VectorX(VectorScale(GetThingRVec(ship), consoleXcoord));
offsetY = VectorY(VectorScale(GetThingLVec(ship), consoleYcoord));
offsetZ = VectorZ(VectorScale(GetThingUVec(ship), consoleZcoord));


I'll probably use this. Then the ships can be activated later after they've left their initial positions!

The dot vector returns the cosine of the angle between 2 vectors...which will be:
-1 >= some flex number <= 1 An angle of 0 degrees gives you a cosine value of exactly 1. An angle of 180 degrees gives you a cosine value of exactly -1.

I realized I made a mistake with my ships by saving them so the front is oriented toward the x axis instead of the y axis so using the ThingViewDot() wouldn't work too good anyway. But now I know to always face the front of my 3dos up toward the y axis.
2005-08-23, 8:23 PM #11
So wait...what was wrong with a ghost object or a seperate console object and just attaching them together? It's far more reliable, simple, elegant...I can't think of a reason why you wouldn't want to do it that way.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-08-24, 1:36 AM #12
Originally posted by ProdigyOddigy:
I don't know what really dot products can do exactly, I should probably find out.

VectorDot() can be used to check if two vectors look in the same general direction (+/- 90 degrees). When the dot product is positive, they do (check attached image #1). It can also be use to see how much "affection" one vector has on another, when dealing with forces (see attached image #2, blue interval is result of dot operation). Finally, it's very useful to get the angle between to vectors. You need an arccos function for this, though. The angle is arccos(VectorDot(a, b) / (VectorLen(a) * VectorLen(b))).
Attachment: 6919/dot_direction.png (866 bytes)
Attachment: 6920/dot_affection.png (638 bytes)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2005-08-24, 11:24 AM #13
In short, the dot product = the cosine of the angle formed 2 normalized vectors, which, if you know anything about trig, you can figure out the angle from such. With 1 being no angle w/ 0º, to 0 being 90º, and -1, being 180º on either side.

Zagibu, what I would do is cosine = VectorDot(VectorNorm(a), VectorNorm(b)); looks smaller and cleaner, but your way works just as fine.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack

↑ Up to the top!