wxywxy.ji Posted November 17, 2011 Share Posted November 17, 2011 In sciprt ) PlugInNode( Node ); Node : ObjectTerrain , MeshObject , Any Type ..... In Plugin ) void PlugInNode(Unigine::Node *pNode) { ... 1. How To Get Vertex List , Any Type ... 2. How To Pass Engine. GetVerticeInNode( pNode ); } In Engine ) Header static UNIGINE_API bool GetVerticeInNode(Unigine::Node* pUnigineNode); Source bool IKynapse::GetVerticeInNode(Unigine::Node* pUnigineNode) { if( NULL == pUnigineNode ) return false; ::Node* pNode = NULL; pNode = static_cast<::Node*>(pUnigineNode->getInterface()); if( pNode == NULL ) reutnr false; <-- Any Time In This Position. if( Node::OBJECT_MESH_DYNAMIC == pNode->getType() ) { return false; } return true; } Link to comment
frustum Posted November 17, 2011 Share Posted November 17, 2011 Look at the source/samples/Api/Objects example. void my_object_create(NodePtr node,float time) { ObjectMeshDynamicPtr object = ObjectMeshDynamic::create(node); if(object.get() == NULL) Log::fatal("my_object_create(): is not an ObjectMeshDynamic\n"); object->clearVertex(); object->clearIndices(); int num = 1024; float inum = 1.0f / num; float scale = cosf(time * 2.0f) * 6.0f; object->addFan(num + 2); object->addVertex(vec3(0.0f)); object->addTexCoord(vec4(0.0f)); for(int i = 0; i <= num; i++) { float angle = UNIGINE_PI * 2.0f * i * inum; float radius = 20.0f + sinf(angle * 6.0f - time) * scale; float x = sinf(angle); float y = cosf(angle); object->addVertex(vec3(y * radius,x * radius,(radius - 20.0f) * 0.5f)); object->addTexCoord(vec4(x,y,0.0f,0.0f)); } object->updateBounds(); object->updateNormals(); object->updateTangents(); object->flush(); } Link to comment
wxywxy.ji Posted November 17, 2011 Author Share Posted November 17, 2011 i will integrate kynapse in PlugIn. i need only get vertex list. vetice In Object Terrain , Mesh , ...... Any Type. i would make cast class like ObjectMeshDynamicPtr for need vertex list? and i want cast. when NodePtr inserted to Ungine Engine. ex ) pNode = static_cast<::Node*>(pUnigineNode->getInterface()); ObjectTerrain* p = ( ObjectTerrain* ) pNode; . equal type...... . ObjectMesh* p = ( ObjectMesh * ) pNode; get Vertex List Link to comment
frustum Posted November 17, 2011 Share Posted November 17, 2011 I will add access to the vertices of ObjectMesh via API. The whole world (with terrain) can be converted into the single mesh in the editor. Link to comment
wxywxy.ji Posted November 17, 2011 Author Share Posted November 17, 2011 i can't understand. please some code. Link to comment
frustum Posted November 17, 2011 Share Posted November 17, 2011 This class will be available in the new SDK. class ObjectMesh : public virtual Object { virtual int getNumVertex(int surface) const = 0; virtual vec3 getVertex(int num,int surface) const = 0; virtual vec3 getNormal(int num,int surface) const = 0; virtual vec4 getTangent(int num,int surface) const = 0; virtual vec4 getTexCoord(int num,int surface) const = 0; virtual int getNumIndices(int surface) const = 0; virtual int getIndex(int num,int surface) const = 0; }; You can export selected nodes into the single ObjectMesh file in the Unigine Editor Nodes window. And after that use new Unigine::ObjectMesh class to obtain the world geometry. Link to comment
wxywxy.ji Posted November 17, 2011 Author Share Posted November 17, 2011 you said me that i will make ObjectMesh Interface Like UnigineNode.cpp File? like this? class ObjectInterface : public NodeInterface, public virtual Object { public: ObjectInterface(::Object *object) : NodeInterface(object), object(object) { } virtual ~ObjectInterface() { } virtual int getNumSurfaces() const { return object->getNumSurfaces(); } virtual int findSurface(const char *name) const { return object->findSurface(name); } virtual const char *getSurfaceName(int surface) const { return object->getSurfaceName(surface); } virtual void setMaterial(const char *name,int surface) const { object->setMaterial(name,surface); } virtual const char *getMaterialName(int surface) const { return object->getMaterialName(surface); } virtual void setProperty(const char *name,int surface) const { object->setProperty(name,surface); } virtual const char *getPropertyName(int surface) const { return object->getPropertyName(surface); } private: ::Object *object; }; /* */ Object *Object::create_object(Node *n) { ::Node *node = GetNodeInterface(n); if(node == NULL || node->isObject() == 0) return NULL; return new ObjectInterface(static_cast< ::Object*>(node)); } /* */ void Object::release(Object *object) { delete object; } Link to comment
frustum Posted November 17, 2011 Share Posted November 17, 2011 We will release new SDK tomorrow. Unigine::ObjectMesh class will be available with the new SDK. Link to comment
wxywxy.ji Posted November 17, 2011 Author Share Posted November 17, 2011 thank you for reply. ask for this topic after i will download new Ungine Engine. Link to comment
wxywxy.ji Posted November 18, 2011 Author Share Posted November 18, 2011 can i get down when? Link to comment
binstream Posted November 18, 2011 Share Posted November 18, 2011 Uploading now, will be available in 4-5 hours. Link to comment
wxywxy.ji Posted November 21, 2011 Author Share Posted November 21, 2011 Unfortunately, because my ungine engine have customized. i would adjust that UnigineNode.cpp , UnigineNode.h , UnigineObject.h , UnigineObjectMesh.h , UnigineObjectMeshDynamic.h , UnigineObjectMeshSkinned.h in ungine source? than can i get vertice any type object? other question. The correct usage is that make extern class , not adjust Unigine Engine Source? how to use unigine engine? Link to comment
wxywxy.ji Posted November 22, 2011 Author Share Posted November 22, 2011 i can get vertex list in OBJECT_MESH. but i can't vertex list in OBJECT_TERRAIN. switch( pUnigineNode->getType() ) { case OBJECT_MESH: { Unigine::ObjectMeshPtr object = Unigine::ObjectMesh::create( pUnigineNode ); int SurfaceCount = object->getNumSurfaces(); int VertexNum = 0; for( int i = 0 ; i < SurfaceCount ; i++ ) { VertexNum = object->getNumVertex( i ); } } break; case OBJECT_TERRAIN: // How To Get? break; case OBJECT_WATER: // How To Get? break; case WORLD_CLUTTER: // How To Get? break; case OBJECT_MESH_DYNAMIC: { Unigine::ObjectMeshDynamicPtr object = Unigine::ObjectMeshDynamic::create( pUnigineNode ); int VertexNum = 0; VertexNum = object->getNumVertex(); } break; } Link to comment
manguste Posted November 23, 2011 Share Posted November 23, 2011 If you want to access terrain vertices, ObjectTerrain need to be converted into a simple ObjectMesh: Open the Nodes panel in the editor. Select ObjectTerrain. Click "Export selected nodes into a mesh file" button. Add the created mesh into the world and access its vertices via ObjectMesh interface. ObjectWater vertices cannot be accessed (and it cannot be converted into a mesh). WorldClutter does not have any vertices at all, it just scatters node references. Link to comment
wxywxy.ji Posted November 24, 2011 Author Share Posted November 24, 2011 conclusion , not automatic get vertex list. PlugIn is Useless. make code Like ObjectMesh or insert Unigine Engine. :( alway adjust Unigine Engine Source <_< Link to comment
wxywxy.ji Posted November 28, 2011 Author Share Posted November 28, 2011 i Found Another Way. This Way Right? [ Ex ] [ Code In PlugIn ] GetVertice( pNode ); int VertexCount = GetVertexCount(); loop(VertexCount) { Unigine::vec3 vPos = PopVertex( i ); } [ Code In Engine Extern - Function ] static std::list<UNIGINE::vec3> m_VertexList; Unigine::vec3 PopVertex() { return m_VertexList; <= delete front iterator after Return Unigine::Vec3; } GetVertice (Unigine::NodePrt pNode) { switch( pNode ) { case AnyType: { int NodeID = pUnigineNode->getID(); ::Node *pNode = Node::getNode( NodeID ); <== ID IS Unique? if( NULL == pNode ) return false; pAnyType = ( AnyType * ) pNode; ::vec3 vPos = pAnyType->GetVertex(....) m_VertexCount.push_back( convertUnigneVec3( vpos ) ); } break; ......... } } Link to comment
wxywxy.ji Posted November 29, 2011 Author Share Posted November 29, 2011 please check this way. Link to comment
ulf.schroeter Posted November 29, 2011 Share Posted November 29, 2011 I am no expert in kynapse and not sure what you exactly what to achive, but maybe you should rethink your plug-in approach and instead try to integrate it directly into unigine source (if available). Unfortunately Unigine C++ API is very limited at the moment. I would guess that you will run into all kinds of additional data access problems (beyond simple vertices) when your integration gets more complex. Have a look into existing pathfinding module as a possible blueprint for your kynapse integration Link to comment
Recommended Posts