Jump to content


Photo

Precise 3D Collisions Dll (P3Dc.Dll)


  • Please log in to reply
411 replies to this topic

#1 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 05 October 2009 - 12:09 AM

P3DC

Now supports GM Studio!

 

Download Newest Version (Thanks to Ciberman for fixing the issues)
*Older Versions*

Download V6.1 (zip)Download V6.00 (.zip), Download V6.00 (.7z), Download V5.02 (.zip), Download V5.01 (.zip), Download V5.00 (.zip), Download V4.00 (.zip)


Features:
-Collision Dectection
-Raycasting
-Create collision meshes in realtime + Load external models (.d3d models -> GM's format)
-Mesh Optimization


CREDIT
Brett Binnersley (Brett14): Made P3DC

Ciberman (Ciberman): Fixed Many Issues with V6.1
Samuel Hanson (Hanson): Made ModModCollisions, P3DC is based on it.
Snake_PL: P3DC V5.02 makes use of GMAPI. V6.00 is GMAPI free.
Thomas Moller: 3D Collision code, some of it is used by P3DC


Please leave feedback & report bugs
~~Brett14;


Edited by brett14, 17 November 2013 - 12:32 PM.

  • 11

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#2 frankpiet

frankpiet

    ^destroyed evil chicken^

  • New Member
  • 760 posts

Posted 05 October 2009 - 01:46 AM

Good job!
construction:
good, as proven campared to modmod
possibly make it an extension, with a help file. just for convenience -_-

presentation:
great, indented code. enough comments to understand it, some more wouldnt hurt.
maybe make the beginner game 3rd person, with the ability to change player models, to demonstrate its full capabilities

extra features?
maybe a feature that returns a vector representing a polygons upside?

anyway 9.5/10
  • 0
Posted Image

#3 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 05 October 2009 - 04:29 AM

Thanks Frank;

I don't plan to make a help file, Although I may add a few more comments. I might add a 3rd person option, but that doesn't really show much more of the dll. That would show what gm's D3D can do. I might add a few models flying into each other or something though.
  • 1

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#4 hanson

hanson

    GMC Member

  • GMC Member
  • 444 posts
  • Version:GM8

Posted 06 October 2009 - 01:07 PM

Looks nice! I'll be trying this out as soon as I find where I hid my gm7 reg info. Thanks for sharing your modifications!
  • 0

#5 WadeMcGillis

WadeMcGillis

    wademcgillis.com

  • GMC Member
  • 971 posts

Posted 06 October 2009 - 02:25 PM

In the expert example, it says that modmod was made by hobbel...
  • 0

#6 hanson

hanson

    GMC Member

  • GMC Member
  • 444 posts
  • Version:GM8

Posted 06 October 2009 - 02:34 PM

And in the op :rolleyes: This is incorrect though. I'm sure it was just a copy-paste-forget.to.edit scenario and will be fixed soon now that it was brought up.
  • 0

#7 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 07 October 2009 - 12:52 AM

Sorry! It was made my hanson, not hobbel... I confused the names of you two. I'll fix it in the next update. I'll also update the first post (to ensure people know). It was a copy-paste error, It will be fixed.

Once again sorry
~~Brett14;

[EDIT]
Btw: This message is directed towards you Frankpiet, you wanted me to make a game? Good news, I'm making one; this is why this was developed. I needed fast collisions-so I made this. It is a 3D Multiplayer game (the expert example is actaully a level from it without the models and the textures)
[/EDIT]

Edited by brett14, 07 October 2009 - 01:25 AM.

  • 1

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#8 Jepie0

Jepie0

    GMC Member

  • GMC Member
  • 213 posts

Posted 07 October 2009 - 01:50 AM

Thankyou Brett14 for continuing hanson's collision dll. I had previously tried hansons version and while it was impressive in concept i found it hard to implement and it tended to by rather unstable at times. Whereas your version is much more simple to implement and use. I am currently using the dll for instant terrain collisions, on a 64x64 terrain consisting of 8192 polys im getting 120fps which is awesome. My previous attempts at doing instant terrain collisions with just pure gml slowed the game down to 4-5fps. So overall congratulations on creating a dll that should become an essential element of any 3d game made with gamemaker.

Wish list:
Possibility of ray casting returning a normal.
(Parent / Child hierarchy), being able to group models in the dll.
So for instance being able to say add 10 boxes to a collision group and then instead of going threw all the objects/models comparing in gm this would be done on the dll side.
The dll then could return a specific id relating to one of the 10 box instances in that group. This would be usefull for knowing which box was hit so u could then change it to a broken box.
Material properties either per face or as above for individual models within a group. Simply being able to set a face or model with a material property of (0-255) would allow for knowing which particle effect to create for a raycast collision.
Rotation of support.
Being able to tell the dll to load a external model (.mod, .obj etc) and use it for collisions.
This would be alot faster than gamemaker having to load a model then break it down and pass on each poly to the dll.
Xygthop3 adapted a script for use with hansons dll to load a .obj into gamemaker that generated a .mod file and collision for the dlll.

The (Parent / Child hierarchy) and material ideas could be done in gamemaker but that would require all model and ray cast comparisons to be done in gamemaker. If i had 10 boxes with different material properties i would have to repeat a raycast 10 times and then via a custom script return the closest box. I think this would be better done inside the dll to further expand the Possibilitys of 3d gamemaker.

Cheers Brett14 keep up the good work, Jepie0
  • 0

#9 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 07 October 2009 - 02:03 AM

Whereas your version is much more simple to implement and use

should become an essential element of any 3d game made with gamemaker.

Thank you.

(Parent / Child hierarchy)

This is a very good idea, however I have not gotten a clue how this would work. If I follow you'd like it so that say we have 3 objects, you can add them all to the dll and it will calculate them for you. So for example we add 3 box objects to the dll, and whenever they move the dll will detect this and update their collision, and when they collid it will auto detect what to do with them. If you have an idea of how to do this please tell me (or send me a link). Please note, I'm not an expert c++ user (However I am an expert gm user). This is only my 2nd time ever using c++... my first was a helloworld program then I didn't come back until this-because I needed fast collisions for a game and modmod was too slow (the reason for that was rotations, that's why they have been ripped out). The only reason it was possible for me to make this is that gml and c++ are very similar.

Being able to tell the dll to load a external model

Currently, At the moment this is my top priority. The first thing I'm trying to do is get models to load in Gamemaker via gml. Once I get this done I'll attempt to convert it over to the dll, to load them through that. I'll have to look at a tutorial or something first though to see how to manage strings and files in c++. Currently you can only load models through your own code/loading type.

[EDIT]
Do you know where a documentated version of the gm model format is? That'd help me make loading models alot easier. Thanks
[/EDIT]
~~Brett14;


[EDIT2]
The next version will contain a "split" model example. This is done purely on the gamemaker side, and can boost speeds massivly. This is done by splitting the collision model into an [X,Y] array of models, then you see which model to collision check against through some simple math. This can reduce the number of polygons becing checked from like 2000 to 10-100. In the experts example I've already done this and I can do 400 raycasts @ 900 fps (capped by gpu, not cpu), whereas without this I'm getting 150-300~
[/EDIT2]

Edited by brett14, 07 October 2009 - 02:12 AM.

  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#10 Jepie0

Jepie0

    GMC Member

  • GMC Member
  • 213 posts

Posted 07 October 2009 - 02:33 AM

What i meant by the (Parent / Child hierarchy) system was being able to add models to the dll but the added models would be assigned a individual id and be assosicated with a group. So when u do a ray cast collision check instead of checking one model id u would be checking a group and all of its models under that group. An easy why to explain it would be via how i imagine the gml would look.

// create event
box_collision_group = p3dc_create_group(); // generates a collision id group

box_col_0 = p3dc_create_group_child(box_collision_group); // dll returns a new id within group
p3dc_add_external_model(box_col_0,"box_metal.obj"); // tells dll to externally load a model and associate it with the child

box_col_1 = p3dc_create_group_child(box_collision_group); // dll returns a new id within group
p3dc_add_external_model(box_col_1,"box_wood.obj"); // tells dll to externally load a model and associate it with the child

box_col_2 = p3dc_create_group_child(box_collision_group); // dll returns a new id within group
p3dc_add_external_model(box_col_2,"box_rock.obj"); // tells dll to externally load a model and associate it with the child

p3dc_group_end(); // ends the group

// draw event when checking for collision
col_dis = p3dc_group_distance_ray_still(box_collision_group,cam_x,cam_y,cam_z,vx,vy,vz); // would check all instances in the group and return the shortest distance
col_id = p3dc_group_id_ray_still(box_collision_group); // returns the last ray collisions found id instead of having to redo a ray cast
col_material = p3dc_group_material_ray_still(box_collision_group); // returns the last ray collisions found material instead of having to redo a ray cast
nx = p3dc_group_normal_ray_still_nx(box_collision_group); // returns the last ray collisions found normal instead of having to redo a ray cast
ny = p3dc_group_normal_ray_still_ny(box_collision_group); // returns the last ray collisions found normal instead of having to redo a ray cast
nz = p3dc_group_normal_ray_still_nz(box_collision_group); // returns the last ray collisions found normal instead of having to redo a ray cast

I'll have alook for the gm model format thing and pm u if i find anything.

Cheers, Jepie0

Edited by Jepie0, 07 October 2009 - 02:37 AM.

  • 0

#11 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 07 October 2009 - 02:46 AM

I'm starting to understand what your asking *I think*. What you want is to create a model group, and when you add a block to the collision group it will be given a unique ID (say the objects id in gm for example). Then when you colid with that group, return the ID of the hit block instead of just 1(true) for a collision or 0(false) for no collision?

