3D engine thing

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

thank you, I’ll try it

pk3d12-17-2021_23-41-23.wick I’m having problems with rendering my 3d model. also I’m just experimenting with this

ok there are 2 problems

  • the obj file calls to use materials from a file that hasn’t been specified, so when it wants to use a material it errors since the material doesn’t exist.
  • my reader doesn’t support vertex normals and uvs so when the obj file tells to make a face with the normals and uvs, it doesn’t parse it correctly so all the vertex positions in the tree mesh is set to 0.

to fix this i updated the code

also
image
and camera and scene are not defined anyway
in this script it’s project.camera and project.scene

2 Likes

can you post this a a html pls and make a tutorial