3D engine thing

Aha, I think I might have figured out why clipping wasn’t working properly. My guess as to why it wasn’t working was because the triangle wouldn’t get clipped on multiple edges. Now I figured out why it wasn’t doing that: it’s because when a triangle gets clipped, its results get put at the end of the clipped triangles list. However, the problem with this is that the program clips the triangle at the end of the list. So, for example, if a triangle needed to be clipped into two triangles, it will clip the two. But then at the next edge, it will clip the last triangle in the list then put the results at the end of the list. Then it will clip another triangle at the end of the list (which are the new triangles) with the same edge and then ignore the other triangle, because it already clipped two triangles (which is the amount of triangles in the list).

I fixed it by putting the new triangles at the beginning of the list instead of the end. Here’s the fix: pk3d.wick (27.8 KB) The not-clipping problem is completely gone. The change of a single line of code that fixed this problem is in line 1101 of the engine code.

Edit:
oh. and i can see that javidx9 actually wrote code to take the triangle at the front of the list, not at the back… but i made it so it gets the triangle at the end of the list… which is wrong as i stated… lol… cries

1 Like

This is so Cool when you can ad Phyics and a Playabel charckter you can make a Verry cool 3D Platformer

1 Like

image
Whoa.

2 Likes

yup, that is a gift from our forum member @pumpkinhead

1 Like

pretty cool engine but i would like to know how to make walls

please don’t revive old posts.

revive power jk also i wanna revive it cause its awesome

how do I include my own 3d model? @pumpkinhead

No reason to not to :|

@pumpkinhead

maybe look here…

It looks like you have to import some custom assets and then call some code ?

2 Likes

Thank you!

Why can’t I open the wick files?

Idk, maybe it no longer works on the newest version or it doesn’t like the custom files ?
edit: didn’t work for me either

1 Like

we could wait for @pumpkinhead to reply

1 Like

Bruh moment.

reviving posts on its own isn’t bad, as long as the reply is relevant. it’s better than making a brand-new topic.

also @Jordy you don’t need to ping pumpkinhead 3 times.

so first what you wanna do is you wanna get your model’s files. it has to be an .obj or .mtl file since the built-in helper function only supports that. (btw an .mtl file are the materials for an .obj file) then you have to change the file extension of those files to .wickobj so that you can actually import them into the project. once you have done that,

to create the mesh you use the following code:

// here the file name would probably be model.wickobj
// but its name in the project is "model.obj"
// you can rename it to anything this is just an example
var mesh = pk3d.createMeshFromAsset( this.project.getAssetByName("model.obj") );

// you can also pass the .mtl file as a second argument 
var meshWithMaterial = pk3d.createMeshFromAsset(
  this.project.getAssetByName("model.obj"),
  this.project.getAssetByName("model.mtl")
);

then you have to push that mesh into an array which in this example would be called scene.

to render the scene you use this code:

// run this on initialization
project.renderer = new pk3d.Renderer(triangleClip);

// run this on update
// camera is a pk3d.Camera instance
project.renderer.render(camera, scene);

but honestly i wouldn’t use this 3d engine for practical use. it’s way too slow cuz it’s in wick editor, and also the triangle sorting is bad for large surfaces because i’m forced to use painter’s algorithm.

i could make a better 3d engine in wick using opengl, but then there would be no point having it in wick.

1 Like

i’m assuming you’re talking about not being able to open archobj.wick and archmtl.wick

that’s because they’re not actually wick files i just changed their file extensions to wick to bypass the file extension restrictions

1 Like

Sorry

This text will be hidden