Edited by brett14, 07 October 2009 - 02:47 AM.

  • 1

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#12 Jepie0

Jepie0

    GMC Member

  • GMC Member
  • 213 posts

Posted 07 October 2009 - 02:50 AM

Yeah thats pretty much it each model under a group would have a unique id and that would be returned. That would open the door for some awesome 3d games currently all the dll can do is just return a distance that then can be used to find a x,y,z position collision.

Example pic of what im working on using your dll to get instant terrain collisions.
Posted Image

Cheers, Jepie0
  • 0

#13 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 07 October 2009 - 02:56 AM

Yeah thats pretty much it each model under a group would have a unique id and that would be returned. That would open the door for some awesome 3d games currently all the dll can do is just return a distance that then can be used to find a x,y,z position collision.

This can already be done quite fast through gml, however I'll add it to the dll to make it simpler to use (and possible a little faster). I think you'd already know how it would be done (same way as modmod does it, you can look at his example) but I'll try to get this in asap. My priority at the moment goes to loading the collision model though. Then I'll try to add this.


---------------BELOW TO SEE HOW TO SHOOT MULTIPLE OBJECTS, AND SEE WHICH IS CLOSEST---------------
[EDIT]
This is the code I'm using to see if I shot a person, and if I did which one I shoot. (Always is the closest, or the level, or nothing)
dis=p3dc_ray_still(levelcolid,x,y,z,vx,vy,vz);//shoot to see how far it is to the level, Returns 0 if shot into space
hit=noone;//Currently we have shot nobody


with(objh_dummy){
var d;
d=p3dc_ray(global.player_collision,x,y,z-5,other.x,other.y,other.z,other.vx,other.vy,other.
vz);//check to see if there was a collision with this player in the given direction
	if(d<other.dis){//if there was AND it is less than the distance to the level
	other.dis=d;//The distance is now to this player (he's the closest)
	other.hit=id;//We set hit to this objects id, becuase we hit it.
	}
}

if dis==0 exit;//Nothing was hit, he shot into space

//If we didn't hit anybody
if(hit==noone){
//EFFECT
exit;//exit
}
with(hit){
//What to do with the hit object
}
[/EDIT]

Edited by brett14, 07 October 2009 - 03:13 AM.

  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#14 Jepie0

Jepie0

    GMC Member

  • GMC Member
  • 213 posts

Posted 07 October 2009 - 03:23 AM

Thanks for the code brett14, im already well aware of how todo the child/parent and material idea in gml i just think the less work gm has todo the better. I just wanted to avoid having todo a giant with loop to compare the returned dll values. Will u be adding normal support in the next release? code wise it should be fairly easy to implement even in c++.

gml normal code
nx = (yy2-yy1)*(zz3-zz1) - (yy3-yy1)*(zz2-zz1);
		ny = (zz2-zz1)*(xx3-xx1) - (zz3-zz1)*(xx2-xx1);
		nz = (xx2-xx1)*(yy3-yy1) - (xx3-xx1)*(yy2-yy1);
		m = sqrt(nx*nx + ny*ny + nz*nz);
		nx /= m;
		ny /= m;
		nz /= m;

Cheers, Jepie0
  • 0

#15 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 07 October 2009 - 03:33 AM

Thanks for the code brett14, im already well aware of how todo the child/parent and material idea in gml i just think the less work gm has todo the better. I just wanted to avoid having todo a giant with loop to compare the returned dll values. Will u be adding normal support in the next release? code wise it should be fairly easy to implement even in c++.

gml normal code

nx = (yy2-yy1)*(zz3-zz1) - (yy3-yy1)*(zz2-zz1);
		ny = (zz2-zz1)*(xx3-xx1) - (zz3-zz1)*(xx2-xx1);
		nz = (xx2-xx1)*(yy3-yy1) - (xx3-xx1)*(yy2-yy1);
		m = sqrt(nx*nx + ny*ny + nz*nz);
		nx /= m;
		ny /= m;
		nz /= m;

Cheers, Jepie0

I agree that less gm=better, normal code probably won't be in the next release.

-----------EDIT-----------


[EDIT]
Okay Jepie, or anybody else that is interested. I'm just starting to plan how I'd add what you want to the dll. So far I have this idea. However there are a few "problems" with it.


Step #1: (Load/Create the models - Same as it is now)
model=p3dc_model_load("playermodel.d3d");//Load the model, working on

Step #2: Create a group
playergroup=p3dc_group_create();

Step #3: Add the models to the group (that were created in step one)
p3dc_group_add(model1,x,y,z,ID NUMBER);
p3dc_group_add(model2,x,y,z,ID NUMBER);
p3dc_group_add(model3,x,y,z,ID NUMBER);
p3dc_group_add(model3,x,y,z,ID NUMBER);//this one was needed twice

Step #4: Close/Finish making the group (the same model will be allowed in multiple groups with DIFFERENT ID's in each one (or the same)) 0 will be reserved for no collision
p3dc_group_finish();

Step #5: Do a collision check (or ray cast) on the group and return the ID of the hit object defined in step 4. If it returns 0, nothing was hit. If it returns anything else that was the object that was hit.
hit=p3dc_group_check(group ID,Checking Args);//Group ID is returned by step 2


This is basically the layout I have for it right now. However, I have a few problems (for you to answer). How do you want to "update" the group because a player in it moved? Or would you like groups to be collections of non-moving objects with ids? How would you like to see this work?

[/EDIT]

~~Brett14;

Edited by brett14, 07 October 2009 - 04:03 AM.

  • 1

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#16 Jepie0

Jepie0

    GMC Member

  • GMC Member
  • 213 posts

Posted 07 October 2009 - 04:15 AM

Its looking good thats basically the concept i was going for. As for the updating i guess a script would need to be called in the step event of the moving object to update its x,y,z position to the dll. If a object does not update its x,y,z it would just be treated as a static object in the dll. Will there be seperate ray casting scripts to return distance and id?

In the below code will the ID NUMBER have to be manually pre-defiend or is that where the playergroup id goes? because p3dc_group_add should probably return a unique id so it can be passed onto a object for future use.

p3dc_group_add(model1,x,y,z,ID NUMBER);
p3dc_group_add(model2,x,y,z,ID NUMBER);
p3dc_group_add(model3,x,y,z,ID NUMBER);
p3dc_group_add(model3,x,y,z,ID NUMBER);//this one was needed twice

Thanks, Jepie0

Edited by Jepie0, 07 October 2009 - 04:17 AM.

  • 0

#17 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 07 October 2009 - 04:31 AM

There will be two different sets of id's.

Groups Ids and the model id's inside of the groups

for example

-group1, Id 1
---model1, Id 1
---model2, Id 2
---model3, Id 3
-group2, Id 2
---model 1, Id 1
---model 1, Id 2
---model 2, Id 3
---model 2, Id 4

So every group has it's own id returned by p3dc_group_create() and in every group you would place models. To answer your question for short, you will be able to add more than 1 group. If your just checking two models, then we would continue like normal. (Unless raycasting, then we'd check them both)

Will there be seperate ray casting scripts to return distance and id?

What I'm thinking right now is call the raycast script, which will return the id of the hit object, and it will store the distance in a variable. Then you'll call
p3dc_get_dis();
right after that, and it'll return the stored varaible for the distance of the last raycast.



However, updating the positions every step brings in another problem. It would be much slower to call the dll in every object every step than one gml loop to do the shooting collisions. How should we get around this? I'm thinking making the groups, but only use them for things like the level. Using it every step in 10 players would be slow.

Edited by brett14, 07 October 2009 - 04:37 AM.

  • 1

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#18 Jepie0

Jepie0

    GMC Member

  • GMC Member
  • 213 posts

Posted 07 October 2009 - 04:51 AM

Only the moving objects would need there x,y,z positions to be updated. As for possible alternatives i came up with 2 ideas.

The first idea would be to not only do collisions in the dll but also basic movement physics, so the dll would move the objects around with xspeed, yspeed, zspeed and friction then there would be no need for constant updating. But the simulation would have to be identical in both gamemaker and the dll which would be hard.

Idea 2 would be just before doing a ray cast group check running a script that via a with loop updates the groups x,y,z position. The problem here is that if there is a large amount of objects in the group it could lead to a big loop.

Im not sure there is a way around not updating moving objects fairly constantly. But having seperate scripts for defining static and moving models would be good. The level and basic objects grouped in it will more than likely all be static only players and npcs etc would need to have there positions passed onto the dll.

Thanks, Jepie0
  • 1

#19 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 07 October 2009 - 05:05 AM

