Would anybody mind giving me an example of how I might go about creating a flat plane custom mesh?
@KidKoder Are you talking about making it with or without the craft module? Either way, there are examples on this thread (Just go to page 1), and on other places in the forums
@XanDDemoX
I tried running your sample code that is supposed to trigger a crash but I couldn’t get it to happen. I’ll keep trying though.
The same thing occurred with assertions not stopping the update function immediately.
As for the raycast issue. This is because when moving entity references from c++ to lua they are wrapped in a special reference object. I need to make some kind of cache in the registry for this so that the same lua object will be returned each time allowing for it to be used as a table key.
@GR00G0 This is a bug. The method should be called resizeIndices()
as you said. resizeVertices()
was renamed to resize()
for potential future compatibility with mesh. For now I’ll probably allow both variations. Proper documentation for the new mesh class is coming along and should be in the next update.
@CamelCoder sorry, I could gave been more clear earlier. Yes, I’d like to create a flat plane mesh in CC specifically. The goal is to create a grid of many vertices that I can manually adjust the height of to create terrain. I haven’t seen this yet on this thread (even on page 1)
I created an empty mesh, added positions to it( yes everything does divide by three) added it with the craft.renderer to a entity, but for some reason it doesnt render at all. I tried everything now, I added correct slightly higher normals, colors, and it just doemst show up. So I wonder now what does a mesh need to be rendered?
When I run an example on iPad, it is ok, but when I run it from aircode, it returns error:
E1:3: attempt to index a nil value(global ‘craft’)
stack traceback:
E1:3: in function ‘setup’
below is the example:
function setup()
-- create a new entity
myEntity = craft.entity()
local r = myEntity:add(craft.renderer, craft.mesh.cube(vec3(1,1,1)))
r.material = craft.material("Materials:Standard")
r.material.map = readImage("Blocks:Brick Red")
myEntity.position = vec3(10,10,10)
myEntity.rotation = quat.eulerAngles(45,45,45)
myEntity.scale = vec3(0.5, 0.5, 0.5)
myEntity:add(craft.rigidbody, DYNAMIC, 0.5)
myEntity:add(craft.shape.box, vec3(1,1,1), vec3(0,0,0))
childEntity = craft.entity()
childEntity.parent = myEntityCopy
--
craft.scene.camera.position = vec3(0,0,5)
craft.scene.camera.rotation = quat.eulerAngles(0,0,180)
end
function update()
end
function draw()
end
And @John or @Simeon I have a suggestion: Do we have a bug list to show the status of the known bugs?
Another bug: in build-in example Voxel Editor, if I do something and save it with the name wolf, my voxel model will cover the wolf model, then I select restore example, the old wolf can not restore.
@John can you give me a small example of how I can renderer an empty Mesh, to wich I added all the positions? It just doesnt work for me for some reason
@GR00G0 I’m not sure that we can create a custom craft.mesh
programmatically yet. Looking at craft.mesh.___class
there doesn’t appear to be a way to set vertex indices yet. Although addElement
seems to be a good candidate, calling it with some vertex indexes doesn’t seem to have any effect.
Compare mesh.indexCount
and mesh.vertexCount
for a craft.mesh.cube
to your mesh. I think you’ll see why it’s not being displayed.
@XanDDemoX They are both the same. And whhat about position(i,v)?
Does anyone know how to find the bounds of a rigidbody? I’m thinking like the example “Models” bounds function, but instead of outlining the bounds of a mesh, outlining the bounds of a dynamic or static body. The reason I’m asking is because this (video) is happening. All suggestions are much appreciated! https://dropbox.com/s/9iy14un5pihvuw0/Problem.MP4?dl=0
@GR00G0 The next beta release will have some major updates and fixes for mesh giving you all those features as well as documentation for it and at least one example.
@Attila717 That doesn’t exist yet but I can add it
@binaryblues We haven’t got craft working with Aircode just yet.
@GR00G0 You are correct, I forgot to test for a second parameter for index
and position
. I overlooked those functions a little from seeing explicit get and set functions in craft.mesh.___class
.
It looks like we’re missing something because even copying the geometry etc directly from a craft.mesh.cube
doesn’t display anything.
e = craft.entity()
m = craft.mesh()
cube = craft.mesh.cube(vec3(1,1,1))
m:resize(cube.vertexCount)
m:resizeIndicies(cube.indexCount)
for i=0, cube.vertexCount-1 do
local pos = vec3(cube:position(i))
m:position(i, pos )
end
for i=0, cube.indexCount-1 do
m:index(i,cube:index(i))
end
for i=0,cube.vertexCount-1 do
local n = vec3(cube:normal(i))
m:normal(i,n)
m:color(i,color(cube:color(i)))
m:uv(i,vec2(cube:uv(i)))
end
local renderer = e:add(craft.renderer,m)
renderer.material = craft.material("Materials:Standard")
renderer.material.map = readImage("Blocks:Brick Red")
e.position = vec3(0,0,0)
craft.scene.camera.rotation = quat.eulerAngles(0,180,0)
craft.scene.camera.position = vec3(0,0,-10)
@John Thanks, that’d be an amazing debugging tool!
@XanDDemoX I guess we’ll wait for the next beta, and if it doesnt work then, we can report it to the devs.
@XanDDemoX Ok. I when you first create a cube or icosphere, resize everything and add the geometry you want it does actually render. So I think this is a bug
Build 80 is now available. If you find any issues with the examples or want to submit a pull request the examples are now available on github:
https://github.com/JohnTM/Craft-Examples
BETA NOTES
- After installing a new version you should be prompted to restore examples, please make sure to press the restore button
- For feedback / questions please visit codea.io/talk (PM simeon or john for access to the beta thread)
NEW FEATURES - Craft
- A new advanced feature-set with support for 3D environments, lighting, physics, voxels and more!
- OBJ model loading (support for other formats coming in future updates)
- Directional, point and spot lights
- Advanced material system with support for physically based rendering
- Voxel rendering and collisions with support for fully custom block types and scripting
- Advanced noise system for terrain generation and other procedural content
- 3D physics, with support for spheres, boxes, capsules and mesh shapes
New Examples
New Assets
CHANGE LOG
18/06/2017
Examples
- Added new examples: Craft Template, Lights & Planet Generator
- Updated all examples to keep up to date with API changes
Assets
- Fixed some naming convention problems with Block asset pack
Runtime
- craft.scene
- Automatic scene management has been removed in favor of manual scene management
- All existing craft projects will be affected by this and must be updated
- See Craft Template for an example of a minimal project that demonstrates this
- craft.entity
- Must now be created using scene:entity() istead of craft.entity()
- craft.light
- intensity property now works
- multiple lights now work correctly
- color property now takes a color() object instead of a vec3() object
- penumbra and angle properties now work correctly for spot lights
- craft.cubeTexture
- constructor now takes 6 image() objects directly (instead of asset strings)
- order is: +X, -X, +Y, -Y, +Z, -Z
- future versions may be altered again
- rendering
- shaders are now optimised before being compiled, this should improve loading and rendering speed in general
[Build 80]
Crashed: Open the built-in reference, click craft.entity, Codea will crash.
Does anyone have an example of a non voxel world?
And how does the setWithNoise method work?