sergey.pozhidaev Posted October 7, 2013 Share Posted October 7, 2013 please tell me about specific of Z-coordinete location in ObjectDynamic. i found 2 ways: 1. place Z coordinate in 2nd vertex buffer position at 4- vec4 component and use non-shader material 2. place XYZ pos in 0 vertex buffer position and use shader material BUT question: if i do not want use shaders to render my object, how to economy memory :D, why so magic trick to transfer only Z coordinate in 2nd buffer pos. and where vec2? script compiler shows errors 1------------------------------------------------------------------------------------------------------------------------------- <material name="dynamic_mesh_base" parent="mesh_base"> <state name="emission" type="switch" items="none,opacity,transparent,lightmap">1</state> <bind object="dynamic" to="mesh"/> <parameter name="emission_color" type="color" shared="1">0.6 0.85 1 1</parameter> </material> ObjectDynamic od = add_editor(new ObjectDynamic(1)); od.setMaterial("dynamic_mesh_base","*"); od.setProperty("surface_base","*"); void add_vertex(vec3 vertex) { od.addVertexFloat(0,vertex,2); od.setVertexFloat(2,vec4(0,0,0,vertex.z),4); } od.setVertexFormat(( ivec3(0,OBJECT_DYNAMIC_TYPE_FLOAT,2), ivec3(4,OBJECT_DYNAMIC_TYPE_FLOAT,1), ivec3(20,OBJECT_DYNAMIC_TYPE_FLOAT,4) )); add_vertex(vec3(-1,0,0)); add_vertex(vec3(5,0,0)); add_vertex(vec3(-1,1,1)); add_vertex(vec3(5,1,1)); 2------------------------------------------------------------------------------------------------------------------------------- <material name="lines" editable="0"> <!-- options --> <options cast_shadow="0" receive_shadow="0" cast_world_shadow="0" receive_world_shadow="0"/> <!-- ambient shaders --> <shader pass="ambient" object="dynamic" vertex="Resources/shaders/lines/vertex.shader" fragment="Resources/shaders/lines/fragment.shader" /> </material> ObjectDynamic od = add_editor(new ObjectDynamic(1)); od.setMaterial("lines","*"); od.setProperty("surface_base","*"); void add_vertex(vec3 vertex) { od.addVertexFloat(0,vertex,3); } od.setVertexFormat(( ivec3(0,OBJECT_DYNAMIC_TYPE_FLOAT,3) )); add_vertex(vec3(-1,0,0)); add_vertex(vec3(5,0,0)); add_vertex(vec3(-1,1,1)); add_vertex(vec3(5,1,1)); Link to comment
frustum Posted October 7, 2013 Share Posted October 7, 2013 Z coordinate is located inside normal W component. the mesh vertex layout is: float2 xy; half4 texcoord; half4 normal; // W is Z coordinate half4 tangent; // W is binormal orientation. Link to comment
Recommended Posts