Number one would just lead to unneeded complication (and It'd be slower)

Think about number two.

Do a gml loop to update the objects and then call the c++ code to check
-or-
we can run a gml loop and check at the same time.

So I'll add groups, they will be able to move, but it'll be faster to do a GM loop. If they are static, use your own loop because it'll be faster than doing a loop to update the objects and then calling a function to check, however the option to update the groups is there. How's that sound?

Edited by brett14, 07 October 2009 - 05:07 AM.

  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#20 Jepie0

Jepie0

    GMC Member

  • GMC Member
  • 213 posts

Posted 07 October 2009 - 05:15 AM

Yep sounds good i was only throwing some ideas around. Leave the position updating to the user to decide when to update individual model positions.

Cheers, jepie0
  • 0

#21 Jepie0

Jepie0

    GMC Member

  • GMC Member
  • 213 posts

Posted 19 October 2009 - 12:56 AM

Iv'e run into a slight problem with your dll. Using the raycasting i get awesome fps doing 20 checks every step and i still get 100fps. The ray casting checks a 8192 poly terrain model. But i recently started doing model compare checks to allow a player character to move around the environment etc. But the fps took a huge hit when doing model compares. I made a simple seperate 3d game with just 30 crates that can move and collide with each other. The fps would drop down to 20-25fps. Would it be a issue with the dll or just a limitation that can't be overcome.

Below is the script i made to check for collisions before moving a crate.
// scr_d3d_model_collision();
// argument0: calling id
// argument1: calling collision id
// argument2: calling x pos
// argument3: calling y pos
// argument4: calling z pos
// argument5: object to check

if (argument5 != -1)
{
	with(argument5)
	{
		if (argument0 != id)
		{
		if (col_id != -1)
		{
			// static collision
			if (col_type = 0)
			{
				if (p3dc_check_still(argument1,argument2,argument3,argument4,col_id) = true)
				{
					argument0.obj_id = id;
					return true;
					exit;
				}
			}
			
			// dynamic collision
			if (col_type = 1)
			{
				if (p3dc_check(argument1,argument2,argument3,argument4,col_id
,x,y,z) = true)
				{
					argument0.obj_id = id;
					return true;
					exit;
				}
			}
		}
		}
	}
}

return false;

// crate step event
// movement
if (scr_d3d_model_collision(id,col_id,x+x_speed,y,z,obj_col_parent) = false)
{
	x += x_speed;
} else x_speed = 0;
		
if (scr_d3d_model_collision(id,col_id,x,y+y_speed,z,obj_col_parent) = false)
{
	y += y_speed;
} else y_speed = 0;

// friction
spd = point_distance(0,0,x_speed,y_speed);
spd_dir = point_direction(0,0,x_speed,y_speed);
	
if (spd > 0)
{
	if ((spd-0.1) > 0) spd -= 0.1; else spd = 0;
	x_speed = lengthdir_x(spd,spd_dir);
	y_speed = lengthdir_y(spd,spd_dir);
}

Thanks, Jepie0
  • 0

#22 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 20 October 2009 - 01:38 AM

I'm not sure if you're doing this or not; but do not collision check the terrain, this can be done with a few raycasts. (Which are much faster; as you've figured out). The problem checking for collisions is that it runs through a loop of every triangle and checks it against every other triangle in the model. So if you're checking one triangle against the 8192 poly one, that's 8192 checks. If you're checking two thats 8192*2, if three thats 8192*3 and so on...

***Add this, it'll increase speeds alot***
***For objects only; does not work for the level***
Only do a collision check if there is a collision on the X,Y axis. This can be done with a circle sprite (equal to the radius of the model) and the collision event (make sure its NOT solid, or you'll have GM reacting to collisions on the X,Y axis). Then in the collision event check for collisions with p3dc (Collision event will not be precise on the X,Y axis and does not take the Z into account, however using it in combination with p3dc can be powerful and will improve speeds)
***********************************

There are also other ways to overcome this (I'm sure there's more, but this is what I'd do).

A: Make the models lower poly (if possible), this will reduce the number of checks needed (a little change on the big models does not effect it as much as little changes on the smaller models; however it all helps)

B: Split your levels/models (collision model) into many smaller ones (X,Y axis only), and collision check against the only needed one. Then create one big models to use for raycasting (contains everything). So for example say you had a 64x64 terrain, split that into a 8x8 array of models, each containing pieces of the large one corresponding to the position on the large one.
Also make it larger (+1,-1) on the sides/top bottom so that the spots will slightly overlap.

model[0,0] contains the height spots [0-8,0-8] for the heights
model[1,0] contains the height spots [7-17,0-8] for the heights
model[2,0] contains the height spots [15-25,0,8] for the heights
model[6,3] contains the height spots [41-51,23-33] for the heights

This does not have to be done by hand, and should be done inside of a loop.

then when checking what model to compare to...
modelcheck=floor(x/SIZEOFTHESQUAES*8);
and collision check against that.

C: Use a couple raycasts and shoot them out of the that each face of the cube is pointing


BTW: I don't plan on adding the groups; I looked at them, and it would be faster to do with GML

Edited by brett14, 20 October 2009 - 01:40 AM.

  • 1

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#23 Jepie0

Jepie0

    GMC Member

  • GMC Member
  • 213 posts

Posted 20 October 2009 - 10:44 AM

Thanks for the tips Brett the box example was just 12 polygon cratesx30 that could move, there was no terrain or floor involved. Using Gm's inbuilt x,y collisions will probably be a good work around. Thats ok about not having groups iv'e already made the scripts i need to work around it. Are u still going to add normal support? otherwise i will have to use Tepi or iccurds script on top of yours.

Thanks, Jepie0
  • 0

#24 DmitriV

DmitriV

    GMC Member

  • GMC Member
  • 11 posts

Posted 20 October 2009 - 09:03 PM

Could you also make an example with simple models. I don't understand it anymore with (map.map) and all the codes form the modmod collision checking. I just want a clear example, a bit to the point... :)

And a last question: what does p3dccolid do?? And how do I make a collision checking code with seperate models? Just add them to one big model like in the Starters example??

Thx, DmitriV
  • 0

#25 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 20 October 2009 - 11:08 PM

p3dc_colid();
checks if there is a collision between two models, both of which can move. So for example this can be used to check if objects have run into each other (example two players).
p3dc_colid_still();
also checks if there is a collision between two models, however in this case only one can move. So for example this can be used to check objects against the level.



I'll try to upload a new example asap.
  • 1

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#26 DmitriV

DmitriV

    GMC Member

  • GMC Member
  • 11 posts

Posted 21 October 2009 - 03:50 PM

No, I mean: What does this:
if(p3dc_check_still(p3dc_collision,tox,toy,z-3,p3dccolid)==1){

Is p3dccolid the whole model?

Where is the whole model defined and added to the collision checking?
In the Starters example its done here:

with(block_0){
p3dc_add_block(x-16,y-16,0,x+16,y+16,32); // <------------ Here it's done -------
d3d_model_block(global.level_model,x-16,y-16,0,x+16,y+16,32,1,1);
instance_destroy();//The object is no longer needed, we destroy it
}

But I can't find that in the experts example...


In my game I've this:
global.fence = d3d_model_create();
global.house = d3d_model_create();
...

d3d_model_load(global.fence,'fence/fence.gmmod');
d3d_model_load(global.house,'objects/house.gmmod');
...

And then:
d3d_model_draw(global.fence,x,y,0,background_get_texture(tx_fence));

How do I add that to my collision checking

Edited by DmitriV, 21 October 2009 - 03:57 PM.

  • 0

#27 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 24 October 2009 - 05:55 AM

Okay sorry about the delayed reply;


Re-download the new version and look at example 2. It will show you how to do everything you'll need. In the create event it will show you how to add game maker .d3d models to your collision model.


Example 1 shows you how to set p3dc up, and use GM primitives.
Example 3 is just like the old experts example, however faster.

But I can't find that in the experts example

In the old example it was done through a bunch of complex scripts to load the model from a custom format... sorry about that; I should have made an in between example sooner.

[EDIT]
if(p3dc_check_still(p3dc_collision,tox,toy,z-3,p3dccolid)==1){
yeah, that has been cleared up (I have used better names in the new version). Anyways p3dc_collision is the player model (a block, all we need) and p3dccolid was the level model.
[/EDIT]

[EDIT2]

Are u still going to add normal support

Most likely not; I don't know how this would work (even with you're help and code)
~Sorry ^_^ ...
[/EDIT2]

Edited by brett14, 24 October 2009 - 07:21 AM.

  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#28 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 26 October 2009 - 01:13 AM

Ellipsoid support

As stated in the first post the only reason this is not included is I can't find an ellipsoid script that produces the exact same result as gamemakers does (I made one before, but i lost it when i reformatted my computer)

Rotations

Possibly coming soon; however I have other priorities at the moment.

A nice logo

Don't have photoshop, the only image minipulation program I have is MS paint... I'll try to get something though.



I'll make an example like that. I'll also make one for shooting multiple objects.



PS: Everything is handled in one object because it is faster
~~Brett14;
  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#29 hanson

hanson

    GMC Member

  • GMC Member
  • 444 posts
  • Version:GM8

Posted 26 October 2009 - 02:17 AM

Just a suggestion: Paint.NET is amazing for the price (free).
For the ellipsoid, it may be nice to have a mathematically "perfect" check as well. That would be easier that generating a model, but would also obviously not match a very low-poly gm ellipsoid.

Edited by hanson, 26 October 2009 - 03:28 AM.

  • 0

#30 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 26 October 2009 - 02:59 AM

@hanson.
I'll look into Pain.NET (or did you mean paint.net?)


I've actually already added a perfect ellipsoid check (comparing distance between the two points to the radius of the model and ellipsoid); however it is not in this version. I added it about 2 hours after I uploaded it. Thanks for the suggestion though.

[EDIT]
I think you meant paint.net (that's what I'm getting right now). Thanks
[/EDIT]


~Brett14;

Edited by brett14, 26 October 2009 - 03:02 AM.

  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#31 hanson

hanson

    GMC Member

  • GMC Member
  • 444 posts
  • Version:GM8

Posted 26 October 2009 - 03:47 AM

Yes, I meant paint.net - sorry 'bout that

keep up the good work!
-hanson
  • 0

#32 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 27 October 2009 - 03:35 AM

Might be at the end of this week though (or even the start of next week), I'm swamped with school, sports, homework, and activities throughout the week. And my weekend is all taken up with Halloween, Paintball, Soccer etc. Not much free time lately, and I'm also working on a few projects so I'll try and get a new version and example up ASAP, however like said before it might be about a week (or a little longer).

Sorry 'bout that...
~~Brett14;

Edited by brett14, 27 October 2009 - 03:36 AM.

  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#33 oiioii

oiioii

    GMC Member

  • New Member
  • 50 posts

Posted 18 November 2009 - 11:23 PM

EXELENT improvement of the DLL
Thanks!!! The speed gets a waaay better!!! :)
Using in my game with HXS2007
  • 0

#34 RamboFox

RamboFox

    Tainted Fortune

  • New Member
  • 992 posts

Posted 22 November 2009 - 03:51 AM

This dll runs so much faster than ModMod - it's helping me heaps!

Just one thing; Is it possible to return a raycasted model's ID, and it's parent instance? (I would like to know whether, for example: My bullet hit the terrain, or an enemy character instead)
  • 0

#35 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 22 November 2009 - 10:00 PM

Yes, it is possible. Below is a [template] of how this would work. It may look like a lot, but most of it is comments, so it is actually quite simple. Use two variables, one to store the id of the hit object, and another to store the distance to it. These are the variables dis and hit.


dis=p3dc_ray_still(levelcolid,x,y,z,vx,vy,vz);//shoot to see how far it is to the level, Returns 0 if shot into space
hit=noone;//Currently we have shot nobody -> This will remain noone if nobody was shot.

//hit an enemy
with(obj_enemy){
var d;
d=p3dc_ray(global.bot_collision,x,y,z-5,other.x,other.y,other.z,other.vx,other.vy,other.
vz);//check to see if there was a collision with this player in the given direction
	if(d<other.dis){//if there was a collision AND it was less than the distance to the level
	other.dis=d;//The distance is now to this player (he's the closest)
	other.hit=id;//We set hit to this objects id, becuase we hit it.
	}
}
//hit an ally
with(obj_ally){
var d;
d=p3dc_ray(global.bot_collision,x,y,z-5,other.x,other.y,other.z,other.vx,other.vy,other.
vz);//check to see if there was a collision with this player in the given direction
	if(d<other.dis){//if there was a collision AND it was less than the distance to the level
	other.dis=d;//The distance is now to this player (he's the closest)
	other.hit=id;//We set hit to this objects id, becuase we hit it.
	}
}
//Repeat the above code for every object that you want to be able to be shot, or just make a parent and detect against it.

//************************************//
//****BELOW IS THE REACTION, ABOVE IS THE DETECTION****//
//************************************//


if dis==0 exit;//Nothing was hit, he shot into space

//We hit the level, do whatever
if(hit==noone){
//EFFECT
exit;//exit --> Needed, so it doesn't continue down to the code below
}

//We hit an object
with(hit){
//What to do with the hit object, for example kill it
instance_destroy();//<--Change this
}

Hope that helps you
~~Brett14;


[REASON FOR EDIT]
Adding more comments to the code, fixing it's format
[/EDIT]

Edited by brett14, 22 November 2009 - 10:05 PM.

  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#36 MasterOfKings

MasterOfKings

    The True Master

  • GMC Member
  • 4888 posts
  • Version:GM8

Posted 25 January 2010 - 09:28 AM

This is a quick 3D collision dll. I'm very impressed! :medieval:
I do have a slight issue though.
I used this to make my first 3D First person shooter, and I used to get a solid 60/60 FPS.
But my project has moved to GM8, not GM7. And now I only get a maximum of 54/60 FPS.

Any ideas why?
Or maybe fixes to the dll?

-MoK
  • 0

Did I help you? If so, help me by pressing the + button above here.


bannersyd.png

banner22z.png


#37 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 25 January 2010 - 07:31 PM

This is a quick 3D collision dll. I'm very impressed! :medieval:
I do have a slight issue though.
I used this to make my first 3D First person shooter, and I used to get a solid 60/60 FPS.
But my project has moved to GM8, not GM7. And now I only get a maximum of 54/60 FPS.

Any ideas why?
Or maybe fixes to the dll?

-MoK

Honestly, I don't think this would be a problem with my dll, but with your programming in GM8. <-- Guess?
Anyways I [might] come out with an update soon, however chances are minimal. (Unless I get any suggestions which would be worth adding)
  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#38 MasterOfKings

MasterOfKings

    The True Master

  • GMC Member
  • 4888 posts
  • Version:GM8

Posted 26 January 2010 - 08:30 AM

Hm.. I just tried your examples with the dll, and found that it isn't the dll.
But the only problem it has is the difference in syntax (only two problems anyway).
I don't get why my game's performance has gone down :).

Anyway, now I see it is a good dll. Great job! ;)

-MoK
  • 1

Did I help you? If so, help me by pressing the + button above here.


bannersyd.png

banner22z.png


#39 jackbbod2

jackbbod2

    GMC Member

  • New Member
  • 4 posts

Posted 07 February 2010 - 09:56 AM

im having a problem with my guy going up ramps. do you know anny ways to fixing this problem?
another thing what program did you use for the models

Edited by jackbbod2, 07 February 2010 - 10:07 AM.

  • 0

#40 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 07 February 2010 - 10:10 PM

im having a problem with my guy going up ramps. do you know anny ways to fixing this problem?
another thing what program did you use for the models

Sorry, I can't help you without code.

For the model, I used a model maker that I made, it's not public. It actually supports multiple textures etc., but I just applied one so that the file size didn't get overly large.

Edited by brett14, 07 February 2010 - 10:11 PM.

  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#41 DmitriV

DmitriV

    GMC Member

  • GMC Member
  • 11 posts

Posted 12 February 2010 - 07:03 PM

Sorry, maybe it's a dumb question, but how do you export a model to .d3d of .map

I use 3ds max and I can export models to .3ds, .obj but not d3d and .map
And why is map_core.map just 2kb ??

Edit:

For the model, I used a model maker that I made, it's not public. It actually supports multiple textures etc., but I just applied one so that the file size didn't get overly large.

Oh and you could you please tell me how I can use multple textures and (advanced) uvmapping. Because when I want to create a complicate house a UV map won't help...

Edit:
Oh, and do you know a faster example of this. I mean something like this could be very helpfull with bullets, but your pointer in your example is maybe a bit too complicated but faster...
http://gmc.yoyogames...howtopic=366771

Edited by DmitriV, 12 February 2010 - 10:25 PM.

  • 0

#42 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 13 February 2010 - 12:01 AM

Sorry, maybe it's a dumb question, but how do you export a model to .d3d of .map

You can't. As stated before it is a custom model format that I had made (smaller and multitextured and faster collisions)

And why is map_core.map just 2kb ??

It's my custom model format, it's not public.

---------------------------------------------------------
Look at example 2, not 3. Three is for users who want to make collisions faster (however, it is much harder and requires a lot of effort on your part, or a custom model format). All you need is a .d3d model to load the model into collisions (it loads map_model.d3d) in example 2.


PS: People seem to be interested in how I made the map. I'm in the middle of making a map/dungeon maker (produces maps like the one in here) that are multitextured, and work easily with p3dc. I've modified P3DC.dll to work with it, however neither is released yet. I'm hoping to get a first beta out soon.

Edited by brett14, 13 February 2010 - 12:02 AM.

  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#43 DmitriV

DmitriV

    GMC Member

  • GMC Member
  • 11 posts

Posted 13 February 2010 - 12:38 PM

Sorry, It was a dumb question. I can make d3d files (Marzipan and Model Creator). I forgot about that... :P

Will it support .3ds files in the future? I mean that would be great in combination with Ultimate3D! :lol:
I can't live with the speed of Game Maker :D , so I think I will do U3D the renderings...

Edited by DmitriV, 13 February 2010 - 12:44 PM.

  • 0

#44 MasterOfKings

MasterOfKings

    The True Master

  • GMC Member
  • 4888 posts
  • Version:GM8

Posted 20 February 2010 - 08:20 AM

No offense, but why are you using P3DC while using U3D? U3D has it's own built-in collision system.

-MoK
  • 0

Did I help you? If so, help me by pressing the + button above here.


bannersyd.png

banner22z.png


#45 Drokokieo

Drokokieo

    GMC Member

  • GMC Member
  • 63 posts
  • Version:Unknown

Posted 26 February 2010 - 12:50 AM

http://www.box.net/shared/cdlyxi9b27

^
Testing a alternate model map.

Yeah, the collisions on this map is WAY off and doesn't seem to work correctly. Any suggestions?

NOTES:
I have edited the file. Open it on that. (Gm8. Sorry, I can't open up Game Maker 7 for some reason...)

Off Topic: Why do I see all of the posts in a list like way? I have to click them to see them. >_> Annoying.

Edited by Drokokieo, 26 February 2010 - 12:51 AM.

  • 0

#46 brett14

brett14

    GMC Member

  • GMC Member
  • 1151 posts
  • Version:GM8

Posted 27 February 2010 - 05:22 AM

Okay, three suggestions (one answer, two suggestions)


Suggestion 1) I fixed the collisions, the reason was it happened was one of those stupid errors we all make (Well, two this time).

in the create event under the //Create a player collision model comment replace the three lines of code with this.
player_colid=p3dc_begin_model();
p3dc_add_block(-14,-14,-25,14,14,-20);
p3dc_end_model();
That will correctly define the collision model you wanted. You have to scale the size of you're collision model to fit in with the size of your map. In my example the map was only about 800x800 in size, where yours goes up into the 8000's


In the step event under if(p3dc_check_still(... replace the whole thing with this
if(p3dc_check_still(player_colid,tox,toy,z,level_colid)==1){
	if(p3dc_check_still(player_colid,x+lengthdir_x(0.2,tdir),y,z,level_colid)==0){
	x+=lengthdir_x(0.2,tdir);
	}
	if(p3dc_check_still(player_colid,x,y+lengthdir_y(0.2,tdir),z,level_colid)==0){
	y+=lengthdir_y(0.2,tdir);
	}
}else{
x=tox;
y=toy;
}
Your problem here was you were checking for a collision 25z positions under where you already were, remove that -3-25 and it was fixed.


Suggestion 2)
Use this as the move code (although not required)
//MOVE
if(keyboard_check(vk_left) or keyboard_check(ord('A'))){
x+=lengthdir_x(3.5*(keyboard_check(vk_shift)+1),direction+90);
y+=lengthdir_y(3.5*(keyboard_check(vk_shift)+1),direction+90);
}
if(keyboard_check(vk_right) or keyboard_check(ord('D'))){
x+=lengthdir_x(3.5*(keyboard_check(vk_shift)+1),direction-90);
y+=lengthdir_y(3.5*(keyboard_check(vk_shift)+1),direction-90);
}
if(keyboard_check(vk_up) or keyboard_check(ord('W')) or mouse_check_button(mb_right)){
x+=lengthdir_x(3.5*(keyboard_check(vk_shift)+1),direction);
y+=lengthdir_y(3.5*(keyboard_check(vk_shift)+1),direction);
//speed=3.5
}
if(keyboard_check(vk_down) or keyboard_check(ord('S'))){
x+=lengthdir_x(3.5*(keyboard_check(vk_shift)+1),direction-180);
y+=lengthdir_y(3.5*(keyboard_check(vk_shift)+1),direction-180);
}

Suggestion 3)
Remove the unneeded polygons from your map, you're using blocks for everything including walls, so you only see 2/12 of the polygons on the cube. If you removed them You would get massive speed improvments (probably up to about 3-4x faster). I'm only getting 23 fps while running your map, and I get up to 230 running mine and there isn't a huge difference in visible polygons - because I removed unseen ones.

Edited by brett14, 27 February 2010 - 05:23 AM.

  • 0

P3DC V6.00 | Editor14 | Large 3D Terrain

GML programmer since 2005, C/C++ programmer since 2009, Java programmer since 2012


#47 Drokokieo

Drokokieo

    GMC Member

  • GMC Member
  • 63 posts
  • Version:Unknown

Posted 27 February 2010 - 03:44 PM

Thanks. I really needed that.

I guess I have to explain about the map model as well...

CODE FROM REAL GAME: obj_camera - Alarm 0 Event - Works - Speed = efficient.
[codebox]p3dc_clear_model(level_colid);
//Create a player collision model
player_colid=p3dc_begin_model();
p3dc_add_block(-16,-16,z,+16,+16,z+48);
p3dc_end_model();


//Reset all variables that add collision models...
obj_camera.fct=0
obj_camera.rct=0
obj_camera.bct=0
obj_camera.hfct=0

//Begin Model making and add floors, walls, ramps, etc. to the map collision model.
level_colid=p3dc_begin_model();
with (marker_floor)
{
obj_camera.floorcollisionsx[obj_camera.fct]=x
obj_camera.floorcollisionsy[obj_camera.fct]=y
obj_camera.floorcollisionsz[obj_camera.fct]=z
obj_camera.fct+=1
}
for (o=0; o<obj_camera.fct; o+=1)
{
p3dc_add_block(obj_camera.floorcollisionsx[o]-32,obj_camera.floorcollisionsy[o]-32,obj_camera.floorcollisionsz[o]-1,obj_camera.floorcollisionsx[o]+32,obj_camera.flo
orcollisionsy[o]+32,obj_camera.floorcollisionsz[o])
}
with (marker_block)
{
obj_camera.blockcollisionsx[obj_camera.bct]=x
obj_camera.blockcollisionsy[obj_camera.bct]=y
obj_camera.blockcollisionsz[obj_camera.bct]=z
obj_camera.blockcollisionsrot[obj_camera.bct]=dire
ction
obj_camera.bct+=1
}
for (o=0; o<obj_camera.bct; o+=1)
{
if blockcollisionsrot[o]=0 or blockcollisionsrot[o]=180
{
p3dc_add_wall(obj_camera.blockcollisionsx[o]-32,obj_camera.blockcollisionsy[o],obj_camera.block
collisionsz[o],obj_camera.blockcollisionsx[o]+32,ob
j_camera.blockcollisionsy[o],obj_camera.blockcollis
ionsz[o]+64)
}
else
if blockcollisionsrot[o]=90 or blockcollisionsrot[o]=270
{
p3dc_add_wall(obj_camera.blockcollisionsx[o],obj_c
amera.blockcollisionsy[o]-32,obj_camera.blockcollisionsz[o],obj_camera.block
collisionsx[o],obj_camera.blockcollisionsy[o]+32,ob
j_camera.blockcollisionsz[o]+64)
}
else
if blockcollisionsrot[o]=45 or blockcollisionsrot[o]=225
{
p3dc_add_wall(obj_camera.blockcollisionsx[o]-32,obj_camera.blockcollisionsy[o]-32,obj_camera.blockcollisionsz[o],obj_camera.block
collisionsx[o]+32,obj_camera.blockcollisionsy[o]+32
,obj_camera.blockcollisionsz[o]+64)
}
else
if blockcollisionsrot[o]=135 or blockcollisionsrot[o]=315
{
p3dc_add_wall(obj_camera.blockcollisionsx[o]+32,ob
j_camera.blockcollisionsy[o]-32,obj_camera.blockcollisionsz[o],obj_camera.block
collisionsx[o]-32,obj_camera.blockcollisionsy[o]+32,obj_camera.bl
ockcollisionsz[o]+64)
}
else
{
p3dc_add_block(obj_camera.blockcollisionsx[o]-32,obj_camera.blockcollisionsy[o]-32,obj_camera.blockcollisionsz[o],obj_camera.block
collisionsx[o]+32,obj_camera.blockcollisionsy[o]+32
,obj_camera.blockcollisionsz[o]+64)
}
}

with (marker_half_floor)
{
obj_camera.hfloorcollisionsx[obj_camera.hfct]=x
obj_camera.hfloorcollisionsy[obj_camera.hfct]=y
obj_camera.hfloorcollisionsz[obj_camera.hfct]=z
obj_camera.hfloorcollisionsrot[obj_camera.hfct]=di
rection
obj_camera.hfct+=1
}
for (o=0; o<obj_camera.hfct; o+=1)
{
if hfloorcollisionsrot[o]=0
{
p3dc_add_triangle(obj_camera.hfloorcollisionsx[o]-32,obj_camera.hfloorcollisionsy[o]-32,obj_camera.hfloorcollisionsz[o],
obj_camera.hfloorcollisionsx[o]+32,obj_camera.hflo
orcollisionsy[o]-32,obj_camera.hfloorcollisionsz[o],
obj_camera.hfloorcollisionsx[o]+32,obj_camera.hflo
orcollisionsy[o]+32,obj_camera.hfloorcollisionsz[o]
)
//d3d_vertex_normal_texture(x-32,y-32,z,x-32,y-32,z,0,0)
//d3d_vertex_normal_texture(x+32,y-32,z,x+32,y-32,z,0,1)
//d3d_vertex_normal_texture(x+32,y+32,z,x+32,y+32,z,
1,1)
}
else
if hfloorcollisionsrot[o]=90
{
p3dc_add_triangle(obj_camera.hfloorcollisionsx[o]-32,obj_camera.hfloorcollisionsy[o]-32,obj_camera.hfloorcollisionsz[o],
obj_camera.hfloorcollisionsx[o]-32,obj_camera.hfloorcollisionsy[o]+32,obj_camera.h
floorcollisionsz[o],
obj_camera.hfloorcollisionsx[o]+32,obj_camera.hflo
orcollisionsy[o]-32,obj_camera.hfloorcollisionsz[o])
//d3d_vertex_normal_texture(x-32,y-32,z,x-32,y-32,z,0,0)
//d3d_vertex_normal_texture(x-32,y+32,z,x-32,y+32,z,1,0)
//d3d_vertex_normal_texture(x+32,y-32,z,x+32,y-32,z,0,1)
}
else
if hfloorcollisionsrot[o]=180
{
p3dc_add_triangle(obj_camera.hfloorcollisionsx[o]-32,obj_camera.hfloorcollisionsy[o]-32,obj_camera.hfloorcollisionsz[o],
obj_camera.hfloorcollisionsx[o]-32,obj_camera.hfloorcollisionsy[o]+32,obj_camera.h
floorcollisionsz[o],
obj_camera.hfloorcollisionsx[o]+32,obj_camera.hflo
orcollisionsy[o]+32,obj_camera.hfloorcollisionsz[o]
)
//d3d_vertex_normal_texture(x-32,y-32,z,x-32,y-32,z,0,0)
//d3d_vertex_normal_texture(x-32,y+32,z,x-32,y+32,z,1,0)
//d3d_vertex_normal_texture(x+32,y+32,z,x+32,y+32,z,
1,1)
}
else
if hfloorcollisionsrot[o]=270
{
p3dc_add_triangle(obj_camera.hfloorcollisionsx[o]-32,obj_camera.hfloorcollisionsy[o]+32,obj_camera.h
floorcollisionsz[o],
obj_camera.hfloorcollisionsx[o]+32,obj_camera.hflo
orcollisionsy[o]-32,obj_camera.hfloorcollisionsz[o],
obj_camera.hfloorcollisionsx[o]+32,obj_camera.hflo
orcollisionsy[o]+32,obj_camera.hfloorcollisionsz[o]
)
//d3d_vertex_normal_texture(x-32,y+32,z,x-32,y+32,z,1,0)
//d3d_vertex_normal_texture(x+32,y-32,z,x+32,y-32,z,0,1)
//d3d_vertex_normal_texture(x+32,y+32,z,x+32,y+32,z,
1,1)
}
else
{
p3dc_add_block(obj_camera.blockcollisionsx[o]-32,obj_camera.blockcollisionsy[o]-32,obj_camera.blockcollisionsz[o],obj_camera.block
collisionsx[o]+32,obj_camera.blockcollisionsy[o]+32
,obj_camera.blockcollisionsz[o]+64)
}

}
with (marker_ramp) //Now for the complicated S**T.
{
obj_camera.rampcollisionsx[obj_camera.rct]=x
obj_camera.rampcollisionsy[obj_camera.rct]=y
obj_camera.rampcollisionsz[obj_camera.rct]=z
obj_camera.rampcollisionsrot[obj_camera.rct]=direc
tion
obj_camera.rct+=1
}

