Jump to content

TFormVector / Point understanding.


Andy Gilbert
 Share

Recommended Posts

Hi, im trying to get my head around the TFormVector and TFormPoint as im sure thats what i need to do in order to get my code to work.

 

I know this might seem simple, but i just dont quite get it at the moment so need a little help. To save me trying to explain ive made a quick diagram of my problem.

 

The fan thing in the image is one model, this contains two groups, "frame" and "fan" and what i do in code is find the "fan" child and make it into an entity, i then want to rotate it like a fan would.

 

But as you might of guessed it does, it rotates around the origin of the model.

 

What do i need to do in order to make it rotate arounds an axis of its own?

 

tformhelp.png

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

Hmm TForm Point & TForm Vector basically convert the point or vector from one objects orientation to another.

 

So for example: Player A is in position (1,1,1) and Player B is in a position (5,7,2) relative to the global point (0,0,0)

 

so if you use TFormPoint between Player A & B with B as the source and A as the destination point you will get the Position of Player B relative to player A and the point will be (4,6,1)

So that the general jist of it, however that is assuming that Player A's rotation is (0,0,0) also. Its all about converting positions vectors etc. relative to certain objects.

 

I'm not sure how you would use it to turn your fan around a new origin. Maybe others have the answer. Personally I would just have them separate and change the origin of the fan to its center. Then write some LUA for the Base that basically loads the fan when it is loaded and turns it.

 

Hope that makes sense. There may be a better solution not sure tho.

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

Hi, thanks for the replies. I guess the skinning / bone idea rick is the solution and the one i first tried, the only reason im going down this road is becasue it appears my computer that im currentl working on that has a "intel HD 2000" graphics adapater makes the model dissapear when i use the "skin" shader, meaning i cant currently do it that way (well it will make it very hard lol)

 

So, thought this might eba work around.

 

Any ideas why models dissapear when i use the skin shader?

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

Can you break the single model into two? If yes. I would do something like this:

 

TModel frame = LoadModel();
TModel fan = LoadModel(frame);  // parent fan to frame

