Jump to content


Photo

Stop Drawing Models Outside Of Fps View


  • Please log in to reply
19 replies to this topic

#1 SoulTaker0227

SoulTaker0227

    GMC Member

  • GMC Member
  • 62 posts

Posted 01 July 2012 - 01:15 PM

Hay guys Idn if this has been done before i did not find anything of this sort but the following script stops 3d models to be drawn
1. You need a sprite (cone sprite) this will be the "view"
2nd. make 2 objects(obj view and the obj you want deactivated)
3rd put this in obj_view's step event
direction=Yourplayerobj.direction
x=Yourplayerobj.x
y=Yourplayerobj.y
image_angle=direction
"Yourplayerobj"is your player object(just rename it)
4rth put this in your other object
   if place_meeting(x,y,yourviewobject)
{
"your draw code"
}

"yourviewobject"is your view object

"your draw code" is all the code in the draw event of the object that should disipear if player is not looking at it

Edited by SoulTaker0227, 01 July 2012 - 01:16 PM.

  • 0

#2 ND4SPD

ND4SPD

    GMC Member

  • GMC Member
  • 2167 posts

Posted 01 July 2012 - 01:42 PM

You're better off just checking the difference between the vector along which the camera is facing, and the vector from the camera to the object. If that angle is too great, then don't draw. This way, you don't need an extra object, and you don't need to do any slow collision detection operations.

I'm sure there are even faster ways than the one I've described.

It IS a clever, simple solution you have there, though! Good idea :D
  • 0

#3 Gamer3D

Gamer3D

    Human* me = this;

  • GMC Member
  • 1588 posts
  • Version:GM8.1

Posted 01 July 2012 - 07:25 PM

You're better off just checking the difference between the vector along which the camera is facing, and the vector from the camera to the object. If that angle is too great, then don't draw. This way, you don't need an extra object, and you don't need to do any slow collision detection operations.

I'm sure there are even faster ways than the one I've described.

There are very few faster ways than calculating the difference between the vectors; speed improvements often arise from testing large numbers of objects using one check, then refining.

It IS a clever, simple solution you have there, though! Good idea :D

Clever, simple, and potentially more expensive than just drawing the thing.
  • 0

#4 Robert3DG+

Robert3DG+

    VR Games

  • GMC Member
  • 1842 posts
  • Version:GM:Studio

Posted 01 July 2012 - 07:37 PM

Some graphics cards may do frustum culling on their own without any assistance from GM. In this case your code is just slowing everything down with a check. 3D games are a (still very fun!) pain!
  • 1

#5 DZiW

DZiW

    GMC Member

  • GMC Member
  • 727 posts

Posted 01 July 2012 - 09:11 PM

While GM enjoys its wrong deliberate selective policy of partial support for some or other features to this or that extend, the only way to check whether *specific* version of GM works any faster with *specific* hardware in *specific* conditions under *specific* OS an d updates, the only true way is to benchmark.
  • 2

#6 SoulTaker0227

SoulTaker0227

    GMC Member

  • GMC Member
  • 62 posts

Posted 31 July 2012 - 07:49 PM

Thanx guys:) i tested my method and it increased my fps from 16 up until alllllllll the way to 50:) and the collision is not slow just put the (point in direction what what what... in every step event, like i said 16 - 50 fps:)) but it onley workes if you got a high poly model like a char then it will work fine but here is nother 2 ideas if they will be put together the fps will go from 16 to 80!! just draw the tryangles in the view and those whom are faceing the player eg.
000000000000___
00000000000***|
000000000|****|
00000000*|****|
0000000** _____
player-
0000000
00000000
000000000
0000000000
00000000000