with (obj_ramp_parent_x) //Now for the complicated S**T.
{
obj_camera.rampcollisionsx[obj_camera.rct]=x
obj_camera.rampcollisionsy[obj_camera.rct]=y
obj_camera.rampcollisionsz[obj_camera.rct]=z
obj_camera.rampcollisionsrot[obj_camera.rct]=direc
tion
obj_camera.rct+=1
}

with (obj_ramp_parent_y) //Now for the complicated S**T.
{
obj_camera.rampcollisionsx[obj_camera.rct]=x
obj_camera.rampcollisionsy[obj_camera.rct]=y
obj_camera.rampcollisionsz[obj_camera.rct]=z
obj_camera.rampcollisionsrot[obj_camera.rct]=direc
tion
obj_camera.rct+=1
}

for (o=0; o<obj_camera.rct; o+=1)
{
if rampcollisionsrot[o]=0
{
p3dc_add_floor(obj_camera.rampcollisionsx[o]-128,obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],obj_camera.rampco
llisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_c
amera.rampcollisionsz[o]+32)
p3dc_add_floor(obj_camera.rampcollisionsx[o]-128,obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],obj_camera.rampco
llisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_c
amera.rampcollisionsz[o])
p3dc_add_wall(obj_camera.rampcollisionsx[o],obj_ca
mera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],obj_camera.rampco
llisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_c
amera.rampcollisionsz[o]+32)