PositionEntity(fan(Vec3(0,height_of_stand,0);  // move the fan model to the height of the stand
TurnEntity(fan(Vec3(0,0,turn_speed);  // turn the fan

 

What you want to do should be doable.

 

You might need to open your model in a modeling program such as UU3D and make sure that the center of the fan is at the (0,0,0) origin.

Link to comment
Share on other sites

HI Clackdor, thanks yes that is the other option, but some models might have more than one spinny thing (not just refering to the fan) and i wanted to try keep them as a single model as aposed to have lots of "parts" of the model that i then i have script together.

 

I made the model which is why the origin is where it is, i could easily change it to the fan, but what about models with more than one fan? :)

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

This is somewhat fascinating to me.

 

Is the fan the only thing revolving around the origin or is the stand also?

 

What about:

 

TPivot pivot = CreatePivot();
PositionEntity(pivot,Vec3(x,y,z)) // posiiton pivot at center of fan
ParentEntity(fan,pivot)
TurnEntity(pivot,Vec());

 

This would cause your green dot center of origin to revolve around the fan. Come to think of it, this might be detrimental to your models with multiple spinny things. But I'll throw it out there anyway.

Link to comment
Share on other sites

Hmm not a bad idea Clackdor but yes i think it would have issue with multiple spinning verts.

 

I can only assume the correct way to do this is to have any parts you want to move or spin to be on bones, then yo get full control over them.

 

Ill have to look into why models using the skin shader dissapear.

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

Hi, im trying to get my head around the TFormVector and TFormPoint as im sure thats what i need to do in order to get my code to work.

 

I know this might seem simple, but i just dont quite get it at the moment so need a little help. To save me trying to explain ive made a quick diagram of my problem.

 

The fan thing in the image is one model, this contains two groups, "frame" and "fan" and what i do in code is find the "fan" child and make it into an entity, i then want to rotate it like a fan would.

 

But as you might of guessed it does, it rotates around the origin of the model.

 

What do i need to do in order to make it rotate arounds an axis of its own?

Thanks

Andy

It helps to use precise terminology. I don't know what a "group" in a model file is, since the engine has no convention with this name. Are you referring to surfaces or child entities?

 

Why wouldn't the fan part be a child entity, with its origin around the intended rotation point? Then you would just call TurnEntity() and it would rotate correctly. Are you transforming vertices to make a surface rotate?

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Hi Josh, a group i refer to is maybe a child? Im not sure what you call them but in most 3D model packages there groups, and when i convert them to a GMF there stilll there named the same so i presumed still groups, but maybe a selection of verts?

 

Either way, i can find this group/set/selection of verts by its name using findchild and then i can rotate as i wish.

 

But thats fine, if the origin is the center of the the child i want to rotate. but like i said in the past threads, what i want two or 3 groups i want to rotate.

 

Lets say like a bike, how would i rotate both wheels around there own axis, you cant have the origin center of both wheels?

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

Hi Josh, a group i refer to is maybe a child? Im not sure what you call them but in most 3D model packages there groups, and when i convert them to a GMF there stilll there named the same so i presumed still groups, but maybe a selection of verts?

 

Either way, i can find this group/set/selection of verts by its name using findchild and then i can rotate as i wish.

 

But thats fine, if the origin is the center of the the child i want to rotate. but like i said in the past threads, what i want two or 3 groups i want to rotate.

 

Lets say like a bike, how would i rotate both wheels around there own axis, you cant have the origin center of both wheels?

 

Thanks

Andy

I would make each object you want to rotate around an axis a separate entity in the model. If you have two bike wheels, use two separate entities for the wheels, with their origin at the point they should rotate around.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

When you say seperate entitiys, that would seperate gmf's, so the bike example would be 2 .gmf's? (frame and wheel x 2) and then you use lua two make them a "model"?

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

I believe he's saying make 2 separate model files and code the iteration like was suggested above. He does this with some example models that come with the engine. It's the easiest way IF you know how to program OR you can get someone to do it for you if you don't.

 

At one time I did have rotate thingoid that would simply call TurnEntity() on the first target. So you would have 2 separate models, place the blades where you want, drag in this turn script and target the blades to it. Set some settings of turn direction and axis and it would keep turning once you ran the game or in editor. If you want to give it a try I can find that thingoid.

Link to comment
Share on other sites

When you say seperate entitiys, that would seperate gmf's, so the bike example would be 2 .gmf's? (frame and wheel x 2) and then you use lua two make them a "model"?

 

Thanks

Andy

 

So for the bicycle example you make 1 frame and 1 wheel. Then you code the LUA script for the frame to load two wheels to positions relevant to the frame and parent them to the frame on Initialization.

 

So yes multiple gmf files. That way you can have a separate origin point for each of them. Essentially you have one "model" and you load 1 mesh and paint it... Unless the fan is also a model with some LUA code and a .phy file. You can really do it whichever way you want but its best to have separate .gmfs. thats the was I do it at least.

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

If you want some basic functionality here is a small script I wrote up. It's very basic. Place the folder in your Leadwerks directory. Reopen the editor. Drag in whatever model you want to rotate. Drag in this script (in the editor it'll be under PI/LE). Press the 0 key to make sure your target index is on 0. Click left mouse button and hold this script object in the scene and drag the mouse to the model you want to rotate and let go of the mouse button. Double click this object to bring up settings and in the bottom group put some values in and click Apply and see it rotate. Very basic but can give you some reusable object to rotate anything you want all the time. More functionality can be added to disable/enable etc.

 

This is just if you want to get what you want done. If you are trying to learn scripting then no worries. I need something like this anyway for a testing situation.

 

http://dl.dropbox.com/u/1293842/Pi-TurnEntity.rar

Link to comment
Share on other sites

When you say seperate entitiys, that would seperate gmf's, so the bike example would be 2 .gmf's? (frame and wheel x 2) and then you use lua two make them a "model"?

 

Thanks

Andy

No, I mean just make sure they are separate objects in the model file. I do this all the time to make wheels, turrets, or anything that rotates. Just use FindChild() to retrieve the entity and you're ready to rotate.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...