the '0' represents the player view and the '|' and '_' represents the tryangles and the '*' just there to hold spaces haha :)
if i knew how to do this i wouldof alredy have posted the script please tell me if somthing like this exists becouse i use P3DC for collison chekking now and that means i need to make a whoooole map model and i cant put a lot of deatail in to that btw also reply if you have an idea too i see most of the toppicks keep at one way to do it if not onley 2 or 3 so why not let every one have a chance to say there ideas. It may change GAME MAKER !!! And its horrble idea of making it slow, i also think it wold of been faster if there where a advance advance mode where you can choose if a var should be a integer or a string or a double ect... Now game maker test what the code is and thus making it a lil bit more slower than thees expencive C# programs!!

Edited by SoulTaker0227, 31 July 2012 - 07:51 PM.

  • 0

#7 time-killer-games

time-killer-games

    GMC Member

  • Banned Users
  • 539 posts
  • Version:GM:Studio

Posted 31 July 2012 - 07:59 PM

^Uhhh...Run that by me one more time? D:

#8 YellowAfterlife

YellowAfterlife

    GMC Member

  • Global Moderators
  • 3490 posts
  • Version:GM:Studio

Posted 31 July 2012 - 08:09 PM

If you are doing lots of drawing operations in each wall segment object, this is going to help.
If you have merged all your static scenery into one or few models, this will have negative effect.
Simple enough.

I've used similar approach in some early 3d games of mine. Have also added a small circle around player to avoid accidental clipping.
  • 0

#9 Gamer3D

Gamer3D

    Human* me = this;

  • GMC Member
  • 1588 posts
  • Version:GM8.1

Posted 31 July 2012 - 09:42 PM

^Uhhh...Run that by me one more time? D:

He wants to know how to do, in GML, all the work that the graphics card is already doing. The answer is to use dot_product_3d for a guess at whether it is in the view frustum and a dot product to test which side the camera is on.