p3dc_add_triangle(obj_camera.rampcollisionsx[o],ob
j_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],
obj_camera.rampcollisionsx[o]-128,obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],
obj_camera.rampcollisionsx[o],obj_camera.rampcolli
sionsy[o]-32,obj_camera.rampcollisionsz[o]+32)

p3dc_add_triangle(obj_camera.rampcollisionsx[o],ob
j_camera.rampcollisionsy[o]+32,obj_camera.rampcolli
sionsz[o],
obj_camera.rampcollisionsx[o]-128,obj_camera.rampcollisionsy[o]+32,obj_camera.ra
mpcollisionsz[o],
obj_camera.rampcollisionsx[o],obj_camera.rampcolli
sionsy[o]+32,obj_camera.rampcollisionsz[o]+32)
}
else
if rampcollisionsrot[o]=90
{
p3dc_add_triangle(obj_camera.rampcollisionsx[o]-32,obj_camera.rampcollisionsy[o]+128,obj_camera.ra
mpcollisionsz[o],
obj_camera.rampcollisionsx[o]+32,obj_camera.rampco
llisionsy[o],obj_camera.rampcollisionsz[o]+32,
obj_camera.rampcollisionsx[o]-32,obj_camera.rampcollisionsy[o],obj_camera.rampco
llisionsz[o]+32)
p3dc_add_triangle(obj_camera.rampcollisionsx[o]-32,obj_camera.rampcollisionsy[o]+128,obj_camera.ra
mpcollisionsz[o],
obj_camera.rampcollisionsx[o]+32,obj_camera.rampco
llisionsy[o]+128,obj_camera.rampcollisionsz[o],
obj_camera.rampcollisionsx[o]+32,obj_camera.rampco
llisionsy[o],obj_camera.rampcollisionsz[o]+32)

p3dc_add_floor(obj_camera.rampcollisionsx[o]-32,obj_camera.rampcollisionsy[o]+128,obj_camera.ra
mpcollisionsz[o],obj_camera.rampcollisionsx[o],obj_
camera.rampcollisionsy[o]+32,obj_camera.rampcollisi
onsz[o])
p3dc_add_wall(obj_camera.rampcollisionsx[o]-32,obj_camera.rampcollisionsy[o],obj_camera.rampco
llisionsz[o],obj_camera.rampcollisionsx[o]+32,obj_c
amera.rampcollisionsy[o],obj_camera.rampcollisionsz
[o]+32)

p3dc_add_triangle(obj_camera.rampcollisionsx[o]-32,obj_camera.rampcollisionsy[o],obj_camera.rampco
llisionsz[o],
obj_camera.rampcollisionsx[o]-32,obj_camera.rampcollisionsy[o]+128,obj_camera.ra
mpcollisionsz[o],
obj_camera.rampcollisionsx[o]-32,obj_camera.rampcollisionsy[o],obj_camera.rampco
llisionsz[o]+32)

p3dc_add_triangle(obj_camera.rampcollisionsx[o]+32
,obj_camera.rampcollisionsy[o],obj_camera.rampcolli
sionsz[o],
obj_camera.rampcollisionsx[o]+32,obj_camera.rampco
llisionsy[o]+128,obj_camera.rampcollisionsz[o],
obj_camera.rampcollisionsx[o]+32,obj_camera.rampco
llisionsy[o],obj_camera.rampcollisionsz[o]+32)
}
else
if rampcollisionsrot[o]=270
{
p3dc_add_triangle(obj_camera.rampcollisionsx[o]-32,obj_camera.rampcollisionsy[o]-128,obj_camera.rampcollisionsz[o],
obj_camera.rampcollisionsx[o]+32,obj_camera.rampco
llisionsy[o],obj_camera.rampcollisionsz[o]+32,
obj_camera.rampcollisionsx[o]-32,obj_camera.rampcollisionsy[o],obj_camera.rampco
llisionsz[o]+32)
p3dc_add_triangle(obj_camera.rampcollisionsx[o]-32,obj_camera.rampcollisionsy[o]-128,obj_camera.rampcollisionsz[o],
obj_camera.rampcollisionsx[o]+32,obj_camera.rampco
llisionsy[o]-128,obj_camera.rampcollisionsz[o],
obj_camera.rampcollisionsx[o]+32,obj_camera.rampco
llisionsy[o],obj_camera.rampcollisionsz[o]+32)

p3dc_add_floor(obj_camera.rampcollisionsx[o]-32,obj_camera.rampcollisionsy[o]-128,obj_camera.rampcollisionsz[o],obj_camera.rampc
ollisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_
camera.rampcollisionsz[o])
p3dc_add_wall(obj_camera.rampcollisionsx[o]-32,obj_camera.rampcollisionsy[o],obj_camera.rampco
llisionsz[o],obj_camera.rampcollisionsx[o]+32,obj_c
amera.rampcollisionsy[o],obj_camera.rampcollisionsz
[o]+32)

p3dc_add_triangle(obj_camera.rampcollisionsx[o]-32,obj_camera.rampcollisionsy[o],obj_camera.rampco
llisionsz[o],
obj_camera.rampcollisionsx[o]-32,obj_camera.rampcollisionsy[o]-128,obj_camera.rampcollisionsz[o],
obj_camera.rampcollisionsx[o]-32,obj_camera.rampcollisionsy[o],obj_camera.rampco
llisionsz[o]+32)

p3dc_add_triangle(obj_camera.rampcollisionsx[o]+32
,obj_camera.rampcollisionsy[o],obj_camera.rampcolli
sionsz[o],
obj_camera.rampcollisionsx[o]+32,obj_camera.rampco
llisionsy[o]-128,obj_camera.rampcollisionsz[o],
obj_camera.rampcollisionsx[o]+32,obj_camera.rampco
llisionsy[o],obj_camera.rampcollisionsz[o]+32)
}
else
if rampcollisionsrot[o]=180
{
p3dc_add_floor(obj_camera.rampcollisionsx[o]+128,o
bj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],obj_camera.rampco
llisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_c
amera.rampcollisionsz[o]+32)
p3dc_add_floor(obj_camera.rampcollisionsx[o]+128,o
bj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],obj_camera.rampco
llisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_c
amera.rampcollisionsz[o])
p3dc_add_wall(obj_camera.rampcollisionsx[o],obj_ca
mera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],obj_camera.rampco
llisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_c
amera.rampcollisionsz[o]+32)


p3dc_add_triangle(obj_camera.rampcollisionsx[o],ob
j_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],
obj_camera.rampcollisionsx[o]+128,obj_camera.rampc
ollisionsy[o]-32,obj_camera.rampcollisionsz[o],
obj_camera.rampcollisionsx[o],obj_camera.rampcolli
sionsy[o]-32,obj_camera.rampcollisionsz[o]+32)

p3dc_add_triangle(obj_camera.rampcollisionsx[o],ob
j_camera.rampcollisionsy[o]+32,obj_camera.rampcolli
sionsz[o],
obj_camera.rampcollisionsx[o]+128,obj_camera.rampc
ollisionsy[o]+32,obj_camera.rampcollisionsz[o],
obj_camera.rampcollisionsx[o],obj_camera.rampcolli
sionsy[o]+32,obj_camera.rampcollisionsz[o]+32)
}
else
{
p3dc_add_floor(obj_camera.rampcollisionsx[o]-128,obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],obj_camera.rampco
llisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_c
amera.rampcollisionsz[o]+32)
p3dc_add_floor(obj_camera.rampcollisionsx[o]-128,obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],obj_camera.rampco
llisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_c
amera.rampcollisionsz[o])
p3dc_add_wall(obj_camera.rampcollisionsx[o],obj_ca
mera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],obj_camera.rampco
llisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_c
amera.rampcollisionsz[o]+32)


