Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
deactivating instance when too far
Topic Started: Dec 12 2012, 11:32 PM (619 Views)
MisuMen
Member Avatar
Advanced Member
[ *  *  * ]
I'm trying to come up with something to decrease lag by deactivating those instance that are far from view. and when getting close, they reactivate. How can I accomplish this when I'm using u3d?
Offline Profile Quote Post Goto Top
 
Despellanion
Member Avatar
Forum God
[ *  *  *  *  *  * ]
If the object is static, just deactivate it in the create event once it has finished loading everything.
Offline Profile Quote Post Goto Top
 
MisuMen
Member Avatar
Advanced Member
[ *  *  * ]
Um no because this instance draws a model. So if I deactivate instance, then the drawing won't reappear again or resets to its normal shape (i scaled this model with u3d).
Offline Profile Quote Post Goto Top
 
Despellanion
Member Avatar
Forum God
[ *  *  *  *  *  * ]
MisuMen
Dec 13 2012, 12:09 AM
Um no because this instance draws a model. So if I deactivate instance, then the drawing won't reappear again or resets to its normal shape (i scaled this model with u3d).
You don't need to have the model object active once it has been loaded, unless you need it to move around, animate or change its materials.
Offline Profile Quote Post Goto Top
 
zelda4evr
Member Avatar
Forum God
[ *  *  *  *  *  * ]
yep, so if at the end of the create event of static models you deactivate them, they will still be visible(collisions still work if I'm not mistaken as well) if an object is dynamic but when it gets too far away becomes static, it can be deactivated by an instance controller.

Posted Image
Offline Profile Quote Post Goto Top
 
MisuMen
Member Avatar
Advanced Member
[ *  *  * ]
Well my object is static but the problem is that its a block being stretched with scale variables to form itself into a wall. So if you deactivate it in create event, I'll draw it as in its original model form (a block)[Well at least this is how I see its happening in my game so its an assumption]

However, I used the CreateLODChain function to lower amount of triangles when at a far distance like this:

CreateLODChain(120,8,128,2,148,0);

It works great but not enough. The lag is a little noticeable now. I'll try to create a control object to verify whether to deactivate instance or not. But in the meantime, are there any other tricks to avoid any lag in my game?
Edited by MisuMen, Dec 14 2012, 02:38 AM.
Offline Profile Quote Post Goto Top
 
Despellanion
Member Avatar
Forum God
[ *  *  *  *  *  * ]
MisuMen
Dec 14 2012, 02:36 AM
Well my object is static but the problem is that its a block being stretched with scale variables to form itself into a wall. So if you deactivate it in create event, I'll draw it as in its original model form (a block)[Well at least this is how I see its happening in my game so its an assumption]
I think you are misunderstanding what I'm getting at.
What you do in the create event is
Code:
 

//First create the cube
width=height=depth2=10;
texture=1;
originx=originy=originz=0.5;
CreateCube();
Step();
//Finally dectivate the object
instance_deactivate_object(); //Can't remember if this is the correct name for the function
Offline Profile Quote Post Goto Top
 
MisuMen
Member Avatar
Advanced Member
[ *  *  * ]
Oopps! I clicked on report button by mistake with quote button.. Sorry.

Anyway, I did understood your instructions and I tried but when I tried it and tested, it turned all my floors into cubes since the original model I'm loading (yes, I'm loading models here) is a cube that I then morph it into a floor by using scalx, scaly, and scalz.

Thats what I've been trying to say the whole time. So its like cancelling the scale variables which its wierd that it should happen.

Anyway, I hope you understand now my prob or there's something i do not understand with your example.

Offline Profile Quote Post Goto Top
 
Reikyrr
Forum God
[ *  *  *  *  *  * ]
MisuMen
Dec 14 2012, 01:47 PM
Oopps! I clicked on report button by mistake with quote button.. Sorry.

Anyway, I did understood your instructions and I tried but when I tried it and tested, it turned all my floors into cubes since the original model I'm loading (yes, I'm loading models here) is a cube that I then morph it into a floor by using scalx, scaly, and scalz.

Thats what I've been trying to say the whole time. So its like cancelling the scale variables which its wierd that it should happen.

Anyway, I hope you understand now my prob or there's something i do not understand with your example.

I dont think the Scale values should be reset if you deactivate the instance. But I cant think of any other reason why this is happening either.
~Inspirational quote~
Offline Profile Quote Post Goto Top
 
Despellanion
Member Avatar
Forum God
[ *  *  *  *  *  * ]
MisuMen
Dec 14 2012, 01:47 PM
Oopps! I clicked on report button by mistake with quote button.. Sorry.

Anyway, I did understood your instructions and I tried but when I tried it and tested, it turned all my floors into cubes since the original model I'm loading (yes, I'm loading models here) is a cube that I then morph it into a floor by using scalx, scaly, and scalz.

Thats what I've been trying to say the whole time. So its like cancelling the scale variables which its wierd that it should happen.

Anyway, I hope you understand now my prob or there's something i do not understand with your example.

It's the same principle there
Code:
 