If you're getting FPS boosts from your current method, one or more of the following is probably true:
  • Your models have ridiculously large polygon counts (Upwards of 128000 polys, I'd guess)
  • You're using a mid-to-high-polygon model in GM8.0 or earlier. Before GM8.1, d3d used software transform and lighting, which is slow than doing it in hardware.
  • You're drawing polygons dynamically instead of using models. This is quite slow, mostly because GM is slow.
  • The draw events have a bunch of calculations in them.
Better solutions for each of these are:
  • Use models with fewer polygons, possibly using a LOD system to choose more detailed models when near the player.
  • Ditto.
  • Use the d3d model system wherever possible (wherever you have a rigid set of polygons). It's much faster.
  • The draw event is a bad place for gameplay-related calculations, and graphics-related calculations can usually be made simpler. Move it or improve it.

  • 0

#10 SoulTaker0227

SoulTaker0227

    GMC Member

  • GMC Member
  • 62 posts

Posted 01 August 2012 - 02:24 PM


^Uhhh...Run that by me one more time? D:

He wants to know how to do, in GML, all the work that the graphics card is already doing. The answer is to use dot_product_3d for a guess at whether it is in the view frustum and a dot product to test which side the camera is on.

If you're getting FPS boosts from your current method, one or more of the following is probably true:
  • Your models have ridiculously large polygon counts (Upwards of 128000 polys, I'd guess)
  • You're using a mid-to-high-polygon model in GM8.0 or earlier. Before GM8.1, d3d used software transform and lighting, which is slow than doing it in hardware.
  • You're drawing polygons dynamically instead of using models. This is quite slow, mostly because GM is slow.
  • The draw events have a bunch of calculations in them.
Better solutions for each of these are:
  • Use models with fewer polygons, possibly using a LOD system to choose more detailed models when near the player.
  • Ditto.
  • Use the d3d model system wherever possible (wherever you have a rigid set of polygons). It's much faster.
  • The draw event is a bad place for gameplay-related calculations, and graphics-related calculations can usually be made simpler. Move it or improve it.


My models are just high polly but like i said if i can onley find a way to draw the pollys in front of the player( and not where he can see, like the back of the model and the sides then this would help a loooot! btw thanx for replying so quiqly guys do post what you think of my idea and do tell me if such a script/engene/dll is afaleble and PLEASE do not tell me about gmorge i have that and it is WAAAAAAYYYYY above my standerd and there is to litlle tutorials about gmorge but thanx again for your support do reply again:)
  • 0

#11 SoulTaker0227

SoulTaker0227

    GMC Member

  • GMC Member
  • 62 posts

Posted 06 August 2012 - 05:53 PM

cumm on guys !!! please do reply! Lets keep this form alive!!!
  • 0

#12 slayer 64

slayer 64

    GMC Member

  • GMC Member
  • 3274 posts
  • Version:GM8.1

Posted 07 August 2012 - 12:46 AM

i don't use frustum culling because my computer does that already. custom frustum culling is dumb. if you can't draw the whole scene and look at it, then it's too expensive.
  • 0

#13 Gamer3D

Gamer3D

    Human* me = this;

  • GMC Member
  • 1588 posts
  • Version:GM8.1

Posted 08 August 2012 - 02:47 AM

cumm on guys !!!

I will strive to interpret this in the funniest (most inappropriate) way possible.

please do reply! Lets keep this form alive!!!

Translation: Shameless bump.

i don't use frustum culling because my computer does that already. custom frustum culling is dumb. if you can't draw the whole scene and look at it, then it's too expensive.

Frustum culling can improve the performance in a scene if performed correctly. The key to determining when to use it is finding how many polygons you need to cull with each test to see a performance increase (usually best to test on mid-range hardware from 2 years ago because modern GFX cards are almost always underused by GM).

Most GM models have few enough polygons that the most expensive part of drawing them is the call to GM's d3d_draw_model function. If you want performance increases, create a visibility tree (if any node is culled, its child nodes are not considered for visibility); I'd recommend using axis-aligned bounding boxes to determine node size and center, then using bounding spheres for frustum culling tests (boxes are more expensive to cull, but trees of contained spheres often waste space).
  • 0

#14 ShubhamBansod

ShubhamBansod

    Pokemon Master

  • GMC Member
  • 255 posts
  • Version:GM8

Posted 08 August 2012 - 02:59 PM

Hay guys Idn if this has been done before i did not find anything of this sort but the following script stops 3d models to be drawn
1. You need a sprite (cone sprite) this will be the "view"
2nd. make 2 objects(obj view and the obj you want deactivated)
3rd put this in obj_view's step event

direction=Yourplayerobj.direction
x=Yourplayerobj.x
y=Yourplayerobj.y
image_angle=direction
"Yourplayerobj"is your player object(just rename it)
4rth put this in your other object
   if place_meeting(x,y,yourviewobject)
{
"your draw code"
}

"yourviewobject"is your view object

"your draw code" is all the code in the draw event of the object that should disipear if player is not looking at it

Nice idea for getting rid of unwnted model....i want to share some code with u....like u r code only draw models in the view i.e collision witn the conical sprite....but if u also use collision_line btwen Player and object_tobe_drwn ....than i will not create a model which was not be seen by player but inside the view...like if there is model tree behind a huge wall by which the player is unable to see...the it will use full.....:)
  • 1

#15 SoulTaker0227

SoulTaker0227

    GMC Member

  • GMC Member
  • 62 posts

Posted 08 August 2012 - 09:01 PM


Hay guys Idn if this has been done before i did not find anything of this sort but the following script stops 3d models to be drawn
1. You need a sprite (cone sprite) this will be the "view"
2nd. make 2 objects(obj view and the obj you want deactivated)
3rd put this in obj_view's step event

direction=Yourplayerobj.direction
x=Yourplayerobj.x
y=Yourplayerobj.y
image_angle=direction
"Yourplayerobj"is your player object(just rename it)
4rth put this in your other object
   if place_meeting(x,y,yourviewobject)
{
"your draw code"
}

"yourviewobject"is your view object

"your draw code" is all the code in the draw event of the object that should disipear if player is not looking at it

Nice idea for getting rid of unwnted model....i want to share some code with u....like u r code only draw models in the view i.e collision witn the conical sprite....but if u also use collision_line btwen Player and object_tobe_drwn ....than i will not create a model which was not be seen by player but inside the view...like if there is model tree behind a huge wall by which the player is unable to see...the it will use full.....:)


Yea realy use full, ill get started on that code!!! :)
  • 0

#16 SoulTaker0227

SoulTaker0227

    GMC Member

  • GMC Member
  • 62 posts

Posted 13 August 2012 - 05:41 PM

Okay i am finished with the code. its the same as the first one, just a litle more advanced :)
pleas do reply and tell me what you think OR if you have a better idea
Link to my example
Link
  • 0

#17 brac37

brac37

    GMC Member

  • GMC Member
  • 765 posts
  • Version:GM7

Posted 17 August 2012 - 08:10 PM

In this terrain example, I use a script that computes the smallest orthogonal rectangular box which contains the cone of view. Next, junks of the terrain are not drawn when they are outside the box. On my old computer, the difference in speed was about a factor two.
  • 1

#18 SoulTaker0227

SoulTaker0227

    GMC Member

  • GMC Member
  • 62 posts

Posted 03 September 2012 - 05:31 PM

Thats exactly what i want!!!! Thanx alot:) now to try to figure it out for my terrain model.... Should i just load my model and put that in my step event?
It kinda looks like that:)
  • 0

#19 Wolf Dreamer

Wolf Dreamer

    GMC Member

  • GMC Member
  • 217 posts
  • Version:GM:HTML5

Posted 05 September 2012 - 07:32 AM

Hay guys Idn if this has been done before i did not find anything of this sort but the following script stops 3d models to be drawn
1. You need a sprite (cone sprite) this will be the "view"
2nd. make 2 objects(obj view and the obj you want deactivated)
3rd put this in obj_view's step event

direction=Yourplayerobj.direction
x=Yourplayerobj.x
y=Yourplayerobj.y
image_angle=direction
"Yourplayerobj"is your player object(just rename it)
4rth put this in your other object
   if place_meeting(x,y,yourviewobject)
{
"your draw code"
}

"yourviewobject"is your view object

"your draw code" is all the code in the draw event of the object that should disipear if player is not looking at it


I had the same idea years ago and told FreeGadgets when he made the first 3D engine for Game Maker. Worked very well and was absolutely necessary on the slow computers of the day.
  • 0

#20 SoulTaker0227

SoulTaker0227

    GMC Member

  • GMC Member
  • 62 posts

Posted 05 September 2012 - 06:48 PM


Hay guys Idn if this has been done before i did not find anything of this sort but the following script stops 3d models to be drawn
1. You need a sprite (cone sprite) this will be the "view"
2nd. make 2 objects(obj view and the obj you want deactivated)
3rd put this in obj_view's step event

direction=Yourplayerobj.direction
x=Yourplayerobj.x
y=Yourplayerobj.y
image_angle=direction
"Yourplayerobj"is your player object(just rename it)
4rth put this in your other object
   if place_meeting(x,y,yourviewobject)
{
"your draw code"
}

"yourviewobject"is your view object

"your draw code" is all the code in the draw event of the object that should disipear if player is not looking at it


I had the same idea years ago and told FreeGadgets when he made the first 3D engine for Game Maker. Worked very well and was absolutely necessary on the slow computers of the day.


OK awsum!!! Thanx for the support :)







____________________________________________________________________________________________________________________________________________________________

If you want a job on 3d texture making continue reading>>>
dont have money now but will have after i release the game..
or you can do it for free of course and i will then shurely put your name in the creddits
more details->
e-mail me
-jacobus.silver@yahoo.com

Edited by SoulTaker0227, 05 September 2012 - 06:49 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users