p3dc_add_triangle(obj_camera.rampcollisionsx[o],ob
j_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],
obj_camera.rampcollisionsx[o]-128,obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],
obj_camera.rampcollisionsx[o],obj_camera.rampcolli
sionsy[o]-32,obj_camera.rampcollisionsz[o]+32)

p3dc_add_triangle(obj_camera.rampcollisionsx[o],ob
j_camera.rampcollisionsy[o]+32,obj_camera.rampcolli
sionsz[o],
obj_camera.rampcollisionsx[o]-128,obj_camera.rampcollisionsy[o]+32,obj_camera.ra
mpcollisionsz[o],
obj_camera.rampcollisionsx[o],obj_camera.rampcolli
sionsy[o]+32,obj_camera.rampcollisionsz[o]+32)
}
}

p3dc_end_model();

if global.shadows_and_other_effects=1
{
//When this is turned on, Ultimate 3D will enable it's special effects while GM Newton will add realistic physics.
//This will boost preformance and boost popularity of the game dearly.

//First make model...
d3d_model_destroy(global.level_model)
global.level_model=d3d_model_create()
for (o=0; o<obj_camera.fct; o+=1)
{
d3d_model_block(global.level_model,obj_camera.floo
rcollisionsx[o]-32,obj_camera.floorcollisionsy[o]-32,obj_camera.floorcollisionsz[o]-1,obj_camera.floorcollisionsx[o]+32,obj_camera.flo
orcollisionsy[o]+32,obj_camera.floorcollisionsz[o],
1,1)
}

for (o=0; o<obj_camera.bct; o+=1)
{
if blockcollisionsrot[o]=0 or blockcollisionsrot[o]=180
{
d3d_model_wall(global.level_model,obj_camera.block
collisionsx[o]-32,obj_camera.blockcollisionsy[o],obj_camera.block
collisionsz[o],obj_camera.blockcollisionsx[o]+32,ob
j_camera.blockcollisionsy[o],obj_camera.blockcollis
ionsz[o]+64,1,1)
}
else
if blockcollisionsrot[o]=90 or blockcollisionsrot[o]=270
{
d3d_model_wall(global.level_model,obj_camera.block
collisionsx[o],obj_camera.blockcollisionsy[o]-32,obj_camera.blockcollisionsz[o],obj_camera.block
collisionsx[o],obj_camera.blockcollisionsy[o]+32,ob
j_camera.blockcollisionsz[o]+64,1,1)
}
else
if blockcollisionsrot[o]=45 or blockcollisionsrot[o]=225
{
d3d_model_wall(global.level_model,obj_camera.block
collisionsx[o]-32,obj_camera.blockcollisionsy[o]-32,obj_camera.blockcollisionsz[o],obj_camera.block
collisionsx[o]+32,obj_camera.blockcollisionsy[o]+32
,obj_camera.blockcollisionsz[o]+64,1,1)
}
else
if blockcollisionsrot[o]=135 or blockcollisionsrot[o]=315
{
d3d_model_wall(global.level_model,obj_camera.block
collisionsx[o]+32,obj_camera.blockcollisionsy[o]-32,obj_camera.blockcollisionsz[o],obj_camera.block
collisionsx[o]-32,obj_camera.blockcollisionsy[o]+32,obj_camera.bl
ockcollisionsz[o]+64,1,1)
}
else
{
d3d_model_block(global.level_model,obj_camera.bloc
kcollisionsx[o]-32,obj_camera.blockcollisionsy[o]-32,obj_camera.blockcollisionsz[o],obj_camera.block
collisionsx[o]+32,obj_camera.blockcollisionsy[o]+32
,obj_camera.blockcollisionsz[o]+64,1,1)
}
}

for (o=0; o<obj_camera.hfct; o+=1)
{
if hfloorcollisionsrot[o]=0
{
d3d_model_primitive_begin(global.level_model,pr_tr
ianglefan)
d3d_model_vertex(global.level_model,obj_camera.hfl
oorcollisionsx[o]-32,obj_camera.hfloorcollisionsy[o]-32,obj_camera.hfloorcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.hfl
oorcollisionsx[o]+32,obj_camera.hfloorcollisionsy[o
]-32,obj_camera.hfloorcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.hfl
oorcollisionsx[o]+32,obj_camera.hfloorcollisionsy[o
]+32,obj_camera.hfloorcollisionsz[o])
d3d_model_primitive_end(global.level_model)
//d3d_vertex_normal_texture(x-32,y-32,z,x-32,y-32,z,0,0)
//d3d_vertex_normal_texture(x+32,y-32,z,x+32,y-32,z,0,1)
//d3d_vertex_normal_texture(x+32,y+32,z,x+32,y+32,z,
1,1)
}
else
if hfloorcollisionsrot[o]=90
{
d3d_model_primitive_begin(global.level_model,pr_tr
ianglefan)
d3d_model_vertex(global.level_model,obj_camera.hfl
oorcollisionsx[o]-32,obj_camera.hfloorcollisionsy[o]-32,obj_camera.hfloorcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.hfl
oorcollisionsx[o]-32,obj_camera.hfloorcollisionsy[o]+32,obj_camera.h
floorcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.hfl
oorcollisionsx[o]+32,obj_camera.hfloorcollisionsy[o
]-32,obj_camera.hfloorcollisionsz[o])
d3d_model_primitive_end(global.level_model)
//d3d_vertex_normal_texture(x-32,y-32,z,x-32,y-32,z,0,0)
//d3d_vertex_normal_texture(x-32,y+32,z,x-32,y+32,z,1,0)
//d3d_vertex_normal_texture(x+32,y-32,z,x+32,y-32,z,0,1)
}
else
if hfloorcollisionsrot[o]=180
{
d3d_model_primitive_begin(global.level_model,pr_tr
ianglefan)
d3d_model_vertex(global.level_model,obj_camera.hfl
oorcollisionsx[o]-32,obj_camera.hfloorcollisionsy[o]-32,obj_camera.hfloorcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.hfl
oorcollisionsx[o]-32,obj_camera.hfloorcollisionsy[o]+32,obj_camera.h
floorcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.hfl
oorcollisionsx[o]+32,obj_camera.hfloorcollisionsy[o
]+32,obj_camera.hfloorcollisionsz[o])
d3d_model_primitive_end(global.level_model)
//d3d_vertex_normal_texture(x-32,y-32,z,x-32,y-32,z,0,0)
//d3d_vertex_normal_texture(x-32,y+32,z,x-32,y+32,z,1,0)
//d3d_vertex_normal_texture(x+32,y+32,z,x+32,y+32,z,
1,1)
}
else
if hfloorcollisionsrot[o]=270
{
d3d_model_primitive_begin(global.level_model,pr_tr
ianglefan)
d3d_model_vertex(global.level_model,obj_camera.hfl
oorcollisionsx[o]-32,obj_camera.hfloorcollisionsy[o]+32,obj_camera.h
floorcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.hfl
oorcollisionsx[o]+32,obj_camera.hfloorcollisionsy[o
]-32,obj_camera.hfloorcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.hfl
oorcollisionsx[o]+32,obj_camera.hfloorcollisionsy[o
]+32,obj_camera.hfloorcollisionsz[o])
d3d_model_primitive_end(global.level_model)
//d3d_vertex_normal_texture(x-32,y+32,z,x-32,y+32,z,1,0)
//d3d_vertex_normal_texture(x+32,y-32,z,x+32,y-32,z,0,1)
//d3d_vertex_normal_texture(x+32,y+32,z,x+32,y+32,z,
1,1)
}
else
{
d3d_model_block(global.level_model,obj_camera.bloc
kcollisionsx[o]-32,obj_camera.blockcollisionsy[o]-32,obj_camera.blockcollisionsz[o],obj_camera.block
collisionsx[o]+32,obj_camera.blockcollisionsy[o]+32
,obj_camera.blockcollisionsz[o]+64,1,1)
}
}


for (o=0; o<obj_camera.rct; o+=1)
{
if rampcollisionsrot[o]=0
{
d3d_model_floor(global.level_model,obj_camera.ramp
collisionsx[o]-128,obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],obj_camera.rampco
llisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_c
amera.rampcollisionsz[o]+32,1,1)
d3d_model_floor(global.level_model,obj_camera.ramp
collisionsx[o]-128,obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],obj_camera.rampco
llisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_c
amera.rampcollisionsz[o],1,1)
d3d_model_wall(global.level_model,obj_camera.rampc
ollisionsx[o],obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],obj_camera.rampco
llisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_c
amera.rampcollisionsz[o]+32,1,1)
d3d_model_primitive_begin(global.level_model,pr_tr
ianglefan)
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o],obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]-128,obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o],obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o]+32)
d3d_model_primitive_end(global.level_model)
d3d_model_primitive_begin(global.level_model,pr_tr
ianglefan)
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o],obj_camera.rampcollisionsy[o]+32,ob
j_camera.rampcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]-128,obj_camera.rampcollisionsy[o]+32,obj_camera.ra
mpcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o],obj_camera.rampcollisionsy[o]+32,ob
j_camera.rampcollisionsz[o]+32)
d3d_model_primitive_end(global.level_model)
}
else
if rampcollisionsrot[o]=90
{
d3d_model_primitive_begin(global.level_model,pr_tr
ianglefan)
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]-32,obj_camera.rampcollisionsy[o]+128,obj_camera.ra
mpcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]+32,obj_camera.rampcollisionsy[o],ob
j_camera.rampcollisionsz[o]+32)
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]-32,obj_camera.rampcollisionsy[o],obj_camera.rampco
llisionsz[o]+32)
d3d_model_primitive_end(global.level_model)
d3d_model_primitive_begin(global.level_model,pr_tr
ianglefan)
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]-32,obj_camera.rampcollisionsy[o]+128,obj_camera.ra
mpcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]+32,obj_camera.rampcollisionsy[o]+12
8,obj_camera.rampcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]+32,obj_camera.rampcollisionsy[o],ob
j_camera.rampcollisionsz[o]+32)
d3d_model_primitive_end(global.level_model)
d3d_model_floor(global.level_model,obj_camera.ramp
collisionsx[o]-32,obj_camera.rampcollisionsy[o]+128,obj_camera.ra
mpcollisionsz[o],obj_camera.rampcollisionsx[o],obj_
camera.rampcollisionsy[o]+32,obj_camera.rampcollisi
onsz[o],1,1)
d3d_model_wall(global.level_model,obj_camera.rampc
ollisionsx[o]-32,obj_camera.rampcollisionsy[o],obj_camera.rampco
llisionsz[o],obj_camera.rampcollisionsx[o]+32,obj_c
amera.rampcollisionsy[o],obj_camera.rampcollisionsz
[o]+32,1,1)
d3d_model_primitive_begin(global.level_model,pr_tr
ianglefan)
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]-32,obj_camera.rampcollisionsy[o],obj_camera.rampco
llisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]-32,obj_camera.rampcollisionsy[o]+128,obj_camera.ra
mpcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]-32,obj_camera.rampcollisionsy[o],obj_camera.rampco
llisionsz[o]+32)
d3d_model_primitive_end(global.level_model)
d3d_model_primitive_begin(global.level_model,pr_tr
ianglefan)
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]+32,obj_camera.rampcollisionsy[o],ob
j_camera.rampcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]+32,obj_camera.rampcollisionsy[o]+12
8,obj_camera.rampcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]+32,obj_camera.rampcollisionsy[o],ob
j_camera.rampcollisionsz[o]+32)
d3d_model_primitive_end(global.level_model)
}
else
if rampcollisionsrot[o]=270
{
d3d_model_primitive_begin(global.level_model,pr_tr
ianglefan)
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]-32,obj_camera.rampcollisionsy[o]-128,obj_camera.rampcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]+32,obj_camera.rampcollisionsy[o],ob
j_camera.rampcollisionsz[o]+32)
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]-32,obj_camera.rampcollisionsy[o],obj_camera.rampco
llisionsz[o]+32)
d3d_model_primitive_end(global.level_model)
d3d_model_primitive_begin(global.level_model,pr_tr
ianglefan)
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]-32,obj_camera.rampcollisionsy[o]-128,obj_camera.rampcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]+32,obj_camera.rampcollisionsy[o]-128,obj_camera.rampcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]+32,obj_camera.rampcollisionsy[o],ob
j_camera.rampcollisionsz[o]+32)
d3d_model_primitive_end(global.level_model)
d3d_model_floor(global.level_model,obj_camera.ramp
collisionsx[o]-32,obj_camera.rampcollisionsy[o]-128,obj_camera.rampcollisionsz[o],obj_camera.rampc
ollisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_
camera.rampcollisionsz[o],1,1)
d3d_model_floor(global.level_model,obj_camera.ramp
collisionsx[o]-32,obj_camera.rampcollisionsy[o],obj_camera.rampco
llisionsz[o],obj_camera.rampcollisionsx[o]+32,obj_c
amera.rampcollisionsy[o],obj_camera.rampcollisionsz
[o]+32,1,1)
d3d_model_primitive_begin(global.level_model,pr_tr
ianglefan)
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]-32,obj_camera.rampcollisionsy[o],obj_camera.rampco
llisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]-32,obj_camera.rampcollisionsy[o]-128,obj_camera.rampcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]-32,obj_camera.rampcollisionsy[o],obj_camera.rampco
llisionsz[o]+32)
d3d_model_primitive_end(global.level_model)
d3d_model_primitive_begin(global.level_model,pr_tr
ianglefan)
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]+32,obj_camera.rampcollisionsy[o],ob
j_camera.rampcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]+32,obj_camera.rampcollisionsy[o]-128,obj_camera.rampcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]+32,obj_camera.rampcollisionsy[o],ob
j_camera.rampcollisionsz[o]+32)
d3d_model_primitive_end(global.level_model)
}
else
if rampcollisionsrot[o]=180
{
d3d_model_floor(global.level_model,obj_camera.ramp
collisionsx[o]+128,obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],obj_camera.rampco
llisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_c
amera.rampcollisionsz[o]+32,1,1)
d3d_model_floor(global.level_model,obj_camera.ramp
collisionsx[o]+128,obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],obj_camera.rampco
llisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_c
amera.rampcollisionsz[o],1,1)
d3d_model_wall(global.level_model,obj_camera.rampc
ollisionsx[o],obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],obj_camera.rampco
llisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_c
amera.rampcollisionsz[o]+32,1,1)
d3d_model_primitive_begin(global.level_model,pr_tr
ianglefan)
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o],obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]+128,obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o],obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o]+32)
d3d_model_primitive_end(global.level_model)
d3d_model_primitive_begin(global.level_model,pr_tr
ianglefan)
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o],obj_camera.rampcollisionsy[o]+32,ob
j_camera.rampcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]+128,obj_camera.rampcollisionsy[o]+3
2,obj_camera.rampcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o],obj_camera.rampcollisionsy[o]+32,ob
j_camera.rampcollisionsz[o]+32)
d3d_model_primitive_end(global.level_model)
}
else
{
d3d_model_floor(global.level_model,obj_camera.ramp
collisionsx[o]-128,obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],obj_camera.rampco
llisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_c
amera.rampcollisionsz[o]+32,1,1)
d3d_model_floor(global.level_model,obj_camera.ramp
collisionsx[o]-128,obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],obj_camera.rampco
llisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_c
amera.rampcollisionsz[o],1,1)
d3d_model_wall(global.level_model,obj_camera.rampc
ollisionsx[o],obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o],obj_camera.rampco
llisionsx[o],obj_camera.rampcollisionsy[o]+32,obj_c
amera.rampcollisionsz[o]+32,1,1)
d3d_model_primitive_begin(global.level_model,pr_tr
ianglefan)
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o],obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]-128,obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o],obj_camera.rampcollisionsy[o]-32,obj_camera.rampcollisionsz[o]+32)
d3d_model_primitive_begin(global.level_model,pr_tr
ianglefan)
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o],obj_camera.rampcollisionsy[o]+32,ob
j_camera.rampcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o]-128,obj_camera.rampcollisionsy[o]+32,obj_camera.ra
mpcollisionsz[o])
d3d_model_vertex(global.level_model,obj_camera.ram
pcollisionsx[o],obj_camera.rampcollisionsy[o]+32,ob
j_camera.rampcollisionsz[o]+32)
d3d_model_primitive_end(global.level_model)
}
}

mapmodel=string_copy(mappath,0,string_length(mappa
th)-4)
d3d_model_save(global.level_model,"models/level_models/"+string(mapmodel)+".d3d")
d3d_model_destroy(global.level_model)
//Okay, so you're wondering why this saves a model.
//Well it's simple. During Debug sessions, I must also save the map as a model for backup purposes.
//This way, if the P3DC stops working... I can just tell it to open the model instead of all of the wall and floors.

//A faster possibility, but I wish to go slow. ^_^

}
else
{
}
alarm[6]=2
[/codebox]

^ This extremely long piece of code makes all of the walls, floors, ramps, and other triangles into one big model. That explains how this happened with unnecessary triangles.
  • 0

#48 DmitriV

DmitriV

    GMC Member

  • GMC Member
  • 11 posts

Posted 20 March 2010 - 09:10 PM

No offense, but why are you using P3DC while using U3D? U3D has it's own built-in collision system.

-MoK

But I like P3DC, it's easy and fast. So I want to know if there will be a .3ds file support in the future.
  • 0

#49 DmitriV

DmitriV

    GMC Member

  • GMC Member
  • 11 posts

Posted 20 March 2010 - 09:35 PM

No offense, but why are you using P3DC while using U3D? U3D has it's own built-in collision system.

-MoK

But I like P3DC, it's easy and fast. So I want to know if there will be a .3ds file support in the future.

Edit:I figured out how the collision checking system in U3D works. Actualy it's quite simple, you just need 5 lines of code. ;)

Edit:Still I would like to see P3DC with 3ds support. :GM8: U3D is bit buggy in my environment...



I noticed I've posted this message twice. Sorry, but that was my internet connection. So I pressed the submit button twice because he didn't load the page.

Edited by DmitriV, 20 March 2010 - 10:29 PM.

  • 0

#50 qwertyuiop23

qwertyuiop23

    GMC Member

  • New Member
  • 940 posts

Posted 21 March 2010 - 06:51 AM

Great DLL. Only one problem: Can't be used in Comp 05.

Two questions:

One: You going to release source at any stage?

Two: The triangle-triangle collisions between two models interest me as I am trying to port triangle-triangle collisions for any object to KingSpace.


You may be wondering why do that? Well Competition 5 states "NO DLLS" so yeah can't go with them. However kingspace when optimized is very quick with gm8.

Cheers
Lance
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users