file="yourmodel.x";
LoadMesh();
scalx=scaly=scalz=2;
Step();
instance_deactivate_object();

I've used this method myself so I know it works.
Offline Profile Quote Post Goto Top
 
MisuMen
Member Avatar
Advanced Member
[ *  *  * ]
Despellanion
Dec 14 2012, 04:52 PM
MisuMen
Dec 14 2012, 01:47 PM
Oopps! I clicked on report button by mistake with quote button.. Sorry.

Anyway, I did understood your instructions and I tried but when I tried it and tested, it turned all my floors into cubes since the original model I'm loading (yes, I'm loading models here) is a cube that I then morph it into a floor by using scalx, scaly, and scalz.

Thats what I've been trying to say the whole time. So its like cancelling the scale variables which its wierd that it should happen.

Anyway, I hope you understand now my prob or there's something i do not understand with your example.

It's the same principle there
Code:
 

file="yourmodel.x";
LoadMesh();
scalx=scaly=scalz=2;
Step();
instance_deactivate_object();

I've used this method myself so I know it works.
sorry but your example didn't solve my issue for that it causes, still, to mess up my models size.

I don't know but I'm now playing around with the mipmaps to see the best results between speed and graphics can solve my issue. And so far, I set my mip map to 3. But it could use more speed though.

:(
Offline Profile Quote Post Goto Top
 
Despellanion
Member Avatar
Forum God
[ *  *  *  *  *  * ]
MisuMen
Dec 14 2012, 09:53 PM
Despellanion
Dec 14 2012, 04:52 PM
MisuMen
Dec 14 2012, 01:47 PM
Oopps! I clicked on report button by mistake with quote button.. Sorry.

Anyway, I did understood your instructions and I tried but when I tried it and tested, it turned all my floors into cubes since the original model I'm loading (yes, I'm loading models here) is a cube that I then morph it into a floor by using scalx, scaly, and scalz.

Thats what I've been trying to say the whole time. So its like cancelling the scale variables which its wierd that it should happen.

Anyway, I hope you understand now my prob or there's something i do not understand with your example.

It's the same principle there
Code:
 

file="yourmodel.x";
LoadMesh();
scalx=scaly=scalz=2;
Step();
instance_deactivate_object();

I've used this method myself so I know it works.
sorry but your example didn't solve my issue for that it causes, still, to mess up my models size.

I don't know but I'm now playing around with the mipmaps to see the best results between speed and graphics can solve my issue. And so far, I set my mip map to 3. But it could use more speed though.

:(
Then it's something else in your code which messes it up, because I know for a fact that it does work. Just try it with a new clean object without any other code in it.
Offline Profile Quote Post Goto Top
 
57E
Member Avatar
Forum Leader
[ *  *  *  *  * ]
I remember having similarish problem when I worked with this method. I don't excatly remember what caused it, but try this:
Code:
 

file="yourmodel.x";
LoadMesh();
external_call(global.u3d_model_step,u3d_index,x,y,z,rotx,roty,rotz,scalx,scaly,scalz,texture);
instance_deactivate_object();

Just replace the "scalx,scaly,scalz" with the vaules you want to use.
Edited by 57E, Dec 14 2012, 10:28 PM.

Offline Profile Quote Post Goto Top
 
MisuMen
Member Avatar
Advanced Member
[ *  *  * ]
57E
Dec 14 2012, 10:27 PM
I remember having similarish problem when I worked with this method. I don't excatly remember what caused it, but try this:
Code:
 

file="yourmodel.x";
LoadMesh();
external_call(global.u3d_model_step,u3d_index,x,y,z,rotx,roty,rotz,scalx,scaly,scalz,texture);
instance_deactivate_object();

Just replace the "scalx,scaly,scalz" with the vaules you want to use.
Yes! That fixed Despellanion's code problem for me, but it seems the lighting is flipped (makes it look like each floor piece is a huge tile) but I bet its the scale that might be a bit inverted, I'll have a look at that. BTW, this code made the mouse view a bit more smoother now, but not fast enough.

However, I'm going to search for one of the u3d example files I have in a folder because I remember one example had a Dynamic Speed script. I'm gonna try that to make things more quicker, although it makes it look like a frame skip thing.

Oh and I recently added shader effects to the game but my laptop gets overheated by this. Need to find a way to optimize my performance and decrease CPU occurring while playing the game.
Offline Profile Quote Post Goto Top
 
zelda4evr
Member Avatar
Forum God
[ *  *  *  *  *  * ]
sometimes to prevent certain issues I used to use a control object to deactivate the instances but only after an alarm of 2 or more so everything could be properly loaded into the engine and then deactivated. This also allows you to reactivate and again deactivate instances and groups of instances(parent objects help) with ease. Sometimes scaling your entire game down can reduce lag because giant polygons are sometimes slower, so you could make your game scale 1/10 of what it is now. If it is lagging, there has to be compromises made somewhere, if you notice on xbox 360 most textures are pretty low res but they use detail maps to make it look better. A lot of times you can have a very low poly count and still have a great looking game if the textures are made right.

Posted Image
Offline Profile Quote Post Goto Top
 
Go to Next Page
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply